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,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/HardwareIntrinsics/General/Vector256/LessThanOrEqualAll.Double.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/******************************************************************************
* This file is auto-generated from a template file by the GenerateTests.csx *
* script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make *
* changes, please update the corresponding template and run according to the *
* directions listed in the file. *
******************************************************************************/
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
namespace JIT.HardwareIntrinsics.General
{
public static partial class Program
{
private static void LessThanOrEqualAllDouble()
{
var test = new VectorBooleanBinaryOpTest__LessThanOrEqualAllDouble();
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
// Validates passing the field of a local class works
test.RunClassLclFldScenario();
// Validates passing an instance member of a class works
test.RunClassFldScenario();
// Validates passing the field of a local struct works
test.RunStructLclFldScenario();
// Validates passing an instance member of a struct works
test.RunStructFldScenario();
if (!test.Succeeded)
{
throw new Exception("One or more scenarios did not complete as expected.");
}
}
}
public sealed unsafe class VectorBooleanBinaryOpTest__LessThanOrEqualAllDouble
{
private struct DataTable
{
private byte[] inArray1;
private byte[] inArray2;
private GCHandle inHandle1;
private GCHandle inHandle2;
private ulong alignment;
public DataTable(Double[] inArray1, Double[] inArray2, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Double>();
int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Double>();
if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray1 = new byte[alignment * 2];
this.inArray2 = new byte[alignment * 2];
this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned);
this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Double, byte>(ref inArray1[0]), (uint)sizeOfinArray1);
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Double, byte>(ref inArray2[0]), (uint)sizeOfinArray2);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment);
public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle1.Free();
inHandle2.Free();
}
private static unsafe void* Align(byte* buffer, ulong expectedAlignment)
{
return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1));
}
}
private struct TestStruct
{
public Vector256<Double> _fld1;
public Vector256<Double> _fld2;
public static TestStruct Create()
{
var testStruct = new TestStruct();
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref testStruct._fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref testStruct._fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>());
return testStruct;
}
public void RunStructFldScenario(VectorBooleanBinaryOpTest__LessThanOrEqualAllDouble testClass)
{
var result = Vector256.LessThanOrEqualAll(_fld1, _fld2);
testClass.ValidateResult(_fld1, _fld2, result);
}
}
private static readonly int LargestVectorSize = 32;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double);
private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double);
private static Double[] _data1 = new Double[Op1ElementCount];
private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
private DataTable _dataTable;
static VectorBooleanBinaryOpTest__LessThanOrEqualAllDouble()
{
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>());
}
public VectorBooleanBinaryOpTest__LessThanOrEqualAllDouble()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>());
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); }
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); }
_dataTable = new DataTable(_data1, _data2, LargestVectorSize);
}
public bool Succeeded { get; set; }
public void RunBasicScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));
var result = Vector256.LessThanOrEqualAll(
Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr)
);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
var method = typeof(Vector256).GetMethod(nameof(Vector256.LessThanOrEqualAll), new Type[] {
typeof(Vector256<Double>),
typeof(Vector256<Double>)
});
if (method is null)
{
method = typeof(Vector256).GetMethod(nameof(Vector256.LessThanOrEqualAll), 1, new Type[] {
typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0))
});
}
if (method.IsGenericMethodDefinition)
{
method = method.MakeGenericMethod(typeof(Double));
}
var result = method.Invoke(null, new object[] {
Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr)
});
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = Vector256.LessThanOrEqualAll(
_clsVar1,
_clsVar2
);
ValidateResult(_clsVar1, _clsVar2, result);
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var op1 = Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr);
var op2 = Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr);
var result = Vector256.LessThanOrEqualAll(op1, op2);
ValidateResult(op1, op2, result);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new VectorBooleanBinaryOpTest__LessThanOrEqualAllDouble();
var result = Vector256.LessThanOrEqualAll(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = Vector256.LessThanOrEqualAll(_fld1, _fld2);
ValidateResult(_fld1, _fld2, result);
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = Vector256.LessThanOrEqualAll(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
}
public void RunStructFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario));
var test = TestStruct.Create();
test.RunStructFldScenario(this);
}
private void ValidateResult(Vector256<Double> op1, Vector256<Double> op2, bool result, [CallerMemberName] string method = "")
{
Double[] inArray1 = new Double[Op1ElementCount];
Double[] inArray2 = new Double[Op2ElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), op1);
Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), op2);
ValidateResult(inArray1, inArray2, result, method);
}
private void ValidateResult(void* op1, void* op2, bool result, [CallerMemberName] string method = "")
{
Double[] inArray1 = new Double[Op1ElementCount];
Double[] inArray2 = new Double[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector256<Double>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector256<Double>>());
ValidateResult(inArray1, inArray2, result, method);
}
private void ValidateResult(Double[] left, Double[] right, bool result, [CallerMemberName] string method = "")
{
bool succeeded = true;
var expectedResult = true;
for (var i = 0; i < Op1ElementCount; i++)
{
expectedResult &= (left[i] <= right[i]);
}
succeeded = (expectedResult == result);
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(Vector256)}.{nameof(Vector256.LessThanOrEqualAll)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})");
TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})");
TestLibrary.TestFramework.LogInformation($" result: ({result})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/******************************************************************************
* This file is auto-generated from a template file by the GenerateTests.csx *
* script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make *
* changes, please update the corresponding template and run according to the *
* directions listed in the file. *
******************************************************************************/
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
namespace JIT.HardwareIntrinsics.General
{
public static partial class Program
{
private static void LessThanOrEqualAllDouble()
{
var test = new VectorBooleanBinaryOpTest__LessThanOrEqualAllDouble();
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
// Validates passing a static member works
test.RunClsVarScenario();
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
// Validates passing the field of a local class works
test.RunClassLclFldScenario();
// Validates passing an instance member of a class works
test.RunClassFldScenario();
// Validates passing the field of a local struct works
test.RunStructLclFldScenario();
// Validates passing an instance member of a struct works
test.RunStructFldScenario();
if (!test.Succeeded)
{
throw new Exception("One or more scenarios did not complete as expected.");
}
}
}
public sealed unsafe class VectorBooleanBinaryOpTest__LessThanOrEqualAllDouble
{
private struct DataTable
{
private byte[] inArray1;
private byte[] inArray2;
private GCHandle inHandle1;
private GCHandle inHandle2;
private ulong alignment;
public DataTable(Double[] inArray1, Double[] inArray2, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Double>();
int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Double>();
if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray1 = new byte[alignment * 2];
this.inArray2 = new byte[alignment * 2];
this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned);
this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Double, byte>(ref inArray1[0]), (uint)sizeOfinArray1);
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Double, byte>(ref inArray2[0]), (uint)sizeOfinArray2);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment);
public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle1.Free();
inHandle2.Free();
}
private static unsafe void* Align(byte* buffer, ulong expectedAlignment)
{
return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1));
}
}
private struct TestStruct
{
public Vector256<Double> _fld1;
public Vector256<Double> _fld2;
public static TestStruct Create()
{
var testStruct = new TestStruct();
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref testStruct._fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref testStruct._fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>());
return testStruct;
}
public void RunStructFldScenario(VectorBooleanBinaryOpTest__LessThanOrEqualAllDouble testClass)
{
var result = Vector256.LessThanOrEqualAll(_fld1, _fld2);
testClass.ValidateResult(_fld1, _fld2, result);
}
}
private static readonly int LargestVectorSize = 32;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double);
private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double);
private static Double[] _data1 = new Double[Op1ElementCount];
private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
private DataTable _dataTable;
static VectorBooleanBinaryOpTest__LessThanOrEqualAllDouble()
{
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>());
}
public VectorBooleanBinaryOpTest__LessThanOrEqualAllDouble()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>());
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); }
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); }
_dataTable = new DataTable(_data1, _data2, LargestVectorSize);
}
public bool Succeeded { get; set; }
public void RunBasicScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));
var result = Vector256.LessThanOrEqualAll(
Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr)
);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
var method = typeof(Vector256).GetMethod(nameof(Vector256.LessThanOrEqualAll), new Type[] {
typeof(Vector256<Double>),
typeof(Vector256<Double>)
});
if (method is null)
{
method = typeof(Vector256).GetMethod(nameof(Vector256.LessThanOrEqualAll), 1, new Type[] {
typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0))
});
}
if (method.IsGenericMethodDefinition)
{
method = method.MakeGenericMethod(typeof(Double));
}
var result = method.Invoke(null, new object[] {
Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr)
});
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = Vector256.LessThanOrEqualAll(
_clsVar1,
_clsVar2
);
ValidateResult(_clsVar1, _clsVar2, result);
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var op1 = Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr);
var op2 = Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr);
var result = Vector256.LessThanOrEqualAll(op1, op2);
ValidateResult(op1, op2, result);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new VectorBooleanBinaryOpTest__LessThanOrEqualAllDouble();
var result = Vector256.LessThanOrEqualAll(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = Vector256.LessThanOrEqualAll(_fld1, _fld2);
ValidateResult(_fld1, _fld2, result);
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = Vector256.LessThanOrEqualAll(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
}
public void RunStructFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario));
var test = TestStruct.Create();
test.RunStructFldScenario(this);
}
private void ValidateResult(Vector256<Double> op1, Vector256<Double> op2, bool result, [CallerMemberName] string method = "")
{
Double[] inArray1 = new Double[Op1ElementCount];
Double[] inArray2 = new Double[Op2ElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), op1);
Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), op2);
ValidateResult(inArray1, inArray2, result, method);
}
private void ValidateResult(void* op1, void* op2, bool result, [CallerMemberName] string method = "")
{
Double[] inArray1 = new Double[Op1ElementCount];
Double[] inArray2 = new Double[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector256<Double>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector256<Double>>());
ValidateResult(inArray1, inArray2, result, method);
}
private void ValidateResult(Double[] left, Double[] right, bool result, [CallerMemberName] string method = "")
{
bool succeeded = true;
var expectedResult = true;
for (var i = 0; i < Op1ElementCount; i++)
{
expectedResult &= (left[i] <= right[i]);
}
succeeded = (expectedResult == result);
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(Vector256)}.{nameof(Vector256.LessThanOrEqualAll)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})");
TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})");
TestLibrary.TestFramework.LogInformation($" result: ({result})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/CopyAttributesAction.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Xml.Xsl.XsltOld
{
using System;
using System.Diagnostics;
using System.Xml;
using System.Xml.XPath;
internal sealed class CopyAttributesAction : Action
{
private const int BeginEvent = 2;
private const int TextEvent = 3;
private const int EndEvent = 4;
private const int Advance = 5;
private static readonly CopyAttributesAction s_Action = new CopyAttributesAction();
internal static CopyAttributesAction GetAction()
{
Debug.Assert(s_Action != null);
return s_Action;
}
internal override void Execute(Processor processor, ActionFrame frame)
{
Debug.Assert(processor != null && frame != null);
while (processor.CanContinue)
{
switch (frame.State)
{
case Initialized:
if (!frame.Node!.HasAttributes || frame.Node.MoveToFirstAttribute() == false)
{
frame.Finished();
break;
}
frame.State = BeginEvent;
goto case BeginEvent;
case BeginEvent:
Debug.Assert(frame.State == BeginEvent);
Debug.Assert(frame.Node!.NodeType == XPathNodeType.Attribute);
if (SendBeginEvent(processor, frame.Node) == false)
{
// This one wasn't output
break;
}
frame.State = TextEvent;
continue;
case TextEvent:
Debug.Assert(frame.State == TextEvent);
Debug.Assert(frame.Node!.NodeType == XPathNodeType.Attribute);
if (SendTextEvent(processor, frame.Node) == false)
{
// This one wasn't output
break;
}
frame.State = EndEvent;
continue;
case EndEvent:
Debug.Assert(frame.State == EndEvent);
Debug.Assert(frame.Node!.NodeType == XPathNodeType.Attribute);
if (SendEndEvent(processor, frame.Node) == false)
{
// This one wasn't output
break;
}
frame.State = Advance;
continue;
case Advance:
Debug.Assert(frame.State == Advance);
Debug.Assert(frame.Node!.NodeType == XPathNodeType.Attribute);
if (frame.Node.MoveToNextAttribute())
{
frame.State = BeginEvent;
continue;
}
else
{
frame.Node.MoveToParent();
frame.Finished();
break;
}
}
break;
}// while (processor.CanContinue)
}
private static bool SendBeginEvent(Processor processor, XPathNavigator node)
{
Debug.Assert(node.NodeType == XPathNodeType.Attribute);
return processor.BeginEvent(XPathNodeType.Attribute, node.Prefix, node.LocalName, node.NamespaceURI, false);
}
private static bool SendTextEvent(Processor processor, XPathNavigator node)
{
Debug.Assert(node.NodeType == XPathNodeType.Attribute);
return processor.TextEvent(node.Value);
}
private static bool SendEndEvent(Processor processor, XPathNavigator node)
{
Debug.Assert(node.NodeType == XPathNodeType.Attribute);
return processor.EndEvent(XPathNodeType.Attribute);
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Xml.Xsl.XsltOld
{
using System;
using System.Diagnostics;
using System.Xml;
using System.Xml.XPath;
internal sealed class CopyAttributesAction : Action
{
private const int BeginEvent = 2;
private const int TextEvent = 3;
private const int EndEvent = 4;
private const int Advance = 5;
private static readonly CopyAttributesAction s_Action = new CopyAttributesAction();
internal static CopyAttributesAction GetAction()
{
Debug.Assert(s_Action != null);
return s_Action;
}
internal override void Execute(Processor processor, ActionFrame frame)
{
Debug.Assert(processor != null && frame != null);
while (processor.CanContinue)
{
switch (frame.State)
{
case Initialized:
if (!frame.Node!.HasAttributes || frame.Node.MoveToFirstAttribute() == false)
{
frame.Finished();
break;
}
frame.State = BeginEvent;
goto case BeginEvent;
case BeginEvent:
Debug.Assert(frame.State == BeginEvent);
Debug.Assert(frame.Node!.NodeType == XPathNodeType.Attribute);
if (SendBeginEvent(processor, frame.Node) == false)
{
// This one wasn't output
break;
}
frame.State = TextEvent;
continue;
case TextEvent:
Debug.Assert(frame.State == TextEvent);
Debug.Assert(frame.Node!.NodeType == XPathNodeType.Attribute);
if (SendTextEvent(processor, frame.Node) == false)
{
// This one wasn't output
break;
}
frame.State = EndEvent;
continue;
case EndEvent:
Debug.Assert(frame.State == EndEvent);
Debug.Assert(frame.Node!.NodeType == XPathNodeType.Attribute);
if (SendEndEvent(processor, frame.Node) == false)
{
// This one wasn't output
break;
}
frame.State = Advance;
continue;
case Advance:
Debug.Assert(frame.State == Advance);
Debug.Assert(frame.Node!.NodeType == XPathNodeType.Attribute);
if (frame.Node.MoveToNextAttribute())
{
frame.State = BeginEvent;
continue;
}
else
{
frame.Node.MoveToParent();
frame.Finished();
break;
}
}
break;
}// while (processor.CanContinue)
}
private static bool SendBeginEvent(Processor processor, XPathNavigator node)
{
Debug.Assert(node.NodeType == XPathNodeType.Attribute);
return processor.BeginEvent(XPathNodeType.Attribute, node.Prefix, node.LocalName, node.NamespaceURI, false);
}
private static bool SendTextEvent(Processor processor, XPathNavigator node)
{
Debug.Assert(node.NodeType == XPathNodeType.Attribute);
return processor.TextEvent(node.Value);
}
private static bool SendEndEvent(Processor processor, XPathNavigator node)
{
Debug.Assert(node.NodeType == XPathNodeType.Attribute);
return processor.EndEvent(XPathNodeType.Attribute);
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/Regression/JitBlue/DevDiv_543057/DevDiv_543057.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
// This tests passing variables in registers, which result in pass-through
// "specialPutArg" Intervals, and then passing a struct with GT_FIELD_LIST
// that also uses a number of registers.
// This case exposed a bug in the stress-limiting of registers where it
// wasn't taking these live "specialPutArg" Intervals into account.
using System;
using System.Runtime.CompilerServices;
// Struct with 4 fields
public struct MyStruct
{
public int f1;
public int f2;
public int f3;
public int f4;
}
public class TestClass
{
public const int Pass = 100;
public const int Fail = -1;
public TestClass()
{
}
// This is just here to set our lclVar to a non-constant.
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public int Dummy1()
{
return 1;
}
// This is here to preference our lclVars to the appropriate parameter registers.
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public void Dummy2(int p1, int p2, int p3, int p4)
{
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public int Check1(int i1, int i2, MyStruct s1, int i3, int i4)
{
if ((s1.f1 != i1) || (s1.f2 != i2) || (s1.f3 != i3) || (s1.f4 != i4))
{
Console.WriteLine("Check1: FAIL");
return Fail;
}
Console.WriteLine("Check1: PASS");
return Pass;
}
// For this repro, we want two parameters that are "specialPutArg" - that is,
// they are passing lclVars that are live in the register they are wanted in,
// and we have to keep them live, because there's no way to mark it as spilled,
// in case it is used as another parameter prior to being killed by the call.
// To do this, we set up 'this' and 'a' such that they are preferenced to
// the first and second parameter registers, but we increase register pressure
// so that they have to be loaded just prior to the call, causing them to
// be put into the argument registers they are preferenced to. Then we
// pass a split struct (ARM) that uses 4 registers for its GT_FIELD_LIST.
// This exceeds the stress limit without any compensation for the "specialPutArg"s.
//
public int TestStruct()
{
MyStruct s1;
s1.f1 = 1; s1.f2 = 2; s1.f3 = 3; s1.f4 = 4;
int a = Dummy1();
// Call an instance method. This gets the value number for 'this' into the 'curSsaNames' in copyprop.
// Also, pass it a bunch of parameters to increase the register pressure here.
Dummy2(a, 2, 3, 4);
// Pass the struct as split ('this' is in the first arg register).
int retVal = Check1(a, 2, s1, 3, 4);
// Use 'this' again so our previous call isn't the last use.
retVal = Check1(a, 2, s1, 3, 4);
return retVal;
}
}
public class DevDiv_543057
{
public static int Main()
{
int retVal = TestClass.Pass;
TestClass c = new TestClass();
if (c.TestStruct() != TestClass.Pass)
{
retVal = TestClass.Fail;
}
return retVal;
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
// This tests passing variables in registers, which result in pass-through
// "specialPutArg" Intervals, and then passing a struct with GT_FIELD_LIST
// that also uses a number of registers.
// This case exposed a bug in the stress-limiting of registers where it
// wasn't taking these live "specialPutArg" Intervals into account.
using System;
using System.Runtime.CompilerServices;
// Struct with 4 fields
public struct MyStruct
{
public int f1;
public int f2;
public int f3;
public int f4;
}
public class TestClass
{
public const int Pass = 100;
public const int Fail = -1;
public TestClass()
{
}
// This is just here to set our lclVar to a non-constant.
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public int Dummy1()
{
return 1;
}
// This is here to preference our lclVars to the appropriate parameter registers.
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public void Dummy2(int p1, int p2, int p3, int p4)
{
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public int Check1(int i1, int i2, MyStruct s1, int i3, int i4)
{
if ((s1.f1 != i1) || (s1.f2 != i2) || (s1.f3 != i3) || (s1.f4 != i4))
{
Console.WriteLine("Check1: FAIL");
return Fail;
}
Console.WriteLine("Check1: PASS");
return Pass;
}
// For this repro, we want two parameters that are "specialPutArg" - that is,
// they are passing lclVars that are live in the register they are wanted in,
// and we have to keep them live, because there's no way to mark it as spilled,
// in case it is used as another parameter prior to being killed by the call.
// To do this, we set up 'this' and 'a' such that they are preferenced to
// the first and second parameter registers, but we increase register pressure
// so that they have to be loaded just prior to the call, causing them to
// be put into the argument registers they are preferenced to. Then we
// pass a split struct (ARM) that uses 4 registers for its GT_FIELD_LIST.
// This exceeds the stress limit without any compensation for the "specialPutArg"s.
//
public int TestStruct()
{
MyStruct s1;
s1.f1 = 1; s1.f2 = 2; s1.f3 = 3; s1.f4 = 4;
int a = Dummy1();
// Call an instance method. This gets the value number for 'this' into the 'curSsaNames' in copyprop.
// Also, pass it a bunch of parameters to increase the register pressure here.
Dummy2(a, 2, 3, 4);
// Pass the struct as split ('this' is in the first arg register).
int retVal = Check1(a, 2, s1, 3, 4);
// Use 'this' again so our previous call isn't the last use.
retVal = Check1(a, 2, s1, 3, 4);
return retVal;
}
}
public class DevDiv_543057
{
public static int Main()
{
int retVal = TestClass.Pass;
TestClass c = new TestClass();
if (c.TestStruct() != TestClass.Pass)
{
retVal = TestClass.Fail;
}
return retVal;
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Linq.Expressions/tests/Dynamic/DynamicObjectDefaultBehaviorTests.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Linq.Expressions;
using Xunit;
namespace System.Dynamic.Tests
{
public class DynamicObjectDefaultBehaviorTests
{
private class TypeOnlyKnownHere
{
}
private struct ValueTypeOnlyKnownHere
{
}
private class NopDynamicObject : DynamicObject
{
// Adds no functionality.
}
[Fact]
public void TryGetMemberDefaultsToFalseWithNoValidation()
{
object result;
Assert.False(new NopDynamicObject().TryGetMember(null, out result));
Assert.Null(result);
}
[Fact]
public void TrySetMemberDefaultsToFalseWithNoValidation()
{
Assert.False(new NopDynamicObject().TrySetMember(null, null));
}
[Fact]
public void TryDeleteMemberDefaultsToFalseWithNoValidation()
{
Assert.False(new NopDynamicObject().TryDeleteMember(null));
}
[Fact]
public void TryInvokeMemberDefaultsToFalseWithNoValidation()
{
object result;
Assert.False(new NopDynamicObject().TryInvokeMember(null, null, out result));
Assert.Null(result);
}
[Fact]
public void TryConvertDefaultsToFalseWithNoValidation()
{
object result;
Assert.False(new NopDynamicObject().TryConvert(null, out result));
Assert.Null(result);
}
[Fact]
public void TryCreateInstanceDefaultsToFalseWithNoValidation()
{
object result;
Assert.False(new NopDynamicObject().TryCreateInstance(null, null, out result));
Assert.Null(result);
}
[Fact]
public void TryInvokeDefaultsToFalseWithNoValidation()
{
object result;
Assert.False(new NopDynamicObject().TryInvoke(null, null, out result));
Assert.Null(result);
}
[Fact]
public void TryBinaryOperationDefaultsToFalseWithNoValidation()
{
object result;
Assert.False(new NopDynamicObject().TryBinaryOperation(null, null, out result));
Assert.Null(result);
}
[Fact]
public void TryUnaryOperationDefaultsToFalseWithNoValidation()
{
object result;
Assert.False(new NopDynamicObject().TryUnaryOperation(null, out result));
Assert.Null(result);
}
[Fact]
public void TryGetIndexDefaultsToFalseWithNoValidation()
{
object result;
Assert.False(new NopDynamicObject().TryGetIndex(null, null, out result));
Assert.Null(result);
}
[Fact]
public void TrySetIndexDefaultsToFalseWithNoValidation()
{
Assert.False(new NopDynamicObject().TrySetIndex(null, null, null));
}
[Fact]
public void TryDeleteIndexDefaultsToFalseWithNoValidation()
{
Assert.False(new NopDynamicObject().TryDeleteIndex(null, null));
}
[Fact]
public void GetDynamicMemberNamesDefaultsToEmptyArray()
{
Assert.Same(Array.Empty<string>(), new NopDynamicObject().GetDynamicMemberNames());
}
[Fact]
public void DefaultPropertiesForMetaObject()
{
Expression exp = Expression.Default(typeof(TypeOnlyKnownHere));
NopDynamicObject nop = new NopDynamicObject();
DynamicMetaObject dmo = nop.GetMetaObject(exp);
Assert.Same(nop, dmo.Value);
Assert.Same(exp, dmo.Expression);
Assert.True(dmo.HasValue);
Assert.Same(BindingRestrictions.Empty, dmo.Restrictions);
}
[Fact]
public void DefaultRuntimeTypeForMetaObjectReferenceType()
{
Expression exp = Expression.Default(typeof(TypeOnlyKnownHere));
NopDynamicObject nop = new NopDynamicObject();
DynamicMetaObject dmo = nop.GetMetaObject(exp);
Assert.Same(typeof(NopDynamicObject), dmo.RuntimeType);
Assert.Same(typeof(NopDynamicObject), dmo.LimitType);
}
[Fact]
public void DefaultRuntimeTypeForMetaObjectValueType()
{
Expression exp = Expression.Default(typeof(ValueTypeOnlyKnownHere));
NopDynamicObject nop = new NopDynamicObject();
DynamicMetaObject dmo = nop.GetMetaObject(exp);
Assert.Same(typeof(ValueTypeOnlyKnownHere), dmo.RuntimeType);
Assert.Same(typeof(ValueTypeOnlyKnownHere), dmo.LimitType);
}
[Fact]
public void MetaObjectNullExpression()
{
NopDynamicObject nop = new NopDynamicObject();
// Ideally the name returned should be "parameter" to match that on GetMetaObject
// but the only way to change this without making other calls incorrect and without
// a breaking change to names would be to catch and rethrow, which is more expensive
// than it's worth.
AssertExtensions.Throws<ArgumentNullException>("expression", () => nop.GetMetaObject(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.Linq.Expressions;
using Xunit;
namespace System.Dynamic.Tests
{
public class DynamicObjectDefaultBehaviorTests
{
private class TypeOnlyKnownHere
{
}
private struct ValueTypeOnlyKnownHere
{
}
private class NopDynamicObject : DynamicObject
{
// Adds no functionality.
}
[Fact]
public void TryGetMemberDefaultsToFalseWithNoValidation()
{
object result;
Assert.False(new NopDynamicObject().TryGetMember(null, out result));
Assert.Null(result);
}
[Fact]
public void TrySetMemberDefaultsToFalseWithNoValidation()
{
Assert.False(new NopDynamicObject().TrySetMember(null, null));
}
[Fact]
public void TryDeleteMemberDefaultsToFalseWithNoValidation()
{
Assert.False(new NopDynamicObject().TryDeleteMember(null));
}
[Fact]
public void TryInvokeMemberDefaultsToFalseWithNoValidation()
{
object result;
Assert.False(new NopDynamicObject().TryInvokeMember(null, null, out result));
Assert.Null(result);
}
[Fact]
public void TryConvertDefaultsToFalseWithNoValidation()
{
object result;
Assert.False(new NopDynamicObject().TryConvert(null, out result));
Assert.Null(result);
}
[Fact]
public void TryCreateInstanceDefaultsToFalseWithNoValidation()
{
object result;
Assert.False(new NopDynamicObject().TryCreateInstance(null, null, out result));
Assert.Null(result);
}
[Fact]
public void TryInvokeDefaultsToFalseWithNoValidation()
{
object result;
Assert.False(new NopDynamicObject().TryInvoke(null, null, out result));
Assert.Null(result);
}
[Fact]
public void TryBinaryOperationDefaultsToFalseWithNoValidation()
{
object result;
Assert.False(new NopDynamicObject().TryBinaryOperation(null, null, out result));
Assert.Null(result);
}
[Fact]
public void TryUnaryOperationDefaultsToFalseWithNoValidation()
{
object result;
Assert.False(new NopDynamicObject().TryUnaryOperation(null, out result));
Assert.Null(result);
}
[Fact]
public void TryGetIndexDefaultsToFalseWithNoValidation()
{
object result;
Assert.False(new NopDynamicObject().TryGetIndex(null, null, out result));
Assert.Null(result);
}
[Fact]
public void TrySetIndexDefaultsToFalseWithNoValidation()
{
Assert.False(new NopDynamicObject().TrySetIndex(null, null, null));
}
[Fact]
public void TryDeleteIndexDefaultsToFalseWithNoValidation()
{
Assert.False(new NopDynamicObject().TryDeleteIndex(null, null));
}
[Fact]
public void GetDynamicMemberNamesDefaultsToEmptyArray()
{
Assert.Same(Array.Empty<string>(), new NopDynamicObject().GetDynamicMemberNames());
}
[Fact]
public void DefaultPropertiesForMetaObject()
{
Expression exp = Expression.Default(typeof(TypeOnlyKnownHere));
NopDynamicObject nop = new NopDynamicObject();
DynamicMetaObject dmo = nop.GetMetaObject(exp);
Assert.Same(nop, dmo.Value);
Assert.Same(exp, dmo.Expression);
Assert.True(dmo.HasValue);
Assert.Same(BindingRestrictions.Empty, dmo.Restrictions);
}
[Fact]
public void DefaultRuntimeTypeForMetaObjectReferenceType()
{
Expression exp = Expression.Default(typeof(TypeOnlyKnownHere));
NopDynamicObject nop = new NopDynamicObject();
DynamicMetaObject dmo = nop.GetMetaObject(exp);
Assert.Same(typeof(NopDynamicObject), dmo.RuntimeType);
Assert.Same(typeof(NopDynamicObject), dmo.LimitType);
}
[Fact]
public void DefaultRuntimeTypeForMetaObjectValueType()
{
Expression exp = Expression.Default(typeof(ValueTypeOnlyKnownHere));
NopDynamicObject nop = new NopDynamicObject();
DynamicMetaObject dmo = nop.GetMetaObject(exp);
Assert.Same(typeof(ValueTypeOnlyKnownHere), dmo.RuntimeType);
Assert.Same(typeof(ValueTypeOnlyKnownHere), dmo.LimitType);
}
[Fact]
public void MetaObjectNullExpression()
{
NopDynamicObject nop = new NopDynamicObject();
// Ideally the name returned should be "parameter" to match that on GetMetaObject
// but the only way to change this without making other calls incorrect and without
// a breaking change to names would be to catch and rethrow, which is more expensive
// than it's worth.
AssertExtensions.Throws<ArgumentNullException>("expression", () => nop.GetMetaObject(null));
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b14066/b14066.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace DefaultNamespace
{
public class Prob
{
public static int Main(System.String[] Args)
{
System.Console.WriteLine(System.Math.Exp(System.Double.PositiveInfinity));
System.Console.WriteLine(System.Math.Exp(System.Double.NegativeInfinity));
return 100;
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace DefaultNamespace
{
public class Prob
{
public static int Main(System.String[] Args)
{
System.Console.WriteLine(System.Math.Exp(System.Double.PositiveInfinity));
System.Console.WriteLine(System.Math.Exp(System.Double.NegativeInfinity));
return 100;
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Formats.Cbor/ref/System.Formats.Cbor.netcoreapp.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.Formats.Cbor
{
public partial class CborReader
{
public System.Half ReadHalf() { throw null; }
}
public partial class CborWriter
{
public void WriteHalf(System.Half value) { }
}
}
| // 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.Formats.Cbor
{
public partial class CborReader
{
public System.Half ReadHalf() { throw null; }
}
public partial class CborWriter
{
public void WriteHalf(System.Half value) { }
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/Microsoft.Extensions.Logging.TraceSource/ref/Microsoft.Extensions.Logging.TraceSource.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 Microsoft.Extensions.Logging
{
public static partial class TraceSourceFactoryExtensions
{
public static Microsoft.Extensions.Logging.ILoggingBuilder AddTraceSource(this Microsoft.Extensions.Logging.ILoggingBuilder builder, System.Diagnostics.SourceSwitch sourceSwitch) { throw null; }
public static Microsoft.Extensions.Logging.ILoggingBuilder AddTraceSource(this Microsoft.Extensions.Logging.ILoggingBuilder builder, System.Diagnostics.SourceSwitch sourceSwitch, System.Diagnostics.TraceListener listener) { throw null; }
public static Microsoft.Extensions.Logging.ILoggingBuilder AddTraceSource(this Microsoft.Extensions.Logging.ILoggingBuilder builder, string switchName) { throw null; }
public static Microsoft.Extensions.Logging.ILoggingBuilder AddTraceSource(this Microsoft.Extensions.Logging.ILoggingBuilder builder, string switchName, System.Diagnostics.TraceListener listener) { throw null; }
}
}
namespace Microsoft.Extensions.Logging.TraceSource
{
[Microsoft.Extensions.Logging.ProviderAliasAttribute("TraceSource")]
public partial class TraceSourceLoggerProvider : Microsoft.Extensions.Logging.ILoggerProvider, System.IDisposable
{
public TraceSourceLoggerProvider(System.Diagnostics.SourceSwitch rootSourceSwitch) { }
public TraceSourceLoggerProvider(System.Diagnostics.SourceSwitch rootSourceSwitch, System.Diagnostics.TraceListener rootTraceListener) { }
public Microsoft.Extensions.Logging.ILogger CreateLogger(string name) { throw null; }
public void Dispose() { }
}
}
| // 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 Microsoft.Extensions.Logging
{
public static partial class TraceSourceFactoryExtensions
{
public static Microsoft.Extensions.Logging.ILoggingBuilder AddTraceSource(this Microsoft.Extensions.Logging.ILoggingBuilder builder, System.Diagnostics.SourceSwitch sourceSwitch) { throw null; }
public static Microsoft.Extensions.Logging.ILoggingBuilder AddTraceSource(this Microsoft.Extensions.Logging.ILoggingBuilder builder, System.Diagnostics.SourceSwitch sourceSwitch, System.Diagnostics.TraceListener listener) { throw null; }
public static Microsoft.Extensions.Logging.ILoggingBuilder AddTraceSource(this Microsoft.Extensions.Logging.ILoggingBuilder builder, string switchName) { throw null; }
public static Microsoft.Extensions.Logging.ILoggingBuilder AddTraceSource(this Microsoft.Extensions.Logging.ILoggingBuilder builder, string switchName, System.Diagnostics.TraceListener listener) { throw null; }
}
}
namespace Microsoft.Extensions.Logging.TraceSource
{
[Microsoft.Extensions.Logging.ProviderAliasAttribute("TraceSource")]
public partial class TraceSourceLoggerProvider : Microsoft.Extensions.Logging.ILoggerProvider, System.IDisposable
{
public TraceSourceLoggerProvider(System.Diagnostics.SourceSwitch rootSourceSwitch) { }
public TraceSourceLoggerProvider(System.Diagnostics.SourceSwitch rootSourceSwitch, System.Diagnostics.TraceListener rootTraceListener) { }
public Microsoft.Extensions.Logging.ILogger CreateLogger(string name) { throw null; }
public void Dispose() { }
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b320147/1086745236.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.Runtime.InteropServices;
public struct AA
{
public void Method1()
{
bool local1 = true;
for (; local1; )
{
if (local1)
break;
}
do
{
if (local1)
break;
}
while (local1);
return;
}
}
[StructLayout(LayoutKind.Sequential)]
public class App
{
static int Main()
{
try
{
Console.WriteLine("Testing AA::Method1");
new AA().Method1();
}
catch (Exception x)
{
Console.WriteLine("Exception handled: " + x.ToString());
}
// JIT Stress test... if jitted it passes
Console.WriteLine("Passed.");
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.Collections;
using System.Runtime.InteropServices;
public struct AA
{
public void Method1()
{
bool local1 = true;
for (; local1; )
{
if (local1)
break;
}
do
{
if (local1)
break;
}
while (local1);
return;
}
}
[StructLayout(LayoutKind.Sequential)]
public class App
{
static int Main()
{
try
{
Console.WriteLine("Testing AA::Method1");
new AA().Method1();
}
catch (Exception x)
{
Console.WriteLine("Exception handled: " + x.ToString());
}
// JIT Stress test... if jitted it passes
Console.WriteLine("Passed.");
return 100;
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.ComponentModel.Composition.Registration/tests/InternalCalls.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using System.Reflection;
namespace System.ComponentModel.Composition.Registration.Tests
{
public static class InternalCalls
{
public static void BuildAttributes(this ExportBuilder builder, Type type, ref List<Attribute> attributes)
{
builder.GetType()
.GetMethod(nameof(BuildAttributes), BindingFlags.NonPublic | BindingFlags.Instance)
.Invoke(builder, new object[] { type, attributes });
}
public static void BuildAttributes(this ImportBuilder builder, Type type, ref List<Attribute> attributes)
{
builder.GetType()
.GetMethod(nameof(BuildAttributes), BindingFlags.NonPublic | BindingFlags.Instance)
.Invoke(builder, new object[] { type, attributes });
}
public static PartBuilder PartBuilder(Predicate<Type> selectType)
{
return (PartBuilder)typeof(PartBuilder)
.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(Predicate<Type>) }, null)
.Invoke(new object[] { selectType });
}
public static PartBuilder<T> PartBuilder<T>(Predicate<Type> selectType)
{
return (PartBuilder<T>)typeof(PartBuilder<T>)
.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(Predicate<Type>) }, null)
.Invoke(new object[] { selectType });
}
public static IEnumerable<Attribute> BuildTypeAttributes(this PartBuilder builder, Type type)
{
return (IEnumerable<Attribute>)builder.GetType()
.GetMethod(nameof(BuildTypeAttributes), BindingFlags.NonPublic | BindingFlags.Instance)
.Invoke(builder, new object[] { type });
}
public static bool BuildConstructorAttributes(this PartBuilder builder, Type type, ref List<Tuple<object, List<Attribute>>> configuredMembers)
{
return (bool)builder.GetType()
.GetMethod(nameof(BuildConstructorAttributes), BindingFlags.NonPublic | BindingFlags.Instance)
.Invoke(builder, new object[] { type, configuredMembers });
}
public static void BuildPropertyAttributes(this PartBuilder builder, Type type, ref List<Tuple<object, List<Attribute>>> configuredMembers)
{
builder.GetType()
.GetMethod(nameof(BuildPropertyAttributes), BindingFlags.NonPublic | BindingFlags.Instance)
.Invoke(builder, new object[] { type, configuredMembers });
}
public static void PartBuilder_BuildDefaultConstructorAttributes(Type type, ref List<Tuple<object, List<Attribute>>> configuredMembers)
{
typeof(PartBuilder)
.GetMethod("BuildDefaultConstructorAttributes", BindingFlags.NonPublic | BindingFlags.Static)
.Invoke(null, new object[] { type, configuredMembers });
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using System.Reflection;
namespace System.ComponentModel.Composition.Registration.Tests
{
public static class InternalCalls
{
public static void BuildAttributes(this ExportBuilder builder, Type type, ref List<Attribute> attributes)
{
builder.GetType()
.GetMethod(nameof(BuildAttributes), BindingFlags.NonPublic | BindingFlags.Instance)
.Invoke(builder, new object[] { type, attributes });
}
public static void BuildAttributes(this ImportBuilder builder, Type type, ref List<Attribute> attributes)
{
builder.GetType()
.GetMethod(nameof(BuildAttributes), BindingFlags.NonPublic | BindingFlags.Instance)
.Invoke(builder, new object[] { type, attributes });
}
public static PartBuilder PartBuilder(Predicate<Type> selectType)
{
return (PartBuilder)typeof(PartBuilder)
.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(Predicate<Type>) }, null)
.Invoke(new object[] { selectType });
}
public static PartBuilder<T> PartBuilder<T>(Predicate<Type> selectType)
{
return (PartBuilder<T>)typeof(PartBuilder<T>)
.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(Predicate<Type>) }, null)
.Invoke(new object[] { selectType });
}
public static IEnumerable<Attribute> BuildTypeAttributes(this PartBuilder builder, Type type)
{
return (IEnumerable<Attribute>)builder.GetType()
.GetMethod(nameof(BuildTypeAttributes), BindingFlags.NonPublic | BindingFlags.Instance)
.Invoke(builder, new object[] { type });
}
public static bool BuildConstructorAttributes(this PartBuilder builder, Type type, ref List<Tuple<object, List<Attribute>>> configuredMembers)
{
return (bool)builder.GetType()
.GetMethod(nameof(BuildConstructorAttributes), BindingFlags.NonPublic | BindingFlags.Instance)
.Invoke(builder, new object[] { type, configuredMembers });
}
public static void BuildPropertyAttributes(this PartBuilder builder, Type type, ref List<Tuple<object, List<Attribute>>> configuredMembers)
{
builder.GetType()
.GetMethod(nameof(BuildPropertyAttributes), BindingFlags.NonPublic | BindingFlags.Instance)
.Invoke(builder, new object[] { type, configuredMembers });
}
public static void PartBuilder_BuildDefaultConstructorAttributes(Type type, ref List<Tuple<object, List<Attribute>>> configuredMembers)
{
typeof(PartBuilder)
.GetMethod("BuildDefaultConstructorAttributes", BindingFlags.NonPublic | BindingFlags.Static)
.Invoke(null, new object[] { type, configuredMembers });
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/coreclr/tools/dotnet-pgo/TraceTypeSystemContext.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.Diagnostics;
using System.Reflection.PortableExecutable;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Text;
using Internal.TypeSystem;
using Internal.TypeSystem.Ecma;
using Microsoft.Diagnostics.Tracing.Etlx;
using System.IO;
using System.IO.MemoryMappedFiles;
using Microsoft.Diagnostics.Tracing.Parsers.Clr;
using System.Reflection.Metadata;
using ILCompiler.Reflection.ReadyToRun;
using System.Runtime.CompilerServices;
namespace Microsoft.Diagnostics.Tools.Pgo
{
class TraceTypeSystemContext : MetadataTypeSystemContext, IMetadataStringDecoderProvider, IAssemblyResolver
{
private readonly PgoTraceProcess _pgoTraceProcess;
private readonly ModuleLoadLogger _moduleLoadLogger;
private int _clrInstanceID;
private readonly Dictionary<string,string> _normalizedFilePathToFilePath = new Dictionary<string,string> (StringComparer.OrdinalIgnoreCase);
public TraceTypeSystemContext(PgoTraceProcess traceProcess, int clrInstanceID, Logger logger)
{
foreach (var traceData in traceProcess.TraceProcess.EventsInProcess.ByEventType<ModuleLoadUnloadTraceData>())
{
if (traceData.ModuleILPath != null)
{
_normalizedFilePathToFilePath[traceData.ModuleILPath] = traceData.ModuleILPath;
}
}
_pgoTraceProcess = traceProcess;
_clrInstanceID = clrInstanceID;
_moduleLoadLogger = new ModuleLoadLogger(logger);
}
public bool Initialize()
{
ModuleDesc systemModule = GetModuleForSimpleName("System.Private.CoreLib", false);
if (systemModule == null)
return false;
SetSystemModule(systemModule);
return true;
}
public override bool SupportsCanon => true;
public override bool SupportsUniversalCanon => false;
private class ModuleData
{
public string SimpleName;
public string FilePath;
public EcmaModule Module;
public MemoryMappedViewAccessor MappedViewAccessor;
}
private class ModuleHashtable : LockFreeReaderHashtable<EcmaModule, ModuleData>
{
protected override int GetKeyHashCode(EcmaModule key)
{
return key.GetHashCode();
}
protected override int GetValueHashCode(ModuleData value)
{
return value.Module.GetHashCode();
}
protected override bool CompareKeyToValue(EcmaModule key, ModuleData value)
{
return Object.ReferenceEquals(key, value.Module);
}
protected override bool CompareValueToValue(ModuleData value1, ModuleData value2)
{
return Object.ReferenceEquals(value1.Module, value2.Module);
}
protected override ModuleData CreateValueFromKey(EcmaModule key)
{
Debug.Fail("CreateValueFromKey not supported");
return null;
}
}
private readonly ModuleHashtable _moduleHashtable = new ModuleHashtable();
private readonly Dictionary<string, ModuleData> _simpleNameHashtable = new Dictionary<string, ModuleData>(StringComparer.OrdinalIgnoreCase);
public override ModuleDesc ResolveAssembly(System.Reflection.AssemblyName name, bool throwIfNotFound)
{
// TODO: catch typesystem BadImageFormatException and throw a new one that also captures the
// assembly name that caused the failure. (Along with the reason, which makes this rather annoying).
return GetModuleForSimpleName(name.Name, throwIfNotFound);
}
public ModuleDesc GetModuleForSimpleName(string simpleName, bool throwIfNotFound = true)
{
lock (this)
{
ModuleData existing;
if (_simpleNameHashtable.TryGetValue(simpleName, out existing))
{
if (existing == null)
{
if (throwIfNotFound)
{
ThrowHelper.ThrowFileNotFoundException(ExceptionStringID.FileLoadErrorGeneric, simpleName);
}
else
{
return null;
}
}
return existing.Module;
}
string filePath = null;
foreach (var module in _pgoTraceProcess.EnumerateLoadedManagedModules())
{
var managedModule = module.ManagedModule;
if (module.ClrInstanceID != _clrInstanceID)
continue;
if (PgoTraceProcess.CompareModuleAgainstSimpleName(simpleName, managedModule))
{
string filePathTemp = PgoTraceProcess.ComputeFilePathOnDiskForModule(managedModule);
// This path may be normalized
if (File.Exists(filePathTemp) || !_normalizedFilePathToFilePath.TryGetValue(filePathTemp, out filePath))
filePath = filePathTemp;
break;
}
}
if (filePath == null)
{
// TODO: the exception is wrong for two reasons: for one, this should be assembly full name, not simple name.
// The other reason is that on CoreCLR, the exception also captures the reason. We should be passing two
// string IDs. This makes this rather annoying.
_moduleLoadLogger.LogModuleLoadFailure(simpleName);
if (throwIfNotFound)
ThrowHelper.ThrowFileNotFoundException(ExceptionStringID.FileLoadErrorGeneric, simpleName);
return null;
}
bool succeededOrReportedError = false;
try
{
ModuleDesc returnValue = AddModule(filePath, simpleName, null, true);
_moduleLoadLogger.LogModuleLoadSuccess(simpleName, filePath);
succeededOrReportedError = true;
return returnValue;
}
catch (Exception) when (!throwIfNotFound)
{
_moduleLoadLogger.LogModuleLoadFailure(simpleName, filePath);
succeededOrReportedError = true;
_simpleNameHashtable.Add(simpleName, null);
return null;
}
finally
{
if (!succeededOrReportedError)
{
_moduleLoadLogger.LogModuleLoadFailure(simpleName, filePath);
_simpleNameHashtable.Add(simpleName, null);
}
}
}
}
public EcmaModule GetModuleFromPath(string filePath, bool throwIfNotLoadable = true)
{
return GetOrAddModuleFromPath(filePath, null, true, throwIfNotLoadable: throwIfNotLoadable);
}
public EcmaModule GetMetadataOnlyModuleFromPath(string filePath)
{
return GetOrAddModuleFromPath(filePath, null, false);
}
public EcmaModule GetMetadataOnlyModuleFromMemory(string filePath, byte[] moduleData)
{
return GetOrAddModuleFromPath(filePath, moduleData, false);
}
private EcmaModule GetOrAddModuleFromPath(string filePath, byte[] moduleData, bool useForBinding, bool throwIfNotLoadable = true)
{
// This method is not expected to be called frequently. Linear search is acceptable.
foreach (var entry in ModuleHashtable.Enumerator.Get(_moduleHashtable))
{
if (entry.FilePath == filePath)
return entry.Module;
}
bool succeeded = false;
try
{
EcmaModule returnValue = AddModule(filePath, null, moduleData, useForBinding, throwIfNotLoadable: throwIfNotLoadable);
if (returnValue != null)
{
_moduleLoadLogger.LogModuleLoadSuccess(returnValue.Assembly.GetName().Name, filePath);
succeeded = true;
return returnValue;
}
}
finally
{
if (!succeeded)
{
_moduleLoadLogger.LogModuleLoadFailure(Path.GetFileNameWithoutExtension(filePath), filePath);
}
}
return null;
}
private static ConditionalWeakTable<PEReader, string> s_peReaderToPath = new ConditionalWeakTable<PEReader, string>();
// Get the file path used to load a PEReader or "Memory" if it wasn't loaded from a file
public string PEReaderToFilePath(PEReader reader)
{
if (!s_peReaderToPath.TryGetValue(reader, out string filepath))
{
filepath = "Memory";
}
return filepath;
}
public static unsafe PEReader OpenPEFile(string filePath, byte[] moduleBytes, out MemoryMappedViewAccessor mappedViewAccessor)
{
// If moduleBytes is specified create PEReader from the in memory array, not from a file on disk
if (moduleBytes != null)
{
var peReader = new PEReader(ImmutableArray.Create<byte>(moduleBytes));
mappedViewAccessor = null;
return peReader;
}
// System.Reflection.Metadata has heuristic that tries to save virtual address space. This heuristic does not work
// well for us since it can make IL access very slow (call to OS for each method IL query). We will map the file
// ourselves to get the desired performance characteristics reliably.
FileStream fileStream = null;
MemoryMappedFile mappedFile = null;
MemoryMappedViewAccessor accessor = null;
try
{
// Create stream because CreateFromFile(string, ...) uses FileShare.None which is too strict
fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 1);
mappedFile = MemoryMappedFile.CreateFromFile(
fileStream, null, fileStream.Length, MemoryMappedFileAccess.Read, HandleInheritability.None, true);
accessor = mappedFile.CreateViewAccessor(0, 0, MemoryMappedFileAccess.Read);
var safeBuffer = accessor.SafeMemoryMappedViewHandle;
var peReader = new PEReader((byte*)safeBuffer.DangerousGetHandle(), (int)safeBuffer.ByteLength);
s_peReaderToPath.Add(peReader, filePath);
// MemoryMappedFile does not need to be kept around. MemoryMappedViewAccessor is enough.
mappedViewAccessor = accessor;
accessor = null;
return peReader;
}
finally
{
accessor?.Dispose();
mappedFile?.Dispose();
fileStream?.Dispose();
}
}
private EcmaModule AddModule(string filePath, string expectedSimpleName, byte[] moduleDataBytes, bool useForBinding, bool throwIfNotLoadable = true)
{
MemoryMappedViewAccessor mappedViewAccessor = null;
PdbSymbolReader pdbReader = null;
try
{
PEReader peReader = OpenPEFile(filePath, moduleDataBytes, out mappedViewAccessor);
if ((!peReader.HasMetadata) && !throwIfNotLoadable)
{
return null;
}
pdbReader = OpenAssociatedSymbolFile(filePath, peReader);
EcmaModule module = EcmaModule.Create(this, peReader, containingAssembly: null, pdbReader);
MetadataReader metadataReader = module.MetadataReader;
string simpleName = metadataReader.GetString(metadataReader.GetAssemblyDefinition().Name);
ModuleData moduleData = new ModuleData()
{
SimpleName = simpleName,
FilePath = filePath,
Module = module,
MappedViewAccessor = mappedViewAccessor
};
lock (this)
{
if (useForBinding)
{
ModuleData actualModuleData;
if (!_simpleNameHashtable.TryGetValue(moduleData.SimpleName, out actualModuleData))
{
_simpleNameHashtable.Add(moduleData.SimpleName, moduleData);
actualModuleData = moduleData;
}
if (actualModuleData != moduleData)
{
if (actualModuleData.FilePath != filePath)
throw new FileNotFoundException("Module with same simple name already exists " + filePath);
return actualModuleData.Module;
}
}
mappedViewAccessor = null; // Ownership has been transfered
pdbReader = null; // Ownership has been transferred
_moduleHashtable.AddOrGetExisting(moduleData);
}
return module;
}
catch when (!throwIfNotLoadable)
{
return null;
}
finally
{
if (mappedViewAccessor != null)
mappedViewAccessor.Dispose();
if (pdbReader != null)
pdbReader.Dispose();
}
}
//
// Symbols
//
private PdbSymbolReader OpenAssociatedSymbolFile(string peFilePath, PEReader peReader)
{
// Assume that the .pdb file is next to the binary
var pdbFilename = Path.ChangeExtension(peFilePath, ".pdb");
if (!File.Exists(pdbFilename))
{
pdbFilename = null;
// If the file doesn't exist, try the path specified in the CodeView section of the image
foreach (DebugDirectoryEntry debugEntry in peReader.ReadDebugDirectory())
{
if (debugEntry.Type != DebugDirectoryEntryType.CodeView)
continue;
string candidateFileName = peReader.ReadCodeViewDebugDirectoryData(debugEntry).Path;
if (Path.IsPathRooted(candidateFileName) && File.Exists(candidateFileName))
{
pdbFilename = candidateFileName;
break;
}
}
if (pdbFilename == null)
return null;
}
// Try to open the symbol file as portable pdb first
PdbSymbolReader reader = PortablePdbSymbolReader.TryOpen(pdbFilename, GetMetadataStringDecoder());
return reader;
}
private MetadataStringDecoder _metadataStringDecoder;
public MetadataStringDecoder GetMetadataStringDecoder()
{
if (_metadataStringDecoder == null)
_metadataStringDecoder = new CachingMetadataStringDecoder(0x10000); // TODO: Tune the size
return _metadataStringDecoder;
}
IAssemblyMetadata IAssemblyResolver.FindAssembly(MetadataReader metadataReader, AssemblyReferenceHandle assemblyReferenceHandle, string parentFile)
{
using var triggerErrors = new ModuleLoadLogger.LoadFailuresAsErrors();
EcmaAssembly ecmaAssembly = (EcmaAssembly)this.GetModuleForSimpleName(metadataReader.GetString(metadataReader.GetAssemblyReference(assemblyReferenceHandle).Name), false);
return new StandaloneAssemblyMetadata(ecmaAssembly.PEReader);
}
IAssemblyMetadata IAssemblyResolver.FindAssembly(string simpleName, string parentFile)
{
using var triggerErrors = new ModuleLoadLogger.LoadFailuresAsErrors();
EcmaAssembly ecmaAssembly = (EcmaAssembly)this.GetModuleForSimpleName(simpleName, false);
return new StandaloneAssemblyMetadata(ecmaAssembly.PEReader);
}
}
}
| // 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.Diagnostics;
using System.Reflection.PortableExecutable;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Text;
using Internal.TypeSystem;
using Internal.TypeSystem.Ecma;
using Microsoft.Diagnostics.Tracing.Etlx;
using System.IO;
using System.IO.MemoryMappedFiles;
using Microsoft.Diagnostics.Tracing.Parsers.Clr;
using System.Reflection.Metadata;
using ILCompiler.Reflection.ReadyToRun;
using System.Runtime.CompilerServices;
namespace Microsoft.Diagnostics.Tools.Pgo
{
class TraceTypeSystemContext : MetadataTypeSystemContext, IMetadataStringDecoderProvider, IAssemblyResolver
{
private readonly PgoTraceProcess _pgoTraceProcess;
private readonly ModuleLoadLogger _moduleLoadLogger;
private int _clrInstanceID;
private readonly Dictionary<string,string> _normalizedFilePathToFilePath = new Dictionary<string,string> (StringComparer.OrdinalIgnoreCase);
public TraceTypeSystemContext(PgoTraceProcess traceProcess, int clrInstanceID, Logger logger)
{
foreach (var traceData in traceProcess.TraceProcess.EventsInProcess.ByEventType<ModuleLoadUnloadTraceData>())
{
if (traceData.ModuleILPath != null)
{
_normalizedFilePathToFilePath[traceData.ModuleILPath] = traceData.ModuleILPath;
}
}
_pgoTraceProcess = traceProcess;
_clrInstanceID = clrInstanceID;
_moduleLoadLogger = new ModuleLoadLogger(logger);
}
public bool Initialize()
{
ModuleDesc systemModule = GetModuleForSimpleName("System.Private.CoreLib", false);
if (systemModule == null)
return false;
SetSystemModule(systemModule);
return true;
}
public override bool SupportsCanon => true;
public override bool SupportsUniversalCanon => false;
private class ModuleData
{
public string SimpleName;
public string FilePath;
public EcmaModule Module;
public MemoryMappedViewAccessor MappedViewAccessor;
}
private class ModuleHashtable : LockFreeReaderHashtable<EcmaModule, ModuleData>
{
protected override int GetKeyHashCode(EcmaModule key)
{
return key.GetHashCode();
}
protected override int GetValueHashCode(ModuleData value)
{
return value.Module.GetHashCode();
}
protected override bool CompareKeyToValue(EcmaModule key, ModuleData value)
{
return Object.ReferenceEquals(key, value.Module);
}
protected override bool CompareValueToValue(ModuleData value1, ModuleData value2)
{
return Object.ReferenceEquals(value1.Module, value2.Module);
}
protected override ModuleData CreateValueFromKey(EcmaModule key)
{
Debug.Fail("CreateValueFromKey not supported");
return null;
}
}
private readonly ModuleHashtable _moduleHashtable = new ModuleHashtable();
private readonly Dictionary<string, ModuleData> _simpleNameHashtable = new Dictionary<string, ModuleData>(StringComparer.OrdinalIgnoreCase);
public override ModuleDesc ResolveAssembly(System.Reflection.AssemblyName name, bool throwIfNotFound)
{
// TODO: catch typesystem BadImageFormatException and throw a new one that also captures the
// assembly name that caused the failure. (Along with the reason, which makes this rather annoying).
return GetModuleForSimpleName(name.Name, throwIfNotFound);
}
public ModuleDesc GetModuleForSimpleName(string simpleName, bool throwIfNotFound = true)
{
lock (this)
{
ModuleData existing;
if (_simpleNameHashtable.TryGetValue(simpleName, out existing))
{
if (existing == null)
{
if (throwIfNotFound)
{
ThrowHelper.ThrowFileNotFoundException(ExceptionStringID.FileLoadErrorGeneric, simpleName);
}
else
{
return null;
}
}
return existing.Module;
}
string filePath = null;
foreach (var module in _pgoTraceProcess.EnumerateLoadedManagedModules())
{
var managedModule = module.ManagedModule;
if (module.ClrInstanceID != _clrInstanceID)
continue;
if (PgoTraceProcess.CompareModuleAgainstSimpleName(simpleName, managedModule))
{
string filePathTemp = PgoTraceProcess.ComputeFilePathOnDiskForModule(managedModule);
// This path may be normalized
if (File.Exists(filePathTemp) || !_normalizedFilePathToFilePath.TryGetValue(filePathTemp, out filePath))
filePath = filePathTemp;
break;
}
}
if (filePath == null)
{
// TODO: the exception is wrong for two reasons: for one, this should be assembly full name, not simple name.
// The other reason is that on CoreCLR, the exception also captures the reason. We should be passing two
// string IDs. This makes this rather annoying.
_moduleLoadLogger.LogModuleLoadFailure(simpleName);
if (throwIfNotFound)
ThrowHelper.ThrowFileNotFoundException(ExceptionStringID.FileLoadErrorGeneric, simpleName);
return null;
}
bool succeededOrReportedError = false;
try
{
ModuleDesc returnValue = AddModule(filePath, simpleName, null, true);
_moduleLoadLogger.LogModuleLoadSuccess(simpleName, filePath);
succeededOrReportedError = true;
return returnValue;
}
catch (Exception) when (!throwIfNotFound)
{
_moduleLoadLogger.LogModuleLoadFailure(simpleName, filePath);
succeededOrReportedError = true;
_simpleNameHashtable.Add(simpleName, null);
return null;
}
finally
{
if (!succeededOrReportedError)
{
_moduleLoadLogger.LogModuleLoadFailure(simpleName, filePath);
_simpleNameHashtable.Add(simpleName, null);
}
}
}
}
public EcmaModule GetModuleFromPath(string filePath, bool throwIfNotLoadable = true)
{
return GetOrAddModuleFromPath(filePath, null, true, throwIfNotLoadable: throwIfNotLoadable);
}
public EcmaModule GetMetadataOnlyModuleFromPath(string filePath)
{
return GetOrAddModuleFromPath(filePath, null, false);
}
public EcmaModule GetMetadataOnlyModuleFromMemory(string filePath, byte[] moduleData)
{
return GetOrAddModuleFromPath(filePath, moduleData, false);
}
private EcmaModule GetOrAddModuleFromPath(string filePath, byte[] moduleData, bool useForBinding, bool throwIfNotLoadable = true)
{
// This method is not expected to be called frequently. Linear search is acceptable.
foreach (var entry in ModuleHashtable.Enumerator.Get(_moduleHashtable))
{
if (entry.FilePath == filePath)
return entry.Module;
}
bool succeeded = false;
try
{
EcmaModule returnValue = AddModule(filePath, null, moduleData, useForBinding, throwIfNotLoadable: throwIfNotLoadable);
if (returnValue != null)
{
_moduleLoadLogger.LogModuleLoadSuccess(returnValue.Assembly.GetName().Name, filePath);
succeeded = true;
return returnValue;
}
}
finally
{
if (!succeeded)
{
_moduleLoadLogger.LogModuleLoadFailure(Path.GetFileNameWithoutExtension(filePath), filePath);
}
}
return null;
}
private static ConditionalWeakTable<PEReader, string> s_peReaderToPath = new ConditionalWeakTable<PEReader, string>();
// Get the file path used to load a PEReader or "Memory" if it wasn't loaded from a file
public string PEReaderToFilePath(PEReader reader)
{
if (!s_peReaderToPath.TryGetValue(reader, out string filepath))
{
filepath = "Memory";
}
return filepath;
}
public static unsafe PEReader OpenPEFile(string filePath, byte[] moduleBytes, out MemoryMappedViewAccessor mappedViewAccessor)
{
// If moduleBytes is specified create PEReader from the in memory array, not from a file on disk
if (moduleBytes != null)
{
var peReader = new PEReader(ImmutableArray.Create<byte>(moduleBytes));
mappedViewAccessor = null;
return peReader;
}
// System.Reflection.Metadata has heuristic that tries to save virtual address space. This heuristic does not work
// well for us since it can make IL access very slow (call to OS for each method IL query). We will map the file
// ourselves to get the desired performance characteristics reliably.
FileStream fileStream = null;
MemoryMappedFile mappedFile = null;
MemoryMappedViewAccessor accessor = null;
try
{
// Create stream because CreateFromFile(string, ...) uses FileShare.None which is too strict
fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 1);
mappedFile = MemoryMappedFile.CreateFromFile(
fileStream, null, fileStream.Length, MemoryMappedFileAccess.Read, HandleInheritability.None, true);
accessor = mappedFile.CreateViewAccessor(0, 0, MemoryMappedFileAccess.Read);
var safeBuffer = accessor.SafeMemoryMappedViewHandle;
var peReader = new PEReader((byte*)safeBuffer.DangerousGetHandle(), (int)safeBuffer.ByteLength);
s_peReaderToPath.Add(peReader, filePath);
// MemoryMappedFile does not need to be kept around. MemoryMappedViewAccessor is enough.
mappedViewAccessor = accessor;
accessor = null;
return peReader;
}
finally
{
accessor?.Dispose();
mappedFile?.Dispose();
fileStream?.Dispose();
}
}
private EcmaModule AddModule(string filePath, string expectedSimpleName, byte[] moduleDataBytes, bool useForBinding, bool throwIfNotLoadable = true)
{
MemoryMappedViewAccessor mappedViewAccessor = null;
PdbSymbolReader pdbReader = null;
try
{
PEReader peReader = OpenPEFile(filePath, moduleDataBytes, out mappedViewAccessor);
if ((!peReader.HasMetadata) && !throwIfNotLoadable)
{
return null;
}
pdbReader = OpenAssociatedSymbolFile(filePath, peReader);
EcmaModule module = EcmaModule.Create(this, peReader, containingAssembly: null, pdbReader);
MetadataReader metadataReader = module.MetadataReader;
string simpleName = metadataReader.GetString(metadataReader.GetAssemblyDefinition().Name);
ModuleData moduleData = new ModuleData()
{
SimpleName = simpleName,
FilePath = filePath,
Module = module,
MappedViewAccessor = mappedViewAccessor
};
lock (this)
{
if (useForBinding)
{
ModuleData actualModuleData;
if (!_simpleNameHashtable.TryGetValue(moduleData.SimpleName, out actualModuleData))
{
_simpleNameHashtable.Add(moduleData.SimpleName, moduleData);
actualModuleData = moduleData;
}
if (actualModuleData != moduleData)
{
if (actualModuleData.FilePath != filePath)
throw new FileNotFoundException("Module with same simple name already exists " + filePath);
return actualModuleData.Module;
}
}
mappedViewAccessor = null; // Ownership has been transfered
pdbReader = null; // Ownership has been transferred
_moduleHashtable.AddOrGetExisting(moduleData);
}
return module;
}
catch when (!throwIfNotLoadable)
{
return null;
}
finally
{
if (mappedViewAccessor != null)
mappedViewAccessor.Dispose();
if (pdbReader != null)
pdbReader.Dispose();
}
}
//
// Symbols
//
private PdbSymbolReader OpenAssociatedSymbolFile(string peFilePath, PEReader peReader)
{
// Assume that the .pdb file is next to the binary
var pdbFilename = Path.ChangeExtension(peFilePath, ".pdb");
if (!File.Exists(pdbFilename))
{
pdbFilename = null;
// If the file doesn't exist, try the path specified in the CodeView section of the image
foreach (DebugDirectoryEntry debugEntry in peReader.ReadDebugDirectory())
{
if (debugEntry.Type != DebugDirectoryEntryType.CodeView)
continue;
string candidateFileName = peReader.ReadCodeViewDebugDirectoryData(debugEntry).Path;
if (Path.IsPathRooted(candidateFileName) && File.Exists(candidateFileName))
{
pdbFilename = candidateFileName;
break;
}
}
if (pdbFilename == null)
return null;
}
// Try to open the symbol file as portable pdb first
PdbSymbolReader reader = PortablePdbSymbolReader.TryOpen(pdbFilename, GetMetadataStringDecoder());
return reader;
}
private MetadataStringDecoder _metadataStringDecoder;
public MetadataStringDecoder GetMetadataStringDecoder()
{
if (_metadataStringDecoder == null)
_metadataStringDecoder = new CachingMetadataStringDecoder(0x10000); // TODO: Tune the size
return _metadataStringDecoder;
}
IAssemblyMetadata IAssemblyResolver.FindAssembly(MetadataReader metadataReader, AssemblyReferenceHandle assemblyReferenceHandle, string parentFile)
{
using var triggerErrors = new ModuleLoadLogger.LoadFailuresAsErrors();
EcmaAssembly ecmaAssembly = (EcmaAssembly)this.GetModuleForSimpleName(metadataReader.GetString(metadataReader.GetAssemblyReference(assemblyReferenceHandle).Name), false);
return new StandaloneAssemblyMetadata(ecmaAssembly.PEReader);
}
IAssemblyMetadata IAssemblyResolver.FindAssembly(string simpleName, string parentFile)
{
using var triggerErrors = new ModuleLoadLogger.LoadFailuresAsErrors();
EcmaAssembly ecmaAssembly = (EcmaAssembly)this.GetModuleForSimpleName(simpleName, false);
return new StandaloneAssemblyMetadata(ecmaAssembly.PEReader);
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Net.Mail/src/System/Net/Mime/ByteEncoder.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.Text;
namespace System.Net.Mime
{
internal abstract class ByteEncoder : IByteEncoder
{
internal abstract WriteStateInfoBase WriteState { get; }
protected abstract bool HasSpecialEncodingForCRLF { get; }
public string GetEncodedString() => Encoding.ASCII.GetString(WriteState.Buffer, 0, WriteState.Length);
public int EncodeBytes(byte[] buffer, int offset, int count, bool dontDeferFinalBytes, bool shouldAppendSpaceToCRLF)
{
// Add Encoding header, if any. e.g. =?encoding?b?
WriteState.AppendHeader();
bool _hasSpecialEncodingForCRLF = HasSpecialEncodingForCRLF;
int cur = offset;
for (; cur < count + offset; cur++)
{
if (LineBreakNeeded(buffer[cur]))
{
AppendPadding();
WriteState.AppendCRLF(shouldAppendSpaceToCRLF);
}
if (_hasSpecialEncodingForCRLF && IsCRLF(buffer, cur, count + offset))
{
AppendEncodedCRLF();
cur++; // Transformed two chars, so shift the index to account for that
}
else
{
ApppendEncodedByte(buffer[cur]);
}
}
if (dontDeferFinalBytes)
{
AppendPadding();
}
// Write out the last footer, if any. e.g. ?=
WriteState.AppendFooter();
return cur - offset;
}
public int EncodeString(string value, Encoding encoding)
{
Debug.Assert(value != null, "value was null");
Debug.Assert(WriteState != null, "writestate was null");
Debug.Assert(WriteState.Buffer != null, "writestate.buffer was null");
if (encoding == Encoding.Latin1) // we don't need to check for codepoints
{
byte[] buffer = encoding.GetBytes(value);
return EncodeBytes(buffer, 0, buffer.Length, true, true);
}
// Add Encoding header, if any. e.g. =?encoding?b?
WriteState.AppendHeader();
bool _hasSpecialEncodingForCRLF = HasSpecialEncodingForCRLF;
int totalBytesCount = 0;
byte[] bytes = new byte[encoding.GetMaxByteCount(2)];
for (int i = 0; i < value.Length; ++i)
{
int codepointSize = GetCodepointSize(value, i);
Debug.Assert(codepointSize == 1 || codepointSize == 2, "codepointSize was not 1 or 2");
int bytesCount = encoding.GetBytes(value, i, codepointSize, bytes, 0);
if (codepointSize == 2)
{
++i; // Transformed two chars, so shift the index to account for that
}
if (LineBreakNeeded(bytes, bytesCount))
{
AppendPadding();
WriteState.AppendCRLF(true);
}
if (_hasSpecialEncodingForCRLF && IsCRLF(bytes, bytesCount))
{
AppendEncodedCRLF();
}
else
{
AppendEncodedCodepoint(bytes, bytesCount);
}
totalBytesCount += bytesCount;
}
AppendPadding();
// Write out the last footer, if any. e.g. ?=
WriteState.AppendFooter();
return totalBytesCount;
}
protected abstract void AppendEncodedCRLF();
protected abstract bool LineBreakNeeded(byte b);
protected abstract bool LineBreakNeeded(byte[] bytes, int count);
protected abstract int GetCodepointSize(string value, int i);
public abstract void AppendPadding();
protected abstract void ApppendEncodedByte(byte b);
private void AppendEncodedCodepoint(byte[] bytes, int count)
{
for (int i = 0; i < count; ++i)
{
ApppendEncodedByte(bytes[i]);
}
}
protected bool IsSurrogatePair(string value, int i)
{
return char.IsSurrogate(value[i]) && i + 1 < value.Length && char.IsSurrogatePair(value[i], value[i + 1]);
}
protected bool IsCRLF(byte[] bytes, int count)
{
return count == 2 && IsCRLF(bytes, 0, count);
}
private bool IsCRLF(byte[] buffer, int i, int bufferSize)
{
return buffer[i] == '\r' && i + 1 < bufferSize && buffer[i + 1] == '\n';
}
}
}
| // 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.Text;
namespace System.Net.Mime
{
internal abstract class ByteEncoder : IByteEncoder
{
internal abstract WriteStateInfoBase WriteState { get; }
protected abstract bool HasSpecialEncodingForCRLF { get; }
public string GetEncodedString() => Encoding.ASCII.GetString(WriteState.Buffer, 0, WriteState.Length);
public int EncodeBytes(byte[] buffer, int offset, int count, bool dontDeferFinalBytes, bool shouldAppendSpaceToCRLF)
{
// Add Encoding header, if any. e.g. =?encoding?b?
WriteState.AppendHeader();
bool _hasSpecialEncodingForCRLF = HasSpecialEncodingForCRLF;
int cur = offset;
for (; cur < count + offset; cur++)
{
if (LineBreakNeeded(buffer[cur]))
{
AppendPadding();
WriteState.AppendCRLF(shouldAppendSpaceToCRLF);
}
if (_hasSpecialEncodingForCRLF && IsCRLF(buffer, cur, count + offset))
{
AppendEncodedCRLF();
cur++; // Transformed two chars, so shift the index to account for that
}
else
{
ApppendEncodedByte(buffer[cur]);
}
}
if (dontDeferFinalBytes)
{
AppendPadding();
}
// Write out the last footer, if any. e.g. ?=
WriteState.AppendFooter();
return cur - offset;
}
public int EncodeString(string value, Encoding encoding)
{
Debug.Assert(value != null, "value was null");
Debug.Assert(WriteState != null, "writestate was null");
Debug.Assert(WriteState.Buffer != null, "writestate.buffer was null");
if (encoding == Encoding.Latin1) // we don't need to check for codepoints
{
byte[] buffer = encoding.GetBytes(value);
return EncodeBytes(buffer, 0, buffer.Length, true, true);
}
// Add Encoding header, if any. e.g. =?encoding?b?
WriteState.AppendHeader();
bool _hasSpecialEncodingForCRLF = HasSpecialEncodingForCRLF;
int totalBytesCount = 0;
byte[] bytes = new byte[encoding.GetMaxByteCount(2)];
for (int i = 0; i < value.Length; ++i)
{
int codepointSize = GetCodepointSize(value, i);
Debug.Assert(codepointSize == 1 || codepointSize == 2, "codepointSize was not 1 or 2");
int bytesCount = encoding.GetBytes(value, i, codepointSize, bytes, 0);
if (codepointSize == 2)
{
++i; // Transformed two chars, so shift the index to account for that
}
if (LineBreakNeeded(bytes, bytesCount))
{
AppendPadding();
WriteState.AppendCRLF(true);
}
if (_hasSpecialEncodingForCRLF && IsCRLF(bytes, bytesCount))
{
AppendEncodedCRLF();
}
else
{
AppendEncodedCodepoint(bytes, bytesCount);
}
totalBytesCount += bytesCount;
}
AppendPadding();
// Write out the last footer, if any. e.g. ?=
WriteState.AppendFooter();
return totalBytesCount;
}
protected abstract void AppendEncodedCRLF();
protected abstract bool LineBreakNeeded(byte b);
protected abstract bool LineBreakNeeded(byte[] bytes, int count);
protected abstract int GetCodepointSize(string value, int i);
public abstract void AppendPadding();
protected abstract void ApppendEncodedByte(byte b);
private void AppendEncodedCodepoint(byte[] bytes, int count)
{
for (int i = 0; i < count; ++i)
{
ApppendEncodedByte(bytes[i]);
}
}
protected bool IsSurrogatePair(string value, int i)
{
return char.IsSurrogate(value[i]) && i + 1 < value.Length && char.IsSurrogatePair(value[i], value[i + 1]);
}
protected bool IsCRLF(byte[] bytes, int count)
{
return count == 2 && IsCRLF(bytes, 0, count);
}
private bool IsCRLF(byte[] buffer, int i, int bufferSize)
{
return buffer[i] == '\r' && i + 1 < bufferSize && buffer[i + 1] == '\n';
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Reflection.Context/tests/Properties/Resources.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="Reason" xml:space="preserve">
<value>This manifest is discovered by the CustomAssemblyTests.GetManifestResourceInfoTest. Do not delete!</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="Reason" xml:space="preserve">
<value>This manifest is discovered by the CustomAssemblyTests.GetManifestResourceInfoTest. Do not delete!</value>
</data>
</root>
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/coreclr/tools/Common/TypeSystem/Mangling/IPrefixMangledType.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
{
/// <summary>
/// When implemented by a <see cref="TypeDesc"/> or <see cref="MethodDesc"/>, instructs a name mangler to use the same mangled name
/// as another entity while prepending a specific prefix to that mangled name.
/// </summary>
public interface IPrefixMangledType
{
/// <summary>
/// Type whose mangled name to use.
/// </summary>
TypeDesc BaseType { get; }
/// <summary>
/// Prefix to apply when mangling.
/// </summary>
string Prefix { get; }
}
}
| // 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
{
/// <summary>
/// When implemented by a <see cref="TypeDesc"/> or <see cref="MethodDesc"/>, instructs a name mangler to use the same mangled name
/// as another entity while prepending a specific prefix to that mangled name.
/// </summary>
public interface IPrefixMangledType
{
/// <summary>
/// Type whose mangled name to use.
/// </summary>
TypeDesc BaseType { get; }
/// <summary>
/// Prefix to apply when mangling.
/// </summary>
string Prefix { get; }
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/Common/XUnitWrapperLibrary/TestFilter.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.Text;
namespace XUnitWrapperLibrary;
public class TestFilter
{
public interface ISearchClause
{
bool IsMatch(string fullyQualifiedName, string displayName, string[] traits);
}
public enum TermKind
{
FullyQualifiedName,
DisplayName
}
public sealed class NameClause : ISearchClause
{
public NameClause(TermKind kind, string filter, bool substring)
{
Kind = kind;
Filter = filter;
Substring = substring;
}
public TermKind Kind { get; }
public string Filter { get; }
public bool Substring { get; }
public bool IsMatch(string fullyQualifiedName, string displayName, string[] traits)
{
string stringToSearch = Kind switch
{
TermKind.FullyQualifiedName => fullyQualifiedName,
TermKind.DisplayName => displayName,
_ => throw new InvalidOperationException()
};
if (Substring)
{
return stringToSearch.Contains(Filter);
}
return stringToSearch == Filter;
}
}
public sealed class AndClause : ISearchClause
{
private ISearchClause _left;
private ISearchClause _right;
public AndClause(ISearchClause left, ISearchClause right)
{
_left = left;
_right = right;
}
public bool IsMatch(string fullyQualifiedName, string displayName, string[] traits) => _left.IsMatch(fullyQualifiedName, displayName, traits) && _right.IsMatch(fullyQualifiedName, displayName, traits);
}
public sealed class OrClause : ISearchClause
{
private ISearchClause _left;
private ISearchClause _right;
public OrClause(ISearchClause left, ISearchClause right)
{
_left = left;
_right = right;
}
public bool IsMatch(string fullyQualifiedName, string displayName, string[] traits) => _left.IsMatch(fullyQualifiedName, displayName, traits) || _right.IsMatch(fullyQualifiedName, displayName, traits);
}
public sealed class NotClause : ISearchClause
{
private ISearchClause _inner;
public NotClause(ISearchClause inner)
{
_inner = inner;
}
public bool IsMatch(string fullyQualifiedName, string displayName, string[] traits) => !_inner.IsMatch(fullyQualifiedName, displayName, traits);
}
private ISearchClause? _filter;
public TestFilter(string filterString)
{
if (filterString.IndexOfAny(new[] { '!', '(', ')', '~', '=' }) != -1)
{
throw new ArgumentException("Complex test filter expressions are not supported today. The only filters supported today are the simple form supported in 'dotnet test --filter' (substrings of the test's fully qualified name). If further filtering options are desired, file an issue on dotnet/runtime for support.", nameof(filterString));
}
_filter = new NameClause(TermKind.FullyQualifiedName, filterString, substring: true);
}
public TestFilter(ISearchClause filter)
{
_filter = filter;
}
public bool ShouldRunTest(string fullyQualifiedName, string displayName, string[]? traits = null) => _filter is null ? true : _filter.IsMatch(fullyQualifiedName, displayName, traits ?? Array.Empty<string>());
}
| // 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.Text;
namespace XUnitWrapperLibrary;
public class TestFilter
{
public interface ISearchClause
{
bool IsMatch(string fullyQualifiedName, string displayName, string[] traits);
}
public enum TermKind
{
FullyQualifiedName,
DisplayName
}
public sealed class NameClause : ISearchClause
{
public NameClause(TermKind kind, string filter, bool substring)
{
Kind = kind;
Filter = filter;
Substring = substring;
}
public TermKind Kind { get; }
public string Filter { get; }
public bool Substring { get; }
public bool IsMatch(string fullyQualifiedName, string displayName, string[] traits)
{
string stringToSearch = Kind switch
{
TermKind.FullyQualifiedName => fullyQualifiedName,
TermKind.DisplayName => displayName,
_ => throw new InvalidOperationException()
};
if (Substring)
{
return stringToSearch.Contains(Filter);
}
return stringToSearch == Filter;
}
}
public sealed class AndClause : ISearchClause
{
private ISearchClause _left;
private ISearchClause _right;
public AndClause(ISearchClause left, ISearchClause right)
{
_left = left;
_right = right;
}
public bool IsMatch(string fullyQualifiedName, string displayName, string[] traits) => _left.IsMatch(fullyQualifiedName, displayName, traits) && _right.IsMatch(fullyQualifiedName, displayName, traits);
}
public sealed class OrClause : ISearchClause
{
private ISearchClause _left;
private ISearchClause _right;
public OrClause(ISearchClause left, ISearchClause right)
{
_left = left;
_right = right;
}
public bool IsMatch(string fullyQualifiedName, string displayName, string[] traits) => _left.IsMatch(fullyQualifiedName, displayName, traits) || _right.IsMatch(fullyQualifiedName, displayName, traits);
}
public sealed class NotClause : ISearchClause
{
private ISearchClause _inner;
public NotClause(ISearchClause inner)
{
_inner = inner;
}
public bool IsMatch(string fullyQualifiedName, string displayName, string[] traits) => !_inner.IsMatch(fullyQualifiedName, displayName, traits);
}
private ISearchClause? _filter;
public TestFilter(string filterString)
{
if (filterString.IndexOfAny(new[] { '!', '(', ')', '~', '=' }) != -1)
{
throw new ArgumentException("Complex test filter expressions are not supported today. The only filters supported today are the simple form supported in 'dotnet test --filter' (substrings of the test's fully qualified name). If further filtering options are desired, file an issue on dotnet/runtime for support.", nameof(filterString));
}
_filter = new NameClause(TermKind.FullyQualifiedName, filterString, substring: true);
}
public TestFilter(ISearchClause filter)
{
_filter = filter;
}
public bool ShouldRunTest(string fullyQualifiedName, string displayName, string[]? traits = null) => _filter is null ? true : _filter.IsMatch(fullyQualifiedName, displayName, traits ?? Array.Empty<string>());
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ChangeRejectedException.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;
namespace System.ComponentModel.Composition
{
/// <summary>
/// The exception that is thrown when one or more recoverable errors occur during
/// composition which results in those changes being rejected.
/// </summary>
public class ChangeRejectedException : CompositionException
{
/// <summary>
/// Initializes a new instance of the <see cref="ChangeRejectedException"/> class.
/// </summary>
public ChangeRejectedException()
: this((string?)null, (Exception?)null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ChangeRejectedException"/> class.
/// </summary>
public ChangeRejectedException(string? message)
: this(message, (Exception?)null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ChangeRejectedException"/> class.
/// </summary>
public ChangeRejectedException(string? message, Exception? innerException)
: base(message, innerException, (IEnumerable<CompositionError>?)null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ChangeRejectedException"/> class.
/// </summary>
/// <param name="errors">List of errors that occured while applying the changes.</param>
public ChangeRejectedException(IEnumerable<CompositionError>? errors)
: base((string?)null, (Exception?)null, errors)
{
}
/// <summary>
/// Gets a message that describes the exception.
/// </summary>
/// <value>
/// A <see cref="string"/> containing a message that describes the
/// <see cref="ChangeRejectedException"/>.
/// </value>
public override string Message
{
get
{
return SR.Format(
SR.CompositionException_ChangesRejected,
base.Message);
}
}
}
}
| // 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;
namespace System.ComponentModel.Composition
{
/// <summary>
/// The exception that is thrown when one or more recoverable errors occur during
/// composition which results in those changes being rejected.
/// </summary>
public class ChangeRejectedException : CompositionException
{
/// <summary>
/// Initializes a new instance of the <see cref="ChangeRejectedException"/> class.
/// </summary>
public ChangeRejectedException()
: this((string?)null, (Exception?)null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ChangeRejectedException"/> class.
/// </summary>
public ChangeRejectedException(string? message)
: this(message, (Exception?)null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ChangeRejectedException"/> class.
/// </summary>
public ChangeRejectedException(string? message, Exception? innerException)
: base(message, innerException, (IEnumerable<CompositionError>?)null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ChangeRejectedException"/> class.
/// </summary>
/// <param name="errors">List of errors that occured while applying the changes.</param>
public ChangeRejectedException(IEnumerable<CompositionError>? errors)
: base((string?)null, (Exception?)null, errors)
{
}
/// <summary>
/// Gets a message that describes the exception.
/// </summary>
/// <value>
/// A <see cref="string"/> containing a message that describes the
/// <see cref="ChangeRejectedException"/>.
/// </value>
public override string Message
{
get
{
return SR.Format(
SR.CompositionException_ChangesRejected,
base.Message);
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/Math/Functions/Double/SinDouble.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
namespace System.MathBenchmarks
{
public partial class Double
{
// Tests Math.Sin(double) over 5000 iterations for the domain -PI/2, +PI/2
private const double sinDelta = 0.0006283185307180;
private const double sinExpectedResult = 1.0000000005445053;
public void Sin() => SinTest();
public static void SinTest()
{
double result = 0.0, value = -1.5707963267948966;
for (int iteration = 0; iteration < MathTests.Iterations; iteration++)
{
value += sinDelta;
result += Math.Sin(value);
}
double diff = Math.Abs(sinExpectedResult - result);
if (diff > MathTests.DoubleEpsilon)
{
throw new Exception($"Expected Result {sinExpectedResult,20:g17}; Actual Result {result,20:g17}");
}
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
namespace System.MathBenchmarks
{
public partial class Double
{
// Tests Math.Sin(double) over 5000 iterations for the domain -PI/2, +PI/2
private const double sinDelta = 0.0006283185307180;
private const double sinExpectedResult = 1.0000000005445053;
public void Sin() => SinTest();
public static void SinTest()
{
double result = 0.0, value = -1.5707963267948966;
for (int iteration = 0; iteration < MathTests.Iterations; iteration++)
{
value += sinDelta;
result += Math.Sin(value);
}
double diff = Math.Abs(sinExpectedResult - result);
if (diff > MathTests.DoubleEpsilon)
{
throw new Exception($"Expected Result {sinExpectedResult,20:g17}; Actual Result {result,20:g17}");
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/HardwareIntrinsics/General/NotSupported/Vector256UInt16AsGeneric_Boolean.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 Vector256UInt16AsGeneric_Boolean()
{
bool succeeded = false;
try
{
Vector256<bool> result = default(Vector256<ushort>).As<ushort, bool>();
}
catch (NotSupportedException)
{
succeeded = true;
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"Vector256UInt16AsGeneric_Boolean: RunNotSupportedScenario failed to throw NotSupportedException.");
TestLibrary.TestFramework.LogInformation(string.Empty);
throw new Exception("One or more scenarios did not complete as expected.");
}
}
}
}
| // 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 Vector256UInt16AsGeneric_Boolean()
{
bool succeeded = false;
try
{
Vector256<bool> result = default(Vector256<ushort>).As<ushort, bool>();
}
catch (NotSupportedException)
{
succeeded = true;
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"Vector256UInt16AsGeneric_Boolean: RunNotSupportedScenario failed to throw NotSupportedException.");
TestLibrary.TestFramework.LogInformation(string.Empty);
throw new Exception("One or more scenarios did not complete as expected.");
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd.Arm64/ShiftLogicalRoundedSaturateScalar.Vector64.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.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 ShiftLogicalRoundedSaturateScalar_Vector64_Int16()
{
var test = new SimpleBinaryOpTest__ShiftLogicalRoundedSaturateScalar_Vector64_Int16();
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__ShiftLogicalRoundedSaturateScalar_Vector64_Int16
{
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(Int16[] inArray1, Int16[] inArray2, Int16[] outArray, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int16>();
int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Int16>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int16>();
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<Int16, byte>(ref inArray1[0]), (uint)sizeOfinArray1);
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Int16, 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<Int16> _fld1;
public Vector64<Int16> _fld2;
public static TestStruct Create()
{
var testStruct = new TestStruct();
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref testStruct._fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref testStruct._fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>());
return testStruct;
}
public void RunStructFldScenario(SimpleBinaryOpTest__ShiftLogicalRoundedSaturateScalar_Vector64_Int16 testClass)
{
var result = AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar(_fld1, _fld2);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(SimpleBinaryOpTest__ShiftLogicalRoundedSaturateScalar_Vector64_Int16 testClass)
{
fixed (Vector64<Int16>* pFld1 = &_fld1)
fixed (Vector64<Int16>* pFld2 = &_fld2)
{
var result = AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar(
AdvSimd.LoadVector64((Int16*)(pFld1)),
AdvSimd.LoadVector64((Int16*)(pFld2))
);
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<Int16>>() / sizeof(Int16);
private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector64<Int16>>() / sizeof(Int16);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<Int16>>() / sizeof(Int16);
private static Int16[] _data1 = new Int16[Op1ElementCount];
private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector64<Int16> _clsVar1;
private static Vector64<Int16> _clsVar2;
private Vector64<Int16> _fld1;
private Vector64<Int16> _fld2;
private DataTable _dataTable;
static SimpleBinaryOpTest__ShiftLogicalRoundedSaturateScalar_Vector64_Int16()
{
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>());
}
public SimpleBinaryOpTest__ShiftLogicalRoundedSaturateScalar_Vector64_Int16()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>());
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); }
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); }
_dataTable = new DataTable(_data1, _data2, new Int16[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.ShiftLogicalRoundedSaturateScalar(
Unsafe.Read<Vector64<Int16>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector64<Int16>>(_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.ShiftLogicalRoundedSaturateScalar(
AdvSimd.LoadVector64((Int16*)(_dataTable.inArray1Ptr)),
AdvSimd.LoadVector64((Int16*)(_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.ShiftLogicalRoundedSaturateScalar), new Type[] { typeof(Vector64<Int16>), typeof(Vector64<Int16>) })
.Invoke(null, new object[] {
Unsafe.Read<Vector64<Int16>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector64<Int16>>(_dataTable.inArray2Ptr)
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int16>)(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.ShiftLogicalRoundedSaturateScalar), new Type[] { typeof(Vector64<Int16>), typeof(Vector64<Int16>) })
.Invoke(null, new object[] {
AdvSimd.LoadVector64((Int16*)(_dataTable.inArray1Ptr)),
AdvSimd.LoadVector64((Int16*)(_dataTable.inArray2Ptr))
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int16>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar(
_clsVar1,
_clsVar2
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector64<Int16>* pClsVar1 = &_clsVar1)
fixed (Vector64<Int16>* pClsVar2 = &_clsVar2)
{
var result = AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar(
AdvSimd.LoadVector64((Int16*)(pClsVar1)),
AdvSimd.LoadVector64((Int16*)(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<Vector64<Int16>>(_dataTable.inArray1Ptr);
var op2 = Unsafe.Read<Vector64<Int16>>(_dataTable.inArray2Ptr);
var result = AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar(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.LoadVector64((Int16*)(_dataTable.inArray1Ptr));
var op2 = AdvSimd.LoadVector64((Int16*)(_dataTable.inArray2Ptr));
var result = AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar(op1, op2);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op2, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new SimpleBinaryOpTest__ShiftLogicalRoundedSaturateScalar_Vector64_Int16();
var result = AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar(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__ShiftLogicalRoundedSaturateScalar_Vector64_Int16();
fixed (Vector64<Int16>* pFld1 = &test._fld1)
fixed (Vector64<Int16>* pFld2 = &test._fld2)
{
var result = AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar(
AdvSimd.LoadVector64((Int16*)(pFld1)),
AdvSimd.LoadVector64((Int16*)(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.ShiftLogicalRoundedSaturateScalar(_fld1, _fld2);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector64<Int16>* pFld1 = &_fld1)
fixed (Vector64<Int16>* pFld2 = &_fld2)
{
var result = AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar(
AdvSimd.LoadVector64((Int16*)(pFld1)),
AdvSimd.LoadVector64((Int16*)(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.ShiftLogicalRoundedSaturateScalar(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.ShiftLogicalRoundedSaturateScalar(
AdvSimd.LoadVector64((Int16*)(&test._fld1)),
AdvSimd.LoadVector64((Int16*)(&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(Vector64<Int16> op1, Vector64<Int16> op2, void* result, [CallerMemberName] string method = "")
{
Int16[] inArray1 = new Int16[Op1ElementCount];
Int16[] inArray2 = new Int16[Op2ElementCount];
Int16[] outArray = new Int16[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), op1);
Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), op2);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int16>>());
ValidateResult(inArray1, inArray2, outArray, method);
}
private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "")
{
Int16[] inArray1 = new Int16[Op1ElementCount];
Int16[] inArray2 = new Int16[Op2ElementCount];
Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<Int16>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector64<Int16>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int16>>());
ValidateResult(inArray1, inArray2, outArray, method);
}
private void ValidateResult(Int16[] left, Int16[] right, Int16[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
if (Helpers.ShiftLogicalRoundedSaturate(left[0], right[0]) != result[0])
{
succeeded = false;
}
else
{
for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != 0)
{
succeeded = false;
break;
}
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd.Arm64)}.{nameof(AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar)}<Int16>(Vector64<Int16>, Vector64<Int16>): {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 ShiftLogicalRoundedSaturateScalar_Vector64_Int16()
{
var test = new SimpleBinaryOpTest__ShiftLogicalRoundedSaturateScalar_Vector64_Int16();
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__ShiftLogicalRoundedSaturateScalar_Vector64_Int16
{
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(Int16[] inArray1, Int16[] inArray2, Int16[] outArray, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int16>();
int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Int16>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int16>();
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<Int16, byte>(ref inArray1[0]), (uint)sizeOfinArray1);
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Int16, 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<Int16> _fld1;
public Vector64<Int16> _fld2;
public static TestStruct Create()
{
var testStruct = new TestStruct();
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref testStruct._fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref testStruct._fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>());
return testStruct;
}
public void RunStructFldScenario(SimpleBinaryOpTest__ShiftLogicalRoundedSaturateScalar_Vector64_Int16 testClass)
{
var result = AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar(_fld1, _fld2);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(SimpleBinaryOpTest__ShiftLogicalRoundedSaturateScalar_Vector64_Int16 testClass)
{
fixed (Vector64<Int16>* pFld1 = &_fld1)
fixed (Vector64<Int16>* pFld2 = &_fld2)
{
var result = AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar(
AdvSimd.LoadVector64((Int16*)(pFld1)),
AdvSimd.LoadVector64((Int16*)(pFld2))
);
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<Int16>>() / sizeof(Int16);
private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector64<Int16>>() / sizeof(Int16);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<Int16>>() / sizeof(Int16);
private static Int16[] _data1 = new Int16[Op1ElementCount];
private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector64<Int16> _clsVar1;
private static Vector64<Int16> _clsVar2;
private Vector64<Int16> _fld1;
private Vector64<Int16> _fld2;
private DataTable _dataTable;
static SimpleBinaryOpTest__ShiftLogicalRoundedSaturateScalar_Vector64_Int16()
{
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>());
}
public SimpleBinaryOpTest__ShiftLogicalRoundedSaturateScalar_Vector64_Int16()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>());
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); }
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); }
_dataTable = new DataTable(_data1, _data2, new Int16[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.ShiftLogicalRoundedSaturateScalar(
Unsafe.Read<Vector64<Int16>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector64<Int16>>(_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.ShiftLogicalRoundedSaturateScalar(
AdvSimd.LoadVector64((Int16*)(_dataTable.inArray1Ptr)),
AdvSimd.LoadVector64((Int16*)(_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.ShiftLogicalRoundedSaturateScalar), new Type[] { typeof(Vector64<Int16>), typeof(Vector64<Int16>) })
.Invoke(null, new object[] {
Unsafe.Read<Vector64<Int16>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector64<Int16>>(_dataTable.inArray2Ptr)
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int16>)(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.ShiftLogicalRoundedSaturateScalar), new Type[] { typeof(Vector64<Int16>), typeof(Vector64<Int16>) })
.Invoke(null, new object[] {
AdvSimd.LoadVector64((Int16*)(_dataTable.inArray1Ptr)),
AdvSimd.LoadVector64((Int16*)(_dataTable.inArray2Ptr))
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int16>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar(
_clsVar1,
_clsVar2
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector64<Int16>* pClsVar1 = &_clsVar1)
fixed (Vector64<Int16>* pClsVar2 = &_clsVar2)
{
var result = AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar(
AdvSimd.LoadVector64((Int16*)(pClsVar1)),
AdvSimd.LoadVector64((Int16*)(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<Vector64<Int16>>(_dataTable.inArray1Ptr);
var op2 = Unsafe.Read<Vector64<Int16>>(_dataTable.inArray2Ptr);
var result = AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar(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.LoadVector64((Int16*)(_dataTable.inArray1Ptr));
var op2 = AdvSimd.LoadVector64((Int16*)(_dataTable.inArray2Ptr));
var result = AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar(op1, op2);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op2, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new SimpleBinaryOpTest__ShiftLogicalRoundedSaturateScalar_Vector64_Int16();
var result = AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar(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__ShiftLogicalRoundedSaturateScalar_Vector64_Int16();
fixed (Vector64<Int16>* pFld1 = &test._fld1)
fixed (Vector64<Int16>* pFld2 = &test._fld2)
{
var result = AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar(
AdvSimd.LoadVector64((Int16*)(pFld1)),
AdvSimd.LoadVector64((Int16*)(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.ShiftLogicalRoundedSaturateScalar(_fld1, _fld2);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector64<Int16>* pFld1 = &_fld1)
fixed (Vector64<Int16>* pFld2 = &_fld2)
{
var result = AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar(
AdvSimd.LoadVector64((Int16*)(pFld1)),
AdvSimd.LoadVector64((Int16*)(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.ShiftLogicalRoundedSaturateScalar(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.ShiftLogicalRoundedSaturateScalar(
AdvSimd.LoadVector64((Int16*)(&test._fld1)),
AdvSimd.LoadVector64((Int16*)(&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(Vector64<Int16> op1, Vector64<Int16> op2, void* result, [CallerMemberName] string method = "")
{
Int16[] inArray1 = new Int16[Op1ElementCount];
Int16[] inArray2 = new Int16[Op2ElementCount];
Int16[] outArray = new Int16[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), op1);
Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), op2);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int16>>());
ValidateResult(inArray1, inArray2, outArray, method);
}
private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "")
{
Int16[] inArray1 = new Int16[Op1ElementCount];
Int16[] inArray2 = new Int16[Op2ElementCount];
Int16[] outArray = new Int16[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<Int16>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector64<Int16>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int16>>());
ValidateResult(inArray1, inArray2, outArray, method);
}
private void ValidateResult(Int16[] left, Int16[] right, Int16[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
if (Helpers.ShiftLogicalRoundedSaturate(left[0], right[0]) != result[0])
{
succeeded = false;
}
else
{
for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != 0)
{
succeeded = false;
break;
}
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd.Arm64)}.{nameof(AdvSimd.Arm64.ShiftLogicalRoundedSaturateScalar)}<Int16>(Vector64<Int16>, Vector64<Int16>): {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,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/Regression/Dev11/External/dev11_28763/R3Contention.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 R3Contention
{
public struct Size
{
public Int32 width;
public Int32 height;
public Size(Int32 width, Int32 height)
{
this.width = width;
this.height = height;
return;
}
public static readonly Size Empty = new Size();
[MethodImpl(MethodImplOptions.NoInlining)]
public static Size Subtract(Size sz1, Size sz2)
{
return Size.Empty;
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static Size Add(Size sz1, Size sz2)
{
return Size.Empty;
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static bool AreEqual(Size sz1, Size sz2)
{
return ((sz1.width == sz2.width) && (sz1.height == sz2.height));
}
}
public class LayoutOptions
{
public string text;
public Int32 borderSize;
public Int32 paddingSize;
public Int32 checkSize;
public Int32 checkPaddingSize;
public Int32 textImageInset;
public bool growBorderBy1PxWhenDefault;
public bool disableWordWrapping;
public Size imageSize;
public int FullCheckSize { get { return (this.checkSize + this.checkPaddingSize); } }
[MethodImpl(MethodImplOptions.NoInlining)]
public Size Compose(Size checkSize, Size imageSize, Size textSize)
{
return Size.Empty;
}
[MethodImpl(MethodImplOptions.NoInlining)]
public Size Decompose(Size checkSize, Size requiredImageSize, Size proposedSize)
{
return Size.Empty;
}
public virtual Size GetTextSize(Size proposedSize)
{
return Size.Empty;
}
[MethodImpl(MethodImplOptions.NoInlining)]
public
Size GetPreferredSizeCore(
Size proposedSize
)
{
int linearBorderAndPadding = ((this.borderSize * 2) + (this.paddingSize * 2));
if (this.growBorderBy1PxWhenDefault)
{
linearBorderAndPadding += 2;
}
Size bordersAndPadding = new Size(linearBorderAndPadding, linearBorderAndPadding);
proposedSize = Size.Subtract(proposedSize, bordersAndPadding);
int checkSizeLinear = this.FullCheckSize;
Size checkSize =
(checkSizeLinear > 0) ?
new Size(checkSizeLinear + 1, checkSizeLinear) :
Size.Empty;
Size textImageInsetSize = new Size(this.textImageInset * 2, this.textImageInset * 2);
Size requiredImageSize =
(!Size.AreEqual(this.imageSize, Size.Empty)) ?
Size.Add(this.imageSize, textImageInsetSize) :
Size.Empty;
proposedSize = Size.Subtract(proposedSize, textImageInsetSize);
proposedSize = this.Decompose(checkSize, requiredImageSize, proposedSize);
Size textSize = Size.Empty;
if (!string.IsNullOrEmpty(this.text))
{
try
{
this.disableWordWrapping = true;
textSize = Size.Add(this.GetTextSize(proposedSize), textImageInsetSize);
}
finally
{
this.disableWordWrapping = false;
}
}
Size requiredSize = this.Compose(checkSize, this.imageSize, textSize);
requiredSize = Size.Add(requiredSize, bordersAndPadding);
return requiredSize;
}
}
internal static class App
{
private static int Main()
{
var layoutOptions = new LayoutOptions();
layoutOptions.text = "Some text.";
layoutOptions.GetPreferredSizeCore(Size.Empty);
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.Runtime.CompilerServices;
namespace R3Contention
{
public struct Size
{
public Int32 width;
public Int32 height;
public Size(Int32 width, Int32 height)
{
this.width = width;
this.height = height;
return;
}
public static readonly Size Empty = new Size();
[MethodImpl(MethodImplOptions.NoInlining)]
public static Size Subtract(Size sz1, Size sz2)
{
return Size.Empty;
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static Size Add(Size sz1, Size sz2)
{
return Size.Empty;
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static bool AreEqual(Size sz1, Size sz2)
{
return ((sz1.width == sz2.width) && (sz1.height == sz2.height));
}
}
public class LayoutOptions
{
public string text;
public Int32 borderSize;
public Int32 paddingSize;
public Int32 checkSize;
public Int32 checkPaddingSize;
public Int32 textImageInset;
public bool growBorderBy1PxWhenDefault;
public bool disableWordWrapping;
public Size imageSize;
public int FullCheckSize { get { return (this.checkSize + this.checkPaddingSize); } }
[MethodImpl(MethodImplOptions.NoInlining)]
public Size Compose(Size checkSize, Size imageSize, Size textSize)
{
return Size.Empty;
}
[MethodImpl(MethodImplOptions.NoInlining)]
public Size Decompose(Size checkSize, Size requiredImageSize, Size proposedSize)
{
return Size.Empty;
}
public virtual Size GetTextSize(Size proposedSize)
{
return Size.Empty;
}
[MethodImpl(MethodImplOptions.NoInlining)]
public
Size GetPreferredSizeCore(
Size proposedSize
)
{
int linearBorderAndPadding = ((this.borderSize * 2) + (this.paddingSize * 2));
if (this.growBorderBy1PxWhenDefault)
{
linearBorderAndPadding += 2;
}
Size bordersAndPadding = new Size(linearBorderAndPadding, linearBorderAndPadding);
proposedSize = Size.Subtract(proposedSize, bordersAndPadding);
int checkSizeLinear = this.FullCheckSize;
Size checkSize =
(checkSizeLinear > 0) ?
new Size(checkSizeLinear + 1, checkSizeLinear) :
Size.Empty;
Size textImageInsetSize = new Size(this.textImageInset * 2, this.textImageInset * 2);
Size requiredImageSize =
(!Size.AreEqual(this.imageSize, Size.Empty)) ?
Size.Add(this.imageSize, textImageInsetSize) :
Size.Empty;
proposedSize = Size.Subtract(proposedSize, textImageInsetSize);
proposedSize = this.Decompose(checkSize, requiredImageSize, proposedSize);
Size textSize = Size.Empty;
if (!string.IsNullOrEmpty(this.text))
{
try
{
this.disableWordWrapping = true;
textSize = Size.Add(this.GetTextSize(proposedSize), textImageInsetSize);
}
finally
{
this.disableWordWrapping = false;
}
}
Size requiredSize = this.Compose(checkSize, this.imageSize, textSize);
requiredSize = Size.Add(requiredSize, bordersAndPadding);
return requiredSize;
}
}
internal static class App
{
private static int Main()
{
var layoutOptions = new LayoutOptions();
layoutOptions.text = "Some text.";
layoutOptions.GetPreferredSizeCore(Size.Empty);
return 100;
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/Microsoft.VisualBasic.Core/tests/CompilerServices/BooleanTypeTests.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.Globalization;
using Microsoft.VisualBasic.CompilerServices;
using Xunit;
namespace Microsoft.VisualBasic.Tests
{
public class BooleanTypeTests
{
[Fact]
public void NullData()
{
// Null is valid input for Boolean.FromObject
Assert.Throws<InvalidCastException>(() => BooleanType.FromString(null));
}
[Theory]
[MemberData(nameof(InvalidStringData))]
public void InvalidCastString(string value)
{
Assert.Throws<InvalidCastException>(() => BooleanType.FromString(value));
}
[Theory]
[MemberData(nameof(InvalidStringData))]
[MemberData(nameof(InvalidObjectData))]
public void InvalidCastObject(object value)
{
Assert.Throws<InvalidCastException>(() => BooleanType.FromObject(value));
}
public static TheoryData<string> InvalidStringData => new TheoryData<string>()
{
{ "" },
{ "23&" },
{ "abc" },
};
public static TheoryData<object> InvalidObjectData => new TheoryData<object>()
{
{ DateTime.Now },
{ 'c' },
{ Guid.Empty }
};
[Theory]
[MemberData(nameof(BoolStringData))]
public void FromString(bool expected, string value)
{
Assert.Equal(expected, BooleanType.FromString(value));
}
[Theory]
[MemberData(nameof(BoolStringData))]
[MemberData(nameof(BoolObjectData))]
public void FromObject(bool expected, object value)
{
Assert.Equal(expected, BooleanType.FromObject(value));
}
public static TheoryData<bool, string> BoolStringData => new TheoryData<bool, string>()
{
{ false, "0"},
{ false, "False"},
{ true, "True"},
{ true, "1"},
{ true, "1" + CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator + "2" },
{ true, "2"},
{ true, "-1"},
{ false, "&H00" },
{ false, "&O00" },
{ true, "&H01" },
{ true, "&O01" },
{ true, "9999999999999999999999999999999999999" }
};
public static TheoryData<bool, object> BoolObjectData => new TheoryData<bool, object>()
{
{ false, 0 },
{ false, null },
{ false, false },
{ true, true },
{ true, 1 },
{ true, "1" + CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator + "2" },
{ true, 2 },
{ true, -1 },
{ false, (byte)0 },
{ true, (byte)1 },
{ false, (short)0 },
{ true, (short)1 },
{ false, (double)0 },
{ true, (double)1 },
{ false, (decimal)0 },
{ true, (decimal)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.Globalization;
using Microsoft.VisualBasic.CompilerServices;
using Xunit;
namespace Microsoft.VisualBasic.Tests
{
public class BooleanTypeTests
{
[Fact]
public void NullData()
{
// Null is valid input for Boolean.FromObject
Assert.Throws<InvalidCastException>(() => BooleanType.FromString(null));
}
[Theory]
[MemberData(nameof(InvalidStringData))]
public void InvalidCastString(string value)
{
Assert.Throws<InvalidCastException>(() => BooleanType.FromString(value));
}
[Theory]
[MemberData(nameof(InvalidStringData))]
[MemberData(nameof(InvalidObjectData))]
public void InvalidCastObject(object value)
{
Assert.Throws<InvalidCastException>(() => BooleanType.FromObject(value));
}
public static TheoryData<string> InvalidStringData => new TheoryData<string>()
{
{ "" },
{ "23&" },
{ "abc" },
};
public static TheoryData<object> InvalidObjectData => new TheoryData<object>()
{
{ DateTime.Now },
{ 'c' },
{ Guid.Empty }
};
[Theory]
[MemberData(nameof(BoolStringData))]
public void FromString(bool expected, string value)
{
Assert.Equal(expected, BooleanType.FromString(value));
}
[Theory]
[MemberData(nameof(BoolStringData))]
[MemberData(nameof(BoolObjectData))]
public void FromObject(bool expected, object value)
{
Assert.Equal(expected, BooleanType.FromObject(value));
}
public static TheoryData<bool, string> BoolStringData => new TheoryData<bool, string>()
{
{ false, "0"},
{ false, "False"},
{ true, "True"},
{ true, "1"},
{ true, "1" + CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator + "2" },
{ true, "2"},
{ true, "-1"},
{ false, "&H00" },
{ false, "&O00" },
{ true, "&H01" },
{ true, "&O01" },
{ true, "9999999999999999999999999999999999999" }
};
public static TheoryData<bool, object> BoolObjectData => new TheoryData<bool, object>()
{
{ false, 0 },
{ false, null },
{ false, false },
{ true, true },
{ true, 1 },
{ true, "1" + CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator + "2" },
{ true, 2 },
{ true, -1 },
{ false, (byte)0 },
{ true, (byte)1 },
{ false, (short)0 },
{ true, (short)1 },
{ false, (double)0 },
{ true, (double)1 },
{ false, (decimal)0 },
{ true, (decimal)1 }
};
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509RevocationFlag.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.Diagnostics;
namespace System.Security.Cryptography.X509Certificates
{
public enum X509RevocationFlag
{
EndCertificateOnly = 0,
EntireChain = 1,
ExcludeRoot = 2,
}
}
| // 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.Diagnostics;
namespace System.Security.Cryptography.X509Certificates
{
public enum X509RevocationFlag
{
EndCertificateOnly = 0,
EntireChain = 1,
ExcludeRoot = 2,
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/Insert.Vector128.Int64.1.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 Insert_Vector128_Int64_1()
{
var test = new InsertTest__Insert_Vector128_Int64_1();
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 InsertTest__Insert_Vector128_Int64_1
{
private struct DataTable
{
private byte[] inArray1;
private byte[] outArray;
private GCHandle inHandle1;
private GCHandle outHandle;
private ulong alignment;
public DataTable(Int64[] inArray1, Int64[] outArray, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int64>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int64>();
if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray1 = new byte[alignment * 2];
this.outArray = new byte[alignment * 2];
this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned);
this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int64, byte>(ref inArray1[0]), (uint)sizeOfinArray1);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle1.Free();
outHandle.Free();
}
private static unsafe void* Align(byte* buffer, ulong expectedAlignment)
{
return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1));
}
}
private struct TestStruct
{
public Vector128<Int64> _fld1;
public Int64 _fld3;
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>>());
testStruct._fld3 = TestLibrary.Generator.GetInt64();
return testStruct;
}
public void RunStructFldScenario(InsertTest__Insert_Vector128_Int64_1 testClass)
{
var result = AdvSimd.Insert(_fld1, ElementIndex, _fld3);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, _fld3, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(InsertTest__Insert_Vector128_Int64_1 testClass)
{
fixed (Vector128<Int64>* pFld1 = &_fld1)
fixed (Int64* pFld3 = &_fld3)
{
var result = AdvSimd.Insert(
AdvSimd.LoadVector128((Int64*)pFld1),
ElementIndex,
*pFld3
);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, _fld3, testClass._dataTable.outArrayPtr);
}
}
}
private static readonly int LargestVectorSize = 16;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64);
private static readonly byte ElementIndex = 1;
private static Int64[] _data1 = new Int64[Op1ElementCount];
private static Vector128<Int64> _clsVar1;
private static Int64 _clsVar3;
private Vector128<Int64> _fld1;
private Int64 _fld3;
private DataTable _dataTable;
static InsertTest__Insert_Vector128_Int64_1()
{
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>>());
_clsVar3 = TestLibrary.Generator.GetInt64();
}
public InsertTest__Insert_Vector128_Int64_1()
{
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>>());
_fld3 = TestLibrary.Generator.GetInt64();
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); }
_dataTable = new DataTable(_data1, 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.Insert(
Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr),
ElementIndex,
_fld3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _fld3, _dataTable.outArrayPtr);
}
public void RunBasicScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));
var result = AdvSimd.Insert(
AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)),
ElementIndex,
_fld3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _fld3, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
Int64 op3 = TestLibrary.Generator.GetInt64();
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.Insert), new Type[] { typeof(Vector128<Int64>), typeof(byte), typeof(Int64) })
.Invoke(null, new object[] {
Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr),
ElementIndex,
op3
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result));
ValidateResult(_dataTable.inArray1Ptr, op3, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));
Int64 op3 = TestLibrary.Generator.GetInt64();
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.Insert), new Type[] { typeof(Vector128<Int64>), typeof(byte), typeof(Int64) })
.Invoke(null, new object[] {
AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)),
ElementIndex,
op3
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result));
ValidateResult(_dataTable.inArray1Ptr, op3, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = AdvSimd.Insert(
_clsVar1,
ElementIndex,
_clsVar3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _clsVar3, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector128<Int64>* pClsVar1 = &_clsVar1)
fixed (Int64* pClsVar3 = &_clsVar3)
{
var result = AdvSimd.Insert(
AdvSimd.LoadVector128((Int64*)pClsVar1),
ElementIndex,
*pClsVar3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _clsVar3, _dataTable.outArrayPtr);
}
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var op1 = Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr);
var op3 = TestLibrary.Generator.GetInt64();
var result = AdvSimd.Insert(op1, ElementIndex, op3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op3, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load));
var op1 = AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr));
var op3 = TestLibrary.Generator.GetInt64();
var result = AdvSimd.Insert(op1, ElementIndex, op3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op3, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new InsertTest__Insert_Vector128_Int64_1();
var result = AdvSimd.Insert(test._fld1, ElementIndex, test._fld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));
var test = new InsertTest__Insert_Vector128_Int64_1();
fixed (Vector128<Int64>* pFld1 = &test._fld1)
fixed (Int64* pFld3 = &test._fld3)
{
var result = AdvSimd.Insert(
AdvSimd.LoadVector128((Int64*)pFld1),
ElementIndex,
*pFld3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = AdvSimd.Insert(_fld1, ElementIndex, _fld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _fld3, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector128<Int64>* pFld1 = &_fld1)
fixed (Int64* pFld3 = &_fld3)
{
var result = AdvSimd.Insert(
AdvSimd.LoadVector128((Int64*)pFld1),
ElementIndex,
*pFld3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _fld3, _dataTable.outArrayPtr);
}
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = AdvSimd.Insert(test._fld1, ElementIndex, test._fld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));
var test = TestStruct.Create();
var result = AdvSimd.Insert(
AdvSimd.LoadVector128((Int64*)(&test._fld1)),
ElementIndex,
test._fld3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld3, _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, Int64 op3, void* result, [CallerMemberName] string method = "")
{
Int64[] inArray1 = new Int64[Op1ElementCount];
Int64[] outArray = new Int64[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), op1);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>());
ValidateResult(inArray1, op3, outArray, method);
}
private void ValidateResult(void* op1, Int64 op3, void* result, [CallerMemberName] string method = "")
{
Int64[] inArray1 = new Int64[Op1ElementCount];
Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Int64>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>());
ValidateResult(inArray1, op3, outArray, method);
}
private void ValidateResult(Int64[] firstOp, Int64 thirdOp, Int64[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (var i = 0; i < RetElementCount; i++)
{
if (Helpers.Insert(firstOp, ElementIndex, thirdOp, i) != result[i])
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.Insert)}<Int64>(Vector128<Int64>, 1, Int64): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" thirdOp: {thirdOp}");
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 Insert_Vector128_Int64_1()
{
var test = new InsertTest__Insert_Vector128_Int64_1();
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 InsertTest__Insert_Vector128_Int64_1
{
private struct DataTable
{
private byte[] inArray1;
private byte[] outArray;
private GCHandle inHandle1;
private GCHandle outHandle;
private ulong alignment;
public DataTable(Int64[] inArray1, Int64[] outArray, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int64>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int64>();
if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray1 = new byte[alignment * 2];
this.outArray = new byte[alignment * 2];
this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned);
this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int64, byte>(ref inArray1[0]), (uint)sizeOfinArray1);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle1.Free();
outHandle.Free();
}
private static unsafe void* Align(byte* buffer, ulong expectedAlignment)
{
return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1));
}
}
private struct TestStruct
{
public Vector128<Int64> _fld1;
public Int64 _fld3;
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>>());
testStruct._fld3 = TestLibrary.Generator.GetInt64();
return testStruct;
}
public void RunStructFldScenario(InsertTest__Insert_Vector128_Int64_1 testClass)
{
var result = AdvSimd.Insert(_fld1, ElementIndex, _fld3);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, _fld3, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(InsertTest__Insert_Vector128_Int64_1 testClass)
{
fixed (Vector128<Int64>* pFld1 = &_fld1)
fixed (Int64* pFld3 = &_fld3)
{
var result = AdvSimd.Insert(
AdvSimd.LoadVector128((Int64*)pFld1),
ElementIndex,
*pFld3
);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, _fld3, testClass._dataTable.outArrayPtr);
}
}
}
private static readonly int LargestVectorSize = 16;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64);
private static readonly byte ElementIndex = 1;
private static Int64[] _data1 = new Int64[Op1ElementCount];
private static Vector128<Int64> _clsVar1;
private static Int64 _clsVar3;
private Vector128<Int64> _fld1;
private Int64 _fld3;
private DataTable _dataTable;
static InsertTest__Insert_Vector128_Int64_1()
{
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>>());
_clsVar3 = TestLibrary.Generator.GetInt64();
}
public InsertTest__Insert_Vector128_Int64_1()
{
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>>());
_fld3 = TestLibrary.Generator.GetInt64();
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); }
_dataTable = new DataTable(_data1, 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.Insert(
Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr),
ElementIndex,
_fld3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _fld3, _dataTable.outArrayPtr);
}
public void RunBasicScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));
var result = AdvSimd.Insert(
AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)),
ElementIndex,
_fld3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _fld3, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
Int64 op3 = TestLibrary.Generator.GetInt64();
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.Insert), new Type[] { typeof(Vector128<Int64>), typeof(byte), typeof(Int64) })
.Invoke(null, new object[] {
Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr),
ElementIndex,
op3
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result));
ValidateResult(_dataTable.inArray1Ptr, op3, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));
Int64 op3 = TestLibrary.Generator.GetInt64();
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.Insert), new Type[] { typeof(Vector128<Int64>), typeof(byte), typeof(Int64) })
.Invoke(null, new object[] {
AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)),
ElementIndex,
op3
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result));
ValidateResult(_dataTable.inArray1Ptr, op3, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = AdvSimd.Insert(
_clsVar1,
ElementIndex,
_clsVar3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _clsVar3, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector128<Int64>* pClsVar1 = &_clsVar1)
fixed (Int64* pClsVar3 = &_clsVar3)
{
var result = AdvSimd.Insert(
AdvSimd.LoadVector128((Int64*)pClsVar1),
ElementIndex,
*pClsVar3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _clsVar3, _dataTable.outArrayPtr);
}
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var op1 = Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr);
var op3 = TestLibrary.Generator.GetInt64();
var result = AdvSimd.Insert(op1, ElementIndex, op3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op3, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load));
var op1 = AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr));
var op3 = TestLibrary.Generator.GetInt64();
var result = AdvSimd.Insert(op1, ElementIndex, op3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op3, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new InsertTest__Insert_Vector128_Int64_1();
var result = AdvSimd.Insert(test._fld1, ElementIndex, test._fld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));
var test = new InsertTest__Insert_Vector128_Int64_1();
fixed (Vector128<Int64>* pFld1 = &test._fld1)
fixed (Int64* pFld3 = &test._fld3)
{
var result = AdvSimd.Insert(
AdvSimd.LoadVector128((Int64*)pFld1),
ElementIndex,
*pFld3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = AdvSimd.Insert(_fld1, ElementIndex, _fld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _fld3, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector128<Int64>* pFld1 = &_fld1)
fixed (Int64* pFld3 = &_fld3)
{
var result = AdvSimd.Insert(
AdvSimd.LoadVector128((Int64*)pFld1),
ElementIndex,
*pFld3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _fld3, _dataTable.outArrayPtr);
}
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = AdvSimd.Insert(test._fld1, ElementIndex, test._fld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));
var test = TestStruct.Create();
var result = AdvSimd.Insert(
AdvSimd.LoadVector128((Int64*)(&test._fld1)),
ElementIndex,
test._fld3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld3, _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, Int64 op3, void* result, [CallerMemberName] string method = "")
{
Int64[] inArray1 = new Int64[Op1ElementCount];
Int64[] outArray = new Int64[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), op1);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>());
ValidateResult(inArray1, op3, outArray, method);
}
private void ValidateResult(void* op1, Int64 op3, void* result, [CallerMemberName] string method = "")
{
Int64[] inArray1 = new Int64[Op1ElementCount];
Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Int64>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>());
ValidateResult(inArray1, op3, outArray, method);
}
private void ValidateResult(Int64[] firstOp, Int64 thirdOp, Int64[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (var i = 0; i < RetElementCount; i++)
{
if (Helpers.Insert(firstOp, ElementIndex, thirdOp, i) != result[i])
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.Insert)}<Int64>(Vector128<Int64>, 1, Int64): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" thirdOp: {thirdOp}");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/Interop/MarshalAPI/IUnknown/TestInALC.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;
using System.Reflection;
namespace TestInALC
{
class Test
{
static int Main(string[] args)
{
string currentAssemblyDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string testAssemblyFullPath = Path.Combine(currentAssemblyDirectory, "IUnknownTest.dll");
return TestLibrary.Utilities.ExecuteAndUnload(testAssemblyFullPath, args);
}
}
}
| // 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;
using System.Reflection;
namespace TestInALC
{
class Test
{
static int Main(string[] args)
{
string currentAssemblyDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string testAssemblyFullPath = Path.Combine(currentAssemblyDirectory, "IUnknownTest.dll");
return TestLibrary.Utilities.ExecuteAndUnload(testAssemblyFullPath, args);
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Runtime/tests/System/Runtime/Serialization/SerializationExceptionTests.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.Runtime.Serialization.Formatters.Binary;
using Xunit;
namespace System.Runtime.Serialization.Tests
{
public class SerializationExceptionTests
{
private const int COR_E_SERIALIZATION = unchecked((int)0x8013150C);
[Fact]
public void Ctor_Default()
{
var exception = new SerializationException();
Assert.NotEmpty(exception.Message);
Assert.Null(exception.InnerException);
Assert.Equal(COR_E_SERIALIZATION, exception.HResult);
}
[Theory]
[InlineData("message")]
public void Ctor_String(string message)
{
var exception = new SerializationException(message);
Assert.Equal(message, exception.Message);
Assert.Null(exception.InnerException);
Assert.Equal(COR_E_SERIALIZATION, exception.HResult);
}
[Theory]
[InlineData("message")]
public void Ctor_String_Exception(string message)
{
var innerException = new Exception();
var exception = new SerializationException(message, innerException);
Assert.Equal(message, exception.Message);
Assert.Equal(innerException, exception.InnerException);
Assert.Equal(COR_E_SERIALIZATION, exception.HResult);
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsBinaryFormatterSupported))]
public void Ctor_SerializationInfo_StreamingContext()
{
using (var memoryStream = new MemoryStream())
{
var formatter = new BinaryFormatter();
formatter.Serialize(memoryStream, new SerializationException());
memoryStream.Seek(0, SeekOrigin.Begin);
Assert.IsType<SerializationException>(formatter.Deserialize(memoryStream));
}
}
}
}
| // 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.Runtime.Serialization.Formatters.Binary;
using Xunit;
namespace System.Runtime.Serialization.Tests
{
public class SerializationExceptionTests
{
private const int COR_E_SERIALIZATION = unchecked((int)0x8013150C);
[Fact]
public void Ctor_Default()
{
var exception = new SerializationException();
Assert.NotEmpty(exception.Message);
Assert.Null(exception.InnerException);
Assert.Equal(COR_E_SERIALIZATION, exception.HResult);
}
[Theory]
[InlineData("message")]
public void Ctor_String(string message)
{
var exception = new SerializationException(message);
Assert.Equal(message, exception.Message);
Assert.Null(exception.InnerException);
Assert.Equal(COR_E_SERIALIZATION, exception.HResult);
}
[Theory]
[InlineData("message")]
public void Ctor_String_Exception(string message)
{
var innerException = new Exception();
var exception = new SerializationException(message, innerException);
Assert.Equal(message, exception.Message);
Assert.Equal(innerException, exception.InnerException);
Assert.Equal(COR_E_SERIALIZATION, exception.HResult);
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsBinaryFormatterSupported))]
public void Ctor_SerializationInfo_StreamingContext()
{
using (var memoryStream = new MemoryStream())
{
var formatter = new BinaryFormatter();
formatter.Serialize(memoryStream, new SerializationException());
memoryStream.Seek(0, SeekOrigin.Begin);
Assert.IsType<SerializationException>(formatter.Deserialize(memoryStream));
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/HardwareIntrinsics/General/Vector64/CreateScalar.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\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 CreateScalarByte()
{
var test = new VectorCreate__CreateScalarByte();
// 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 VectorCreate__CreateScalarByte
{
private static readonly int LargestVectorSize = 8;
private static readonly int ElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte);
public bool Succeeded { get; set; } = true;
public void RunBasicScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario));
Byte value = TestLibrary.Generator.GetByte();
Vector64<Byte> result = Vector64.CreateScalar(value);
ValidateResult(result, value);
}
public void RunReflectionScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario));
Byte value = TestLibrary.Generator.GetByte();
object result = typeof(Vector64)
.GetMethod(nameof(Vector64.CreateScalar), new Type[] { typeof(Byte) })
.Invoke(null, new object[] { value });
ValidateResult((Vector64<Byte>)(result), value);
}
private void ValidateResult(Vector64<Byte> result, Byte expectedValue, [CallerMemberName] string method = "")
{
Byte[] resultElements = new Byte[ElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref resultElements[0]), result);
ValidateResult(resultElements, expectedValue, method);
}
private void ValidateResult(Byte[] resultElements, Byte expectedValue, [CallerMemberName] string method = "")
{
bool succeeded = true;
if (resultElements[0] != expectedValue)
{
succeeded = false;
}
else
{
for (var i = 1; i < ElementCount; i++)
{
if (resultElements[i] != 0)
{
succeeded = false;
break;
}
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"Vector64.CreateScalar(Byte): {method} failed:");
TestLibrary.TestFramework.LogInformation($" value: {expectedValue}");
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 CreateScalarByte()
{
var test = new VectorCreate__CreateScalarByte();
// 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 VectorCreate__CreateScalarByte
{
private static readonly int LargestVectorSize = 8;
private static readonly int ElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte);
public bool Succeeded { get; set; } = true;
public void RunBasicScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario));
Byte value = TestLibrary.Generator.GetByte();
Vector64<Byte> result = Vector64.CreateScalar(value);
ValidateResult(result, value);
}
public void RunReflectionScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario));
Byte value = TestLibrary.Generator.GetByte();
object result = typeof(Vector64)
.GetMethod(nameof(Vector64.CreateScalar), new Type[] { typeof(Byte) })
.Invoke(null, new object[] { value });
ValidateResult((Vector64<Byte>)(result), value);
}
private void ValidateResult(Vector64<Byte> result, Byte expectedValue, [CallerMemberName] string method = "")
{
Byte[] resultElements = new Byte[ElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref resultElements[0]), result);
ValidateResult(resultElements, expectedValue, method);
}
private void ValidateResult(Byte[] resultElements, Byte expectedValue, [CallerMemberName] string method = "")
{
bool succeeded = true;
if (resultElements[0] != expectedValue)
{
succeeded = false;
}
else
{
for (var i = 1; i < ElementCount; i++)
{
if (resultElements[i] != 0)
{
succeeded = false;
break;
}
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"Vector64.CreateScalar(Byte): {method} failed:");
TestLibrary.TestFramework.LogInformation($" value: {expectedValue}");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", resultElements)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/LoadAndInsertScalar.Vector128.UInt16.7.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.Reflection;
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 LoadAndInsertScalar_Vector128_UInt16_7()
{
var test = new LoadAndInsertTest__LoadAndInsertScalar_Vector128_UInt16_7();
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 LoadAndInsertTest__LoadAndInsertScalar_Vector128_UInt16_7
{
private struct DataTable
{
private byte[] inArray1;
private byte[] outArray;
private GCHandle inHandle1;
private GCHandle outHandle;
private ulong alignment;
public DataTable(UInt16[] inArray1, UInt16[] outArray, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<UInt16>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<UInt16>();
if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray1 = new byte[alignment * 2];
this.outArray = new byte[alignment * 2];
this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned);
this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<UInt16, byte>(ref inArray1[0]), (uint)sizeOfinArray1);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle1.Free();
outHandle.Free();
}
private static unsafe void* Align(byte* buffer, ulong expectedAlignment)
{
return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1));
}
}
private struct TestStruct
{
public Vector128<UInt16> _fld1;
public UInt16 _fld3;
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>>());
testStruct._fld3 = TestLibrary.Generator.GetUInt16();
return testStruct;
}
public void RunStructFldScenario(LoadAndInsertTest__LoadAndInsertScalar_Vector128_UInt16_7 testClass)
{
fixed (UInt16* pFld3 = &_fld3)
{
var result = AdvSimd.LoadAndInsertScalar(_fld1, 7, pFld3);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
}
testClass.ValidateResult(_fld1, _fld3, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(LoadAndInsertTest__LoadAndInsertScalar_Vector128_UInt16_7 testClass)
{
fixed (Vector128<UInt16>* pFld1 = &_fld1)
fixed (UInt16* pFld3 = &_fld3)
{
var result = AdvSimd.LoadAndInsertScalar(
AdvSimd.LoadVector128((UInt16*)pFld1),
7,
pFld3
);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, _fld3, testClass._dataTable.outArrayPtr);
}
}
}
private static readonly int LargestVectorSize = 16;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<UInt16>>() / sizeof(UInt16);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt16>>() / sizeof(UInt16);
private static readonly byte ElementIndex = 7;
private static UInt16[] _data1 = new UInt16[Op1ElementCount];
private static Vector128<UInt16> _clsVar1;
private static UInt16 _clsVar3;
private Vector128<UInt16> _fld1;
private UInt16 _fld3;
private DataTable _dataTable;
static LoadAndInsertTest__LoadAndInsertScalar_Vector128_UInt16_7()
{
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>>());
_clsVar3 = TestLibrary.Generator.GetUInt16();
}
public LoadAndInsertTest__LoadAndInsertScalar_Vector128_UInt16_7()
{
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>>());
_fld3 = TestLibrary.Generator.GetUInt16();
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt16(); }
_dataTable = new DataTable(_data1, new UInt16[RetElementCount], LargestVectorSize);
}
public bool IsSupported => AdvSimd.IsSupported;
public bool Succeeded { get; set; }
public void RunBasicScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));
UInt16 op3 = TestLibrary.Generator.GetUInt16();
var result = AdvSimd.LoadAndInsertScalar(
Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray1Ptr),
7,
&op3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, op3, _dataTable.outArrayPtr);
}
public void RunBasicScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));
UInt16 op3 = TestLibrary.Generator.GetUInt16();
var result = AdvSimd.LoadAndInsertScalar(
AdvSimd.LoadVector128((UInt16*)(_dataTable.inArray1Ptr)),
7,
&op3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, op3, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
UInt16 op3 = TestLibrary.Generator.GetUInt16();
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.LoadAndInsertScalar), new Type[] { typeof(Vector128<UInt16>), typeof(byte), typeof(UInt16*) })
.Invoke(null, new object[] {
Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray1Ptr),
ElementIndex,
Pointer.Box(&op3, typeof(UInt16*))
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt16>)(result));
ValidateResult(_dataTable.inArray1Ptr, op3, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));
UInt16 op3 = TestLibrary.Generator.GetUInt16();
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.LoadAndInsertScalar), new Type[] { typeof(Vector128<UInt16>), typeof(byte), typeof(UInt16*) })
.Invoke(null, new object[] {
AdvSimd.LoadVector128((UInt16*)(_dataTable.inArray1Ptr)),
ElementIndex,
Pointer.Box(&op3, typeof(UInt16*))
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt16>)(result));
ValidateResult(_dataTable.inArray1Ptr, op3, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
fixed (UInt16* pClsVar3 = &_clsVar3)
{
var result = AdvSimd.LoadAndInsertScalar(
_clsVar1,
7,
pClsVar3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
}
ValidateResult(_clsVar1, _clsVar3, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector128<UInt16>* pClsVar1 = &_clsVar1)
fixed (UInt16* pClsVar3 = &_clsVar3)
{
var result = AdvSimd.LoadAndInsertScalar(
AdvSimd.LoadVector128((UInt16*)pClsVar1),
7,
pClsVar3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
}
ValidateResult(_clsVar1, _clsVar3, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var op1 = Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray1Ptr);
var op3 = TestLibrary.Generator.GetUInt16();
var result = AdvSimd.LoadAndInsertScalar(op1, 7, &op3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op3, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load));
var op1 = AdvSimd.LoadVector128((UInt16*)(_dataTable.inArray1Ptr));
var op3 = TestLibrary.Generator.GetUInt16();
var result = AdvSimd.LoadAndInsertScalar(op1, 7, &op3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op3, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new LoadAndInsertTest__LoadAndInsertScalar_Vector128_UInt16_7();
fixed (UInt16* pFld3 = &test._fld3)
{
var result = AdvSimd.LoadAndInsertScalar(test._fld1, 7, pFld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr);
}
}
public void RunClassLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));
var test = new LoadAndInsertTest__LoadAndInsertScalar_Vector128_UInt16_7();
fixed (Vector128<UInt16>* pFld1 = &test._fld1)
fixed (UInt16* pFld3 = &test._fld3)
{
var result = AdvSimd.LoadAndInsertScalar(
AdvSimd.LoadVector128((UInt16*)pFld1),
7,
pFld3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
fixed (UInt16* pFld3 = &_fld3)
{
var result = AdvSimd.LoadAndInsertScalar(_fld1, 7, pFld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
}
ValidateResult(_fld1, _fld3, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector128<UInt16>* pFld1 = &_fld1)
fixed (UInt16* pFld3 = &_fld3)
{
var result = AdvSimd.LoadAndInsertScalar(
AdvSimd.LoadVector128((UInt16*)pFld1),
7,
pFld3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _fld3, _dataTable.outArrayPtr);
}
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = AdvSimd.LoadAndInsertScalar(test._fld1, 7, &test._fld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));
var test = TestStruct.Create();
var result = AdvSimd.LoadAndInsertScalar(
AdvSimd.LoadVector128((UInt16*)(&test._fld1)),
7,
&test._fld3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld3, _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, UInt16 op3, void* result, [CallerMemberName] string method = "")
{
UInt16[] inArray1 = new UInt16[Op1ElementCount];
UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), op1);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt16>>());
ValidateResult(inArray1, op3, outArray, method);
}
private void ValidateResult(void* op1, UInt16 op3, void* result, [CallerMemberName] string method = "")
{
UInt16[] inArray1 = new UInt16[Op1ElementCount];
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<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt16>>());
ValidateResult(inArray1, op3, outArray, method);
}
private void ValidateResult(UInt16[] firstOp, UInt16 thirdOp, UInt16[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (var i = 0; i < RetElementCount; i++)
{
if (Helpers.Insert(firstOp, ElementIndex, thirdOp, i) != result[i])
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.LoadAndInsertScalar)}<UInt16>(Vector128<UInt16>, 7, UInt16*): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" thirdOp: {thirdOp}");
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.Reflection;
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 LoadAndInsertScalar_Vector128_UInt16_7()
{
var test = new LoadAndInsertTest__LoadAndInsertScalar_Vector128_UInt16_7();
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 LoadAndInsertTest__LoadAndInsertScalar_Vector128_UInt16_7
{
private struct DataTable
{
private byte[] inArray1;
private byte[] outArray;
private GCHandle inHandle1;
private GCHandle outHandle;
private ulong alignment;
public DataTable(UInt16[] inArray1, UInt16[] outArray, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<UInt16>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<UInt16>();
if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray1 = new byte[alignment * 2];
this.outArray = new byte[alignment * 2];
this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned);
this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<UInt16, byte>(ref inArray1[0]), (uint)sizeOfinArray1);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle1.Free();
outHandle.Free();
}
private static unsafe void* Align(byte* buffer, ulong expectedAlignment)
{
return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1));
}
}
private struct TestStruct
{
public Vector128<UInt16> _fld1;
public UInt16 _fld3;
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>>());
testStruct._fld3 = TestLibrary.Generator.GetUInt16();
return testStruct;
}
public void RunStructFldScenario(LoadAndInsertTest__LoadAndInsertScalar_Vector128_UInt16_7 testClass)
{
fixed (UInt16* pFld3 = &_fld3)
{
var result = AdvSimd.LoadAndInsertScalar(_fld1, 7, pFld3);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
}
testClass.ValidateResult(_fld1, _fld3, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(LoadAndInsertTest__LoadAndInsertScalar_Vector128_UInt16_7 testClass)
{
fixed (Vector128<UInt16>* pFld1 = &_fld1)
fixed (UInt16* pFld3 = &_fld3)
{
var result = AdvSimd.LoadAndInsertScalar(
AdvSimd.LoadVector128((UInt16*)pFld1),
7,
pFld3
);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, _fld3, testClass._dataTable.outArrayPtr);
}
}
}
private static readonly int LargestVectorSize = 16;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<UInt16>>() / sizeof(UInt16);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt16>>() / sizeof(UInt16);
private static readonly byte ElementIndex = 7;
private static UInt16[] _data1 = new UInt16[Op1ElementCount];
private static Vector128<UInt16> _clsVar1;
private static UInt16 _clsVar3;
private Vector128<UInt16> _fld1;
private UInt16 _fld3;
private DataTable _dataTable;
static LoadAndInsertTest__LoadAndInsertScalar_Vector128_UInt16_7()
{
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>>());
_clsVar3 = TestLibrary.Generator.GetUInt16();
}
public LoadAndInsertTest__LoadAndInsertScalar_Vector128_UInt16_7()
{
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>>());
_fld3 = TestLibrary.Generator.GetUInt16();
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt16(); }
_dataTable = new DataTable(_data1, new UInt16[RetElementCount], LargestVectorSize);
}
public bool IsSupported => AdvSimd.IsSupported;
public bool Succeeded { get; set; }
public void RunBasicScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));
UInt16 op3 = TestLibrary.Generator.GetUInt16();
var result = AdvSimd.LoadAndInsertScalar(
Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray1Ptr),
7,
&op3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, op3, _dataTable.outArrayPtr);
}
public void RunBasicScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));
UInt16 op3 = TestLibrary.Generator.GetUInt16();
var result = AdvSimd.LoadAndInsertScalar(
AdvSimd.LoadVector128((UInt16*)(_dataTable.inArray1Ptr)),
7,
&op3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, op3, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
UInt16 op3 = TestLibrary.Generator.GetUInt16();
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.LoadAndInsertScalar), new Type[] { typeof(Vector128<UInt16>), typeof(byte), typeof(UInt16*) })
.Invoke(null, new object[] {
Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray1Ptr),
ElementIndex,
Pointer.Box(&op3, typeof(UInt16*))
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt16>)(result));
ValidateResult(_dataTable.inArray1Ptr, op3, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));
UInt16 op3 = TestLibrary.Generator.GetUInt16();
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.LoadAndInsertScalar), new Type[] { typeof(Vector128<UInt16>), typeof(byte), typeof(UInt16*) })
.Invoke(null, new object[] {
AdvSimd.LoadVector128((UInt16*)(_dataTable.inArray1Ptr)),
ElementIndex,
Pointer.Box(&op3, typeof(UInt16*))
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt16>)(result));
ValidateResult(_dataTable.inArray1Ptr, op3, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
fixed (UInt16* pClsVar3 = &_clsVar3)
{
var result = AdvSimd.LoadAndInsertScalar(
_clsVar1,
7,
pClsVar3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
}
ValidateResult(_clsVar1, _clsVar3, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector128<UInt16>* pClsVar1 = &_clsVar1)
fixed (UInt16* pClsVar3 = &_clsVar3)
{
var result = AdvSimd.LoadAndInsertScalar(
AdvSimd.LoadVector128((UInt16*)pClsVar1),
7,
pClsVar3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
}
ValidateResult(_clsVar1, _clsVar3, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var op1 = Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray1Ptr);
var op3 = TestLibrary.Generator.GetUInt16();
var result = AdvSimd.LoadAndInsertScalar(op1, 7, &op3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op3, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load));
var op1 = AdvSimd.LoadVector128((UInt16*)(_dataTable.inArray1Ptr));
var op3 = TestLibrary.Generator.GetUInt16();
var result = AdvSimd.LoadAndInsertScalar(op1, 7, &op3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op3, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new LoadAndInsertTest__LoadAndInsertScalar_Vector128_UInt16_7();
fixed (UInt16* pFld3 = &test._fld3)
{
var result = AdvSimd.LoadAndInsertScalar(test._fld1, 7, pFld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr);
}
}
public void RunClassLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));
var test = new LoadAndInsertTest__LoadAndInsertScalar_Vector128_UInt16_7();
fixed (Vector128<UInt16>* pFld1 = &test._fld1)
fixed (UInt16* pFld3 = &test._fld3)
{
var result = AdvSimd.LoadAndInsertScalar(
AdvSimd.LoadVector128((UInt16*)pFld1),
7,
pFld3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
fixed (UInt16* pFld3 = &_fld3)
{
var result = AdvSimd.LoadAndInsertScalar(_fld1, 7, pFld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
}
ValidateResult(_fld1, _fld3, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector128<UInt16>* pFld1 = &_fld1)
fixed (UInt16* pFld3 = &_fld3)
{
var result = AdvSimd.LoadAndInsertScalar(
AdvSimd.LoadVector128((UInt16*)pFld1),
7,
pFld3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _fld3, _dataTable.outArrayPtr);
}
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = AdvSimd.LoadAndInsertScalar(test._fld1, 7, &test._fld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld3, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));
var test = TestStruct.Create();
var result = AdvSimd.LoadAndInsertScalar(
AdvSimd.LoadVector128((UInt16*)(&test._fld1)),
7,
&test._fld3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld3, _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, UInt16 op3, void* result, [CallerMemberName] string method = "")
{
UInt16[] inArray1 = new UInt16[Op1ElementCount];
UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), op1);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt16>>());
ValidateResult(inArray1, op3, outArray, method);
}
private void ValidateResult(void* op1, UInt16 op3, void* result, [CallerMemberName] string method = "")
{
UInt16[] inArray1 = new UInt16[Op1ElementCount];
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<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt16>>());
ValidateResult(inArray1, op3, outArray, method);
}
private void ValidateResult(UInt16[] firstOp, UInt16 thirdOp, UInt16[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (var i = 0; i < RetElementCount; i++)
{
if (Helpers.Insert(firstOp, ElementIndex, thirdOp, i) != result[i])
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.LoadAndInsertScalar)}<UInt16>(Vector128<UInt16>, 7, UInt16*): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" thirdOp: {thirdOp}");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.Mangling.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;
namespace Internal.IL.Stubs
{
partial class MethodBaseGetCurrentMethodThunk : IPrefixMangledMethod
{
MethodDesc IPrefixMangledMethod.BaseMethod
{
get
{
return Method;
}
}
string IPrefixMangledMethod.Prefix
{
get
{
return "GetCurrentMethod";
}
}
}
}
| // 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;
namespace Internal.IL.Stubs
{
partial class MethodBaseGetCurrentMethodThunk : IPrefixMangledMethod
{
MethodDesc IPrefixMangledMethod.BaseMethod
{
get
{
return Method;
}
}
string IPrefixMangledMethod.Prefix
{
get
{
return "GetCurrentMethod";
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Net.WebClient/src/System/Net/WebClient.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.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Net.Cache;
using System.Security;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace System.Net
{
public class WebClient : Component
{
private const int DefaultCopyBufferLength = 8192;
private const int DefaultDownloadBufferLength = 65536;
private const string DefaultUploadFileContentType = "application/octet-stream";
private const string UploadFileContentType = "multipart/form-data";
private const string UploadValuesContentType = "application/x-www-form-urlencoded";
private Uri? _baseAddress;
private ICredentials? _credentials;
private WebHeaderCollection? _headers;
private NameValueCollection? _requestParameters;
private WebResponse? _webResponse;
private WebRequest? _webRequest;
private Encoding _encoding = Encoding.Default;
private string? _method;
private long _contentLength = -1;
private bool _initWebClientAsync;
private bool _canceled;
private ProgressData? _progress;
private IWebProxy? _proxy;
private bool _proxySet;
private int _callNesting; // > 0 if we're in a Read/Write call
private AsyncOperation? _asyncOp;
private SendOrPostCallback? _downloadDataOperationCompleted;
private SendOrPostCallback? _openReadOperationCompleted;
private SendOrPostCallback? _openWriteOperationCompleted;
private SendOrPostCallback? _downloadStringOperationCompleted;
private SendOrPostCallback? _downloadFileOperationCompleted;
private SendOrPostCallback? _uploadStringOperationCompleted;
private SendOrPostCallback? _uploadDataOperationCompleted;
private SendOrPostCallback? _uploadFileOperationCompleted;
private SendOrPostCallback? _uploadValuesOperationCompleted;
private SendOrPostCallback? _reportDownloadProgressChanged;
private SendOrPostCallback? _reportUploadProgressChanged;
[Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public WebClient()
{
// We don't know if derived types need finalizing, but WebClient doesn't.
if (GetType() == typeof(WebClient))
{
GC.SuppressFinalize(this);
}
}
public event DownloadStringCompletedEventHandler? DownloadStringCompleted;
public event DownloadDataCompletedEventHandler? DownloadDataCompleted;
public event AsyncCompletedEventHandler? DownloadFileCompleted;
public event UploadStringCompletedEventHandler? UploadStringCompleted;
public event UploadDataCompletedEventHandler? UploadDataCompleted;
public event UploadFileCompletedEventHandler? UploadFileCompleted;
public event UploadValuesCompletedEventHandler? UploadValuesCompleted;
public event OpenReadCompletedEventHandler? OpenReadCompleted;
public event OpenWriteCompletedEventHandler? OpenWriteCompleted;
public event DownloadProgressChangedEventHandler? DownloadProgressChanged;
public event UploadProgressChangedEventHandler? UploadProgressChanged;
protected virtual void OnDownloadStringCompleted(DownloadStringCompletedEventArgs e) => DownloadStringCompleted?.Invoke(this, e);
protected virtual void OnDownloadDataCompleted(DownloadDataCompletedEventArgs e) => DownloadDataCompleted?.Invoke(this, e);
protected virtual void OnDownloadFileCompleted(AsyncCompletedEventArgs e) => DownloadFileCompleted?.Invoke(this, e);
protected virtual void OnDownloadProgressChanged(DownloadProgressChangedEventArgs e) => DownloadProgressChanged?.Invoke(this, e);
protected virtual void OnUploadStringCompleted(UploadStringCompletedEventArgs e) => UploadStringCompleted?.Invoke(this, e);
protected virtual void OnUploadDataCompleted(UploadDataCompletedEventArgs e) => UploadDataCompleted?.Invoke(this, e);
protected virtual void OnUploadFileCompleted(UploadFileCompletedEventArgs e) => UploadFileCompleted?.Invoke(this, e);
protected virtual void OnUploadValuesCompleted(UploadValuesCompletedEventArgs e) => UploadValuesCompleted?.Invoke(this, e);
protected virtual void OnUploadProgressChanged(UploadProgressChangedEventArgs e) => UploadProgressChanged?.Invoke(this, e);
protected virtual void OnOpenReadCompleted(OpenReadCompletedEventArgs e) => OpenReadCompleted?.Invoke(this, e);
protected virtual void OnOpenWriteCompleted(OpenWriteCompletedEventArgs e) => OpenWriteCompleted?.Invoke(this, e);
private void StartOperation()
{
if (Interlocked.Increment(ref _callNesting) > 1)
{
EndOperation();
throw new NotSupportedException(SR.net_webclient_no_concurrent_io_allowed);
}
_contentLength = -1;
_webResponse = null;
_webRequest = null;
_method = null;
_canceled = false;
_progress?.Reset();
}
private AsyncOperation StartAsyncOperation(object? userToken)
{
if (!_initWebClientAsync)
{
// Set up the async delegates
_openReadOperationCompleted = arg => OnOpenReadCompleted((OpenReadCompletedEventArgs)arg!);
_openWriteOperationCompleted = arg => OnOpenWriteCompleted((OpenWriteCompletedEventArgs)arg!);
_downloadStringOperationCompleted = arg => OnDownloadStringCompleted((DownloadStringCompletedEventArgs)arg!);
_downloadDataOperationCompleted = arg => OnDownloadDataCompleted((DownloadDataCompletedEventArgs)arg!);
_downloadFileOperationCompleted = arg => OnDownloadFileCompleted((AsyncCompletedEventArgs)arg!);
_uploadStringOperationCompleted = arg => OnUploadStringCompleted((UploadStringCompletedEventArgs)arg!);
_uploadDataOperationCompleted = arg => OnUploadDataCompleted((UploadDataCompletedEventArgs)arg!);
_uploadFileOperationCompleted = arg => OnUploadFileCompleted((UploadFileCompletedEventArgs)arg!);
_uploadValuesOperationCompleted = arg => OnUploadValuesCompleted((UploadValuesCompletedEventArgs)arg!);
_reportDownloadProgressChanged = arg => OnDownloadProgressChanged((DownloadProgressChangedEventArgs)arg!);
_reportUploadProgressChanged = arg => OnUploadProgressChanged((UploadProgressChangedEventArgs)arg!);
_progress = new ProgressData();
_initWebClientAsync = true;
}
AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(userToken);
StartOperation();
_asyncOp = asyncOp;
return asyncOp;
}
private void EndOperation() => Interlocked.Decrement(ref _callNesting);
public Encoding Encoding
{
get { return _encoding; }
set
{
ArgumentNullException.ThrowIfNull(value);
_encoding = value;
}
}
[AllowNull]
public string BaseAddress
{
get { return _baseAddress != null ? _baseAddress.ToString() : string.Empty; }
set
{
if (string.IsNullOrEmpty(value))
{
_baseAddress = null;
}
else
{
try
{
_baseAddress = new Uri(value);
}
catch (UriFormatException e)
{
throw new ArgumentException(SR.net_webclient_invalid_baseaddress, nameof(value), e);
}
}
}
}
public ICredentials? Credentials
{
get { return _credentials; }
set { _credentials = value; }
}
public bool UseDefaultCredentials
{
get { return _credentials == CredentialCache.DefaultCredentials; }
set { _credentials = value ? CredentialCache.DefaultCredentials : null; }
}
[AllowNull]
public WebHeaderCollection Headers
{
get { return _headers ??= new WebHeaderCollection(); }
set { _headers = value; }
}
[AllowNull]
public NameValueCollection QueryString
{
get { return _requestParameters ??= new NameValueCollection(); }
set { _requestParameters = value; }
}
public WebHeaderCollection? ResponseHeaders => _webResponse?.Headers;
public IWebProxy? Proxy
{
get { return _proxySet ? _proxy : WebRequest.DefaultWebProxy; }
set
{
_proxy = value;
_proxySet = true;
}
}
public RequestCachePolicy? CachePolicy { get; set; }
public bool IsBusy => Volatile.Read(ref _callNesting) > 0;
protected virtual WebRequest GetWebRequest(Uri address)
{
#pragma warning disable SYSLIB0014 // WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.
WebRequest request = WebRequest.Create(address);
#pragma warning restore SYSLIB0014
CopyHeadersTo(request);
if (Credentials != null)
{
request.Credentials = Credentials;
}
if (_method != null)
{
request.Method = _method;
}
if (_contentLength != -1)
{
request.ContentLength = _contentLength;
}
if (_proxySet)
{
request.Proxy = _proxy;
}
if (CachePolicy != null)
{
request.CachePolicy = CachePolicy;
}
return request;
}
protected virtual WebResponse GetWebResponse(WebRequest request)
{
WebResponse response = request.GetResponse();
_webResponse = response;
return response;
}
protected virtual WebResponse GetWebResponse(WebRequest request, IAsyncResult result)
{
WebResponse response = request.EndGetResponse(result);
_webResponse = response;
return response;
}
private async Task<WebResponse> GetWebResponseTaskAsync(WebRequest request)
{
// We would like to simply await request.GetResponseAsync(), but WebClient exposes
// a protected member GetWebResponse(WebRequest, IAsyncResult) that derived instances expect to
// be used to get the response, and it needs to be passed the IAsyncResult that was returned
// from WebRequest.BeginGetResponse.
var awaitable = new BeginEndAwaitableAdapter();
request.BeginGetResponse(BeginEndAwaitableAdapter.Callback, awaitable);
return GetWebResponse(request, await awaitable);
}
public byte[] DownloadData(string address) =>
DownloadData(GetUri(address));
public byte[] DownloadData(Uri address!!)
{
StartOperation();
try
{
WebRequest request;
return DownloadDataInternal(address, out request);
}
finally
{
EndOperation();
}
}
private byte[] DownloadDataInternal(Uri address, out WebRequest request)
{
WebRequest? tmpRequest = null;
byte[] result;
try
{
tmpRequest = _webRequest = GetWebRequest(GetUri(address));
result = DownloadBits(tmpRequest, new ChunkedMemoryStream())!;
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
AbortRequest(tmpRequest);
if (e is WebException || e is SecurityException) throw;
throw new WebException(SR.net_webclient, e);
}
request = tmpRequest;
return result;
}
public void DownloadFile(string address, string fileName) =>
DownloadFile(GetUri(address), fileName);
public void DownloadFile(Uri address!!, string fileName!!)
{
WebRequest? request = null;
FileStream? fs = null;
bool succeeded = false;
StartOperation();
try
{
fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);
request = _webRequest = GetWebRequest(GetUri(address));
DownloadBits(request, fs);
succeeded = true;
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
AbortRequest(request);
if (e is WebException || e is SecurityException) throw;
throw new WebException(SR.net_webclient, e);
}
finally
{
if (fs != null)
{
fs.Close();
if (!succeeded)
{
File.Delete(fileName);
}
}
EndOperation();
}
}
public Stream OpenRead(string address) =>
OpenRead(GetUri(address));
public Stream OpenRead(Uri address!!)
{
WebRequest? request = null;
StartOperation();
try
{
request = _webRequest = GetWebRequest(GetUri(address));
WebResponse response = _webResponse = GetWebResponse(request);
return response.GetResponseStream();
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
AbortRequest(request);
if (e is WebException || e is SecurityException) throw;
throw new WebException(SR.net_webclient, e);
}
finally
{
EndOperation();
}
}
public Stream OpenWrite(string address) =>
OpenWrite(GetUri(address), null);
public Stream OpenWrite(Uri address) =>
OpenWrite(address, null);
public Stream OpenWrite(string address, string? method) =>
OpenWrite(GetUri(address), method);
public Stream OpenWrite(Uri address!!, string? method)
{
method ??= MapToDefaultMethod(address);
WebRequest? request = null;
StartOperation();
try
{
_method = method;
request = _webRequest = GetWebRequest(GetUri(address));
return new WebClientWriteStream(
request.GetRequestStream(),
request,
this);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
AbortRequest(request);
if (e is WebException || e is SecurityException) throw;
throw new WebException(SR.net_webclient, e);
}
finally
{
EndOperation();
}
}
public byte[] UploadData(string address, byte[] data) =>
UploadData(GetUri(address), null, data);
public byte[] UploadData(Uri address, byte[] data) =>
UploadData(address, null, data);
public byte[] UploadData(string address, string? method, byte[] data) =>
UploadData(GetUri(address), method, data);
public byte[] UploadData(Uri address!!, string? method, byte[] data!!)
{
method ??= MapToDefaultMethod(address);
StartOperation();
try
{
WebRequest request;
return UploadDataInternal(address, method, data, out request);
}
finally
{
EndOperation();
}
}
private byte[] UploadDataInternal(Uri address, string method, byte[] data, out WebRequest request)
{
WebRequest? tmpRequest = null;
byte[] result;
try
{
_method = method;
_contentLength = data.Length;
tmpRequest = _webRequest = GetWebRequest(GetUri(address));
result = UploadBits(tmpRequest, null, data, 0, null, null);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
AbortRequest(tmpRequest);
if (e is WebException || e is SecurityException) throw;
throw new WebException(SR.net_webclient, e);
}
request = tmpRequest;
return result;
}
private void OpenFileInternal(
bool needsHeaderAndBoundary, string fileName,
out FileStream fs, out byte[] buffer, ref byte[]? formHeaderBytes, ref byte[]? boundaryBytes)
{
fileName = Path.GetFullPath(fileName);
WebHeaderCollection headers = Headers;
string? contentType = headers[HttpKnownHeaderNames.ContentType];
if (contentType == null)
{
contentType = DefaultUploadFileContentType;
}
else if (contentType.StartsWith("multipart/", StringComparison.OrdinalIgnoreCase))
{
throw new WebException(SR.net_webclient_Multipart);
}
fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
int buffSize = DefaultCopyBufferLength;
_contentLength = -1;
if (string.Equals(_method, "POST", StringComparison.Ordinal))
{
if (needsHeaderAndBoundary)
{
string boundary = $"---------------------{DateTime.Now.Ticks:x}";
headers[HttpKnownHeaderNames.ContentType] = UploadFileContentType + "; boundary=" + boundary;
string formHeader =
"--" + boundary + "\r\n" +
"Content-Disposition: form-data; name=\"file\"; filename=\"" + Path.GetFileName(fileName) + "\"\r\n" + // TODO: Should the filename path be encoded?
"Content-Type: " + contentType + "\r\n" +
"\r\n";
formHeaderBytes = Encoding.UTF8.GetBytes(formHeader);
boundaryBytes = Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
}
else
{
formHeaderBytes = Array.Empty<byte>();
boundaryBytes = Array.Empty<byte>();
}
if (fs.CanSeek)
{
_contentLength = fs.Length + formHeaderBytes.Length + boundaryBytes.Length;
buffSize = (int)Math.Min(DefaultCopyBufferLength, fs.Length);
}
}
else
{
headers[HttpKnownHeaderNames.ContentType] = contentType;
formHeaderBytes = null;
boundaryBytes = null;
if (fs.CanSeek)
{
_contentLength = fs.Length;
buffSize = (int)Math.Min(DefaultCopyBufferLength, fs.Length);
}
}
buffer = new byte[buffSize];
}
public byte[] UploadFile(string address, string fileName) =>
UploadFile(GetUri(address), fileName);
public byte[] UploadFile(Uri address, string fileName) =>
UploadFile(address, null, fileName);
public byte[] UploadFile(string address, string? method, string fileName) =>
UploadFile(GetUri(address), method, fileName);
public byte[] UploadFile(Uri address!!, string? method, string fileName!!)
{
method ??= MapToDefaultMethod(address);
FileStream? fs = null;
WebRequest? request = null;
StartOperation();
try
{
_method = method;
byte[]? formHeaderBytes = null, boundaryBytes = null, buffer;
Uri uri = GetUri(address);
bool needsHeaderAndBoundary = (uri.Scheme != Uri.UriSchemeFile);
OpenFileInternal(needsHeaderAndBoundary, fileName, out fs, out buffer, ref formHeaderBytes, ref boundaryBytes);
request = _webRequest = GetWebRequest(uri);
return UploadBits(request, fs, buffer, 0, formHeaderBytes, boundaryBytes);
}
catch (Exception e)
{
fs?.Close();
if (e is OutOfMemoryException) throw;
AbortRequest(request);
if (e is WebException || e is SecurityException) throw;
throw new WebException(SR.net_webclient, e);
}
finally
{
EndOperation();
}
}
private byte[] GetValuesToUpload(NameValueCollection data)
{
WebHeaderCollection headers = Headers;
string? contentType = headers[HttpKnownHeaderNames.ContentType];
if (contentType != null && !string.Equals(contentType, UploadValuesContentType, StringComparison.OrdinalIgnoreCase))
{
throw new WebException(SR.net_webclient_ContentType);
}
headers[HttpKnownHeaderNames.ContentType] = UploadValuesContentType;
string delimiter = string.Empty;
var values = new StringBuilder();
foreach (string? name in data.AllKeys)
{
values.Append(delimiter);
values.Append(UrlEncode(name));
values.Append('=');
values.Append(UrlEncode(data[name]));
delimiter = "&";
}
byte[] buffer = Encoding.ASCII.GetBytes(values.ToString());
_contentLength = buffer.Length;
return buffer;
}
public byte[] UploadValues(string address, NameValueCollection data) =>
UploadValues(GetUri(address), null, data);
public byte[] UploadValues(Uri address, NameValueCollection data) =>
UploadValues(address, null, data);
public byte[] UploadValues(string address, string? method, NameValueCollection data) =>
UploadValues(GetUri(address), method, data);
public byte[] UploadValues(Uri address!!, string? method, NameValueCollection data!!)
{
method ??= MapToDefaultMethod(address);
WebRequest? request = null;
StartOperation();
try
{
byte[] buffer = GetValuesToUpload(data);
_method = method;
request = _webRequest = GetWebRequest(GetUri(address));
return UploadBits(request, null, buffer, 0, null, null);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
AbortRequest(request);
if (e is WebException || e is SecurityException) throw;
throw new WebException(SR.net_webclient, e);
}
finally
{
EndOperation();
}
}
public string UploadString(string address, string data) =>
UploadString(GetUri(address), null, data);
public string UploadString(Uri address, string data) =>
UploadString(address, null, data);
public string UploadString(string address, string? method, string data) =>
UploadString(GetUri(address), method, data);
public string UploadString(Uri address!!, string? method, string data!!)
{
method ??= MapToDefaultMethod(address);
StartOperation();
try
{
WebRequest request;
byte[] requestData = Encoding.GetBytes(data);
byte[] responseData = UploadDataInternal(address, method, requestData, out request);
return GetStringUsingEncoding(request, responseData);
}
finally
{
EndOperation();
}
}
public string DownloadString(string address) =>
DownloadString(GetUri(address));
public string DownloadString(Uri address!!)
{
StartOperation();
try
{
WebRequest request;
byte[] data = DownloadDataInternal(address, out request);
return GetStringUsingEncoding(request, data);
}
finally
{
EndOperation();
}
}
private static void AbortRequest(WebRequest? request)
{
try { request?.Abort(); }
catch (Exception exception) when (!(exception is OutOfMemoryException)) { }
}
private void CopyHeadersTo(WebRequest request)
{
if (_headers == null)
{
return;
}
var hwr = request as HttpWebRequest;
if (hwr == null)
{
return;
}
string? accept = _headers[HttpKnownHeaderNames.Accept];
string? connection = _headers[HttpKnownHeaderNames.Connection];
string? contentType = _headers[HttpKnownHeaderNames.ContentType];
string? expect = _headers[HttpKnownHeaderNames.Expect];
string? referrer = _headers[HttpKnownHeaderNames.Referer];
string? userAgent = _headers[HttpKnownHeaderNames.UserAgent];
string? host = _headers[HttpKnownHeaderNames.Host];
_headers.Remove(HttpKnownHeaderNames.Accept);
_headers.Remove(HttpKnownHeaderNames.Connection);
_headers.Remove(HttpKnownHeaderNames.ContentType);
_headers.Remove(HttpKnownHeaderNames.Expect);
_headers.Remove(HttpKnownHeaderNames.Referer);
_headers.Remove(HttpKnownHeaderNames.UserAgent);
_headers.Remove(HttpKnownHeaderNames.Host);
request.Headers = _headers;
if (!string.IsNullOrEmpty(accept))
{
hwr.Accept = accept;
}
if (!string.IsNullOrEmpty(connection))
{
hwr.Connection = connection;
}
if (!string.IsNullOrEmpty(contentType))
{
hwr.ContentType = contentType;
}
if (!string.IsNullOrEmpty(expect))
{
hwr.Expect = expect;
}
if (!string.IsNullOrEmpty(referrer))
{
hwr.Referer = referrer;
}
if (!string.IsNullOrEmpty(userAgent))
{
hwr.UserAgent = userAgent;
}
if (!string.IsNullOrEmpty(host))
{
hwr.Host = host;
}
}
private Uri GetUri(string address!!)
{
Uri? uri;
if (_baseAddress != null)
{
if (!Uri.TryCreate(_baseAddress, address, out uri))
{
return new Uri(Path.GetFullPath(address));
}
}
else if (!Uri.TryCreate(address, UriKind.Absolute, out uri))
{
return new Uri(Path.GetFullPath(address));
}
return GetUri(uri);
}
private Uri GetUri(Uri address!!)
{
Uri? uri = address;
if (!address.IsAbsoluteUri && _baseAddress != null && !Uri.TryCreate(_baseAddress, address, out uri))
{
return address;
}
if (string.IsNullOrEmpty(uri.Query) && _requestParameters != null)
{
var sb = new StringBuilder();
string delimiter = string.Empty;
for (int i = 0; i < _requestParameters.Count; ++i)
{
sb.Append(delimiter).Append(_requestParameters.AllKeys[i]).Append('=').Append(_requestParameters[i]);
delimiter = "&";
}
uri = new UriBuilder(uri) { Query = sb.ToString() }.Uri;
}
return uri;
}
private byte[]? DownloadBits(WebRequest request, Stream writeStream)
{
try
{
WebResponse response = _webResponse = GetWebResponse(request);
long contentLength = response.ContentLength;
byte[] copyBuffer = new byte[contentLength == -1 || contentLength > DefaultDownloadBufferLength ? DefaultDownloadBufferLength : contentLength];
if (writeStream is ChunkedMemoryStream)
{
if (contentLength > int.MaxValue)
{
throw new WebException(SR.net_webstatus_MessageLengthLimitExceeded, WebExceptionStatus.MessageLengthLimitExceeded);
}
writeStream.SetLength(copyBuffer.Length);
}
using (Stream readStream = response.GetResponseStream())
{
if (readStream != null)
{
int bytesRead;
while ((bytesRead = readStream.Read(copyBuffer, 0, copyBuffer.Length)) != 0)
{
writeStream.Write(copyBuffer, 0, bytesRead);
}
}
}
return (writeStream as ChunkedMemoryStream)?.ToArray();
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
writeStream?.Close();
AbortRequest(request);
if (e is WebException || e is SecurityException) throw;
throw new WebException(SR.net_webclient, e);
}
}
private async void DownloadBitsAsync(
WebRequest request, Stream writeStream,
AsyncOperation asyncOp, Action<byte[]?, Exception?, AsyncOperation> completionDelegate)
{
Debug.Assert(_progress != null, "ProgressData should have been initialized");
Debug.Assert(asyncOp != null);
Exception? exception = null;
try
{
WebResponse response = _webResponse = await GetWebResponseTaskAsync(request).ConfigureAwait(false);
long contentLength = response.ContentLength;
byte[] copyBuffer = new byte[contentLength == -1 || contentLength > DefaultDownloadBufferLength ? DefaultDownloadBufferLength : contentLength];
if (writeStream is ChunkedMemoryStream)
{
if (contentLength > int.MaxValue)
{
throw new WebException(SR.net_webstatus_MessageLengthLimitExceeded, WebExceptionStatus.MessageLengthLimitExceeded);
}
writeStream.SetLength(copyBuffer.Length);
}
if (contentLength >= 0)
{
_progress.TotalBytesToReceive = contentLength;
}
using (writeStream)
using (Stream readStream = response.GetResponseStream())
{
if (readStream != null)
{
while (true)
{
int bytesRead = await readStream.ReadAsync(new Memory<byte>(copyBuffer)).ConfigureAwait(false);
if (bytesRead == 0)
{
break;
}
_progress.BytesReceived += bytesRead;
if (_progress.BytesReceived != _progress.TotalBytesToReceive)
{
PostProgressChanged(asyncOp, _progress);
}
await writeStream.WriteAsync(new ReadOnlyMemory<byte>(copyBuffer, 0, bytesRead)).ConfigureAwait(false);
}
}
if (_progress.TotalBytesToReceive < 0)
{
_progress.TotalBytesToReceive = _progress.BytesReceived;
}
PostProgressChanged(asyncOp, _progress);
}
completionDelegate((writeStream as ChunkedMemoryStream)?.ToArray(), null, asyncOp);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
exception = GetExceptionToPropagate(e);
AbortRequest(request);
writeStream?.Close();
}
finally
{
if (exception != null)
{
completionDelegate(null, exception, asyncOp);
}
}
}
private byte[] UploadBits(
WebRequest request, Stream? readStream, byte[] buffer, int chunkSize,
byte[]? header, byte[]? footer)
{
try
{
if (request.RequestUri.Scheme == Uri.UriSchemeFile)
{
header = footer = null;
}
using (Stream writeStream = request.GetRequestStream())
{
if (header != null)
{
writeStream.Write(header, 0, header.Length);
}
if (readStream != null)
{
using (readStream)
{
while (true)
{
int bytesRead = readStream.Read(buffer, 0, buffer.Length);
if (bytesRead <= 0)
break;
writeStream.Write(buffer, 0, bytesRead);
}
}
}
else
{
for (int pos = 0; pos < buffer.Length;)
{
int toWrite = buffer.Length - pos;
if (chunkSize != 0 && toWrite > chunkSize)
{
toWrite = chunkSize;
}
writeStream.Write(buffer, pos, toWrite);
pos += toWrite;
}
}
if (footer != null)
{
writeStream.Write(footer, 0, footer.Length);
}
}
return DownloadBits(request, new ChunkedMemoryStream())!;
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
AbortRequest(request);
if (e is WebException || e is SecurityException) throw;
throw new WebException(SR.net_webclient, e);
}
}
private async void UploadBitsAsync(
WebRequest request, Stream? readStream, byte[] buffer, int chunkSize,
byte[]? header, byte[]? footer,
AsyncOperation asyncOp, Action<byte[]?, Exception?, AsyncOperation> completionDelegate)
{
Debug.Assert(asyncOp != null);
Debug.Assert(_progress != null, "ProgressData should have been initialized");
_progress.HasUploadPhase = true;
Exception? exception = null;
try
{
if (request.RequestUri.Scheme == Uri.UriSchemeFile)
{
header = footer = null;
}
using (Stream writeStream = await request.GetRequestStreamAsync().ConfigureAwait(false))
{
if (header != null)
{
await writeStream.WriteAsync(new ReadOnlyMemory<byte>(header)).ConfigureAwait(false);
_progress.BytesSent += header.Length;
PostProgressChanged(asyncOp, _progress);
}
if (readStream != null)
{
using (readStream)
{
while (true)
{
int bytesRead = await readStream.ReadAsync(new Memory<byte>(buffer)).ConfigureAwait(false);
if (bytesRead <= 0) break;
await writeStream.WriteAsync(new ReadOnlyMemory<byte>(buffer, 0, bytesRead)).ConfigureAwait(false);
_progress.BytesSent += bytesRead;
PostProgressChanged(asyncOp, _progress);
}
}
}
else
{
for (int pos = 0; pos < buffer.Length;)
{
int toWrite = buffer.Length - pos;
if (chunkSize != 0 && toWrite > chunkSize)
{
toWrite = chunkSize;
}
await writeStream.WriteAsync(new ReadOnlyMemory<byte>(buffer, pos, toWrite)).ConfigureAwait(false);
pos += toWrite;
_progress.BytesSent += toWrite;
PostProgressChanged(asyncOp, _progress);
}
}
if (footer != null)
{
await writeStream.WriteAsync(new ReadOnlyMemory<byte>(footer)).ConfigureAwait(false);
_progress.BytesSent += footer.Length;
PostProgressChanged(asyncOp, _progress);
}
}
DownloadBitsAsync(request, new ChunkedMemoryStream(), asyncOp, completionDelegate);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
exception = GetExceptionToPropagate(e);
AbortRequest(request);
}
finally
{
if (exception != null)
{
completionDelegate(null, exception, asyncOp);
}
}
}
private static bool ByteArrayHasPrefix(byte[] prefix, byte[] byteArray)
{
if (prefix == null || byteArray == null || prefix.Length > byteArray.Length)
{
return false;
}
for (int i = 0; i < prefix.Length; i++)
{
if (prefix[i] != byteArray[i])
{
return false;
}
}
return true;
}
private static readonly char[] s_parseContentTypeSeparators = new char[] { ';', '=', ' ' };
private static readonly Encoding[] s_knownEncodings = { Encoding.UTF8, Encoding.UTF32, Encoding.Unicode, Encoding.BigEndianUnicode };
private string GetStringUsingEncoding(WebRequest request, byte[] data)
{
Encoding? enc = null;
int bomLengthInData = -1;
// Figure out encoding by first checking for encoding string in Content-Type HTTP header
// This can throw NotImplementedException if the derived class of WebRequest doesn't support it.
string? contentType;
try
{
contentType = request.ContentType;
}
catch (Exception e) when (e is NotImplementedException || e is NotSupportedException) // some types do this
{
contentType = null;
}
if (contentType != null)
{
contentType = contentType.ToLowerInvariant();
string[] parsedList = contentType.Split(s_parseContentTypeSeparators);
bool nextItem = false;
foreach (string item in parsedList)
{
if (item == "charset")
{
nextItem = true;
}
else if (nextItem)
{
try
{
enc = Encoding.GetEncoding(item);
}
catch (ArgumentException)
{
// Eat ArgumentException here.
// We'll assume that Content-Type encoding might have been garbled and wasn't present at all.
break;
}
// Unexpected exceptions are thrown back to caller
}
}
}
// If no content encoding listed in the ContentType HTTP header, or no Content-Type header present, then
// check for a byte-order-mark (BOM) in the data to figure out encoding.
if (enc == null)
{
// UTF32 must be tested before Unicode because it's BOM is the same but longer.
Encoding[] encodings = s_knownEncodings;
for (int i = 0; i < encodings.Length; i++)
{
byte[] preamble = encodings[i].GetPreamble();
if (ByteArrayHasPrefix(preamble, data))
{
enc = encodings[i];
bomLengthInData = preamble.Length;
break;
}
}
}
// Do we have an encoding guess? If not, use default.
if (enc == null)
{
enc = Encoding;
}
// Calculate BOM length based on encoding guess. Then check for it in the data.
if (bomLengthInData == -1)
{
byte[] preamble = enc.GetPreamble();
bomLengthInData = ByteArrayHasPrefix(preamble, data) ? preamble.Length : 0;
}
// Convert byte array to string stripping off any BOM before calling Format().
// This is required since Format() doesn't handle stripping off BOM.
return enc.GetString(data, bomLengthInData, data.Length - bomLengthInData);
}
private string MapToDefaultMethod(Uri address)
{
Uri uri = !address.IsAbsoluteUri && _baseAddress != null ?
new Uri(_baseAddress, address) :
address;
return string.Equals(uri.Scheme, Uri.UriSchemeFtp, StringComparison.Ordinal) ?
"STOR" :
"POST";
}
[return: NotNullIfNotNull("str")]
private static string? UrlEncode(string? str)
{
if (str == null)
return null;
byte[] bytes = Encoding.UTF8.GetBytes(str);
return Encoding.ASCII.GetString(UrlEncodeBytesToBytesInternal(bytes, 0, bytes.Length, false));
}
private static byte[] UrlEncodeBytesToBytesInternal(byte[] bytes, int offset, int count, bool alwaysCreateReturnValue)
{
int cSpaces = 0;
int cUnsafe = 0;
// Count them first.
for (int i = 0; i < count; i++)
{
char ch = (char)bytes[offset + i];
if (ch == ' ')
{
cSpaces++;
}
else if (!IsSafe(ch))
{
cUnsafe++;
}
}
// If nothing to expand.
if (!alwaysCreateReturnValue && cSpaces == 0 && cUnsafe == 0)
return bytes;
// Expand not 'safe' characters into %XX, spaces to +.
byte[] expandedBytes = new byte[count + cUnsafe * 2];
int pos = 0;
for (int i = 0; i < count; i++)
{
byte b = bytes[offset + i];
char ch = (char)b;
if (IsSafe(ch))
{
expandedBytes[pos++] = b;
}
else if (ch == ' ')
{
expandedBytes[pos++] = (byte)'+';
}
else
{
expandedBytes[pos++] = (byte)'%';
expandedBytes[pos++] = (byte)HexConverter.ToCharLower(b >> 4);
expandedBytes[pos++] = (byte)HexConverter.ToCharLower(b);
}
}
return expandedBytes;
}
private static bool IsSafe(char ch)
{
if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch >= '0' && ch <= '9')
{
return true;
}
switch (ch)
{
case '-':
case '_':
case '.':
case '!':
case '*':
case '\'':
case '(':
case ')':
return true;
}
return false;
}
private void InvokeOperationCompleted(AsyncOperation asyncOp, SendOrPostCallback callback, AsyncCompletedEventArgs eventArgs)
{
if (Interlocked.CompareExchange(ref _asyncOp, null, asyncOp) == asyncOp)
{
EndOperation();
asyncOp.PostOperationCompleted(callback, eventArgs);
}
}
public void OpenReadAsync(Uri address) =>
OpenReadAsync(address, null);
public void OpenReadAsync(Uri address!!, object? userToken)
{
AsyncOperation asyncOp = StartAsyncOperation(userToken);
try
{
WebRequest request = _webRequest = GetWebRequest(GetUri(address));
request.BeginGetResponse(iar =>
{
Stream? stream = null;
Exception? exception = null;
try
{
WebResponse response = _webResponse = GetWebResponse(request, iar);
stream = response.GetResponseStream();
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
exception = GetExceptionToPropagate(e);
}
InvokeOperationCompleted(asyncOp, _openReadOperationCompleted!, new OpenReadCompletedEventArgs(stream, exception, _canceled, asyncOp.UserSuppliedState));
}, null);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
InvokeOperationCompleted(asyncOp, _openReadOperationCompleted!,
new OpenReadCompletedEventArgs(null, GetExceptionToPropagate(e), _canceled, asyncOp.UserSuppliedState));
}
}
public void OpenWriteAsync(Uri address) =>
OpenWriteAsync(address, null, null);
public void OpenWriteAsync(Uri address, string? method) =>
OpenWriteAsync(address, method, null);
public void OpenWriteAsync(Uri address!!, string? method, object? userToken)
{
method ??= MapToDefaultMethod(address);
AsyncOperation asyncOp = StartAsyncOperation(userToken);
try
{
_method = method;
WebRequest request = _webRequest = GetWebRequest(GetUri(address));
request.BeginGetRequestStream(iar =>
{
WebClientWriteStream? stream = null;
Exception? exception = null;
try
{
stream = new WebClientWriteStream(request.EndGetRequestStream(iar), request, this);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
exception = GetExceptionToPropagate(e);
}
InvokeOperationCompleted(asyncOp, _openWriteOperationCompleted!, new OpenWriteCompletedEventArgs(stream, exception, _canceled, asyncOp.UserSuppliedState));
}, null);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
var eventArgs = new OpenWriteCompletedEventArgs(null, GetExceptionToPropagate(e), _canceled, asyncOp.UserSuppliedState);
InvokeOperationCompleted(asyncOp, _openWriteOperationCompleted!, eventArgs);
}
}
private void DownloadStringAsyncCallback(byte[]? returnBytes, Exception? exception, object state)
{
AsyncOperation asyncOp = (AsyncOperation)state;
string? stringData = null;
try
{
if (returnBytes != null)
{
stringData = GetStringUsingEncoding(_webRequest!, returnBytes);
}
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
exception = GetExceptionToPropagate(e);
}
var eventArgs = new DownloadStringCompletedEventArgs(stringData, exception, _canceled, asyncOp.UserSuppliedState);
InvokeOperationCompleted(asyncOp, _downloadStringOperationCompleted!, eventArgs);
}
public void DownloadStringAsync(Uri address) =>
DownloadStringAsync(address, null);
public void DownloadStringAsync(Uri address!!, object? userToken)
{
AsyncOperation asyncOp = StartAsyncOperation(userToken);
try
{
WebRequest request = _webRequest = GetWebRequest(GetUri(address));
DownloadBitsAsync(request, new ChunkedMemoryStream(), asyncOp, DownloadStringAsyncCallback);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
DownloadStringAsyncCallback(null, GetExceptionToPropagate(e), asyncOp);
}
}
private void DownloadDataAsyncCallback(byte[]? returnBytes, Exception? exception, object state)
{
AsyncOperation asyncOp = (AsyncOperation)state;
DownloadDataCompletedEventArgs eventArgs = new DownloadDataCompletedEventArgs(returnBytes, exception, _canceled, asyncOp.UserSuppliedState!);
InvokeOperationCompleted(asyncOp, _downloadDataOperationCompleted!, eventArgs);
}
public void DownloadDataAsync(Uri address) =>
DownloadDataAsync(address, null);
public void DownloadDataAsync(Uri address!!, object? userToken)
{
AsyncOperation asyncOp = StartAsyncOperation(userToken);
try
{
WebRequest request = _webRequest = GetWebRequest(GetUri(address));
DownloadBitsAsync(request, new ChunkedMemoryStream(), asyncOp, DownloadDataAsyncCallback);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
DownloadDataAsyncCallback(null, GetExceptionToPropagate(e), asyncOp);
}
}
private void DownloadFileAsyncCallback(byte[]? returnBytes, Exception? exception, object state)
{
AsyncOperation asyncOp = (AsyncOperation)state;
AsyncCompletedEventArgs eventArgs = new AsyncCompletedEventArgs(exception, _canceled, asyncOp.UserSuppliedState);
InvokeOperationCompleted(asyncOp, _downloadFileOperationCompleted!, eventArgs);
}
public void DownloadFileAsync(Uri address, string fileName) =>
DownloadFileAsync(address, fileName, null);
public void DownloadFileAsync(Uri address!!, string fileName!!, object? userToken)
{
FileStream? fs = null;
AsyncOperation asyncOp = StartAsyncOperation(userToken);
try
{
fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);
WebRequest request = _webRequest = GetWebRequest(GetUri(address));
DownloadBitsAsync(request, fs, asyncOp, DownloadFileAsyncCallback);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
fs?.Close();
DownloadFileAsyncCallback(null, GetExceptionToPropagate(e), asyncOp);
}
}
public void UploadStringAsync(Uri address, string data) =>
UploadStringAsync(address, null, data, null);
public void UploadStringAsync(Uri address, string? method, string data) =>
UploadStringAsync(address, method, data, null);
public void UploadStringAsync(Uri address!!, string? method, string data!!, object? userToken)
{
method ??= MapToDefaultMethod(address);
AsyncOperation asyncOp = StartAsyncOperation(userToken);
try
{
byte[] requestData = Encoding.GetBytes(data);
_method = method;
_contentLength = requestData.Length;
WebRequest request = _webRequest = GetWebRequest(GetUri(address));
UploadBitsAsync(
request, null, requestData, 0, null, null, asyncOp,
(bytesResult, error, uploadAsyncOp) =>
{
string? stringResult = null;
if (error == null && bytesResult != null)
{
try
{
stringResult = GetStringUsingEncoding(_webRequest, bytesResult);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
error = GetExceptionToPropagate(e);
}
}
InvokeOperationCompleted(uploadAsyncOp, _uploadStringOperationCompleted!,
new UploadStringCompletedEventArgs(stringResult, error, _canceled, uploadAsyncOp.UserSuppliedState));
});
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
var eventArgs = new UploadStringCompletedEventArgs(null, GetExceptionToPropagate(e), _canceled, asyncOp.UserSuppliedState);
InvokeOperationCompleted(asyncOp, _uploadStringOperationCompleted!, eventArgs);
}
}
public void UploadDataAsync(Uri address, byte[] data) =>
UploadDataAsync(address, null, data, null);
public void UploadDataAsync(Uri address, string? method, byte[] data) =>
UploadDataAsync(address, method, data, null);
public void UploadDataAsync(Uri address!!, string? method, byte[] data!!, object? userToken)
{
method ??= MapToDefaultMethod(address);
AsyncOperation asyncOp = StartAsyncOperation(userToken);
try
{
_method = method;
_contentLength = data.Length;
WebRequest request = _webRequest = GetWebRequest(GetUri(address));
int chunkSize = 0;
if (UploadProgressChanged != null)
{
// If ProgressCallback is requested, we should send the buffer in chunks
chunkSize = (int)Math.Min((long)DefaultCopyBufferLength, data.Length);
}
UploadBitsAsync(
request, null, data, chunkSize, null, null, asyncOp,
(result, error, uploadAsyncOp) =>
InvokeOperationCompleted(asyncOp, _uploadDataOperationCompleted!, new UploadDataCompletedEventArgs(result, error, _canceled, uploadAsyncOp.UserSuppliedState)));
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
var eventArgs = new UploadDataCompletedEventArgs(null, GetExceptionToPropagate(e), _canceled, asyncOp.UserSuppliedState);
InvokeOperationCompleted(asyncOp, _uploadDataOperationCompleted!, eventArgs);
}
}
public void UploadFileAsync(Uri address, string fileName) =>
UploadFileAsync(address, null, fileName, null);
public void UploadFileAsync(Uri address, string? method, string fileName) =>
UploadFileAsync(address, method, fileName, null);
public void UploadFileAsync(Uri address!!, string? method, string fileName!!, object? userToken)
{
method ??= MapToDefaultMethod(address);
FileStream? fs = null;
AsyncOperation asyncOp = StartAsyncOperation(userToken);
try
{
_method = method;
byte[]? formHeaderBytes = null, boundaryBytes = null, buffer = null;
Uri uri = GetUri(address);
bool needsHeaderAndBoundary = (uri.Scheme != Uri.UriSchemeFile);
OpenFileInternal(needsHeaderAndBoundary, fileName, out fs, out buffer, ref formHeaderBytes, ref boundaryBytes);
WebRequest request = _webRequest = GetWebRequest(uri);
UploadBitsAsync(
request, fs, buffer, 0, formHeaderBytes, boundaryBytes, asyncOp,
(result, error, uploadAsyncOp) =>
InvokeOperationCompleted(asyncOp, _uploadFileOperationCompleted!, new UploadFileCompletedEventArgs(result, error, _canceled, uploadAsyncOp.UserSuppliedState)));
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
fs?.Close();
var eventArgs = new UploadFileCompletedEventArgs(null, GetExceptionToPropagate(e), _canceled, asyncOp.UserSuppliedState);
InvokeOperationCompleted(asyncOp, _uploadFileOperationCompleted!, eventArgs);
}
}
public void UploadValuesAsync(Uri address, NameValueCollection data) =>
UploadValuesAsync(address, null, data, null);
public void UploadValuesAsync(Uri address, string? method, NameValueCollection data) =>
UploadValuesAsync(address, method, data, null);
public void UploadValuesAsync(Uri address!!, string? method, NameValueCollection data!!, object? userToken)
{
method ??= MapToDefaultMethod(address);
AsyncOperation asyncOp = StartAsyncOperation(userToken);
try
{
byte[] buffer = GetValuesToUpload(data);
_method = method;
WebRequest request = _webRequest = GetWebRequest(GetUri(address));
int chunkSize = 0;
if (UploadProgressChanged != null)
{
// If ProgressCallback is requested, we should send the buffer in chunks
chunkSize = (int)Math.Min((long)DefaultCopyBufferLength, buffer.Length);
}
UploadBitsAsync(
request, null, buffer, chunkSize, null, null, asyncOp,
(result, error, uploadAsyncOp) =>
InvokeOperationCompleted(asyncOp, _uploadValuesOperationCompleted!, new UploadValuesCompletedEventArgs(result, error, _canceled, uploadAsyncOp.UserSuppliedState)));
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
var eventArgs = new UploadValuesCompletedEventArgs(null, GetExceptionToPropagate(e), _canceled, asyncOp.UserSuppliedState!);
InvokeOperationCompleted(asyncOp, _uploadValuesOperationCompleted!, eventArgs);
}
}
private static Exception GetExceptionToPropagate(Exception e) =>
e is WebException || e is SecurityException ? e : new WebException(SR.net_webclient, e);
public void CancelAsync()
{
WebRequest? request = _webRequest;
_canceled = true;
AbortRequest(request);
}
public Task<string> DownloadStringTaskAsync(string address) =>
DownloadStringTaskAsync(GetUri(address));
public Task<string> DownloadStringTaskAsync(Uri address)
{
// Create the task to be returned
var tcs = new TaskCompletionSource<string>(address);
DownloadStringCompletedEventHandler? handler = null;
handler = (sender, e) => HandleCompletion(tcs, e, (args) => args.Result, handler, (webClient, completion) => webClient.DownloadStringCompleted -= completion);
DownloadStringCompleted += handler;
// Start the async operation.
try { DownloadStringAsync(address, tcs); }
catch
{
DownloadStringCompleted -= handler;
throw;
}
// Return the task that represents the async operation
return tcs.Task;
}
public Task<Stream> OpenReadTaskAsync(string address) =>
OpenReadTaskAsync(GetUri(address));
public Task<Stream> OpenReadTaskAsync(Uri address)
{
// Create the task to be returned
var tcs = new TaskCompletionSource<Stream>(address);
// Setup the callback event handler
OpenReadCompletedEventHandler? handler = null;
handler = (sender, e) => HandleCompletion(tcs, e, (args) => args.Result, handler, (webClient, completion) => webClient.OpenReadCompleted -= completion);
OpenReadCompleted += handler;
// Start the async operation.
try { OpenReadAsync(address, tcs); }
catch
{
OpenReadCompleted -= handler;
throw;
}
// Return the task that represents the async operation
return tcs.Task;
}
public Task<Stream> OpenWriteTaskAsync(string address) =>
OpenWriteTaskAsync(GetUri(address), null);
public Task<Stream> OpenWriteTaskAsync(Uri address) =>
OpenWriteTaskAsync(address, null);
public Task<Stream> OpenWriteTaskAsync(string address, string? method) =>
OpenWriteTaskAsync(GetUri(address), method);
public Task<Stream> OpenWriteTaskAsync(Uri address, string? method)
{
// Create the task to be returned
var tcs = new TaskCompletionSource<Stream>(address);
// Setup the callback event handler
OpenWriteCompletedEventHandler? handler = null;
handler = (sender, e) => HandleCompletion(tcs, e, (args) => args.Result, handler, (webClient, completion) => webClient.OpenWriteCompleted -= completion);
OpenWriteCompleted += handler;
// Start the async operation.
try { OpenWriteAsync(address, method, tcs); }
catch
{
OpenWriteCompleted -= handler;
throw;
}
// Return the task that represents the async operation
return tcs.Task;
}
public Task<string> UploadStringTaskAsync(string address, string data) =>
UploadStringTaskAsync(address, null, data);
public Task<string> UploadStringTaskAsync(Uri address, string data) =>
UploadStringTaskAsync(address, null, data);
public Task<string> UploadStringTaskAsync(string address, string? method, string data) =>
UploadStringTaskAsync(GetUri(address), method, data);
public Task<string> UploadStringTaskAsync(Uri address, string? method, string data)
{
// Create the task to be returned
var tcs = new TaskCompletionSource<string>(address);
// Setup the callback event handler
UploadStringCompletedEventHandler? handler = null;
handler = (sender, e) => HandleCompletion(tcs, e, (args) => args.Result, handler, (webClient, completion) => webClient.UploadStringCompleted -= completion);
UploadStringCompleted += handler;
// Start the async operation.
try { UploadStringAsync(address, method, data, tcs); }
catch
{
UploadStringCompleted -= handler;
throw;
}
// Return the task that represents the async operation
return tcs.Task;
}
public Task<byte[]> DownloadDataTaskAsync(string address) =>
DownloadDataTaskAsync(GetUri(address));
public Task<byte[]> DownloadDataTaskAsync(Uri address)
{
// Create the task to be returned
var tcs = new TaskCompletionSource<byte[]>(address);
// Setup the callback event handler
DownloadDataCompletedEventHandler? handler = null;
handler = (sender, e) => HandleCompletion(tcs, e, (args) => args.Result, handler, (webClient, completion) => webClient.DownloadDataCompleted -= completion);
DownloadDataCompleted += handler;
// Start the async operation.
try { DownloadDataAsync(address, tcs); }
catch
{
DownloadDataCompleted -= handler;
throw;
}
// Return the task that represents the async operation
return tcs.Task;
}
public Task DownloadFileTaskAsync(string address, string fileName) =>
DownloadFileTaskAsync(GetUri(address), fileName);
public Task DownloadFileTaskAsync(Uri address, string fileName)
{
// Create the task to be returned
var tcs = new TaskCompletionSource<object?>(address);
// Setup the callback event handler
AsyncCompletedEventHandler? handler = null;
handler = (sender, e) => HandleCompletion(tcs, e, (args) => null, handler, (webClient, completion) => webClient.DownloadFileCompleted -= completion);
DownloadFileCompleted += handler;
// Start the async operation.
try { DownloadFileAsync(address, fileName, tcs); }
catch
{
DownloadFileCompleted -= handler;
throw;
}
// Return the task that represents the async operation
return tcs.Task;
}
public Task<byte[]> UploadDataTaskAsync(string address, byte[] data) =>
UploadDataTaskAsync(GetUri(address), null, data);
public Task<byte[]> UploadDataTaskAsync(Uri address, byte[] data) =>
UploadDataTaskAsync(address, null, data);
public Task<byte[]> UploadDataTaskAsync(string address, string? method, byte[] data) =>
UploadDataTaskAsync(GetUri(address), method, data);
public Task<byte[]> UploadDataTaskAsync(Uri address, string? method, byte[] data)
{
// Create the task to be returned
var tcs = new TaskCompletionSource<byte[]>(address);
// Setup the callback event handler
UploadDataCompletedEventHandler? handler = null;
handler = (sender, e) => HandleCompletion(tcs, e, (args) => args.Result, handler, (webClient, completion) => webClient.UploadDataCompleted -= completion);
UploadDataCompleted += handler;
// Start the async operation.
try { UploadDataAsync(address, method, data, tcs); }
catch
{
UploadDataCompleted -= handler;
throw;
}
// Return the task that represents the async operation
return tcs.Task;
}
public Task<byte[]> UploadFileTaskAsync(string address, string fileName) =>
UploadFileTaskAsync(GetUri(address), null, fileName);
public Task<byte[]> UploadFileTaskAsync(Uri address, string fileName) =>
UploadFileTaskAsync(address, null, fileName);
public Task<byte[]> UploadFileTaskAsync(string address, string? method, string fileName) =>
UploadFileTaskAsync(GetUri(address), method, fileName);
public Task<byte[]> UploadFileTaskAsync(Uri address, string? method, string fileName)
{
// Create the task to be returned
var tcs = new TaskCompletionSource<byte[]>(address);
// Setup the callback event handler
UploadFileCompletedEventHandler? handler = null;
handler = (sender, e) => HandleCompletion(tcs, e, (args) => args.Result, handler, (webClient, completion) => webClient.UploadFileCompleted -= completion);
UploadFileCompleted += handler;
// Start the async operation.
try { UploadFileAsync(address, method, fileName, tcs); }
catch
{
UploadFileCompleted -= handler;
throw;
}
// Return the task that represents the async operation
return tcs.Task;
}
public Task<byte[]> UploadValuesTaskAsync(string address, NameValueCollection data) =>
UploadValuesTaskAsync(GetUri(address), null, data);
public Task<byte[]> UploadValuesTaskAsync(string address, string? method, NameValueCollection data) =>
UploadValuesTaskAsync(GetUri(address), method, data);
public Task<byte[]> UploadValuesTaskAsync(Uri address, NameValueCollection data) =>
UploadValuesTaskAsync(address, null, data);
public Task<byte[]> UploadValuesTaskAsync(Uri address, string? method, NameValueCollection data)
{
// Create the task to be returned
var tcs = new TaskCompletionSource<byte[]>(address);
// Setup the callback event handler
UploadValuesCompletedEventHandler? handler = null;
handler = (sender, e) => HandleCompletion(tcs, e, (args) => args.Result, handler, (webClient, completion) => webClient.UploadValuesCompleted -= completion);
UploadValuesCompleted += handler;
// Start the async operation.
try { UploadValuesAsync(address, method, data, tcs); }
catch
{
UploadValuesCompleted -= handler;
throw;
}
// Return the task that represents the async operation
return tcs.Task;
}
private void HandleCompletion<TAsyncCompletedEventArgs, TCompletionDelegate, T>(TaskCompletionSource<T> tcs, TAsyncCompletedEventArgs e, Func<TAsyncCompletedEventArgs, T> getResult, TCompletionDelegate handler, Action<WebClient, TCompletionDelegate> unregisterHandler)
where TAsyncCompletedEventArgs : AsyncCompletedEventArgs
{
if (e.UserState == tcs)
{
try { unregisterHandler(this, handler); }
finally
{
if (e.Error != null) tcs.TrySetException(e.Error);
else if (e.Cancelled) tcs.TrySetCanceled();
else tcs.TrySetResult(getResult(e));
}
}
}
private void PostProgressChanged(AsyncOperation asyncOp, ProgressData progress)
{
if (asyncOp != null && (progress.BytesSent > 0 || progress.BytesReceived > 0))
{
int progressPercentage;
if (progress.HasUploadPhase)
{
if (UploadProgressChanged != null)
{
progressPercentage = progress.TotalBytesToReceive < 0 && progress.BytesReceived == 0 ?
progress.TotalBytesToSend < 0 ? 0 : progress.TotalBytesToSend == 0 ? 50 : (int)((50 * progress.BytesSent) / progress.TotalBytesToSend) :
progress.TotalBytesToSend < 0 ? 50 : progress.TotalBytesToReceive == 0 ? 100 : (int)((50 * progress.BytesReceived) / progress.TotalBytesToReceive + 50);
asyncOp.Post(_reportUploadProgressChanged!, new UploadProgressChangedEventArgs(progressPercentage, asyncOp.UserSuppliedState!, progress.BytesSent, progress.TotalBytesToSend, progress.BytesReceived, progress.TotalBytesToReceive));
}
}
else if (DownloadProgressChanged != null)
{
progressPercentage = progress.TotalBytesToReceive < 0 ? 0 : progress.TotalBytesToReceive == 0 ? 100 : (int)((100 * progress.BytesReceived) / progress.TotalBytesToReceive);
asyncOp.Post(_reportDownloadProgressChanged!, new DownloadProgressChangedEventArgs(progressPercentage, asyncOp.UserSuppliedState!, progress.BytesReceived, progress.TotalBytesToReceive));
}
}
}
#region Supporting Types
private sealed class ProgressData
{
internal long BytesSent;
internal long TotalBytesToSend = -1;
internal long BytesReceived;
internal long TotalBytesToReceive = -1;
internal bool HasUploadPhase;
internal void Reset()
{
BytesSent = 0;
TotalBytesToSend = -1;
BytesReceived = 0;
TotalBytesToReceive = -1;
HasUploadPhase = false;
}
}
private sealed class WebClientWriteStream : DelegatingStream
{
private readonly WebRequest _request;
private readonly WebClient _webClient;
public WebClientWriteStream(Stream stream, WebRequest request, WebClient webClient) : base(stream)
{
_request = request;
_webClient = webClient;
}
protected override void Dispose(bool disposing)
{
try
{
if (disposing)
{
_webClient.GetWebResponse(_request).Dispose();
}
}
finally
{
base.Dispose(disposing);
}
}
}
#endregion
#region Obsolete designer support
//introduced to support design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public bool AllowReadStreamBuffering { get; set; }
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public bool AllowWriteStreamBuffering { get; set; }
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public event WriteStreamClosedEventHandler? WriteStreamClosed { add { } remove { } }
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void OnWriteStreamClosed(WriteStreamClosedEventArgs e) { }
#endregion
}
#region Delegates and supporting *CompletedEventArgs classes used by event-based async code
public delegate void OpenReadCompletedEventHandler(object sender, OpenReadCompletedEventArgs e);
public delegate void OpenWriteCompletedEventHandler(object sender, OpenWriteCompletedEventArgs e);
public delegate void DownloadStringCompletedEventHandler(object sender, DownloadStringCompletedEventArgs e);
public delegate void DownloadDataCompletedEventHandler(object sender, DownloadDataCompletedEventArgs e);
public delegate void UploadStringCompletedEventHandler(object sender, UploadStringCompletedEventArgs e);
public delegate void UploadDataCompletedEventHandler(object sender, UploadDataCompletedEventArgs e);
public delegate void UploadFileCompletedEventHandler(object sender, UploadFileCompletedEventArgs e);
public delegate void UploadValuesCompletedEventHandler(object sender, UploadValuesCompletedEventArgs e);
public delegate void DownloadProgressChangedEventHandler(object sender, DownloadProgressChangedEventArgs e);
public delegate void UploadProgressChangedEventHandler(object sender, UploadProgressChangedEventArgs e);
[EditorBrowsable(EditorBrowsableState.Never)]
public delegate void WriteStreamClosedEventHandler(object sender, WriteStreamClosedEventArgs e);
public class OpenReadCompletedEventArgs : AsyncCompletedEventArgs
{
private readonly Stream? _result;
internal OpenReadCompletedEventArgs(Stream? result, Exception? exception, bool cancelled, object? userToken) : base(exception, cancelled, userToken)
{
_result = result;
}
public Stream Result
{
get
{
RaiseExceptionIfNecessary();
return _result!;
}
}
}
public class OpenWriteCompletedEventArgs : AsyncCompletedEventArgs
{
private readonly Stream? _result;
internal OpenWriteCompletedEventArgs(Stream? result, Exception? exception, bool cancelled, object? userToken) : base(exception, cancelled, userToken)
{
_result = result;
}
public Stream Result
{
get
{
RaiseExceptionIfNecessary();
return _result!;
}
}
}
public class DownloadStringCompletedEventArgs : AsyncCompletedEventArgs
{
private readonly string? _result;
internal DownloadStringCompletedEventArgs(string? result, Exception? exception, bool cancelled, object? userToken) : base(exception, cancelled, userToken)
{
_result = result;
}
public string Result
{
get
{
RaiseExceptionIfNecessary();
return _result!;
}
}
}
public class DownloadDataCompletedEventArgs : AsyncCompletedEventArgs
{
private readonly byte[]? _result;
internal DownloadDataCompletedEventArgs(byte[]? result, Exception? exception, bool cancelled, object? userToken) : base(exception, cancelled, userToken)
{
_result = result;
}
public byte[] Result
{
get
{
RaiseExceptionIfNecessary();
return _result!;
}
}
}
public class UploadStringCompletedEventArgs : AsyncCompletedEventArgs
{
private readonly string? _result;
internal UploadStringCompletedEventArgs(string? result, Exception? exception, bool cancelled, object? userToken) : base(exception, cancelled, userToken)
{
_result = result;
}
public string Result
{
get
{
RaiseExceptionIfNecessary();
return _result!;
}
}
}
public class UploadDataCompletedEventArgs : AsyncCompletedEventArgs
{
private readonly byte[]? _result;
internal UploadDataCompletedEventArgs(byte[]? result, Exception? exception, bool cancelled, object? userToken) : base(exception, cancelled, userToken)
{
_result = result;
}
public byte[] Result
{
get
{
RaiseExceptionIfNecessary();
return _result!;
}
}
}
public class UploadFileCompletedEventArgs : AsyncCompletedEventArgs
{
private readonly byte[]? _result;
internal UploadFileCompletedEventArgs(byte[]? result, Exception? exception, bool cancelled, object? userToken) : base(exception, cancelled, userToken)
{
_result = result;
}
public byte[] Result
{
get
{
RaiseExceptionIfNecessary();
return _result!;
}
}
}
public class UploadValuesCompletedEventArgs : AsyncCompletedEventArgs
{
private readonly byte[]? _result;
internal UploadValuesCompletedEventArgs(byte[]? result, Exception? exception, bool cancelled, object? userToken) : base(exception, cancelled, userToken)
{
_result = result;
}
public byte[] Result
{
get
{
RaiseExceptionIfNecessary();
return _result!;
}
}
}
public class DownloadProgressChangedEventArgs : ProgressChangedEventArgs
{
internal DownloadProgressChangedEventArgs(int progressPercentage, object? userToken, long bytesReceived, long totalBytesToReceive) :
base(progressPercentage, userToken)
{
BytesReceived = bytesReceived;
TotalBytesToReceive = totalBytesToReceive;
}
public long BytesReceived { get; }
public long TotalBytesToReceive { get; }
}
public class UploadProgressChangedEventArgs : ProgressChangedEventArgs
{
internal UploadProgressChangedEventArgs(int progressPercentage, object? userToken, long bytesSent, long totalBytesToSend, long bytesReceived, long totalBytesToReceive) :
base(progressPercentage, userToken)
{
BytesReceived = bytesReceived;
TotalBytesToReceive = totalBytesToReceive;
BytesSent = bytesSent;
TotalBytesToSend = totalBytesToSend;
}
public long BytesReceived { get; }
public long TotalBytesToReceive { get; }
public long BytesSent { get; }
public long TotalBytesToSend { get; }
}
[EditorBrowsable(EditorBrowsableState.Never)]
public class WriteStreamClosedEventArgs : EventArgs
{
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public WriteStreamClosedEventArgs() { }
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public Exception? Error { get { return null; } }
}
#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.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Net.Cache;
using System.Security;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace System.Net
{
public class WebClient : Component
{
private const int DefaultCopyBufferLength = 8192;
private const int DefaultDownloadBufferLength = 65536;
private const string DefaultUploadFileContentType = "application/octet-stream";
private const string UploadFileContentType = "multipart/form-data";
private const string UploadValuesContentType = "application/x-www-form-urlencoded";
private Uri? _baseAddress;
private ICredentials? _credentials;
private WebHeaderCollection? _headers;
private NameValueCollection? _requestParameters;
private WebResponse? _webResponse;
private WebRequest? _webRequest;
private Encoding _encoding = Encoding.Default;
private string? _method;
private long _contentLength = -1;
private bool _initWebClientAsync;
private bool _canceled;
private ProgressData? _progress;
private IWebProxy? _proxy;
private bool _proxySet;
private int _callNesting; // > 0 if we're in a Read/Write call
private AsyncOperation? _asyncOp;
private SendOrPostCallback? _downloadDataOperationCompleted;
private SendOrPostCallback? _openReadOperationCompleted;
private SendOrPostCallback? _openWriteOperationCompleted;
private SendOrPostCallback? _downloadStringOperationCompleted;
private SendOrPostCallback? _downloadFileOperationCompleted;
private SendOrPostCallback? _uploadStringOperationCompleted;
private SendOrPostCallback? _uploadDataOperationCompleted;
private SendOrPostCallback? _uploadFileOperationCompleted;
private SendOrPostCallback? _uploadValuesOperationCompleted;
private SendOrPostCallback? _reportDownloadProgressChanged;
private SendOrPostCallback? _reportUploadProgressChanged;
[Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public WebClient()
{
// We don't know if derived types need finalizing, but WebClient doesn't.
if (GetType() == typeof(WebClient))
{
GC.SuppressFinalize(this);
}
}
public event DownloadStringCompletedEventHandler? DownloadStringCompleted;
public event DownloadDataCompletedEventHandler? DownloadDataCompleted;
public event AsyncCompletedEventHandler? DownloadFileCompleted;
public event UploadStringCompletedEventHandler? UploadStringCompleted;
public event UploadDataCompletedEventHandler? UploadDataCompleted;
public event UploadFileCompletedEventHandler? UploadFileCompleted;
public event UploadValuesCompletedEventHandler? UploadValuesCompleted;
public event OpenReadCompletedEventHandler? OpenReadCompleted;
public event OpenWriteCompletedEventHandler? OpenWriteCompleted;
public event DownloadProgressChangedEventHandler? DownloadProgressChanged;
public event UploadProgressChangedEventHandler? UploadProgressChanged;
protected virtual void OnDownloadStringCompleted(DownloadStringCompletedEventArgs e) => DownloadStringCompleted?.Invoke(this, e);
protected virtual void OnDownloadDataCompleted(DownloadDataCompletedEventArgs e) => DownloadDataCompleted?.Invoke(this, e);
protected virtual void OnDownloadFileCompleted(AsyncCompletedEventArgs e) => DownloadFileCompleted?.Invoke(this, e);
protected virtual void OnDownloadProgressChanged(DownloadProgressChangedEventArgs e) => DownloadProgressChanged?.Invoke(this, e);
protected virtual void OnUploadStringCompleted(UploadStringCompletedEventArgs e) => UploadStringCompleted?.Invoke(this, e);
protected virtual void OnUploadDataCompleted(UploadDataCompletedEventArgs e) => UploadDataCompleted?.Invoke(this, e);
protected virtual void OnUploadFileCompleted(UploadFileCompletedEventArgs e) => UploadFileCompleted?.Invoke(this, e);
protected virtual void OnUploadValuesCompleted(UploadValuesCompletedEventArgs e) => UploadValuesCompleted?.Invoke(this, e);
protected virtual void OnUploadProgressChanged(UploadProgressChangedEventArgs e) => UploadProgressChanged?.Invoke(this, e);
protected virtual void OnOpenReadCompleted(OpenReadCompletedEventArgs e) => OpenReadCompleted?.Invoke(this, e);
protected virtual void OnOpenWriteCompleted(OpenWriteCompletedEventArgs e) => OpenWriteCompleted?.Invoke(this, e);
private void StartOperation()
{
if (Interlocked.Increment(ref _callNesting) > 1)
{
EndOperation();
throw new NotSupportedException(SR.net_webclient_no_concurrent_io_allowed);
}
_contentLength = -1;
_webResponse = null;
_webRequest = null;
_method = null;
_canceled = false;
_progress?.Reset();
}
private AsyncOperation StartAsyncOperation(object? userToken)
{
if (!_initWebClientAsync)
{
// Set up the async delegates
_openReadOperationCompleted = arg => OnOpenReadCompleted((OpenReadCompletedEventArgs)arg!);
_openWriteOperationCompleted = arg => OnOpenWriteCompleted((OpenWriteCompletedEventArgs)arg!);
_downloadStringOperationCompleted = arg => OnDownloadStringCompleted((DownloadStringCompletedEventArgs)arg!);
_downloadDataOperationCompleted = arg => OnDownloadDataCompleted((DownloadDataCompletedEventArgs)arg!);
_downloadFileOperationCompleted = arg => OnDownloadFileCompleted((AsyncCompletedEventArgs)arg!);
_uploadStringOperationCompleted = arg => OnUploadStringCompleted((UploadStringCompletedEventArgs)arg!);
_uploadDataOperationCompleted = arg => OnUploadDataCompleted((UploadDataCompletedEventArgs)arg!);
_uploadFileOperationCompleted = arg => OnUploadFileCompleted((UploadFileCompletedEventArgs)arg!);
_uploadValuesOperationCompleted = arg => OnUploadValuesCompleted((UploadValuesCompletedEventArgs)arg!);
_reportDownloadProgressChanged = arg => OnDownloadProgressChanged((DownloadProgressChangedEventArgs)arg!);
_reportUploadProgressChanged = arg => OnUploadProgressChanged((UploadProgressChangedEventArgs)arg!);
_progress = new ProgressData();
_initWebClientAsync = true;
}
AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(userToken);
StartOperation();
_asyncOp = asyncOp;
return asyncOp;
}
private void EndOperation() => Interlocked.Decrement(ref _callNesting);
public Encoding Encoding
{
get { return _encoding; }
set
{
ArgumentNullException.ThrowIfNull(value);
_encoding = value;
}
}
[AllowNull]
public string BaseAddress
{
get { return _baseAddress != null ? _baseAddress.ToString() : string.Empty; }
set
{
if (string.IsNullOrEmpty(value))
{
_baseAddress = null;
}
else
{
try
{
_baseAddress = new Uri(value);
}
catch (UriFormatException e)
{
throw new ArgumentException(SR.net_webclient_invalid_baseaddress, nameof(value), e);
}
}
}
}
public ICredentials? Credentials
{
get { return _credentials; }
set { _credentials = value; }
}
public bool UseDefaultCredentials
{
get { return _credentials == CredentialCache.DefaultCredentials; }
set { _credentials = value ? CredentialCache.DefaultCredentials : null; }
}
[AllowNull]
public WebHeaderCollection Headers
{
get { return _headers ??= new WebHeaderCollection(); }
set { _headers = value; }
}
[AllowNull]
public NameValueCollection QueryString
{
get { return _requestParameters ??= new NameValueCollection(); }
set { _requestParameters = value; }
}
public WebHeaderCollection? ResponseHeaders => _webResponse?.Headers;
public IWebProxy? Proxy
{
get { return _proxySet ? _proxy : WebRequest.DefaultWebProxy; }
set
{
_proxy = value;
_proxySet = true;
}
}
public RequestCachePolicy? CachePolicy { get; set; }
public bool IsBusy => Volatile.Read(ref _callNesting) > 0;
protected virtual WebRequest GetWebRequest(Uri address)
{
#pragma warning disable SYSLIB0014 // WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.
WebRequest request = WebRequest.Create(address);
#pragma warning restore SYSLIB0014
CopyHeadersTo(request);
if (Credentials != null)
{
request.Credentials = Credentials;
}
if (_method != null)
{
request.Method = _method;
}
if (_contentLength != -1)
{
request.ContentLength = _contentLength;
}
if (_proxySet)
{
request.Proxy = _proxy;
}
if (CachePolicy != null)
{
request.CachePolicy = CachePolicy;
}
return request;
}
protected virtual WebResponse GetWebResponse(WebRequest request)
{
WebResponse response = request.GetResponse();
_webResponse = response;
return response;
}
protected virtual WebResponse GetWebResponse(WebRequest request, IAsyncResult result)
{
WebResponse response = request.EndGetResponse(result);
_webResponse = response;
return response;
}
private async Task<WebResponse> GetWebResponseTaskAsync(WebRequest request)
{
// We would like to simply await request.GetResponseAsync(), but WebClient exposes
// a protected member GetWebResponse(WebRequest, IAsyncResult) that derived instances expect to
// be used to get the response, and it needs to be passed the IAsyncResult that was returned
// from WebRequest.BeginGetResponse.
var awaitable = new BeginEndAwaitableAdapter();
request.BeginGetResponse(BeginEndAwaitableAdapter.Callback, awaitable);
return GetWebResponse(request, await awaitable);
}
public byte[] DownloadData(string address) =>
DownloadData(GetUri(address));
public byte[] DownloadData(Uri address!!)
{
StartOperation();
try
{
WebRequest request;
return DownloadDataInternal(address, out request);
}
finally
{
EndOperation();
}
}
private byte[] DownloadDataInternal(Uri address, out WebRequest request)
{
WebRequest? tmpRequest = null;
byte[] result;
try
{
tmpRequest = _webRequest = GetWebRequest(GetUri(address));
result = DownloadBits(tmpRequest, new ChunkedMemoryStream())!;
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
AbortRequest(tmpRequest);
if (e is WebException || e is SecurityException) throw;
throw new WebException(SR.net_webclient, e);
}
request = tmpRequest;
return result;
}
public void DownloadFile(string address, string fileName) =>
DownloadFile(GetUri(address), fileName);
public void DownloadFile(Uri address!!, string fileName!!)
{
WebRequest? request = null;
FileStream? fs = null;
bool succeeded = false;
StartOperation();
try
{
fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);
request = _webRequest = GetWebRequest(GetUri(address));
DownloadBits(request, fs);
succeeded = true;
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
AbortRequest(request);
if (e is WebException || e is SecurityException) throw;
throw new WebException(SR.net_webclient, e);
}
finally
{
if (fs != null)
{
fs.Close();
if (!succeeded)
{
File.Delete(fileName);
}
}
EndOperation();
}
}
public Stream OpenRead(string address) =>
OpenRead(GetUri(address));
public Stream OpenRead(Uri address!!)
{
WebRequest? request = null;
StartOperation();
try
{
request = _webRequest = GetWebRequest(GetUri(address));
WebResponse response = _webResponse = GetWebResponse(request);
return response.GetResponseStream();
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
AbortRequest(request);
if (e is WebException || e is SecurityException) throw;
throw new WebException(SR.net_webclient, e);
}
finally
{
EndOperation();
}
}
public Stream OpenWrite(string address) =>
OpenWrite(GetUri(address), null);
public Stream OpenWrite(Uri address) =>
OpenWrite(address, null);
public Stream OpenWrite(string address, string? method) =>
OpenWrite(GetUri(address), method);
public Stream OpenWrite(Uri address!!, string? method)
{
method ??= MapToDefaultMethod(address);
WebRequest? request = null;
StartOperation();
try
{
_method = method;
request = _webRequest = GetWebRequest(GetUri(address));
return new WebClientWriteStream(
request.GetRequestStream(),
request,
this);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
AbortRequest(request);
if (e is WebException || e is SecurityException) throw;
throw new WebException(SR.net_webclient, e);
}
finally
{
EndOperation();
}
}
public byte[] UploadData(string address, byte[] data) =>
UploadData(GetUri(address), null, data);
public byte[] UploadData(Uri address, byte[] data) =>
UploadData(address, null, data);
public byte[] UploadData(string address, string? method, byte[] data) =>
UploadData(GetUri(address), method, data);
public byte[] UploadData(Uri address!!, string? method, byte[] data!!)
{
method ??= MapToDefaultMethod(address);
StartOperation();
try
{
WebRequest request;
return UploadDataInternal(address, method, data, out request);
}
finally
{
EndOperation();
}
}
private byte[] UploadDataInternal(Uri address, string method, byte[] data, out WebRequest request)
{
WebRequest? tmpRequest = null;
byte[] result;
try
{
_method = method;
_contentLength = data.Length;
tmpRequest = _webRequest = GetWebRequest(GetUri(address));
result = UploadBits(tmpRequest, null, data, 0, null, null);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
AbortRequest(tmpRequest);
if (e is WebException || e is SecurityException) throw;
throw new WebException(SR.net_webclient, e);
}
request = tmpRequest;
return result;
}
private void OpenFileInternal(
bool needsHeaderAndBoundary, string fileName,
out FileStream fs, out byte[] buffer, ref byte[]? formHeaderBytes, ref byte[]? boundaryBytes)
{
fileName = Path.GetFullPath(fileName);
WebHeaderCollection headers = Headers;
string? contentType = headers[HttpKnownHeaderNames.ContentType];
if (contentType == null)
{
contentType = DefaultUploadFileContentType;
}
else if (contentType.StartsWith("multipart/", StringComparison.OrdinalIgnoreCase))
{
throw new WebException(SR.net_webclient_Multipart);
}
fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
int buffSize = DefaultCopyBufferLength;
_contentLength = -1;
if (string.Equals(_method, "POST", StringComparison.Ordinal))
{
if (needsHeaderAndBoundary)
{
string boundary = $"---------------------{DateTime.Now.Ticks:x}";
headers[HttpKnownHeaderNames.ContentType] = UploadFileContentType + "; boundary=" + boundary;
string formHeader =
"--" + boundary + "\r\n" +
"Content-Disposition: form-data; name=\"file\"; filename=\"" + Path.GetFileName(fileName) + "\"\r\n" + // TODO: Should the filename path be encoded?
"Content-Type: " + contentType + "\r\n" +
"\r\n";
formHeaderBytes = Encoding.UTF8.GetBytes(formHeader);
boundaryBytes = Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
}
else
{
formHeaderBytes = Array.Empty<byte>();
boundaryBytes = Array.Empty<byte>();
}
if (fs.CanSeek)
{
_contentLength = fs.Length + formHeaderBytes.Length + boundaryBytes.Length;
buffSize = (int)Math.Min(DefaultCopyBufferLength, fs.Length);
}
}
else
{
headers[HttpKnownHeaderNames.ContentType] = contentType;
formHeaderBytes = null;
boundaryBytes = null;
if (fs.CanSeek)
{
_contentLength = fs.Length;
buffSize = (int)Math.Min(DefaultCopyBufferLength, fs.Length);
}
}
buffer = new byte[buffSize];
}
public byte[] UploadFile(string address, string fileName) =>
UploadFile(GetUri(address), fileName);
public byte[] UploadFile(Uri address, string fileName) =>
UploadFile(address, null, fileName);
public byte[] UploadFile(string address, string? method, string fileName) =>
UploadFile(GetUri(address), method, fileName);
public byte[] UploadFile(Uri address!!, string? method, string fileName!!)
{
method ??= MapToDefaultMethod(address);
FileStream? fs = null;
WebRequest? request = null;
StartOperation();
try
{
_method = method;
byte[]? formHeaderBytes = null, boundaryBytes = null, buffer;
Uri uri = GetUri(address);
bool needsHeaderAndBoundary = (uri.Scheme != Uri.UriSchemeFile);
OpenFileInternal(needsHeaderAndBoundary, fileName, out fs, out buffer, ref formHeaderBytes, ref boundaryBytes);
request = _webRequest = GetWebRequest(uri);
return UploadBits(request, fs, buffer, 0, formHeaderBytes, boundaryBytes);
}
catch (Exception e)
{
fs?.Close();
if (e is OutOfMemoryException) throw;
AbortRequest(request);
if (e is WebException || e is SecurityException) throw;
throw new WebException(SR.net_webclient, e);
}
finally
{
EndOperation();
}
}
private byte[] GetValuesToUpload(NameValueCollection data)
{
WebHeaderCollection headers = Headers;
string? contentType = headers[HttpKnownHeaderNames.ContentType];
if (contentType != null && !string.Equals(contentType, UploadValuesContentType, StringComparison.OrdinalIgnoreCase))
{
throw new WebException(SR.net_webclient_ContentType);
}
headers[HttpKnownHeaderNames.ContentType] = UploadValuesContentType;
string delimiter = string.Empty;
var values = new StringBuilder();
foreach (string? name in data.AllKeys)
{
values.Append(delimiter);
values.Append(UrlEncode(name));
values.Append('=');
values.Append(UrlEncode(data[name]));
delimiter = "&";
}
byte[] buffer = Encoding.ASCII.GetBytes(values.ToString());
_contentLength = buffer.Length;
return buffer;
}
public byte[] UploadValues(string address, NameValueCollection data) =>
UploadValues(GetUri(address), null, data);
public byte[] UploadValues(Uri address, NameValueCollection data) =>
UploadValues(address, null, data);
public byte[] UploadValues(string address, string? method, NameValueCollection data) =>
UploadValues(GetUri(address), method, data);
public byte[] UploadValues(Uri address!!, string? method, NameValueCollection data!!)
{
method ??= MapToDefaultMethod(address);
WebRequest? request = null;
StartOperation();
try
{
byte[] buffer = GetValuesToUpload(data);
_method = method;
request = _webRequest = GetWebRequest(GetUri(address));
return UploadBits(request, null, buffer, 0, null, null);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
AbortRequest(request);
if (e is WebException || e is SecurityException) throw;
throw new WebException(SR.net_webclient, e);
}
finally
{
EndOperation();
}
}
public string UploadString(string address, string data) =>
UploadString(GetUri(address), null, data);
public string UploadString(Uri address, string data) =>
UploadString(address, null, data);
public string UploadString(string address, string? method, string data) =>
UploadString(GetUri(address), method, data);
public string UploadString(Uri address!!, string? method, string data!!)
{
method ??= MapToDefaultMethod(address);
StartOperation();
try
{
WebRequest request;
byte[] requestData = Encoding.GetBytes(data);
byte[] responseData = UploadDataInternal(address, method, requestData, out request);
return GetStringUsingEncoding(request, responseData);
}
finally
{
EndOperation();
}
}
public string DownloadString(string address) =>
DownloadString(GetUri(address));
public string DownloadString(Uri address!!)
{
StartOperation();
try
{
WebRequest request;
byte[] data = DownloadDataInternal(address, out request);
return GetStringUsingEncoding(request, data);
}
finally
{
EndOperation();
}
}
private static void AbortRequest(WebRequest? request)
{
try { request?.Abort(); }
catch (Exception exception) when (!(exception is OutOfMemoryException)) { }
}
private void CopyHeadersTo(WebRequest request)
{
if (_headers == null)
{
return;
}
var hwr = request as HttpWebRequest;
if (hwr == null)
{
return;
}
string? accept = _headers[HttpKnownHeaderNames.Accept];
string? connection = _headers[HttpKnownHeaderNames.Connection];
string? contentType = _headers[HttpKnownHeaderNames.ContentType];
string? expect = _headers[HttpKnownHeaderNames.Expect];
string? referrer = _headers[HttpKnownHeaderNames.Referer];
string? userAgent = _headers[HttpKnownHeaderNames.UserAgent];
string? host = _headers[HttpKnownHeaderNames.Host];
_headers.Remove(HttpKnownHeaderNames.Accept);
_headers.Remove(HttpKnownHeaderNames.Connection);
_headers.Remove(HttpKnownHeaderNames.ContentType);
_headers.Remove(HttpKnownHeaderNames.Expect);
_headers.Remove(HttpKnownHeaderNames.Referer);
_headers.Remove(HttpKnownHeaderNames.UserAgent);
_headers.Remove(HttpKnownHeaderNames.Host);
request.Headers = _headers;
if (!string.IsNullOrEmpty(accept))
{
hwr.Accept = accept;
}
if (!string.IsNullOrEmpty(connection))
{
hwr.Connection = connection;
}
if (!string.IsNullOrEmpty(contentType))
{
hwr.ContentType = contentType;
}
if (!string.IsNullOrEmpty(expect))
{
hwr.Expect = expect;
}
if (!string.IsNullOrEmpty(referrer))
{
hwr.Referer = referrer;
}
if (!string.IsNullOrEmpty(userAgent))
{
hwr.UserAgent = userAgent;
}
if (!string.IsNullOrEmpty(host))
{
hwr.Host = host;
}
}
private Uri GetUri(string address!!)
{
Uri? uri;
if (_baseAddress != null)
{
if (!Uri.TryCreate(_baseAddress, address, out uri))
{
return new Uri(Path.GetFullPath(address));
}
}
else if (!Uri.TryCreate(address, UriKind.Absolute, out uri))
{
return new Uri(Path.GetFullPath(address));
}
return GetUri(uri);
}
private Uri GetUri(Uri address!!)
{
Uri? uri = address;
if (!address.IsAbsoluteUri && _baseAddress != null && !Uri.TryCreate(_baseAddress, address, out uri))
{
return address;
}
if (string.IsNullOrEmpty(uri.Query) && _requestParameters != null)
{
var sb = new StringBuilder();
string delimiter = string.Empty;
for (int i = 0; i < _requestParameters.Count; ++i)
{
sb.Append(delimiter).Append(_requestParameters.AllKeys[i]).Append('=').Append(_requestParameters[i]);
delimiter = "&";
}
uri = new UriBuilder(uri) { Query = sb.ToString() }.Uri;
}
return uri;
}
private byte[]? DownloadBits(WebRequest request, Stream writeStream)
{
try
{
WebResponse response = _webResponse = GetWebResponse(request);
long contentLength = response.ContentLength;
byte[] copyBuffer = new byte[contentLength == -1 || contentLength > DefaultDownloadBufferLength ? DefaultDownloadBufferLength : contentLength];
if (writeStream is ChunkedMemoryStream)
{
if (contentLength > int.MaxValue)
{
throw new WebException(SR.net_webstatus_MessageLengthLimitExceeded, WebExceptionStatus.MessageLengthLimitExceeded);
}
writeStream.SetLength(copyBuffer.Length);
}
using (Stream readStream = response.GetResponseStream())
{
if (readStream != null)
{
int bytesRead;
while ((bytesRead = readStream.Read(copyBuffer, 0, copyBuffer.Length)) != 0)
{
writeStream.Write(copyBuffer, 0, bytesRead);
}
}
}
return (writeStream as ChunkedMemoryStream)?.ToArray();
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
writeStream?.Close();
AbortRequest(request);
if (e is WebException || e is SecurityException) throw;
throw new WebException(SR.net_webclient, e);
}
}
private async void DownloadBitsAsync(
WebRequest request, Stream writeStream,
AsyncOperation asyncOp, Action<byte[]?, Exception?, AsyncOperation> completionDelegate)
{
Debug.Assert(_progress != null, "ProgressData should have been initialized");
Debug.Assert(asyncOp != null);
Exception? exception = null;
try
{
WebResponse response = _webResponse = await GetWebResponseTaskAsync(request).ConfigureAwait(false);
long contentLength = response.ContentLength;
byte[] copyBuffer = new byte[contentLength == -1 || contentLength > DefaultDownloadBufferLength ? DefaultDownloadBufferLength : contentLength];
if (writeStream is ChunkedMemoryStream)
{
if (contentLength > int.MaxValue)
{
throw new WebException(SR.net_webstatus_MessageLengthLimitExceeded, WebExceptionStatus.MessageLengthLimitExceeded);
}
writeStream.SetLength(copyBuffer.Length);
}
if (contentLength >= 0)
{
_progress.TotalBytesToReceive = contentLength;
}
using (writeStream)
using (Stream readStream = response.GetResponseStream())
{
if (readStream != null)
{
while (true)
{
int bytesRead = await readStream.ReadAsync(new Memory<byte>(copyBuffer)).ConfigureAwait(false);
if (bytesRead == 0)
{
break;
}
_progress.BytesReceived += bytesRead;
if (_progress.BytesReceived != _progress.TotalBytesToReceive)
{
PostProgressChanged(asyncOp, _progress);
}
await writeStream.WriteAsync(new ReadOnlyMemory<byte>(copyBuffer, 0, bytesRead)).ConfigureAwait(false);
}
}
if (_progress.TotalBytesToReceive < 0)
{
_progress.TotalBytesToReceive = _progress.BytesReceived;
}
PostProgressChanged(asyncOp, _progress);
}
completionDelegate((writeStream as ChunkedMemoryStream)?.ToArray(), null, asyncOp);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
exception = GetExceptionToPropagate(e);
AbortRequest(request);
writeStream?.Close();
}
finally
{
if (exception != null)
{
completionDelegate(null, exception, asyncOp);
}
}
}
private byte[] UploadBits(
WebRequest request, Stream? readStream, byte[] buffer, int chunkSize,
byte[]? header, byte[]? footer)
{
try
{
if (request.RequestUri.Scheme == Uri.UriSchemeFile)
{
header = footer = null;
}
using (Stream writeStream = request.GetRequestStream())
{
if (header != null)
{
writeStream.Write(header, 0, header.Length);
}
if (readStream != null)
{
using (readStream)
{
while (true)
{
int bytesRead = readStream.Read(buffer, 0, buffer.Length);
if (bytesRead <= 0)
break;
writeStream.Write(buffer, 0, bytesRead);
}
}
}
else
{
for (int pos = 0; pos < buffer.Length;)
{
int toWrite = buffer.Length - pos;
if (chunkSize != 0 && toWrite > chunkSize)
{
toWrite = chunkSize;
}
writeStream.Write(buffer, pos, toWrite);
pos += toWrite;
}
}
if (footer != null)
{
writeStream.Write(footer, 0, footer.Length);
}
}
return DownloadBits(request, new ChunkedMemoryStream())!;
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
AbortRequest(request);
if (e is WebException || e is SecurityException) throw;
throw new WebException(SR.net_webclient, e);
}
}
private async void UploadBitsAsync(
WebRequest request, Stream? readStream, byte[] buffer, int chunkSize,
byte[]? header, byte[]? footer,
AsyncOperation asyncOp, Action<byte[]?, Exception?, AsyncOperation> completionDelegate)
{
Debug.Assert(asyncOp != null);
Debug.Assert(_progress != null, "ProgressData should have been initialized");
_progress.HasUploadPhase = true;
Exception? exception = null;
try
{
if (request.RequestUri.Scheme == Uri.UriSchemeFile)
{
header = footer = null;
}
using (Stream writeStream = await request.GetRequestStreamAsync().ConfigureAwait(false))
{
if (header != null)
{
await writeStream.WriteAsync(new ReadOnlyMemory<byte>(header)).ConfigureAwait(false);
_progress.BytesSent += header.Length;
PostProgressChanged(asyncOp, _progress);
}
if (readStream != null)
{
using (readStream)
{
while (true)
{
int bytesRead = await readStream.ReadAsync(new Memory<byte>(buffer)).ConfigureAwait(false);
if (bytesRead <= 0) break;
await writeStream.WriteAsync(new ReadOnlyMemory<byte>(buffer, 0, bytesRead)).ConfigureAwait(false);
_progress.BytesSent += bytesRead;
PostProgressChanged(asyncOp, _progress);
}
}
}
else
{
for (int pos = 0; pos < buffer.Length;)
{
int toWrite = buffer.Length - pos;
if (chunkSize != 0 && toWrite > chunkSize)
{
toWrite = chunkSize;
}
await writeStream.WriteAsync(new ReadOnlyMemory<byte>(buffer, pos, toWrite)).ConfigureAwait(false);
pos += toWrite;
_progress.BytesSent += toWrite;
PostProgressChanged(asyncOp, _progress);
}
}
if (footer != null)
{
await writeStream.WriteAsync(new ReadOnlyMemory<byte>(footer)).ConfigureAwait(false);
_progress.BytesSent += footer.Length;
PostProgressChanged(asyncOp, _progress);
}
}
DownloadBitsAsync(request, new ChunkedMemoryStream(), asyncOp, completionDelegate);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
exception = GetExceptionToPropagate(e);
AbortRequest(request);
}
finally
{
if (exception != null)
{
completionDelegate(null, exception, asyncOp);
}
}
}
private static bool ByteArrayHasPrefix(byte[] prefix, byte[] byteArray)
{
if (prefix == null || byteArray == null || prefix.Length > byteArray.Length)
{
return false;
}
for (int i = 0; i < prefix.Length; i++)
{
if (prefix[i] != byteArray[i])
{
return false;
}
}
return true;
}
private static readonly char[] s_parseContentTypeSeparators = new char[] { ';', '=', ' ' };
private static readonly Encoding[] s_knownEncodings = { Encoding.UTF8, Encoding.UTF32, Encoding.Unicode, Encoding.BigEndianUnicode };
private string GetStringUsingEncoding(WebRequest request, byte[] data)
{
Encoding? enc = null;
int bomLengthInData = -1;
// Figure out encoding by first checking for encoding string in Content-Type HTTP header
// This can throw NotImplementedException if the derived class of WebRequest doesn't support it.
string? contentType;
try
{
contentType = request.ContentType;
}
catch (Exception e) when (e is NotImplementedException || e is NotSupportedException) // some types do this
{
contentType = null;
}
if (contentType != null)
{
contentType = contentType.ToLowerInvariant();
string[] parsedList = contentType.Split(s_parseContentTypeSeparators);
bool nextItem = false;
foreach (string item in parsedList)
{
if (item == "charset")
{
nextItem = true;
}
else if (nextItem)
{
try
{
enc = Encoding.GetEncoding(item);
}
catch (ArgumentException)
{
// Eat ArgumentException here.
// We'll assume that Content-Type encoding might have been garbled and wasn't present at all.
break;
}
// Unexpected exceptions are thrown back to caller
}
}
}
// If no content encoding listed in the ContentType HTTP header, or no Content-Type header present, then
// check for a byte-order-mark (BOM) in the data to figure out encoding.
if (enc == null)
{
// UTF32 must be tested before Unicode because it's BOM is the same but longer.
Encoding[] encodings = s_knownEncodings;
for (int i = 0; i < encodings.Length; i++)
{
byte[] preamble = encodings[i].GetPreamble();
if (ByteArrayHasPrefix(preamble, data))
{
enc = encodings[i];
bomLengthInData = preamble.Length;
break;
}
}
}
// Do we have an encoding guess? If not, use default.
if (enc == null)
{
enc = Encoding;
}
// Calculate BOM length based on encoding guess. Then check for it in the data.
if (bomLengthInData == -1)
{
byte[] preamble = enc.GetPreamble();
bomLengthInData = ByteArrayHasPrefix(preamble, data) ? preamble.Length : 0;
}
// Convert byte array to string stripping off any BOM before calling Format().
// This is required since Format() doesn't handle stripping off BOM.
return enc.GetString(data, bomLengthInData, data.Length - bomLengthInData);
}
private string MapToDefaultMethod(Uri address)
{
Uri uri = !address.IsAbsoluteUri && _baseAddress != null ?
new Uri(_baseAddress, address) :
address;
return string.Equals(uri.Scheme, Uri.UriSchemeFtp, StringComparison.Ordinal) ?
"STOR" :
"POST";
}
[return: NotNullIfNotNull("str")]
private static string? UrlEncode(string? str)
{
if (str == null)
return null;
byte[] bytes = Encoding.UTF8.GetBytes(str);
return Encoding.ASCII.GetString(UrlEncodeBytesToBytesInternal(bytes, 0, bytes.Length, false));
}
private static byte[] UrlEncodeBytesToBytesInternal(byte[] bytes, int offset, int count, bool alwaysCreateReturnValue)
{
int cSpaces = 0;
int cUnsafe = 0;
// Count them first.
for (int i = 0; i < count; i++)
{
char ch = (char)bytes[offset + i];
if (ch == ' ')
{
cSpaces++;
}
else if (!IsSafe(ch))
{
cUnsafe++;
}
}
// If nothing to expand.
if (!alwaysCreateReturnValue && cSpaces == 0 && cUnsafe == 0)
return bytes;
// Expand not 'safe' characters into %XX, spaces to +.
byte[] expandedBytes = new byte[count + cUnsafe * 2];
int pos = 0;
for (int i = 0; i < count; i++)
{
byte b = bytes[offset + i];
char ch = (char)b;
if (IsSafe(ch))
{
expandedBytes[pos++] = b;
}
else if (ch == ' ')
{
expandedBytes[pos++] = (byte)'+';
}
else
{
expandedBytes[pos++] = (byte)'%';
expandedBytes[pos++] = (byte)HexConverter.ToCharLower(b >> 4);
expandedBytes[pos++] = (byte)HexConverter.ToCharLower(b);
}
}
return expandedBytes;
}
private static bool IsSafe(char ch)
{
if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch >= '0' && ch <= '9')
{
return true;
}
switch (ch)
{
case '-':
case '_':
case '.':
case '!':
case '*':
case '\'':
case '(':
case ')':
return true;
}
return false;
}
private void InvokeOperationCompleted(AsyncOperation asyncOp, SendOrPostCallback callback, AsyncCompletedEventArgs eventArgs)
{
if (Interlocked.CompareExchange(ref _asyncOp, null, asyncOp) == asyncOp)
{
EndOperation();
asyncOp.PostOperationCompleted(callback, eventArgs);
}
}
public void OpenReadAsync(Uri address) =>
OpenReadAsync(address, null);
public void OpenReadAsync(Uri address!!, object? userToken)
{
AsyncOperation asyncOp = StartAsyncOperation(userToken);
try
{
WebRequest request = _webRequest = GetWebRequest(GetUri(address));
request.BeginGetResponse(iar =>
{
Stream? stream = null;
Exception? exception = null;
try
{
WebResponse response = _webResponse = GetWebResponse(request, iar);
stream = response.GetResponseStream();
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
exception = GetExceptionToPropagate(e);
}
InvokeOperationCompleted(asyncOp, _openReadOperationCompleted!, new OpenReadCompletedEventArgs(stream, exception, _canceled, asyncOp.UserSuppliedState));
}, null);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
InvokeOperationCompleted(asyncOp, _openReadOperationCompleted!,
new OpenReadCompletedEventArgs(null, GetExceptionToPropagate(e), _canceled, asyncOp.UserSuppliedState));
}
}
public void OpenWriteAsync(Uri address) =>
OpenWriteAsync(address, null, null);
public void OpenWriteAsync(Uri address, string? method) =>
OpenWriteAsync(address, method, null);
public void OpenWriteAsync(Uri address!!, string? method, object? userToken)
{
method ??= MapToDefaultMethod(address);
AsyncOperation asyncOp = StartAsyncOperation(userToken);
try
{
_method = method;
WebRequest request = _webRequest = GetWebRequest(GetUri(address));
request.BeginGetRequestStream(iar =>
{
WebClientWriteStream? stream = null;
Exception? exception = null;
try
{
stream = new WebClientWriteStream(request.EndGetRequestStream(iar), request, this);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
exception = GetExceptionToPropagate(e);
}
InvokeOperationCompleted(asyncOp, _openWriteOperationCompleted!, new OpenWriteCompletedEventArgs(stream, exception, _canceled, asyncOp.UserSuppliedState));
}, null);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
var eventArgs = new OpenWriteCompletedEventArgs(null, GetExceptionToPropagate(e), _canceled, asyncOp.UserSuppliedState);
InvokeOperationCompleted(asyncOp, _openWriteOperationCompleted!, eventArgs);
}
}
private void DownloadStringAsyncCallback(byte[]? returnBytes, Exception? exception, object state)
{
AsyncOperation asyncOp = (AsyncOperation)state;
string? stringData = null;
try
{
if (returnBytes != null)
{
stringData = GetStringUsingEncoding(_webRequest!, returnBytes);
}
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
exception = GetExceptionToPropagate(e);
}
var eventArgs = new DownloadStringCompletedEventArgs(stringData, exception, _canceled, asyncOp.UserSuppliedState);
InvokeOperationCompleted(asyncOp, _downloadStringOperationCompleted!, eventArgs);
}
public void DownloadStringAsync(Uri address) =>
DownloadStringAsync(address, null);
public void DownloadStringAsync(Uri address!!, object? userToken)
{
AsyncOperation asyncOp = StartAsyncOperation(userToken);
try
{
WebRequest request = _webRequest = GetWebRequest(GetUri(address));
DownloadBitsAsync(request, new ChunkedMemoryStream(), asyncOp, DownloadStringAsyncCallback);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
DownloadStringAsyncCallback(null, GetExceptionToPropagate(e), asyncOp);
}
}
private void DownloadDataAsyncCallback(byte[]? returnBytes, Exception? exception, object state)
{
AsyncOperation asyncOp = (AsyncOperation)state;
DownloadDataCompletedEventArgs eventArgs = new DownloadDataCompletedEventArgs(returnBytes, exception, _canceled, asyncOp.UserSuppliedState!);
InvokeOperationCompleted(asyncOp, _downloadDataOperationCompleted!, eventArgs);
}
public void DownloadDataAsync(Uri address) =>
DownloadDataAsync(address, null);
public void DownloadDataAsync(Uri address!!, object? userToken)
{
AsyncOperation asyncOp = StartAsyncOperation(userToken);
try
{
WebRequest request = _webRequest = GetWebRequest(GetUri(address));
DownloadBitsAsync(request, new ChunkedMemoryStream(), asyncOp, DownloadDataAsyncCallback);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
DownloadDataAsyncCallback(null, GetExceptionToPropagate(e), asyncOp);
}
}
private void DownloadFileAsyncCallback(byte[]? returnBytes, Exception? exception, object state)
{
AsyncOperation asyncOp = (AsyncOperation)state;
AsyncCompletedEventArgs eventArgs = new AsyncCompletedEventArgs(exception, _canceled, asyncOp.UserSuppliedState);
InvokeOperationCompleted(asyncOp, _downloadFileOperationCompleted!, eventArgs);
}
public void DownloadFileAsync(Uri address, string fileName) =>
DownloadFileAsync(address, fileName, null);
public void DownloadFileAsync(Uri address!!, string fileName!!, object? userToken)
{
FileStream? fs = null;
AsyncOperation asyncOp = StartAsyncOperation(userToken);
try
{
fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);
WebRequest request = _webRequest = GetWebRequest(GetUri(address));
DownloadBitsAsync(request, fs, asyncOp, DownloadFileAsyncCallback);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
fs?.Close();
DownloadFileAsyncCallback(null, GetExceptionToPropagate(e), asyncOp);
}
}
public void UploadStringAsync(Uri address, string data) =>
UploadStringAsync(address, null, data, null);
public void UploadStringAsync(Uri address, string? method, string data) =>
UploadStringAsync(address, method, data, null);
public void UploadStringAsync(Uri address!!, string? method, string data!!, object? userToken)
{
method ??= MapToDefaultMethod(address);
AsyncOperation asyncOp = StartAsyncOperation(userToken);
try
{
byte[] requestData = Encoding.GetBytes(data);
_method = method;
_contentLength = requestData.Length;
WebRequest request = _webRequest = GetWebRequest(GetUri(address));
UploadBitsAsync(
request, null, requestData, 0, null, null, asyncOp,
(bytesResult, error, uploadAsyncOp) =>
{
string? stringResult = null;
if (error == null && bytesResult != null)
{
try
{
stringResult = GetStringUsingEncoding(_webRequest, bytesResult);
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
error = GetExceptionToPropagate(e);
}
}
InvokeOperationCompleted(uploadAsyncOp, _uploadStringOperationCompleted!,
new UploadStringCompletedEventArgs(stringResult, error, _canceled, uploadAsyncOp.UserSuppliedState));
});
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
var eventArgs = new UploadStringCompletedEventArgs(null, GetExceptionToPropagate(e), _canceled, asyncOp.UserSuppliedState);
InvokeOperationCompleted(asyncOp, _uploadStringOperationCompleted!, eventArgs);
}
}
public void UploadDataAsync(Uri address, byte[] data) =>
UploadDataAsync(address, null, data, null);
public void UploadDataAsync(Uri address, string? method, byte[] data) =>
UploadDataAsync(address, method, data, null);
public void UploadDataAsync(Uri address!!, string? method, byte[] data!!, object? userToken)
{
method ??= MapToDefaultMethod(address);
AsyncOperation asyncOp = StartAsyncOperation(userToken);
try
{
_method = method;
_contentLength = data.Length;
WebRequest request = _webRequest = GetWebRequest(GetUri(address));
int chunkSize = 0;
if (UploadProgressChanged != null)
{
// If ProgressCallback is requested, we should send the buffer in chunks
chunkSize = (int)Math.Min((long)DefaultCopyBufferLength, data.Length);
}
UploadBitsAsync(
request, null, data, chunkSize, null, null, asyncOp,
(result, error, uploadAsyncOp) =>
InvokeOperationCompleted(asyncOp, _uploadDataOperationCompleted!, new UploadDataCompletedEventArgs(result, error, _canceled, uploadAsyncOp.UserSuppliedState)));
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
var eventArgs = new UploadDataCompletedEventArgs(null, GetExceptionToPropagate(e), _canceled, asyncOp.UserSuppliedState);
InvokeOperationCompleted(asyncOp, _uploadDataOperationCompleted!, eventArgs);
}
}
public void UploadFileAsync(Uri address, string fileName) =>
UploadFileAsync(address, null, fileName, null);
public void UploadFileAsync(Uri address, string? method, string fileName) =>
UploadFileAsync(address, method, fileName, null);
public void UploadFileAsync(Uri address!!, string? method, string fileName!!, object? userToken)
{
method ??= MapToDefaultMethod(address);
FileStream? fs = null;
AsyncOperation asyncOp = StartAsyncOperation(userToken);
try
{
_method = method;
byte[]? formHeaderBytes = null, boundaryBytes = null, buffer = null;
Uri uri = GetUri(address);
bool needsHeaderAndBoundary = (uri.Scheme != Uri.UriSchemeFile);
OpenFileInternal(needsHeaderAndBoundary, fileName, out fs, out buffer, ref formHeaderBytes, ref boundaryBytes);
WebRequest request = _webRequest = GetWebRequest(uri);
UploadBitsAsync(
request, fs, buffer, 0, formHeaderBytes, boundaryBytes, asyncOp,
(result, error, uploadAsyncOp) =>
InvokeOperationCompleted(asyncOp, _uploadFileOperationCompleted!, new UploadFileCompletedEventArgs(result, error, _canceled, uploadAsyncOp.UserSuppliedState)));
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
fs?.Close();
var eventArgs = new UploadFileCompletedEventArgs(null, GetExceptionToPropagate(e), _canceled, asyncOp.UserSuppliedState);
InvokeOperationCompleted(asyncOp, _uploadFileOperationCompleted!, eventArgs);
}
}
public void UploadValuesAsync(Uri address, NameValueCollection data) =>
UploadValuesAsync(address, null, data, null);
public void UploadValuesAsync(Uri address, string? method, NameValueCollection data) =>
UploadValuesAsync(address, method, data, null);
public void UploadValuesAsync(Uri address!!, string? method, NameValueCollection data!!, object? userToken)
{
method ??= MapToDefaultMethod(address);
AsyncOperation asyncOp = StartAsyncOperation(userToken);
try
{
byte[] buffer = GetValuesToUpload(data);
_method = method;
WebRequest request = _webRequest = GetWebRequest(GetUri(address));
int chunkSize = 0;
if (UploadProgressChanged != null)
{
// If ProgressCallback is requested, we should send the buffer in chunks
chunkSize = (int)Math.Min((long)DefaultCopyBufferLength, buffer.Length);
}
UploadBitsAsync(
request, null, buffer, chunkSize, null, null, asyncOp,
(result, error, uploadAsyncOp) =>
InvokeOperationCompleted(asyncOp, _uploadValuesOperationCompleted!, new UploadValuesCompletedEventArgs(result, error, _canceled, uploadAsyncOp.UserSuppliedState)));
}
catch (Exception e) when (!(e is OutOfMemoryException))
{
var eventArgs = new UploadValuesCompletedEventArgs(null, GetExceptionToPropagate(e), _canceled, asyncOp.UserSuppliedState!);
InvokeOperationCompleted(asyncOp, _uploadValuesOperationCompleted!, eventArgs);
}
}
private static Exception GetExceptionToPropagate(Exception e) =>
e is WebException || e is SecurityException ? e : new WebException(SR.net_webclient, e);
public void CancelAsync()
{
WebRequest? request = _webRequest;
_canceled = true;
AbortRequest(request);
}
public Task<string> DownloadStringTaskAsync(string address) =>
DownloadStringTaskAsync(GetUri(address));
public Task<string> DownloadStringTaskAsync(Uri address)
{
// Create the task to be returned
var tcs = new TaskCompletionSource<string>(address);
DownloadStringCompletedEventHandler? handler = null;
handler = (sender, e) => HandleCompletion(tcs, e, (args) => args.Result, handler, (webClient, completion) => webClient.DownloadStringCompleted -= completion);
DownloadStringCompleted += handler;
// Start the async operation.
try { DownloadStringAsync(address, tcs); }
catch
{
DownloadStringCompleted -= handler;
throw;
}
// Return the task that represents the async operation
return tcs.Task;
}
public Task<Stream> OpenReadTaskAsync(string address) =>
OpenReadTaskAsync(GetUri(address));
public Task<Stream> OpenReadTaskAsync(Uri address)
{
// Create the task to be returned
var tcs = new TaskCompletionSource<Stream>(address);
// Setup the callback event handler
OpenReadCompletedEventHandler? handler = null;
handler = (sender, e) => HandleCompletion(tcs, e, (args) => args.Result, handler, (webClient, completion) => webClient.OpenReadCompleted -= completion);
OpenReadCompleted += handler;
// Start the async operation.
try { OpenReadAsync(address, tcs); }
catch
{
OpenReadCompleted -= handler;
throw;
}
// Return the task that represents the async operation
return tcs.Task;
}
public Task<Stream> OpenWriteTaskAsync(string address) =>
OpenWriteTaskAsync(GetUri(address), null);
public Task<Stream> OpenWriteTaskAsync(Uri address) =>
OpenWriteTaskAsync(address, null);
public Task<Stream> OpenWriteTaskAsync(string address, string? method) =>
OpenWriteTaskAsync(GetUri(address), method);
public Task<Stream> OpenWriteTaskAsync(Uri address, string? method)
{
// Create the task to be returned
var tcs = new TaskCompletionSource<Stream>(address);
// Setup the callback event handler
OpenWriteCompletedEventHandler? handler = null;
handler = (sender, e) => HandleCompletion(tcs, e, (args) => args.Result, handler, (webClient, completion) => webClient.OpenWriteCompleted -= completion);
OpenWriteCompleted += handler;
// Start the async operation.
try { OpenWriteAsync(address, method, tcs); }
catch
{
OpenWriteCompleted -= handler;
throw;
}
// Return the task that represents the async operation
return tcs.Task;
}
public Task<string> UploadStringTaskAsync(string address, string data) =>
UploadStringTaskAsync(address, null, data);
public Task<string> UploadStringTaskAsync(Uri address, string data) =>
UploadStringTaskAsync(address, null, data);
public Task<string> UploadStringTaskAsync(string address, string? method, string data) =>
UploadStringTaskAsync(GetUri(address), method, data);
public Task<string> UploadStringTaskAsync(Uri address, string? method, string data)
{
// Create the task to be returned
var tcs = new TaskCompletionSource<string>(address);
// Setup the callback event handler
UploadStringCompletedEventHandler? handler = null;
handler = (sender, e) => HandleCompletion(tcs, e, (args) => args.Result, handler, (webClient, completion) => webClient.UploadStringCompleted -= completion);
UploadStringCompleted += handler;
// Start the async operation.
try { UploadStringAsync(address, method, data, tcs); }
catch
{
UploadStringCompleted -= handler;
throw;
}
// Return the task that represents the async operation
return tcs.Task;
}
public Task<byte[]> DownloadDataTaskAsync(string address) =>
DownloadDataTaskAsync(GetUri(address));
public Task<byte[]> DownloadDataTaskAsync(Uri address)
{
// Create the task to be returned
var tcs = new TaskCompletionSource<byte[]>(address);
// Setup the callback event handler
DownloadDataCompletedEventHandler? handler = null;
handler = (sender, e) => HandleCompletion(tcs, e, (args) => args.Result, handler, (webClient, completion) => webClient.DownloadDataCompleted -= completion);
DownloadDataCompleted += handler;
// Start the async operation.
try { DownloadDataAsync(address, tcs); }
catch
{
DownloadDataCompleted -= handler;
throw;
}
// Return the task that represents the async operation
return tcs.Task;
}
public Task DownloadFileTaskAsync(string address, string fileName) =>
DownloadFileTaskAsync(GetUri(address), fileName);
public Task DownloadFileTaskAsync(Uri address, string fileName)
{
// Create the task to be returned
var tcs = new TaskCompletionSource<object?>(address);
// Setup the callback event handler
AsyncCompletedEventHandler? handler = null;
handler = (sender, e) => HandleCompletion(tcs, e, (args) => null, handler, (webClient, completion) => webClient.DownloadFileCompleted -= completion);
DownloadFileCompleted += handler;
// Start the async operation.
try { DownloadFileAsync(address, fileName, tcs); }
catch
{
DownloadFileCompleted -= handler;
throw;
}
// Return the task that represents the async operation
return tcs.Task;
}
public Task<byte[]> UploadDataTaskAsync(string address, byte[] data) =>
UploadDataTaskAsync(GetUri(address), null, data);
public Task<byte[]> UploadDataTaskAsync(Uri address, byte[] data) =>
UploadDataTaskAsync(address, null, data);
public Task<byte[]> UploadDataTaskAsync(string address, string? method, byte[] data) =>
UploadDataTaskAsync(GetUri(address), method, data);
public Task<byte[]> UploadDataTaskAsync(Uri address, string? method, byte[] data)
{
// Create the task to be returned
var tcs = new TaskCompletionSource<byte[]>(address);
// Setup the callback event handler
UploadDataCompletedEventHandler? handler = null;
handler = (sender, e) => HandleCompletion(tcs, e, (args) => args.Result, handler, (webClient, completion) => webClient.UploadDataCompleted -= completion);
UploadDataCompleted += handler;
// Start the async operation.
try { UploadDataAsync(address, method, data, tcs); }
catch
{
UploadDataCompleted -= handler;
throw;
}
// Return the task that represents the async operation
return tcs.Task;
}
public Task<byte[]> UploadFileTaskAsync(string address, string fileName) =>
UploadFileTaskAsync(GetUri(address), null, fileName);
public Task<byte[]> UploadFileTaskAsync(Uri address, string fileName) =>
UploadFileTaskAsync(address, null, fileName);
public Task<byte[]> UploadFileTaskAsync(string address, string? method, string fileName) =>
UploadFileTaskAsync(GetUri(address), method, fileName);
public Task<byte[]> UploadFileTaskAsync(Uri address, string? method, string fileName)
{
// Create the task to be returned
var tcs = new TaskCompletionSource<byte[]>(address);
// Setup the callback event handler
UploadFileCompletedEventHandler? handler = null;
handler = (sender, e) => HandleCompletion(tcs, e, (args) => args.Result, handler, (webClient, completion) => webClient.UploadFileCompleted -= completion);
UploadFileCompleted += handler;
// Start the async operation.
try { UploadFileAsync(address, method, fileName, tcs); }
catch
{
UploadFileCompleted -= handler;
throw;
}
// Return the task that represents the async operation
return tcs.Task;
}
public Task<byte[]> UploadValuesTaskAsync(string address, NameValueCollection data) =>
UploadValuesTaskAsync(GetUri(address), null, data);
public Task<byte[]> UploadValuesTaskAsync(string address, string? method, NameValueCollection data) =>
UploadValuesTaskAsync(GetUri(address), method, data);
public Task<byte[]> UploadValuesTaskAsync(Uri address, NameValueCollection data) =>
UploadValuesTaskAsync(address, null, data);
public Task<byte[]> UploadValuesTaskAsync(Uri address, string? method, NameValueCollection data)
{
// Create the task to be returned
var tcs = new TaskCompletionSource<byte[]>(address);
// Setup the callback event handler
UploadValuesCompletedEventHandler? handler = null;
handler = (sender, e) => HandleCompletion(tcs, e, (args) => args.Result, handler, (webClient, completion) => webClient.UploadValuesCompleted -= completion);
UploadValuesCompleted += handler;
// Start the async operation.
try { UploadValuesAsync(address, method, data, tcs); }
catch
{
UploadValuesCompleted -= handler;
throw;
}
// Return the task that represents the async operation
return tcs.Task;
}
private void HandleCompletion<TAsyncCompletedEventArgs, TCompletionDelegate, T>(TaskCompletionSource<T> tcs, TAsyncCompletedEventArgs e, Func<TAsyncCompletedEventArgs, T> getResult, TCompletionDelegate handler, Action<WebClient, TCompletionDelegate> unregisterHandler)
where TAsyncCompletedEventArgs : AsyncCompletedEventArgs
{
if (e.UserState == tcs)
{
try { unregisterHandler(this, handler); }
finally
{
if (e.Error != null) tcs.TrySetException(e.Error);
else if (e.Cancelled) tcs.TrySetCanceled();
else tcs.TrySetResult(getResult(e));
}
}
}
private void PostProgressChanged(AsyncOperation asyncOp, ProgressData progress)
{
if (asyncOp != null && (progress.BytesSent > 0 || progress.BytesReceived > 0))
{
int progressPercentage;
if (progress.HasUploadPhase)
{
if (UploadProgressChanged != null)
{
progressPercentage = progress.TotalBytesToReceive < 0 && progress.BytesReceived == 0 ?
progress.TotalBytesToSend < 0 ? 0 : progress.TotalBytesToSend == 0 ? 50 : (int)((50 * progress.BytesSent) / progress.TotalBytesToSend) :
progress.TotalBytesToSend < 0 ? 50 : progress.TotalBytesToReceive == 0 ? 100 : (int)((50 * progress.BytesReceived) / progress.TotalBytesToReceive + 50);
asyncOp.Post(_reportUploadProgressChanged!, new UploadProgressChangedEventArgs(progressPercentage, asyncOp.UserSuppliedState!, progress.BytesSent, progress.TotalBytesToSend, progress.BytesReceived, progress.TotalBytesToReceive));
}
}
else if (DownloadProgressChanged != null)
{
progressPercentage = progress.TotalBytesToReceive < 0 ? 0 : progress.TotalBytesToReceive == 0 ? 100 : (int)((100 * progress.BytesReceived) / progress.TotalBytesToReceive);
asyncOp.Post(_reportDownloadProgressChanged!, new DownloadProgressChangedEventArgs(progressPercentage, asyncOp.UserSuppliedState!, progress.BytesReceived, progress.TotalBytesToReceive));
}
}
}
#region Supporting Types
private sealed class ProgressData
{
internal long BytesSent;
internal long TotalBytesToSend = -1;
internal long BytesReceived;
internal long TotalBytesToReceive = -1;
internal bool HasUploadPhase;
internal void Reset()
{
BytesSent = 0;
TotalBytesToSend = -1;
BytesReceived = 0;
TotalBytesToReceive = -1;
HasUploadPhase = false;
}
}
private sealed class WebClientWriteStream : DelegatingStream
{
private readonly WebRequest _request;
private readonly WebClient _webClient;
public WebClientWriteStream(Stream stream, WebRequest request, WebClient webClient) : base(stream)
{
_request = request;
_webClient = webClient;
}
protected override void Dispose(bool disposing)
{
try
{
if (disposing)
{
_webClient.GetWebResponse(_request).Dispose();
}
}
finally
{
base.Dispose(disposing);
}
}
}
#endregion
#region Obsolete designer support
//introduced to support design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public bool AllowReadStreamBuffering { get; set; }
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public bool AllowWriteStreamBuffering { get; set; }
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public event WriteStreamClosedEventHandler? WriteStreamClosed { add { } remove { } }
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void OnWriteStreamClosed(WriteStreamClosedEventArgs e) { }
#endregion
}
#region Delegates and supporting *CompletedEventArgs classes used by event-based async code
public delegate void OpenReadCompletedEventHandler(object sender, OpenReadCompletedEventArgs e);
public delegate void OpenWriteCompletedEventHandler(object sender, OpenWriteCompletedEventArgs e);
public delegate void DownloadStringCompletedEventHandler(object sender, DownloadStringCompletedEventArgs e);
public delegate void DownloadDataCompletedEventHandler(object sender, DownloadDataCompletedEventArgs e);
public delegate void UploadStringCompletedEventHandler(object sender, UploadStringCompletedEventArgs e);
public delegate void UploadDataCompletedEventHandler(object sender, UploadDataCompletedEventArgs e);
public delegate void UploadFileCompletedEventHandler(object sender, UploadFileCompletedEventArgs e);
public delegate void UploadValuesCompletedEventHandler(object sender, UploadValuesCompletedEventArgs e);
public delegate void DownloadProgressChangedEventHandler(object sender, DownloadProgressChangedEventArgs e);
public delegate void UploadProgressChangedEventHandler(object sender, UploadProgressChangedEventArgs e);
[EditorBrowsable(EditorBrowsableState.Never)]
public delegate void WriteStreamClosedEventHandler(object sender, WriteStreamClosedEventArgs e);
public class OpenReadCompletedEventArgs : AsyncCompletedEventArgs
{
private readonly Stream? _result;
internal OpenReadCompletedEventArgs(Stream? result, Exception? exception, bool cancelled, object? userToken) : base(exception, cancelled, userToken)
{
_result = result;
}
public Stream Result
{
get
{
RaiseExceptionIfNecessary();
return _result!;
}
}
}
public class OpenWriteCompletedEventArgs : AsyncCompletedEventArgs
{
private readonly Stream? _result;
internal OpenWriteCompletedEventArgs(Stream? result, Exception? exception, bool cancelled, object? userToken) : base(exception, cancelled, userToken)
{
_result = result;
}
public Stream Result
{
get
{
RaiseExceptionIfNecessary();
return _result!;
}
}
}
public class DownloadStringCompletedEventArgs : AsyncCompletedEventArgs
{
private readonly string? _result;
internal DownloadStringCompletedEventArgs(string? result, Exception? exception, bool cancelled, object? userToken) : base(exception, cancelled, userToken)
{
_result = result;
}
public string Result
{
get
{
RaiseExceptionIfNecessary();
return _result!;
}
}
}
public class DownloadDataCompletedEventArgs : AsyncCompletedEventArgs
{
private readonly byte[]? _result;
internal DownloadDataCompletedEventArgs(byte[]? result, Exception? exception, bool cancelled, object? userToken) : base(exception, cancelled, userToken)
{
_result = result;
}
public byte[] Result
{
get
{
RaiseExceptionIfNecessary();
return _result!;
}
}
}
public class UploadStringCompletedEventArgs : AsyncCompletedEventArgs
{
private readonly string? _result;
internal UploadStringCompletedEventArgs(string? result, Exception? exception, bool cancelled, object? userToken) : base(exception, cancelled, userToken)
{
_result = result;
}
public string Result
{
get
{
RaiseExceptionIfNecessary();
return _result!;
}
}
}
public class UploadDataCompletedEventArgs : AsyncCompletedEventArgs
{
private readonly byte[]? _result;
internal UploadDataCompletedEventArgs(byte[]? result, Exception? exception, bool cancelled, object? userToken) : base(exception, cancelled, userToken)
{
_result = result;
}
public byte[] Result
{
get
{
RaiseExceptionIfNecessary();
return _result!;
}
}
}
public class UploadFileCompletedEventArgs : AsyncCompletedEventArgs
{
private readonly byte[]? _result;
internal UploadFileCompletedEventArgs(byte[]? result, Exception? exception, bool cancelled, object? userToken) : base(exception, cancelled, userToken)
{
_result = result;
}
public byte[] Result
{
get
{
RaiseExceptionIfNecessary();
return _result!;
}
}
}
public class UploadValuesCompletedEventArgs : AsyncCompletedEventArgs
{
private readonly byte[]? _result;
internal UploadValuesCompletedEventArgs(byte[]? result, Exception? exception, bool cancelled, object? userToken) : base(exception, cancelled, userToken)
{
_result = result;
}
public byte[] Result
{
get
{
RaiseExceptionIfNecessary();
return _result!;
}
}
}
public class DownloadProgressChangedEventArgs : ProgressChangedEventArgs
{
internal DownloadProgressChangedEventArgs(int progressPercentage, object? userToken, long bytesReceived, long totalBytesToReceive) :
base(progressPercentage, userToken)
{
BytesReceived = bytesReceived;
TotalBytesToReceive = totalBytesToReceive;
}
public long BytesReceived { get; }
public long TotalBytesToReceive { get; }
}
public class UploadProgressChangedEventArgs : ProgressChangedEventArgs
{
internal UploadProgressChangedEventArgs(int progressPercentage, object? userToken, long bytesSent, long totalBytesToSend, long bytesReceived, long totalBytesToReceive) :
base(progressPercentage, userToken)
{
BytesReceived = bytesReceived;
TotalBytesToReceive = totalBytesToReceive;
BytesSent = bytesSent;
TotalBytesToSend = totalBytesToSend;
}
public long BytesReceived { get; }
public long TotalBytesToReceive { get; }
public long BytesSent { get; }
public long TotalBytesToSend { get; }
}
[EditorBrowsable(EditorBrowsableState.Never)]
public class WriteStreamClosedEventArgs : EventArgs
{
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public WriteStreamClosedEventArgs() { }
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public Exception? Error { get { return null; } }
}
#endregion
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/coreclr/System.Private.CoreLib/src/System/WeakReference.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.Runtime.Serialization;
using System.Runtime.CompilerServices;
using System.Diagnostics;
namespace System
{
public partial class WeakReference : ISerializable
{
// If you fix bugs here, please fix them in WeakReference<T> at the same time.
// This field is not a regular GC handle. It can have a special values that are used to prevent a race condition between setting the target and finalization.
internal IntPtr m_handle;
// Migrating InheritanceDemands requires this default ctor, so we can mark it SafeCritical
protected WeakReference()
{
Debug.Fail("WeakReference's protected default ctor should never be used!");
throw new NotImplementedException();
}
// Determines whether or not this instance of WeakReference still refers to an object
// that has not been collected.
//
public extern virtual bool IsAlive
{
[MethodImpl(MethodImplOptions.InternalCall)]
get;
}
// Returns a boolean indicating whether or not we're tracking objects until they're collected (true)
// or just until they're finalized (false).
//
public virtual bool TrackResurrection => IsTrackResurrection();
// Gets the Object stored in the handle if it's accessible.
// Or sets it.
//
public extern virtual object? Target
{
[MethodImpl(MethodImplOptions.InternalCall)]
get;
[MethodImpl(MethodImplOptions.InternalCall)]
set;
}
// Free all system resources associated with this reference.
//
// Note: The WeakReference finalizer is not actually run, but
// treated specially in gc.cpp's ScanForFinalization
// This is needed for subclasses deriving from WeakReference, however.
// Additionally, there may be some cases during shutdown when we run this finalizer.
[MethodImpl(MethodImplOptions.InternalCall)]
extern ~WeakReference();
[MethodImpl(MethodImplOptions.InternalCall)]
private extern void Create(object? target, bool trackResurrection);
[MethodImpl(MethodImplOptions.InternalCall)]
private extern bool IsTrackResurrection();
}
}
| // 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.Serialization;
using System.Runtime.CompilerServices;
using System.Diagnostics;
namespace System
{
public partial class WeakReference : ISerializable
{
// If you fix bugs here, please fix them in WeakReference<T> at the same time.
// This field is not a regular GC handle. It can have a special values that are used to prevent a race condition between setting the target and finalization.
internal IntPtr m_handle;
// Migrating InheritanceDemands requires this default ctor, so we can mark it SafeCritical
protected WeakReference()
{
Debug.Fail("WeakReference's protected default ctor should never be used!");
throw new NotImplementedException();
}
// Determines whether or not this instance of WeakReference still refers to an object
// that has not been collected.
//
public extern virtual bool IsAlive
{
[MethodImpl(MethodImplOptions.InternalCall)]
get;
}
// Returns a boolean indicating whether or not we're tracking objects until they're collected (true)
// or just until they're finalized (false).
//
public virtual bool TrackResurrection => IsTrackResurrection();
// Gets the Object stored in the handle if it's accessible.
// Or sets it.
//
public extern virtual object? Target
{
[MethodImpl(MethodImplOptions.InternalCall)]
get;
[MethodImpl(MethodImplOptions.InternalCall)]
set;
}
// Free all system resources associated with this reference.
//
// Note: The WeakReference finalizer is not actually run, but
// treated specially in gc.cpp's ScanForFinalization
// This is needed for subclasses deriving from WeakReference, however.
// Additionally, there may be some cases during shutdown when we run this finalizer.
[MethodImpl(MethodImplOptions.InternalCall)]
extern ~WeakReference();
[MethodImpl(MethodImplOptions.InternalCall)]
private extern void Create(object? target, bool trackResurrection);
[MethodImpl(MethodImplOptions.InternalCall)]
private extern bool IsTrackResurrection();
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/ShiftRightLogicalAdd.Vector128.SByte.1.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.Arm;
namespace JIT.HardwareIntrinsics.Arm
{
public static partial class Program
{
private static void ShiftRightLogicalAdd_Vector128_SByte_1()
{
var test = new ImmBinaryOpTest__ShiftRightLogicalAdd_Vector128_SByte_1();
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 ImmBinaryOpTest__ShiftRightLogicalAdd_Vector128_SByte_1
{
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(ImmBinaryOpTest__ShiftRightLogicalAdd_Vector128_SByte_1 testClass)
{
var result = AdvSimd.ShiftRightLogicalAdd(_fld1, _fld2, 1);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(ImmBinaryOpTest__ShiftRightLogicalAdd_Vector128_SByte_1 testClass)
{
fixed (Vector128<SByte>* pFld1 = &_fld1)
fixed (Vector128<SByte>* pFld2 = &_fld2)
{
var result = AdvSimd.ShiftRightLogicalAdd(
AdvSimd.LoadVector128((SByte*)(pFld1)),
AdvSimd.LoadVector128((SByte*)(pFld2)),
1
);
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 readonly byte Imm = 1;
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 ImmBinaryOpTest__ShiftRightLogicalAdd_Vector128_SByte_1()
{
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 ImmBinaryOpTest__ShiftRightLogicalAdd_Vector128_SByte_1()
{
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.IsSupported;
public bool Succeeded { get; set; }
public void RunBasicScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));
var result = AdvSimd.ShiftRightLogicalAdd(
Unsafe.Read<Vector128<SByte>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr),
1
);
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.ShiftRightLogicalAdd(
AdvSimd.LoadVector128((SByte*)(_dataTable.inArray1Ptr)),
AdvSimd.LoadVector128((SByte*)(_dataTable.inArray2Ptr)),
1
);
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.ShiftRightLogicalAdd), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>), typeof(byte) })
.Invoke(null, new object[] {
Unsafe.Read<Vector128<SByte>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr),
(byte)1
});
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).GetMethod(nameof(AdvSimd.ShiftRightLogicalAdd), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>), typeof(byte) })
.Invoke(null, new object[] {
AdvSimd.LoadVector128((SByte*)(_dataTable.inArray1Ptr)),
AdvSimd.LoadVector128((SByte*)(_dataTable.inArray2Ptr)),
(byte)1
});
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.ShiftRightLogicalAdd(
_clsVar1,
_clsVar2,
1
);
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.ShiftRightLogicalAdd(
AdvSimd.LoadVector128((SByte*)(pClsVar1)),
AdvSimd.LoadVector128((SByte*)(pClsVar2)),
1
);
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.ShiftRightLogicalAdd(op1, op2, 1);
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.ShiftRightLogicalAdd(op1, op2, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op2, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new ImmBinaryOpTest__ShiftRightLogicalAdd_Vector128_SByte_1();
var result = AdvSimd.ShiftRightLogicalAdd(test._fld1, test._fld2, 1);
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 ImmBinaryOpTest__ShiftRightLogicalAdd_Vector128_SByte_1();
fixed (Vector128<SByte>* pFld1 = &test._fld1)
fixed (Vector128<SByte>* pFld2 = &test._fld2)
{
var result = AdvSimd.ShiftRightLogicalAdd(
AdvSimd.LoadVector128((SByte*)(pFld1)),
AdvSimd.LoadVector128((SByte*)(pFld2)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = AdvSimd.ShiftRightLogicalAdd(_fld1, _fld2, 1);
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.ShiftRightLogicalAdd(
AdvSimd.LoadVector128((SByte*)(pFld1)),
AdvSimd.LoadVector128((SByte*)(pFld2)),
1
);
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.ShiftRightLogicalAdd(test._fld1, test._fld2, 1);
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.ShiftRightLogicalAdd(
AdvSimd.LoadVector128((SByte*)(&test._fld1)),
AdvSimd.LoadVector128((SByte*)(&test._fld2)),
1
);
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> firstOp, Vector128<SByte> secondOp, 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]), firstOp);
Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), secondOp);
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* firstOp, void* secondOp, 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>(firstOp), (uint)Unsafe.SizeOf<Vector128<SByte>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(secondOp), (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[] firstOp, SByte[] secondOp, SByte[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (var i = 0; i < RetElementCount; i++)
{
if (Helpers.ShiftRightLogicalAdd(firstOp[i], secondOp[i], Imm) != result[i])
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.ShiftRightLogicalAdd)}<SByte>(Vector128<SByte>, Vector128<SByte>, 1): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" secondOp: ({string.Join(", ", secondOp)})");
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.Arm;
namespace JIT.HardwareIntrinsics.Arm
{
public static partial class Program
{
private static void ShiftRightLogicalAdd_Vector128_SByte_1()
{
var test = new ImmBinaryOpTest__ShiftRightLogicalAdd_Vector128_SByte_1();
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 ImmBinaryOpTest__ShiftRightLogicalAdd_Vector128_SByte_1
{
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(ImmBinaryOpTest__ShiftRightLogicalAdd_Vector128_SByte_1 testClass)
{
var result = AdvSimd.ShiftRightLogicalAdd(_fld1, _fld2, 1);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(ImmBinaryOpTest__ShiftRightLogicalAdd_Vector128_SByte_1 testClass)
{
fixed (Vector128<SByte>* pFld1 = &_fld1)
fixed (Vector128<SByte>* pFld2 = &_fld2)
{
var result = AdvSimd.ShiftRightLogicalAdd(
AdvSimd.LoadVector128((SByte*)(pFld1)),
AdvSimd.LoadVector128((SByte*)(pFld2)),
1
);
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 readonly byte Imm = 1;
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 ImmBinaryOpTest__ShiftRightLogicalAdd_Vector128_SByte_1()
{
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 ImmBinaryOpTest__ShiftRightLogicalAdd_Vector128_SByte_1()
{
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.IsSupported;
public bool Succeeded { get; set; }
public void RunBasicScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));
var result = AdvSimd.ShiftRightLogicalAdd(
Unsafe.Read<Vector128<SByte>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr),
1
);
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.ShiftRightLogicalAdd(
AdvSimd.LoadVector128((SByte*)(_dataTable.inArray1Ptr)),
AdvSimd.LoadVector128((SByte*)(_dataTable.inArray2Ptr)),
1
);
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.ShiftRightLogicalAdd), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>), typeof(byte) })
.Invoke(null, new object[] {
Unsafe.Read<Vector128<SByte>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr),
(byte)1
});
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).GetMethod(nameof(AdvSimd.ShiftRightLogicalAdd), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>), typeof(byte) })
.Invoke(null, new object[] {
AdvSimd.LoadVector128((SByte*)(_dataTable.inArray1Ptr)),
AdvSimd.LoadVector128((SByte*)(_dataTable.inArray2Ptr)),
(byte)1
});
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.ShiftRightLogicalAdd(
_clsVar1,
_clsVar2,
1
);
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.ShiftRightLogicalAdd(
AdvSimd.LoadVector128((SByte*)(pClsVar1)),
AdvSimd.LoadVector128((SByte*)(pClsVar2)),
1
);
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.ShiftRightLogicalAdd(op1, op2, 1);
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.ShiftRightLogicalAdd(op1, op2, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op2, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new ImmBinaryOpTest__ShiftRightLogicalAdd_Vector128_SByte_1();
var result = AdvSimd.ShiftRightLogicalAdd(test._fld1, test._fld2, 1);
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 ImmBinaryOpTest__ShiftRightLogicalAdd_Vector128_SByte_1();
fixed (Vector128<SByte>* pFld1 = &test._fld1)
fixed (Vector128<SByte>* pFld2 = &test._fld2)
{
var result = AdvSimd.ShiftRightLogicalAdd(
AdvSimd.LoadVector128((SByte*)(pFld1)),
AdvSimd.LoadVector128((SByte*)(pFld2)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = AdvSimd.ShiftRightLogicalAdd(_fld1, _fld2, 1);
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.ShiftRightLogicalAdd(
AdvSimd.LoadVector128((SByte*)(pFld1)),
AdvSimd.LoadVector128((SByte*)(pFld2)),
1
);
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.ShiftRightLogicalAdd(test._fld1, test._fld2, 1);
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.ShiftRightLogicalAdd(
AdvSimd.LoadVector128((SByte*)(&test._fld1)),
AdvSimd.LoadVector128((SByte*)(&test._fld2)),
1
);
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> firstOp, Vector128<SByte> secondOp, 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]), firstOp);
Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), secondOp);
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* firstOp, void* secondOp, 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>(firstOp), (uint)Unsafe.SizeOf<Vector128<SByte>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(secondOp), (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[] firstOp, SByte[] secondOp, SByte[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (var i = 0; i < RetElementCount; i++)
{
if (Helpers.ShiftRightLogicalAdd(firstOp[i], secondOp[i], Imm) != result[i])
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.ShiftRightLogicalAdd)}<SByte>(Vector128<SByte>, Vector128<SByte>, 1): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" secondOp: ({string.Join(", ", secondOp)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonNode.To.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.Nodes
{
public abstract partial class JsonNode
{
/// <summary>
/// Converts the current instance to string in JSON format.
/// </summary>
/// <param name="options">Options to control the serialization behavior.</param>
/// <returns>JSON representation of current instance.</returns>
public string ToJsonString(JsonSerializerOptions? options = null)
{
using var output = new PooledByteBufferWriter(JsonSerializerOptions.BufferSizeDefault);
using (var writer = new Utf8JsonWriter(output, options == null ? default(JsonWriterOptions) : options.GetWriterOptions()))
{
WriteTo(writer, options);
}
return JsonHelpers.Utf8GetString(output.WrittenMemory.ToArray());
}
/// <summary>
/// Gets a string representation for the current value appropriate to the node type.
/// </summary>
/// <returns>A string representation for the current value appropriate to the node type.</returns>
public override string ToString()
{
// Special case for string; don't quote it.
if (this is JsonValue)
{
if (this is JsonValue<string> jsonString)
{
return jsonString.Value;
}
if (this is JsonValue<JsonElement> jsonElement &&
jsonElement.Value.ValueKind == JsonValueKind.String)
{
return jsonElement.Value.GetString()!;
}
}
using var output = new PooledByteBufferWriter(JsonSerializerOptions.BufferSizeDefault);
using (var writer = new Utf8JsonWriter(output, new JsonWriterOptions { Indented = true }))
{
WriteTo(writer);
}
return JsonHelpers.Utf8GetString(output.WrittenMemory.ToArray());
}
/// <summary>
/// Write the <see cref="JsonNode"/> into the provided <see cref="Utf8JsonWriter"/> as JSON.
/// </summary>
/// <param name="writer">The <see cref="Utf8JsonWriter"/>.</param>
/// <exception cref="ArgumentNullException">
/// The <paramref name="writer"/> parameter is <see langword="null"/>.
/// </exception>
/// <param name="options">Options to control the serialization behavior.</param>
public abstract void WriteTo(Utf8JsonWriter writer, JsonSerializerOptions? options = null);
}
}
| // 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.Nodes
{
public abstract partial class JsonNode
{
/// <summary>
/// Converts the current instance to string in JSON format.
/// </summary>
/// <param name="options">Options to control the serialization behavior.</param>
/// <returns>JSON representation of current instance.</returns>
public string ToJsonString(JsonSerializerOptions? options = null)
{
using var output = new PooledByteBufferWriter(JsonSerializerOptions.BufferSizeDefault);
using (var writer = new Utf8JsonWriter(output, options == null ? default(JsonWriterOptions) : options.GetWriterOptions()))
{
WriteTo(writer, options);
}
return JsonHelpers.Utf8GetString(output.WrittenMemory.ToArray());
}
/// <summary>
/// Gets a string representation for the current value appropriate to the node type.
/// </summary>
/// <returns>A string representation for the current value appropriate to the node type.</returns>
public override string ToString()
{
// Special case for string; don't quote it.
if (this is JsonValue)
{
if (this is JsonValue<string> jsonString)
{
return jsonString.Value;
}
if (this is JsonValue<JsonElement> jsonElement &&
jsonElement.Value.ValueKind == JsonValueKind.String)
{
return jsonElement.Value.GetString()!;
}
}
using var output = new PooledByteBufferWriter(JsonSerializerOptions.BufferSizeDefault);
using (var writer = new Utf8JsonWriter(output, new JsonWriterOptions { Indented = true }))
{
WriteTo(writer);
}
return JsonHelpers.Utf8GetString(output.WrittenMemory.ToArray());
}
/// <summary>
/// Write the <see cref="JsonNode"/> into the provided <see cref="Utf8JsonWriter"/> as JSON.
/// </summary>
/// <param name="writer">The <see cref="Utf8JsonWriter"/>.</param>
/// <exception cref="ArgumentNullException">
/// The <paramref name="writer"/> parameter is <see langword="null"/>.
/// </exception>
/// <param name="options">Options to control the serialization behavior.</param>
public abstract void WriteTo(Utf8JsonWriter writer, JsonSerializerOptions? options = null);
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Reflection.Emit/tests/ConstructorBuilder/ConstructorBuilderSetCustomAttribute.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Linq;
using Xunit;
namespace System.Reflection.Emit.Tests
{
public class ConstructorBuilderSetCustomAttribute
{
[Fact]
public void SetCustomAttribute_ConstructorBuilder_ByteArray()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Public);
ConstructorBuilder constructor = type.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new Type[] { typeof(int) });
ConstructorInfo attributeConstructor = typeof(IntAllAttribute).GetConstructor(new Type[] { typeof(int) });
constructor.SetCustomAttribute(attributeConstructor, new byte[] { 1, 0, 5, 0, 0, 0 });
constructor.GetILGenerator().Emit(OpCodes.Ret);
Type createdType = type.CreateTypeInfo().AsType();
ConstructorInfo createdConstructor = createdType.GetConstructor(new Type[] { typeof(int) });
Attribute[] attributes = createdConstructor.GetCustomAttributes().ToArray();
IntAllAttribute attribute = Assert.IsType<IntAllAttribute>(attributes[0]);
Assert.Equal(5, attribute._i);
}
[Fact]
public void SetCustomAttribute_ConstructorBuilder_ByteArray_NullConstructorBuilder_ThrowsArgumentNullException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Public);
ConstructorBuilder constructor = type.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new Type[0]);
AssertExtensions.Throws<ArgumentNullException>("con", () => constructor.SetCustomAttribute(null, new byte[0]));
}
[Fact]
public void SetCustomAttribute_CustomAttributeBuilder()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Public);
ConstructorBuilder constructor = type.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new Type[0]);
ILGenerator ilGenerator = constructor.GetILGenerator();
ilGenerator.Emit(OpCodes.Ldarg_1);
ConstructorInfo attributeConstructor = typeof(IntAllAttribute).GetConstructor(new Type[] { typeof(int) });
CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(attributeConstructor, new object[] { 2 });
constructor.SetCustomAttribute(attributeBuilder);
Type createdType = type.CreateTypeInfo().AsType();
ConstructorInfo createdConstructor = createdType.GetConstructor(new Type[0]);
Attribute[] customAttributes = (Attribute[])CustomAttributeExtensions.GetCustomAttributes(createdConstructor, true).ToArray();
Assert.Equal(1, customAttributes.Length);
Assert.Equal(2, ((IntAllAttribute)customAttributes[0])._i);
}
[Fact]
public void SetCustomAttribute_NullCustomAttributeBuilder_ThrowsArgumentNullException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Public);
ConstructorBuilder constructor = type.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new Type[0]);
ILGenerator ilGenerator = constructor.GetILGenerator();
ilGenerator.Emit(OpCodes.Ldarg_1);
AssertExtensions.Throws<ArgumentNullException>("customBuilder", () => constructor.SetCustomAttribute(null));
}
[Fact]
public void GetCustomAttributes_ThrowsNotSupportedException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Public);
ConstructorBuilder constructor = type.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new Type[0]);
Assert.Throws<NotSupportedException>(() => constructor.GetCustomAttributes());
}
[Fact]
public void IsDefined_ThrowsNotSupportedException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Public);
ConstructorBuilder constructor = type.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new Type[0]);
Assert.Throws<NotSupportedException>(() => constructor.IsDefined(typeof(IntAllAttribute)));
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Linq;
using Xunit;
namespace System.Reflection.Emit.Tests
{
public class ConstructorBuilderSetCustomAttribute
{
[Fact]
public void SetCustomAttribute_ConstructorBuilder_ByteArray()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Public);
ConstructorBuilder constructor = type.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new Type[] { typeof(int) });
ConstructorInfo attributeConstructor = typeof(IntAllAttribute).GetConstructor(new Type[] { typeof(int) });
constructor.SetCustomAttribute(attributeConstructor, new byte[] { 1, 0, 5, 0, 0, 0 });
constructor.GetILGenerator().Emit(OpCodes.Ret);
Type createdType = type.CreateTypeInfo().AsType();
ConstructorInfo createdConstructor = createdType.GetConstructor(new Type[] { typeof(int) });
Attribute[] attributes = createdConstructor.GetCustomAttributes().ToArray();
IntAllAttribute attribute = Assert.IsType<IntAllAttribute>(attributes[0]);
Assert.Equal(5, attribute._i);
}
[Fact]
public void SetCustomAttribute_ConstructorBuilder_ByteArray_NullConstructorBuilder_ThrowsArgumentNullException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Public);
ConstructorBuilder constructor = type.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new Type[0]);
AssertExtensions.Throws<ArgumentNullException>("con", () => constructor.SetCustomAttribute(null, new byte[0]));
}
[Fact]
public void SetCustomAttribute_CustomAttributeBuilder()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Public);
ConstructorBuilder constructor = type.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new Type[0]);
ILGenerator ilGenerator = constructor.GetILGenerator();
ilGenerator.Emit(OpCodes.Ldarg_1);
ConstructorInfo attributeConstructor = typeof(IntAllAttribute).GetConstructor(new Type[] { typeof(int) });
CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(attributeConstructor, new object[] { 2 });
constructor.SetCustomAttribute(attributeBuilder);
Type createdType = type.CreateTypeInfo().AsType();
ConstructorInfo createdConstructor = createdType.GetConstructor(new Type[0]);
Attribute[] customAttributes = (Attribute[])CustomAttributeExtensions.GetCustomAttributes(createdConstructor, true).ToArray();
Assert.Equal(1, customAttributes.Length);
Assert.Equal(2, ((IntAllAttribute)customAttributes[0])._i);
}
[Fact]
public void SetCustomAttribute_NullCustomAttributeBuilder_ThrowsArgumentNullException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Public);
ConstructorBuilder constructor = type.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new Type[0]);
ILGenerator ilGenerator = constructor.GetILGenerator();
ilGenerator.Emit(OpCodes.Ldarg_1);
AssertExtensions.Throws<ArgumentNullException>("customBuilder", () => constructor.SetCustomAttribute(null));
}
[Fact]
public void GetCustomAttributes_ThrowsNotSupportedException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Public);
ConstructorBuilder constructor = type.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new Type[0]);
Assert.Throws<NotSupportedException>(() => constructor.GetCustomAttributes());
}
[Fact]
public void IsDefined_ThrowsNotSupportedException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Public);
ConstructorBuilder constructor = type.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new Type[0]);
Assert.Throws<NotSupportedException>(() => constructor.IsDefined(typeof(IntAllAttribute)));
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/mono/mono/tests/delegate7.cs | using System;
using System.Runtime.InteropServices;
class Tests {
delegate void SimpleDelegate ();
static void F1 () {
v += 1;
Console.WriteLine ("Test.F1");
}
static void F2 () {
v += 2;
Console.WriteLine ("Test.F2");
}
static void F4 () {
v += 4;
Console.WriteLine ("Test.F4");
}
static void F8 () {
v += 8;
Console.WriteLine ("Test.F8");
}
public static int Main () {
return TestDriver.RunTests (typeof (Tests));
}
static int v = 0;
static bool check_is_expected_v (SimpleDelegate d, int expected_v)
{
v = 0;
d ();
return v == expected_v;
}
static public int test_0_test () {
SimpleDelegate d1 = new SimpleDelegate (F1);
SimpleDelegate d2 = new SimpleDelegate (F2);
SimpleDelegate d4 = new SimpleDelegate (F4);
SimpleDelegate d8 = new SimpleDelegate (F8);
if (d1 - d1 != null)
return 1;
if (!check_is_expected_v (d1 - d2, 1))
return 2;
if (!check_is_expected_v (d1 - d4, 1))
return 3;
if (!check_is_expected_v (d2 - d1, 2))
return 4;
if (d2 - d2 != null)
return 5;
if (!check_is_expected_v (d2 - d4, 2))
return 6;
if (!check_is_expected_v (d4 - d1, 4))
return 7;
if (!check_is_expected_v (d4 - d2, 4))
return 8;
if (d4 - d4 != null)
return 9;
SimpleDelegate d12 = d1 + d2;
SimpleDelegate d14 = d1 + d4;
SimpleDelegate d24 = d2 + d4;
if (!check_is_expected_v (d12 - d1, 2))
return 11;
if (!check_is_expected_v (d12 - d2, 1))
return 12;
if (!check_is_expected_v (d12 - d4, 3))
return 13;
if (!check_is_expected_v (d14 - d1, 4))
return 14;
if (!check_is_expected_v (d14 - d2, 5))
return 15;
if (!check_is_expected_v (d14 - d4, 1))
return 16;
if (!check_is_expected_v (d14 - d1, 4))
return 17;
if (!check_is_expected_v (d14 - d2, 5))
return 18;
if (!check_is_expected_v (d14 - d4, 1))
return 19;
if (d12 - d12 != null)
return 21;
if (!check_is_expected_v (d12 - d14, 3))
return 22;
if (!check_is_expected_v (d12 - d24, 3))
return 23;
if (!check_is_expected_v (d14 - d12, 5))
return 24;
if (d14 - d14 != null)
return 25;
if (!check_is_expected_v (d14 - d24, 5))
return 26;
if (!check_is_expected_v (d24 - d12, 6))
return 27;
if (!check_is_expected_v (d24 - d14, 6))
return 28;
if (d24 - d24 != null)
return 29;
SimpleDelegate d124 = d1 + d2 + d4;
if (!check_is_expected_v (d124 - d1, 6))
return 31;
if (!check_is_expected_v (d124 - d2, 5))
return 32;
if (!check_is_expected_v (d124 - d4, 3))
return 33;
if (!check_is_expected_v (d124 - d12, 4))
return 34;
if (!check_is_expected_v (d124 - d14, 7))
return 35;
if (!check_is_expected_v (d124 - d24, 1))
return 36;
if (d124 - d124 != null)
return 37;
SimpleDelegate d1248 = d1 + d2 + d4 + d8;
if (!check_is_expected_v (d1248 - (d1 + d2), 12))
return 41;
if (!check_is_expected_v (d1248 - (d1 + d4), 15))
return 42;
if (!check_is_expected_v (d1248 - (d1 + d8), 15))
return 43;
if (!check_is_expected_v (d1248 - (d2 + d4), 9))
return 44;
if (!check_is_expected_v (d1248 - (d2 + d8), 15))
return 45;
if (!check_is_expected_v (d1248 - (d4 + d8), 3))
return 46;
if (!check_is_expected_v (d1248 - (d1 + d2 + d4), 8))
return 51;
if (!check_is_expected_v (d1248 - (d1 + d2 + d8), 15))
return 52;
if (!check_is_expected_v (d1248 - (d1 + d4 + d8), 15))
return 53;
if (!check_is_expected_v (d1248 - (d2 + d4 + d8), 1))
return 54;
if (!check_is_expected_v (d1248 - (d2 + d4 + d8), 1))
return 54;
if (d1248 - d1248 != null)
return 55;
return 0;
}
// Regression test for bug #50366
static public int test_0_delegate_equality () {
if (new SimpleDelegate (F1) == new SimpleDelegate (F1))
return 0;
else
return 1;
}
}
| using System;
using System.Runtime.InteropServices;
class Tests {
delegate void SimpleDelegate ();
static void F1 () {
v += 1;
Console.WriteLine ("Test.F1");
}
static void F2 () {
v += 2;
Console.WriteLine ("Test.F2");
}
static void F4 () {
v += 4;
Console.WriteLine ("Test.F4");
}
static void F8 () {
v += 8;
Console.WriteLine ("Test.F8");
}
public static int Main () {
return TestDriver.RunTests (typeof (Tests));
}
static int v = 0;
static bool check_is_expected_v (SimpleDelegate d, int expected_v)
{
v = 0;
d ();
return v == expected_v;
}
static public int test_0_test () {
SimpleDelegate d1 = new SimpleDelegate (F1);
SimpleDelegate d2 = new SimpleDelegate (F2);
SimpleDelegate d4 = new SimpleDelegate (F4);
SimpleDelegate d8 = new SimpleDelegate (F8);
if (d1 - d1 != null)
return 1;
if (!check_is_expected_v (d1 - d2, 1))
return 2;
if (!check_is_expected_v (d1 - d4, 1))
return 3;
if (!check_is_expected_v (d2 - d1, 2))
return 4;
if (d2 - d2 != null)
return 5;
if (!check_is_expected_v (d2 - d4, 2))
return 6;
if (!check_is_expected_v (d4 - d1, 4))
return 7;
if (!check_is_expected_v (d4 - d2, 4))
return 8;
if (d4 - d4 != null)
return 9;
SimpleDelegate d12 = d1 + d2;
SimpleDelegate d14 = d1 + d4;
SimpleDelegate d24 = d2 + d4;
if (!check_is_expected_v (d12 - d1, 2))
return 11;
if (!check_is_expected_v (d12 - d2, 1))
return 12;
if (!check_is_expected_v (d12 - d4, 3))
return 13;
if (!check_is_expected_v (d14 - d1, 4))
return 14;
if (!check_is_expected_v (d14 - d2, 5))
return 15;
if (!check_is_expected_v (d14 - d4, 1))
return 16;
if (!check_is_expected_v (d14 - d1, 4))
return 17;
if (!check_is_expected_v (d14 - d2, 5))
return 18;
if (!check_is_expected_v (d14 - d4, 1))
return 19;
if (d12 - d12 != null)
return 21;
if (!check_is_expected_v (d12 - d14, 3))
return 22;
if (!check_is_expected_v (d12 - d24, 3))
return 23;
if (!check_is_expected_v (d14 - d12, 5))
return 24;
if (d14 - d14 != null)
return 25;
if (!check_is_expected_v (d14 - d24, 5))
return 26;
if (!check_is_expected_v (d24 - d12, 6))
return 27;
if (!check_is_expected_v (d24 - d14, 6))
return 28;
if (d24 - d24 != null)
return 29;
SimpleDelegate d124 = d1 + d2 + d4;
if (!check_is_expected_v (d124 - d1, 6))
return 31;
if (!check_is_expected_v (d124 - d2, 5))
return 32;
if (!check_is_expected_v (d124 - d4, 3))
return 33;
if (!check_is_expected_v (d124 - d12, 4))
return 34;
if (!check_is_expected_v (d124 - d14, 7))
return 35;
if (!check_is_expected_v (d124 - d24, 1))
return 36;
if (d124 - d124 != null)
return 37;
SimpleDelegate d1248 = d1 + d2 + d4 + d8;
if (!check_is_expected_v (d1248 - (d1 + d2), 12))
return 41;
if (!check_is_expected_v (d1248 - (d1 + d4), 15))
return 42;
if (!check_is_expected_v (d1248 - (d1 + d8), 15))
return 43;
if (!check_is_expected_v (d1248 - (d2 + d4), 9))
return 44;
if (!check_is_expected_v (d1248 - (d2 + d8), 15))
return 45;
if (!check_is_expected_v (d1248 - (d4 + d8), 3))
return 46;
if (!check_is_expected_v (d1248 - (d1 + d2 + d4), 8))
return 51;
if (!check_is_expected_v (d1248 - (d1 + d2 + d8), 15))
return 52;
if (!check_is_expected_v (d1248 - (d1 + d4 + d8), 15))
return 53;
if (!check_is_expected_v (d1248 - (d2 + d4 + d8), 1))
return 54;
if (!check_is_expected_v (d1248 - (d2 + d4 + d8), 1))
return 54;
if (d1248 - d1248 != null)
return 55;
return 0;
}
// Regression test for bug #50366
static public int test_0_delegate_equality () {
if (new SimpleDelegate (F1) == new SimpleDelegate (F1))
return 0;
else
return 1;
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Data.Common/ref/System.Data.Common.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.Data
{
public enum AcceptRejectRule
{
None = 0,
Cascade = 1,
}
[System.FlagsAttribute]
public enum CommandBehavior
{
Default = 0,
SingleResult = 1,
SchemaOnly = 2,
KeyInfo = 4,
SingleRow = 8,
SequentialAccess = 16,
CloseConnection = 32,
}
public enum CommandType
{
Text = 1,
StoredProcedure = 4,
TableDirect = 512,
}
public enum ConflictOption
{
CompareAllSearchableValues = 1,
CompareRowVersion = 2,
OverwriteChanges = 3,
}
[System.FlagsAttribute]
public enum ConnectionState
{
Closed = 0,
Open = 1,
Connecting = 2,
Executing = 4,
Fetching = 8,
Broken = 16,
}
[System.ComponentModel.DefaultPropertyAttribute("ConstraintName")]
public abstract partial class Constraint
{
internal Constraint() { }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public virtual string ConstraintName { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.PropertyCollection ExtendedProperties { get { throw null; } }
public abstract System.Data.DataTable? Table { get; }
[System.CLSCompliantAttribute(false)]
protected virtual System.Data.DataSet? _DataSet { get { throw null; } }
protected void CheckStateForProperty() { }
protected internal void SetDataSet(System.Data.DataSet dataSet) { }
public override string ToString() { throw null; }
}
[System.ComponentModel.DefaultEventAttribute("CollectionChanged")]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.ConstraintsCollectionEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public sealed partial class ConstraintCollection : System.Data.InternalDataCollectionBase
{
internal ConstraintCollection() { }
public System.Data.Constraint this[int index] { get { throw null; } }
public System.Data.Constraint? this[string? name] { get { throw null; } }
protected override System.Collections.ArrayList List { get { throw null; } }
public event System.ComponentModel.CollectionChangeEventHandler? CollectionChanged { add { } remove { } }
public void Add(System.Data.Constraint constraint) { }
public System.Data.Constraint Add(string? name, System.Data.DataColumn column, bool primaryKey) { throw null; }
public System.Data.Constraint Add(string? name, System.Data.DataColumn primaryKeyColumn, System.Data.DataColumn foreignKeyColumn) { throw null; }
public System.Data.Constraint Add(string? name, System.Data.DataColumn[] columns, bool primaryKey) { throw null; }
public System.Data.Constraint Add(string? name, System.Data.DataColumn[] primaryKeyColumns, System.Data.DataColumn[] foreignKeyColumns) { throw null; }
public void AddRange(System.Data.Constraint[]? constraints) { }
public bool CanRemove(System.Data.Constraint constraint) { throw null; }
public void Clear() { }
public bool Contains(string? name) { throw null; }
public void CopyTo(System.Data.Constraint[] array, int index) { }
public int IndexOf(System.Data.Constraint? constraint) { throw null; }
public int IndexOf(string? constraintName) { throw null; }
public void Remove(System.Data.Constraint constraint) { }
public void Remove(string name) { }
public void RemoveAt(int index) { }
}
public partial class ConstraintException : System.Data.DataException
{
public ConstraintException() { }
protected ConstraintException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public ConstraintException(string? s) { }
public ConstraintException(string? message, System.Exception? innerException) { }
}
[System.ComponentModel.DefaultPropertyAttribute("ColumnName")]
[System.ComponentModel.DesignTimeVisibleAttribute(false)]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.DataColumnEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.ToolboxItemAttribute(false)]
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
public partial class DataColumn : System.ComponentModel.MarshalByValueComponent
{
public DataColumn() { }
public DataColumn(string? columnName) { }
public DataColumn(string? columnName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type dataType) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types or types used in expressions may be trimmed if not referenced directly.")]
public DataColumn(string? columnName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type dataType, string? expr) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types or types used in expressions may be trimmed if not referenced directly.")]
public DataColumn(string? columnName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type dataType, string? expr, System.Data.MappingType type) { }
[System.ComponentModel.DefaultValueAttribute(true)]
public bool AllowDBNull { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(false)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public bool AutoIncrement { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute((long)0)]
public long AutoIncrementSeed { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute((long)1)]
public long AutoIncrementStep { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Caption { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(System.Data.MappingType.Element)]
public virtual System.Data.MappingType ColumnMapping { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string ColumnName { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(System.Data.DataSetDateTime.UnspecifiedLocal)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public System.Data.DataSetDateTime DateTimeMode { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Expression { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from types used in the expressions may be trimmed if not referenced directly.")] set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.PropertyCollection ExtendedProperties { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute(-1)]
public int MaxLength { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Namespace { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public int Ordinal { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Prefix { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(false)]
public bool ReadOnly { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.DataTable? Table { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public bool Unique { get { throw null; } set { } }
protected internal void CheckNotAllowNull() { }
protected void CheckUnique() { }
protected virtual void OnPropertyChanging(System.ComponentModel.PropertyChangedEventArgs pcevent) { }
protected internal void RaisePropertyChanging(string name) { }
public void SetOrdinal(int ordinal) { }
public override string ToString() { throw null; }
}
public partial class DataColumnChangeEventArgs : System.EventArgs
{
public DataColumnChangeEventArgs(System.Data.DataRow row, System.Data.DataColumn? column, object? value) { }
public System.Data.DataColumn? Column { get { throw null; } }
public object? ProposedValue { get { throw null; } set { } }
public System.Data.DataRow Row { get { throw null; } }
}
public delegate void DataColumnChangeEventHandler(object sender, System.Data.DataColumnChangeEventArgs e);
[System.ComponentModel.DefaultEventAttribute("CollectionChanged")]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.ColumnsCollectionEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public sealed partial class DataColumnCollection : System.Data.InternalDataCollectionBase
{
internal DataColumnCollection() { }
public System.Data.DataColumn this[int index] { get { throw null; } }
public System.Data.DataColumn? this[string name] { get { throw null; } }
protected override System.Collections.ArrayList List { get { throw null; } }
public event System.ComponentModel.CollectionChangeEventHandler? CollectionChanged { add { } remove { } }
public System.Data.DataColumn Add() { throw null; }
public void Add(System.Data.DataColumn column) { }
public System.Data.DataColumn Add(string? columnName) { throw null; }
public System.Data.DataColumn Add(string? columnName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type type) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members might be trimmed for some data types or expressions.")]
public System.Data.DataColumn Add(string? columnName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type type, string expression) { throw null; }
public void AddRange(System.Data.DataColumn[] columns) { }
public bool CanRemove(System.Data.DataColumn? column) { throw null; }
public void Clear() { }
public bool Contains(string name) { throw null; }
public void CopyTo(System.Data.DataColumn[] array, int index) { }
public int IndexOf(System.Data.DataColumn? column) { throw null; }
public int IndexOf(string? columnName) { throw null; }
public void Remove(System.Data.DataColumn column) { }
public void Remove(string name) { }
public void RemoveAt(int index) { }
}
public partial class DataException : System.SystemException
{
public DataException() { }
protected DataException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public DataException(string? s) { }
public DataException(string? s, System.Exception? innerException) { }
}
public static partial class DataReaderExtensions
{
public static bool GetBoolean(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static byte GetByte(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static long GetBytes(this System.Data.Common.DbDataReader reader, string name, long dataOffset, byte[] buffer, int bufferOffset, int length) { throw null; }
public static char GetChar(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static long GetChars(this System.Data.Common.DbDataReader reader, string name, long dataOffset, char[] buffer, int bufferOffset, int length) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static System.Data.Common.DbDataReader GetData(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static string GetDataTypeName(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static System.DateTime GetDateTime(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static decimal GetDecimal(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static double GetDouble(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static System.Type GetFieldType(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static System.Threading.Tasks.Task<T> GetFieldValueAsync<T>(this System.Data.Common.DbDataReader reader, string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public static T GetFieldValue<T>(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static float GetFloat(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static System.Guid GetGuid(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static short GetInt16(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static int GetInt32(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static long GetInt64(this System.Data.Common.DbDataReader reader, string name) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static System.Type GetProviderSpecificFieldType(this System.Data.Common.DbDataReader reader, string name) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static object GetProviderSpecificValue(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static System.IO.Stream GetStream(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static string GetString(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static System.IO.TextReader GetTextReader(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static object GetValue(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static bool IsDBNull(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static System.Threading.Tasks.Task<bool> IsDBNullAsync(this System.Data.Common.DbDataReader reader, string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
[System.ComponentModel.DefaultPropertyAttribute("RelationName")]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.DataRelationEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public partial class DataRelation
{
public DataRelation(string? relationName, System.Data.DataColumn parentColumn, System.Data.DataColumn childColumn) { }
public DataRelation(string? relationName, System.Data.DataColumn parentColumn, System.Data.DataColumn childColumn, bool createConstraints) { }
public DataRelation(string? relationName, System.Data.DataColumn[] parentColumns, System.Data.DataColumn[] childColumns) { }
public DataRelation(string? relationName, System.Data.DataColumn[] parentColumns, System.Data.DataColumn[] childColumns, bool createConstraints) { }
[System.ComponentModel.BrowsableAttribute(false)]
public DataRelation(string relationName, string? parentTableName, string? parentTableNamespace, string? childTableName, string? childTableNamespace, string[]? parentColumnNames, string[]? childColumnNames, bool nested) { }
[System.ComponentModel.BrowsableAttribute(false)]
public DataRelation(string relationName, string? parentTableName, string? childTableName, string[]? parentColumnNames, string[]? childColumnNames, bool nested) { }
public virtual System.Data.DataColumn[] ChildColumns { get { throw null; } }
public virtual System.Data.ForeignKeyConstraint? ChildKeyConstraint { get { throw null; } }
public virtual System.Data.DataTable ChildTable { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public virtual System.Data.DataSet? DataSet { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.PropertyCollection ExtendedProperties { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute(false)]
public virtual bool Nested { get { throw null; } set { } }
public virtual System.Data.DataColumn[] ParentColumns { get { throw null; } }
public virtual System.Data.UniqueConstraint? ParentKeyConstraint { get { throw null; } }
public virtual System.Data.DataTable ParentTable { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public virtual string RelationName { get { throw null; } set { } }
protected void CheckStateForProperty() { }
protected internal void OnPropertyChanging(System.ComponentModel.PropertyChangedEventArgs pcevent) { }
protected internal void RaisePropertyChanging(string name) { }
public override string ToString() { throw null; }
}
[System.ComponentModel.DefaultEventAttribute("CollectionChanged")]
[System.ComponentModel.DefaultPropertyAttribute("Table")]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.DataRelationCollectionEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public abstract partial class DataRelationCollection : System.Data.InternalDataCollectionBase
{
protected DataRelationCollection() { }
public abstract System.Data.DataRelation this[int index] { get; }
public abstract System.Data.DataRelation? this[string? name] { get; }
public event System.ComponentModel.CollectionChangeEventHandler? CollectionChanged { add { } remove { } }
public virtual System.Data.DataRelation Add(System.Data.DataColumn parentColumn, System.Data.DataColumn childColumn) { throw null; }
public virtual System.Data.DataRelation Add(System.Data.DataColumn[] parentColumns, System.Data.DataColumn[] childColumns) { throw null; }
public void Add(System.Data.DataRelation relation) { }
public virtual System.Data.DataRelation Add(string? name, System.Data.DataColumn parentColumn, System.Data.DataColumn childColumn) { throw null; }
public virtual System.Data.DataRelation Add(string? name, System.Data.DataColumn parentColumn, System.Data.DataColumn childColumn, bool createConstraints) { throw null; }
public virtual System.Data.DataRelation Add(string? name, System.Data.DataColumn[] parentColumns, System.Data.DataColumn[] childColumns) { throw null; }
public virtual System.Data.DataRelation Add(string? name, System.Data.DataColumn[] parentColumns, System.Data.DataColumn[] childColumns, bool createConstraints) { throw null; }
protected virtual void AddCore(System.Data.DataRelation relation) { }
public virtual void AddRange(System.Data.DataRelation[]? relations) { }
public virtual bool CanRemove(System.Data.DataRelation? relation) { throw null; }
public virtual void Clear() { }
public virtual bool Contains(string? name) { throw null; }
public void CopyTo(System.Data.DataRelation[] array, int index) { }
protected abstract System.Data.DataSet GetDataSet();
public virtual int IndexOf(System.Data.DataRelation? relation) { throw null; }
public virtual int IndexOf(string? relationName) { throw null; }
protected virtual void OnCollectionChanged(System.ComponentModel.CollectionChangeEventArgs ccevent) { }
protected virtual void OnCollectionChanging(System.ComponentModel.CollectionChangeEventArgs ccevent) { }
public void Remove(System.Data.DataRelation relation) { }
public void Remove(string name) { }
public void RemoveAt(int index) { }
protected virtual void RemoveCore(System.Data.DataRelation relation) { }
}
public partial class DataRow
{
protected internal DataRow(System.Data.DataRowBuilder builder) { }
public bool HasErrors { get { throw null; } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public object this[System.Data.DataColumn column] { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public object this[System.Data.DataColumn column, System.Data.DataRowVersion version] { get { throw null; } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public object this[int columnIndex] { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public object this[int columnIndex, System.Data.DataRowVersion version] { get { throw null; } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public object this[string columnName] { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public object this[string columnName, System.Data.DataRowVersion version] { get { throw null; } }
public object?[] ItemArray { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string RowError { get { throw null; } set { } }
public System.Data.DataRowState RowState { get { throw null; } }
public System.Data.DataTable Table { get { throw null; } }
public void AcceptChanges() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public void BeginEdit() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public void CancelEdit() { }
public void ClearErrors() { }
public void Delete() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public void EndEdit() { }
public System.Data.DataRow[] GetChildRows(System.Data.DataRelation? relation) { throw null; }
public System.Data.DataRow[] GetChildRows(System.Data.DataRelation? relation, System.Data.DataRowVersion version) { throw null; }
public System.Data.DataRow[] GetChildRows(string? relationName) { throw null; }
public System.Data.DataRow[] GetChildRows(string? relationName, System.Data.DataRowVersion version) { throw null; }
public string GetColumnError(System.Data.DataColumn column) { throw null; }
public string GetColumnError(int columnIndex) { throw null; }
public string GetColumnError(string columnName) { throw null; }
public System.Data.DataColumn[] GetColumnsInError() { throw null; }
public System.Data.DataRow? GetParentRow(System.Data.DataRelation? relation) { throw null; }
public System.Data.DataRow? GetParentRow(System.Data.DataRelation? relation, System.Data.DataRowVersion version) { throw null; }
public System.Data.DataRow? GetParentRow(string? relationName) { throw null; }
public System.Data.DataRow? GetParentRow(string? relationName, System.Data.DataRowVersion version) { throw null; }
public System.Data.DataRow[] GetParentRows(System.Data.DataRelation? relation) { throw null; }
public System.Data.DataRow[] GetParentRows(System.Data.DataRelation? relation, System.Data.DataRowVersion version) { throw null; }
public System.Data.DataRow[] GetParentRows(string? relationName) { throw null; }
public System.Data.DataRow[] GetParentRows(string? relationName, System.Data.DataRowVersion version) { throw null; }
public bool HasVersion(System.Data.DataRowVersion version) { throw null; }
public bool IsNull(System.Data.DataColumn column) { throw null; }
public bool IsNull(System.Data.DataColumn column, System.Data.DataRowVersion version) { throw null; }
public bool IsNull(int columnIndex) { throw null; }
public bool IsNull(string columnName) { throw null; }
public void RejectChanges() { }
public void SetAdded() { }
public void SetColumnError(System.Data.DataColumn column, string? error) { }
public void SetColumnError(int columnIndex, string? error) { }
public void SetColumnError(string columnName, string? error) { }
public void SetModified() { }
protected void SetNull(System.Data.DataColumn column) { }
public void SetParentRow(System.Data.DataRow? parentRow) { }
public void SetParentRow(System.Data.DataRow? parentRow, System.Data.DataRelation? relation) { }
}
[System.FlagsAttribute]
public enum DataRowAction
{
Nothing = 0,
Delete = 1,
Change = 2,
Rollback = 4,
Commit = 8,
Add = 16,
ChangeOriginal = 32,
ChangeCurrentAndOriginal = 64,
}
public sealed partial class DataRowBuilder
{
internal DataRowBuilder() { }
}
public partial class DataRowChangeEventArgs : System.EventArgs
{
public DataRowChangeEventArgs(System.Data.DataRow row, System.Data.DataRowAction action) { }
public System.Data.DataRowAction Action { get { throw null; } }
public System.Data.DataRow Row { get { throw null; } }
}
public delegate void DataRowChangeEventHandler(object sender, System.Data.DataRowChangeEventArgs e);
public sealed partial class DataRowCollection : System.Data.InternalDataCollectionBase
{
internal DataRowCollection() { }
public override int Count { get { throw null; } }
public System.Data.DataRow this[int index] { get { throw null; } }
public void Add(System.Data.DataRow row) { }
public System.Data.DataRow Add(params object?[] values) { throw null; }
public void Clear() { }
public bool Contains(object? key) { throw null; }
public bool Contains(object?[] keys) { throw null; }
public override void CopyTo(System.Array ar, int index) { }
public void CopyTo(System.Data.DataRow[] array, int index) { }
public System.Data.DataRow? Find(object? key) { throw null; }
public System.Data.DataRow? Find(object?[] keys) { throw null; }
public override System.Collections.IEnumerator GetEnumerator() { throw null; }
public int IndexOf(System.Data.DataRow? row) { throw null; }
public void InsertAt(System.Data.DataRow row, int pos) { }
public void Remove(System.Data.DataRow row) { }
public void RemoveAt(int index) { }
}
public static partial class DataRowComparer
{
public static System.Data.DataRowComparer<System.Data.DataRow> Default { get { throw null; } }
}
public sealed partial class DataRowComparer<TRow> : System.Collections.Generic.IEqualityComparer<TRow> where TRow : System.Data.DataRow
{
internal DataRowComparer() { }
public static System.Data.DataRowComparer<TRow> Default { get { throw null; } }
public bool Equals(TRow? leftRow, TRow? rightRow) { throw null; }
public int GetHashCode(TRow row) { throw null; }
}
public static partial class DataRowExtensions
{
public static T? Field<T>(this System.Data.DataRow row, System.Data.DataColumn column) { throw null; }
public static T? Field<T>(this System.Data.DataRow row, System.Data.DataColumn column, System.Data.DataRowVersion version) { throw null; }
public static T? Field<T>(this System.Data.DataRow row, int columnIndex) { throw null; }
public static T? Field<T>(this System.Data.DataRow row, int columnIndex, System.Data.DataRowVersion version) { throw null; }
public static T? Field<T>(this System.Data.DataRow row, string columnName) { throw null; }
public static T? Field<T>(this System.Data.DataRow row, string columnName, System.Data.DataRowVersion version) { throw null; }
public static void SetField<T>(this System.Data.DataRow row, System.Data.DataColumn column, T? value) { }
public static void SetField<T>(this System.Data.DataRow row, int columnIndex, T? value) { }
public static void SetField<T>(this System.Data.DataRow row, string columnName, T? value) { }
}
[System.FlagsAttribute]
public enum DataRowState
{
Detached = 1,
Unchanged = 2,
Added = 4,
Deleted = 8,
Modified = 16,
}
public enum DataRowVersion
{
Original = 256,
Current = 512,
Proposed = 1024,
Default = 1536,
}
public partial class DataRowView : System.ComponentModel.ICustomTypeDescriptor, System.ComponentModel.IDataErrorInfo, System.ComponentModel.IEditableObject, System.ComponentModel.INotifyPropertyChanged
{
internal DataRowView() { }
public System.Data.DataView DataView { get { throw null; } }
public bool IsEdit { get { throw null; } }
public bool IsNew { get { throw null; } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public object this[int ndx] { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public object this[string property] { get { throw null; } set { } }
public System.Data.DataRow Row { get { throw null; } }
public System.Data.DataRowVersion RowVersion { get { throw null; } }
string System.ComponentModel.IDataErrorInfo.Error { get { throw null; } }
string System.ComponentModel.IDataErrorInfo.this[string colName] { get { throw null; } }
public event System.ComponentModel.PropertyChangedEventHandler? PropertyChanged { add { } remove { } }
public void BeginEdit() { }
public void CancelEdit() { }
public System.Data.DataView CreateChildView(System.Data.DataRelation relation) { throw null; }
public System.Data.DataView CreateChildView(System.Data.DataRelation relation, bool followParent) { throw null; }
public System.Data.DataView CreateChildView(string relationName) { throw null; }
public System.Data.DataView CreateChildView(string relationName, bool followParent) { throw null; }
public void Delete() { }
public void EndEdit() { }
public override bool Equals(object? other) { throw null; }
public override int GetHashCode() { throw null; }
System.ComponentModel.AttributeCollection System.ComponentModel.ICustomTypeDescriptor.GetAttributes() { throw null; }
string System.ComponentModel.ICustomTypeDescriptor.GetClassName() { throw null; }
string System.ComponentModel.ICustomTypeDescriptor.GetComponentName() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
System.ComponentModel.TypeConverter System.ComponentModel.ICustomTypeDescriptor.GetConverter() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
System.ComponentModel.EventDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultEvent() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")]
System.ComponentModel.PropertyDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultProperty() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")]
object System.ComponentModel.ICustomTypeDescriptor.GetEditor(System.Type editorBaseType) { throw null; }
System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents(System.Attribute[]? attributes) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")]
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties(System.Attribute[]? attributes) { throw null; }
object System.ComponentModel.ICustomTypeDescriptor.GetPropertyOwner(System.ComponentModel.PropertyDescriptor? pd) { throw null; }
}
[System.ComponentModel.DefaultPropertyAttribute("DataSetName")]
[System.ComponentModel.DesignerAttribute("Microsoft.VSDesigner.Data.VS.DataSetDesigner, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.ToolboxItemAttribute("Microsoft.VSDesigner.Data.VS.DataSetToolboxItem, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.Xml.Serialization.XmlRootAttribute("DataSet")]
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetDataSetSchema")]
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors)]
public partial class DataSet : System.ComponentModel.MarshalByValueComponent, System.ComponentModel.IListSource, System.ComponentModel.ISupportInitialize, System.ComponentModel.ISupportInitializeNotification, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
{
public DataSet() { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected DataSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected DataSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context, bool ConstructSchema) { }
public DataSet(string dataSetName) { }
[System.ComponentModel.DefaultValueAttribute(false)]
public bool CaseSensitive { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
public string DataSetName { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.DataViewManager DefaultViewManager { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute(true)]
public bool EnforceConstraints { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.PropertyCollection ExtendedProperties { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool HasErrors { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool IsInitialized { get { throw null; } }
public System.Globalization.CultureInfo Locale { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Namespace { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Prefix { get { throw null; } set { } }
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
public System.Data.DataRelationCollection Relations { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute(System.Data.SerializationFormat.Xml)]
public System.Data.SerializationFormat RemotingFormat { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public virtual System.Data.SchemaSerializationMode SchemaSerializationMode { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public override System.ComponentModel.ISite? Site { get { throw null; } set { } }
bool System.ComponentModel.IListSource.ContainsListCollection { get { throw null; } }
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
public System.Data.DataTableCollection Tables { get { throw null; } }
public event System.EventHandler? Initialized { add { } remove { } }
public event System.Data.MergeFailedEventHandler? MergeFailed { add { } remove { } }
public void AcceptChanges() { }
public void BeginInit() { }
public void Clear() { }
public virtual System.Data.DataSet Clone() { throw null; }
public System.Data.DataSet Copy() { throw null; }
public System.Data.DataTableReader CreateDataReader() { throw null; }
public System.Data.DataTableReader CreateDataReader(params System.Data.DataTable[] dataTables) { throw null; }
protected System.Data.SchemaSerializationMode DetermineSchemaSerializationMode(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { throw null; }
protected System.Data.SchemaSerializationMode DetermineSchemaSerializationMode(System.Xml.XmlReader reader) { throw null; }
public void EndInit() { }
public System.Data.DataSet? GetChanges() { throw null; }
public System.Data.DataSet? GetChanges(System.Data.DataRowState rowStates) { throw null; }
public static System.Xml.Schema.XmlSchemaComplexType GetDataSetSchema(System.Xml.Schema.XmlSchemaSet? schemaSet) { throw null; }
public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
protected virtual System.Xml.Schema.XmlSchema? GetSchemaSerializable() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected void GetSerializationData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public string GetXml() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public string GetXmlSchema() { throw null; }
public bool HasChanges() { throw null; }
public bool HasChanges(System.Data.DataRowState rowStates) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void InferXmlSchema(System.IO.Stream? stream, string[]? nsArray) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void InferXmlSchema(System.IO.TextReader? reader, string[]? nsArray) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void InferXmlSchema(string fileName, string[]? nsArray) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void InferXmlSchema(System.Xml.XmlReader? reader, string[]? nsArray) { }
protected virtual void InitializeDerivedDataSet() { }
protected bool IsBinarySerialized(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Using LoadOption may cause members from types used in the expression column to be trimmed if not referenced directly.")]
public void Load(System.Data.IDataReader reader, System.Data.LoadOption loadOption, params System.Data.DataTable[] tables) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Using LoadOption may cause members from types used in the expression column to be trimmed if not referenced directly.")]
public virtual void Load(System.Data.IDataReader reader, System.Data.LoadOption loadOption, System.Data.FillErrorEventHandler? errorHandler, params System.Data.DataTable[] tables) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Using LoadOption may cause members from types used in the expression column to be trimmed if not referenced directly.")]
public void Load(System.Data.IDataReader reader, System.Data.LoadOption loadOption, params string[] tables) { }
public void Merge(System.Data.DataRow[] rows) { }
public void Merge(System.Data.DataRow[] rows, bool preserveChanges, System.Data.MissingSchemaAction missingSchemaAction) { }
public void Merge(System.Data.DataSet dataSet) { }
public void Merge(System.Data.DataSet dataSet, bool preserveChanges) { }
public void Merge(System.Data.DataSet dataSet, bool preserveChanges, System.Data.MissingSchemaAction missingSchemaAction) { }
public void Merge(System.Data.DataTable table) { }
public void Merge(System.Data.DataTable table, bool preserveChanges, System.Data.MissingSchemaAction missingSchemaAction) { }
protected virtual void OnPropertyChanging(System.ComponentModel.PropertyChangedEventArgs pcevent) { }
protected virtual void OnRemoveRelation(System.Data.DataRelation relation) { }
protected internal virtual void OnRemoveTable(System.Data.DataTable table) { }
protected internal void RaisePropertyChanging(string name) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(System.IO.Stream? stream) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(System.IO.Stream? stream, System.Data.XmlReadMode mode) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(System.IO.TextReader? reader) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(System.IO.TextReader? reader, System.Data.XmlReadMode mode) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(string fileName) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(string fileName, System.Data.XmlReadMode mode) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(System.Xml.XmlReader? reader) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(System.Xml.XmlReader? reader, System.Data.XmlReadMode mode) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void ReadXmlSchema(System.IO.Stream? stream) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void ReadXmlSchema(System.IO.TextReader? reader) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void ReadXmlSchema(string fileName) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void ReadXmlSchema(System.Xml.XmlReader? reader) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected virtual void ReadXmlSerializable(System.Xml.XmlReader reader) { }
public virtual void RejectChanges() { }
public virtual void Reset() { }
protected virtual bool ShouldSerializeRelations() { throw null; }
protected virtual bool ShouldSerializeTables() { throw null; }
System.Collections.IList System.ComponentModel.IListSource.GetList() { throw null; }
System.Xml.Schema.XmlSchema System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.Stream? stream) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.Stream? stream, System.Data.XmlWriteMode mode) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.TextWriter? writer) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.TextWriter? writer, System.Data.XmlWriteMode mode) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(string fileName) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(string fileName, System.Data.XmlWriteMode mode) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.Xml.XmlWriter? writer) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.Xml.XmlWriter? writer, System.Data.XmlWriteMode mode) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.IO.Stream? stream) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.IO.Stream? stream, System.Converter<System.Type, string> multipleTargetConverter) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.IO.TextWriter? writer) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.IO.TextWriter? writer, System.Converter<System.Type, string> multipleTargetConverter) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(string fileName) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(string fileName, System.Converter<System.Type, string> multipleTargetConverter) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.Xml.XmlWriter? writer) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.Xml.XmlWriter? writer, System.Converter<System.Type, string> multipleTargetConverter) { }
}
public enum DataSetDateTime
{
Local = 1,
Unspecified = 2,
UnspecifiedLocal = 3,
Utc = 4,
}
[System.AttributeUsageAttribute(System.AttributeTargets.All)]
[System.ObsoleteAttribute("DataSysDescriptionAttribute has been deprecated and is not supported.")]
public partial class DataSysDescriptionAttribute : System.ComponentModel.DescriptionAttribute
{
[System.ObsoleteAttribute("DataSysDescriptionAttribute has been deprecated and is not supported.")]
public DataSysDescriptionAttribute(string description) { }
public override string Description { get { throw null; } }
}
[System.ComponentModel.DefaultEventAttribute("RowChanging")]
[System.ComponentModel.DefaultPropertyAttribute("TableName")]
[System.ComponentModel.DesignTimeVisibleAttribute(false)]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.DataTableEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.ToolboxItemAttribute(false)]
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetDataTableSchema")]
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors)]
public partial class DataTable : System.ComponentModel.MarshalByValueComponent, System.ComponentModel.IListSource, System.ComponentModel.ISupportInitialize, System.ComponentModel.ISupportInitializeNotification, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
{
protected internal bool fInitInProgress;
public DataTable() { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected DataTable(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public DataTable(string? tableName) { }
public DataTable(string? tableName, string? tableNamespace) { }
public bool CaseSensitive { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.DataRelationCollection ChildRelations { get { throw null; } }
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
public System.Data.DataColumnCollection Columns { get { throw null; } }
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
public System.Data.ConstraintCollection Constraints { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.DataSet? DataSet { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.DataView DefaultView { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string DisplayExpression { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from types used in the expressions may be trimmed if not referenced directly.")] set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.PropertyCollection ExtendedProperties { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool HasErrors { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool IsInitialized { get { throw null; } }
public System.Globalization.CultureInfo Locale { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(50)]
public int MinimumCapacity { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Namespace { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.DataRelationCollection ParentRelations { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Prefix { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(System.Data.SerializationFormat.Xml)]
public System.Data.SerializationFormat RemotingFormat { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.DataRowCollection Rows { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public override System.ComponentModel.ISite? Site { get { throw null; } set { } }
bool System.ComponentModel.IListSource.ContainsListCollection { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string TableName { get { throw null; } set { } }
public event System.Data.DataColumnChangeEventHandler? ColumnChanged { add { } remove { } }
public event System.Data.DataColumnChangeEventHandler? ColumnChanging { add { } remove { } }
public event System.EventHandler? Initialized { add { } remove { } }
public event System.Data.DataRowChangeEventHandler? RowChanged { add { } remove { } }
public event System.Data.DataRowChangeEventHandler? RowChanging { add { } remove { } }
public event System.Data.DataRowChangeEventHandler? RowDeleted { add { } remove { } }
public event System.Data.DataRowChangeEventHandler? RowDeleting { add { } remove { } }
public event System.Data.DataTableClearEventHandler? TableCleared { add { } remove { } }
public event System.Data.DataTableClearEventHandler? TableClearing { add { } remove { } }
public event System.Data.DataTableNewRowEventHandler? TableNewRow { add { } remove { } }
public void AcceptChanges() { }
public virtual void BeginInit() { }
public void BeginLoadData() { }
public void Clear() { }
public virtual System.Data.DataTable Clone() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter or expression might be trimmed.")]
public object Compute(string? expression, string? filter) { throw null; }
public System.Data.DataTable Copy() { throw null; }
public System.Data.DataTableReader CreateDataReader() { throw null; }
protected virtual System.Data.DataTable CreateInstance() { throw null; }
public virtual void EndInit() { }
public void EndLoadData() { }
public System.Data.DataTable? GetChanges() { throw null; }
public System.Data.DataTable? GetChanges(System.Data.DataRowState rowStates) { throw null; }
public static System.Xml.Schema.XmlSchemaComplexType GetDataTableSchema(System.Xml.Schema.XmlSchemaSet? schemaSet) { throw null; }
public System.Data.DataRow[] GetErrors() { throw null; }
public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
protected virtual System.Type GetRowType() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected virtual System.Xml.Schema.XmlSchema? GetSchema() { throw null; }
public void ImportRow(System.Data.DataRow? row) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from types used in the expression column to be trimmed if not referenced directly.")]
public void Load(System.Data.IDataReader reader) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Using LoadOption may cause members from types used in the expression column to be trimmed if not referenced directly.")]
public void Load(System.Data.IDataReader reader, System.Data.LoadOption loadOption) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Using LoadOption may cause members from types used in the expression column to be trimmed if not referenced directly.")]
public virtual void Load(System.Data.IDataReader reader, System.Data.LoadOption loadOption, System.Data.FillErrorEventHandler? errorHandler) { }
public System.Data.DataRow LoadDataRow(object?[] values, bool fAcceptChanges) { throw null; }
public System.Data.DataRow LoadDataRow(object?[] values, System.Data.LoadOption loadOption) { throw null; }
public void Merge(System.Data.DataTable table) { }
public void Merge(System.Data.DataTable table, bool preserveChanges) { }
public void Merge(System.Data.DataTable table, bool preserveChanges, System.Data.MissingSchemaAction missingSchemaAction) { }
public System.Data.DataRow NewRow() { throw null; }
protected internal System.Data.DataRow[] NewRowArray(int size) { throw null; }
protected virtual System.Data.DataRow NewRowFromBuilder(System.Data.DataRowBuilder builder) { throw null; }
protected internal virtual void OnColumnChanged(System.Data.DataColumnChangeEventArgs e) { }
protected internal virtual void OnColumnChanging(System.Data.DataColumnChangeEventArgs e) { }
protected virtual void OnPropertyChanging(System.ComponentModel.PropertyChangedEventArgs pcevent) { }
protected virtual void OnRemoveColumn(System.Data.DataColumn column) { }
protected virtual void OnRowChanged(System.Data.DataRowChangeEventArgs e) { }
protected virtual void OnRowChanging(System.Data.DataRowChangeEventArgs e) { }
protected virtual void OnRowDeleted(System.Data.DataRowChangeEventArgs e) { }
protected virtual void OnRowDeleting(System.Data.DataRowChangeEventArgs e) { }
protected virtual void OnTableCleared(System.Data.DataTableClearEventArgs e) { }
protected virtual void OnTableClearing(System.Data.DataTableClearEventArgs e) { }
protected virtual void OnTableNewRow(System.Data.DataTableNewRowEventArgs e) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(System.IO.Stream? stream) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(System.IO.TextReader? reader) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(string fileName) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(System.Xml.XmlReader? reader) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void ReadXmlSchema(System.IO.Stream? stream) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void ReadXmlSchema(System.IO.TextReader? reader) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void ReadXmlSchema(string fileName) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void ReadXmlSchema(System.Xml.XmlReader? reader) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected virtual void ReadXmlSerializable(System.Xml.XmlReader? reader) { }
public void RejectChanges() { }
public virtual void Reset() { }
public System.Data.DataRow[] Select() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")]
public System.Data.DataRow[] Select(string? filterExpression) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")]
public System.Data.DataRow[] Select(string? filterExpression, string? sort) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")]
public System.Data.DataRow[] Select(string? filterExpression, string? sort, System.Data.DataViewRowState recordStates) { throw null; }
System.Collections.IList System.ComponentModel.IListSource.GetList() { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public override string ToString() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.Stream? stream) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.Stream? stream, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.Stream? stream, System.Data.XmlWriteMode mode) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.Stream? stream, System.Data.XmlWriteMode mode, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.TextWriter? writer) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.TextWriter? writer, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.TextWriter? writer, System.Data.XmlWriteMode mode) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.TextWriter? writer, System.Data.XmlWriteMode mode, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(string fileName) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(string fileName, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(string fileName, System.Data.XmlWriteMode mode) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(string fileName, System.Data.XmlWriteMode mode, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.Xml.XmlWriter? writer) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.Xml.XmlWriter? writer, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.Xml.XmlWriter? writer, System.Data.XmlWriteMode mode) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.Xml.XmlWriter? writer, System.Data.XmlWriteMode mode, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.IO.Stream? stream) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.IO.Stream? stream, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.IO.TextWriter? writer) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.IO.TextWriter? writer, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(string fileName) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(string fileName, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.Xml.XmlWriter? writer) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.Xml.XmlWriter? writer, bool writeHierarchy) { }
}
public sealed partial class DataTableClearEventArgs : System.EventArgs
{
public DataTableClearEventArgs(System.Data.DataTable dataTable) { }
public System.Data.DataTable Table { get { throw null; } }
public string TableName { get { throw null; } }
public string TableNamespace { get { throw null; } }
}
public delegate void DataTableClearEventHandler(object sender, System.Data.DataTableClearEventArgs e);
[System.ComponentModel.DefaultEventAttribute("CollectionChanged")]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.TablesCollectionEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.ListBindableAttribute(false)]
public sealed partial class DataTableCollection : System.Data.InternalDataCollectionBase
{
internal DataTableCollection() { }
public System.Data.DataTable this[int index] { get { throw null; } }
public System.Data.DataTable? this[string? name] { get { throw null; } }
public System.Data.DataTable? this[string? name, string tableNamespace] { get { throw null; } }
protected override System.Collections.ArrayList List { get { throw null; } }
public event System.ComponentModel.CollectionChangeEventHandler? CollectionChanged { add { } remove { } }
public event System.ComponentModel.CollectionChangeEventHandler? CollectionChanging { add { } remove { } }
public System.Data.DataTable Add() { throw null; }
public void Add(System.Data.DataTable table) { }
public System.Data.DataTable Add(string? name) { throw null; }
public System.Data.DataTable Add(string? name, string? tableNamespace) { throw null; }
public void AddRange(System.Data.DataTable?[]? tables) { }
public bool CanRemove(System.Data.DataTable? table) { throw null; }
public void Clear() { }
public bool Contains(string? name) { throw null; }
public bool Contains(string name, string tableNamespace) { throw null; }
public void CopyTo(System.Data.DataTable[] array, int index) { }
public int IndexOf(System.Data.DataTable? table) { throw null; }
public int IndexOf(string? tableName) { throw null; }
public int IndexOf(string tableName, string tableNamespace) { throw null; }
public void Remove(System.Data.DataTable table) { }
public void Remove(string name) { }
public void Remove(string name, string tableNamespace) { }
public void RemoveAt(int index) { }
}
public static partial class DataTableExtensions
{
public static System.Data.DataView AsDataView(this System.Data.DataTable table) { throw null; }
public static System.Data.DataView AsDataView<T>(this System.Data.EnumerableRowCollection<T> source) where T : System.Data.DataRow { throw null; }
public static System.Data.EnumerableRowCollection<System.Data.DataRow> AsEnumerable(this System.Data.DataTable source) { throw null; }
public static System.Data.DataTable CopyToDataTable<T>(this System.Collections.Generic.IEnumerable<T> source) where T : System.Data.DataRow { throw null; }
public static void CopyToDataTable<T>(this System.Collections.Generic.IEnumerable<T> source, System.Data.DataTable table, System.Data.LoadOption options) where T : System.Data.DataRow { }
public static void CopyToDataTable<T>(this System.Collections.Generic.IEnumerable<T> source, System.Data.DataTable table, System.Data.LoadOption options, System.Data.FillErrorEventHandler? errorHandler) where T : System.Data.DataRow { }
}
public sealed partial class DataTableNewRowEventArgs : System.EventArgs
{
public DataTableNewRowEventArgs(System.Data.DataRow dataRow) { }
public System.Data.DataRow Row { get { throw null; } }
}
public delegate void DataTableNewRowEventHandler(object sender, System.Data.DataTableNewRowEventArgs e);
public sealed partial class DataTableReader : System.Data.Common.DbDataReader
{
public DataTableReader(System.Data.DataTable dataTable) { }
public DataTableReader(System.Data.DataTable[] dataTables) { }
public override int Depth { get { throw null; } }
public override int FieldCount { get { throw null; } }
public override bool HasRows { get { throw null; } }
public override bool IsClosed { get { throw null; } }
public override object this[int ordinal] { get { throw null; } }
public override object this[string name] { get { throw null; } }
public override int RecordsAffected { get { throw null; } }
public override void Close() { }
public override bool GetBoolean(int ordinal) { throw null; }
public override byte GetByte(int ordinal) { throw null; }
public override long GetBytes(int ordinal, long dataIndex, byte[]? buffer, int bufferIndex, int length) { throw null; }
public override char GetChar(int ordinal) { throw null; }
public override long GetChars(int ordinal, long dataIndex, char[]? buffer, int bufferIndex, int length) { throw null; }
public override string GetDataTypeName(int ordinal) { throw null; }
public override System.DateTime GetDateTime(int ordinal) { throw null; }
public override decimal GetDecimal(int ordinal) { throw null; }
public override double GetDouble(int ordinal) { throw null; }
public override System.Collections.IEnumerator GetEnumerator() { throw null; }
public override System.Type GetFieldType(int ordinal) { throw null; }
public override float GetFloat(int ordinal) { throw null; }
public override System.Guid GetGuid(int ordinal) { throw null; }
public override short GetInt16(int ordinal) { throw null; }
public override int GetInt32(int ordinal) { throw null; }
public override long GetInt64(int ordinal) { throw null; }
public override string GetName(int ordinal) { throw null; }
public override int GetOrdinal(string name) { throw null; }
public override System.Type GetProviderSpecificFieldType(int ordinal) { throw null; }
public override object GetProviderSpecificValue(int ordinal) { throw null; }
public override int GetProviderSpecificValues(object[] values) { throw null; }
public override System.Data.DataTable GetSchemaTable() { throw null; }
public override string GetString(int ordinal) { throw null; }
public override object GetValue(int ordinal) { throw null; }
public override int GetValues(object[] values) { throw null; }
public override bool IsDBNull(int ordinal) { throw null; }
public override bool NextResult() { throw null; }
public override bool Read() { throw null; }
}
[System.ComponentModel.DesignerAttribute("Microsoft.VSDesigner.Data.VS.DataViewDesigner, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.DefaultEventAttribute("PositionChanged")]
[System.ComponentModel.DefaultPropertyAttribute("Table")]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.DataSourceEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public partial class DataView : System.ComponentModel.MarshalByValueComponent, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.ComponentModel.IBindingList, System.ComponentModel.IBindingListView, System.ComponentModel.ISupportInitialize, System.ComponentModel.ISupportInitializeNotification, System.ComponentModel.ITypedList
{
public DataView() { }
public DataView(System.Data.DataTable? table) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")]
public DataView(System.Data.DataTable table, string? RowFilter, string? Sort, System.Data.DataViewRowState RowState) { }
[System.ComponentModel.DefaultValueAttribute(true)]
public bool AllowDelete { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(true)]
public bool AllowEdit { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(true)]
public bool AllowNew { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(false)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public bool ApplyDefaultSort { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public int Count { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.DataViewManager? DataViewManager { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool IsInitialized { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
protected bool IsOpen { get { throw null; } }
public System.Data.DataRowView this[int recordIndex] { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute("")]
public virtual string? RowFilter { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")] set { } }
[System.ComponentModel.DefaultValueAttribute(System.Data.DataViewRowState.CurrentRows)]
public System.Data.DataViewRowState RowStateFilter { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Sort { get { throw null; } set { } }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
bool System.Collections.IList.IsFixedSize { get { throw null; } }
bool System.Collections.IList.IsReadOnly { get { throw null; } }
object? System.Collections.IList.this[int recordIndex] { get { throw null; } set { } }
bool System.ComponentModel.IBindingList.AllowEdit { get { throw null; } }
bool System.ComponentModel.IBindingList.AllowNew { get { throw null; } }
bool System.ComponentModel.IBindingList.AllowRemove { get { throw null; } }
bool System.ComponentModel.IBindingList.IsSorted { get { throw null; } }
System.ComponentModel.ListSortDirection System.ComponentModel.IBindingList.SortDirection { get { throw null; } }
System.ComponentModel.PropertyDescriptor? System.ComponentModel.IBindingList.SortProperty { get { throw null; } }
bool System.ComponentModel.IBindingList.SupportsChangeNotification { get { throw null; } }
bool System.ComponentModel.IBindingList.SupportsSearching { get { throw null; } }
bool System.ComponentModel.IBindingList.SupportsSorting { get { throw null; } }
string? System.ComponentModel.IBindingListView.Filter { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")] set { } }
System.ComponentModel.ListSortDescriptionCollection System.ComponentModel.IBindingListView.SortDescriptions { get { throw null; } }
bool System.ComponentModel.IBindingListView.SupportsAdvancedSorting { get { throw null; } }
bool System.ComponentModel.IBindingListView.SupportsFiltering { get { throw null; } }
public event System.EventHandler? Initialized { add { } remove { } }
public event System.ComponentModel.ListChangedEventHandler? ListChanged { add { } remove { } }
public virtual System.Data.DataRowView AddNew() { throw null; }
public void BeginInit() { }
protected void Close() { }
protected virtual void ColumnCollectionChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e) { }
public void CopyTo(System.Array array, int index) { }
public void Delete(int index) { }
protected override void Dispose(bool disposing) { }
public void EndInit() { }
public virtual bool Equals(System.Data.DataView? view) { throw null; }
public int Find(object? key) { throw null; }
public int Find(object?[] key) { throw null; }
public System.Data.DataRowView[] FindRows(object? key) { throw null; }
public System.Data.DataRowView[] FindRows(object?[] key) { throw null; }
public System.Collections.IEnumerator GetEnumerator() { throw null; }
protected virtual void IndexListChanged(object sender, System.ComponentModel.ListChangedEventArgs e) { }
protected virtual void OnListChanged(System.ComponentModel.ListChangedEventArgs e) { }
protected void Open() { }
protected void Reset() { }
int System.Collections.IList.Add(object? value) { throw null; }
void System.Collections.IList.Clear() { }
bool System.Collections.IList.Contains(object? value) { throw null; }
int System.Collections.IList.IndexOf(object? value) { throw null; }
void System.Collections.IList.Insert(int index, object? value) { }
void System.Collections.IList.Remove(object? value) { }
void System.Collections.IList.RemoveAt(int index) { }
void System.ComponentModel.IBindingList.AddIndex(System.ComponentModel.PropertyDescriptor property) { }
object? System.ComponentModel.IBindingList.AddNew() { throw null; }
void System.ComponentModel.IBindingList.ApplySort(System.ComponentModel.PropertyDescriptor property, System.ComponentModel.ListSortDirection direction) { }
int System.ComponentModel.IBindingList.Find(System.ComponentModel.PropertyDescriptor property, object key) { throw null; }
void System.ComponentModel.IBindingList.RemoveIndex(System.ComponentModel.PropertyDescriptor property) { }
void System.ComponentModel.IBindingList.RemoveSort() { }
void System.ComponentModel.IBindingListView.ApplySort(System.ComponentModel.ListSortDescriptionCollection sorts) { }
void System.ComponentModel.IBindingListView.RemoveFilter() { }
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ITypedList.GetItemProperties(System.ComponentModel.PropertyDescriptor[] listAccessors) { throw null; }
string System.ComponentModel.ITypedList.GetListName(System.ComponentModel.PropertyDescriptor[] listAccessors) { throw null; }
public System.Data.DataTable ToTable() { throw null; }
public System.Data.DataTable ToTable(bool distinct, params string[] columnNames) { throw null; }
public System.Data.DataTable ToTable(string? tableName) { throw null; }
public System.Data.DataTable ToTable(string? tableName, bool distinct, params string[] columnNames) { throw null; }
protected void UpdateIndex() { }
protected virtual void UpdateIndex(bool force) { }
}
[System.ComponentModel.DesignerAttribute("Microsoft.VSDesigner.Data.VS.DataViewManagerDesigner, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public partial class DataViewManager : System.ComponentModel.MarshalByValueComponent, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.ComponentModel.IBindingList, System.ComponentModel.ITypedList
{
public DataViewManager() { }
public DataViewManager(System.Data.DataSet? dataSet) { }
[System.ComponentModel.DefaultValueAttribute(null)]
[System.Diagnostics.CodeAnalysis.DisallowNullAttribute]
public System.Data.DataSet? DataSet { get { throw null; } set { } }
public string DataViewSettingCollectionString { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Members of types used in the RowFilter expression might be trimmed.")] set { } }
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
public System.Data.DataViewSettingCollection DataViewSettings { get { throw null; } }
int System.Collections.ICollection.Count { get { throw null; } }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
bool System.Collections.IList.IsFixedSize { get { throw null; } }
bool System.Collections.IList.IsReadOnly { get { throw null; } }
object? System.Collections.IList.this[int index] { get { throw null; } set { } }
bool System.ComponentModel.IBindingList.AllowEdit { get { throw null; } }
bool System.ComponentModel.IBindingList.AllowNew { get { throw null; } }
bool System.ComponentModel.IBindingList.AllowRemove { get { throw null; } }
bool System.ComponentModel.IBindingList.IsSorted { get { throw null; } }
System.ComponentModel.ListSortDirection System.ComponentModel.IBindingList.SortDirection { get { throw null; } }
System.ComponentModel.PropertyDescriptor? System.ComponentModel.IBindingList.SortProperty { get { throw null; } }
bool System.ComponentModel.IBindingList.SupportsChangeNotification { get { throw null; } }
bool System.ComponentModel.IBindingList.SupportsSearching { get { throw null; } }
bool System.ComponentModel.IBindingList.SupportsSorting { get { throw null; } }
public event System.ComponentModel.ListChangedEventHandler? ListChanged { add { } remove { } }
public System.Data.DataView CreateDataView(System.Data.DataTable table) { throw null; }
protected virtual void OnListChanged(System.ComponentModel.ListChangedEventArgs e) { }
protected virtual void RelationCollectionChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e) { }
void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
int System.Collections.IList.Add(object? value) { throw null; }
void System.Collections.IList.Clear() { }
bool System.Collections.IList.Contains(object? value) { throw null; }
int System.Collections.IList.IndexOf(object? value) { throw null; }
void System.Collections.IList.Insert(int index, object? value) { }
void System.Collections.IList.Remove(object? value) { }
void System.Collections.IList.RemoveAt(int index) { }
void System.ComponentModel.IBindingList.AddIndex(System.ComponentModel.PropertyDescriptor property) { }
object? System.ComponentModel.IBindingList.AddNew() { throw null; }
void System.ComponentModel.IBindingList.ApplySort(System.ComponentModel.PropertyDescriptor property, System.ComponentModel.ListSortDirection direction) { }
int System.ComponentModel.IBindingList.Find(System.ComponentModel.PropertyDescriptor property, object key) { throw null; }
void System.ComponentModel.IBindingList.RemoveIndex(System.ComponentModel.PropertyDescriptor property) { }
void System.ComponentModel.IBindingList.RemoveSort() { }
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ITypedList.GetItemProperties(System.ComponentModel.PropertyDescriptor[] listAccessors) { throw null; }
string System.ComponentModel.ITypedList.GetListName(System.ComponentModel.PropertyDescriptor[] listAccessors) { throw null; }
protected virtual void TableCollectionChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e) { }
}
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.DataViewRowStateEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.FlagsAttribute]
public enum DataViewRowState
{
None = 0,
Unchanged = 2,
Added = 4,
Deleted = 8,
ModifiedCurrent = 16,
CurrentRows = 22,
ModifiedOriginal = 32,
OriginalRows = 42,
}
[System.ComponentModel.TypeConverterAttribute(typeof(System.ComponentModel.ExpandableObjectConverter))]
public partial class DataViewSetting
{
internal DataViewSetting() { }
public bool ApplyDefaultSort { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.DataViewManager? DataViewManager { get { throw null; } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string RowFilter { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")] set { } }
public System.Data.DataViewRowState RowStateFilter { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Sort { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.DataTable? Table { get { throw null; } }
}
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.DataViewSettingsCollectionEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public partial class DataViewSettingCollection : System.Collections.ICollection, System.Collections.IEnumerable
{
internal DataViewSettingCollection() { }
[System.ComponentModel.BrowsableAttribute(false)]
public virtual int Count { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool IsReadOnly { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool IsSynchronized { get { throw null; } }
public virtual System.Data.DataViewSetting this[System.Data.DataTable table] { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.DisallowNullAttribute]
public virtual System.Data.DataViewSetting? this[int index] { get { throw null; } set { } }
public virtual System.Data.DataViewSetting? this[string tableName] { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public object SyncRoot { get { throw null; } }
public void CopyTo(System.Array ar, int index) { }
public void CopyTo(System.Data.DataViewSetting[] ar, int index) { }
public System.Collections.IEnumerator GetEnumerator() { throw null; }
}
public sealed partial class DBConcurrencyException : System.SystemException
{
public DBConcurrencyException() { }
public DBConcurrencyException(string? message) { }
public DBConcurrencyException(string? message, System.Exception? inner) { }
public DBConcurrencyException(string? message, System.Exception? inner, System.Data.DataRow[]? dataRows) { }
[System.Diagnostics.CodeAnalysis.DisallowNullAttribute]
public System.Data.DataRow? Row { get { throw null; } set { } }
public int RowCount { get { throw null; } }
public void CopyToRows(System.Data.DataRow[] array) { }
public void CopyToRows(System.Data.DataRow[] array, int arrayIndex) { }
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
}
public enum DbType
{
AnsiString = 0,
Binary = 1,
Byte = 2,
Boolean = 3,
Currency = 4,
Date = 5,
DateTime = 6,
Decimal = 7,
Double = 8,
Guid = 9,
Int16 = 10,
Int32 = 11,
Int64 = 12,
Object = 13,
SByte = 14,
Single = 15,
String = 16,
Time = 17,
UInt16 = 18,
UInt32 = 19,
UInt64 = 20,
VarNumeric = 21,
AnsiStringFixedLength = 22,
StringFixedLength = 23,
Xml = 25,
DateTime2 = 26,
DateTimeOffset = 27,
}
public partial class DeletedRowInaccessibleException : System.Data.DataException
{
public DeletedRowInaccessibleException() { }
protected DeletedRowInaccessibleException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public DeletedRowInaccessibleException(string? s) { }
public DeletedRowInaccessibleException(string? message, System.Exception? innerException) { }
}
public partial class DuplicateNameException : System.Data.DataException
{
public DuplicateNameException() { }
protected DuplicateNameException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public DuplicateNameException(string? s) { }
public DuplicateNameException(string? message, System.Exception? innerException) { }
}
public abstract partial class EnumerableRowCollection : System.Collections.IEnumerable
{
internal EnumerableRowCollection() { }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
public static partial class EnumerableRowCollectionExtensions
{
public static System.Data.EnumerableRowCollection<TResult> Cast<TResult>(this System.Data.EnumerableRowCollection source) { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderByDescending<TRow, TKey>(this System.Data.EnumerableRowCollection<TRow> source, System.Func<TRow, TKey> keySelector) { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderByDescending<TRow, TKey>(this System.Data.EnumerableRowCollection<TRow> source, System.Func<TRow, TKey> keySelector, System.Collections.Generic.IComparer<TKey> comparer) { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderBy<TRow, TKey>(this System.Data.EnumerableRowCollection<TRow> source, System.Func<TRow, TKey> keySelector) { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderBy<TRow, TKey>(this System.Data.EnumerableRowCollection<TRow> source, System.Func<TRow, TKey> keySelector, System.Collections.Generic.IComparer<TKey> comparer) { throw null; }
public static System.Data.EnumerableRowCollection<S> Select<TRow, S>(this System.Data.EnumerableRowCollection<TRow> source, System.Func<TRow, S> selector) { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> ThenByDescending<TRow, TKey>(this System.Data.OrderedEnumerableRowCollection<TRow> source, System.Func<TRow, TKey> keySelector) { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> ThenByDescending<TRow, TKey>(this System.Data.OrderedEnumerableRowCollection<TRow> source, System.Func<TRow, TKey> keySelector, System.Collections.Generic.IComparer<TKey> comparer) { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> ThenBy<TRow, TKey>(this System.Data.OrderedEnumerableRowCollection<TRow> source, System.Func<TRow, TKey> keySelector) { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> ThenBy<TRow, TKey>(this System.Data.OrderedEnumerableRowCollection<TRow> source, System.Func<TRow, TKey> keySelector, System.Collections.Generic.IComparer<TKey> comparer) { throw null; }
public static System.Data.EnumerableRowCollection<TRow> Where<TRow>(this System.Data.EnumerableRowCollection<TRow> source, System.Func<TRow, bool> predicate) { throw null; }
}
public partial class EnumerableRowCollection<TRow> : System.Data.EnumerableRowCollection, System.Collections.Generic.IEnumerable<TRow>, System.Collections.IEnumerable
{
internal EnumerableRowCollection() { }
public System.Collections.Generic.IEnumerator<TRow> GetEnumerator() { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
public partial class EvaluateException : System.Data.InvalidExpressionException
{
public EvaluateException() { }
protected EvaluateException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public EvaluateException(string? s) { }
public EvaluateException(string? message, System.Exception? innerException) { }
}
public partial class FillErrorEventArgs : System.EventArgs
{
public FillErrorEventArgs(System.Data.DataTable? dataTable, object?[]? values) { }
public bool Continue { get { throw null; } set { } }
public System.Data.DataTable? DataTable { get { throw null; } }
public System.Exception? Errors { get { throw null; } set { } }
public object?[] Values { get { throw null; } }
}
public delegate void FillErrorEventHandler(object sender, System.Data.FillErrorEventArgs e);
[System.ComponentModel.DefaultPropertyAttribute("ConstraintName")]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.ForeignKeyConstraintEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public partial class ForeignKeyConstraint : System.Data.Constraint
{
public ForeignKeyConstraint(System.Data.DataColumn parentColumn, System.Data.DataColumn childColumn) { }
public ForeignKeyConstraint(System.Data.DataColumn[] parentColumns, System.Data.DataColumn[] childColumns) { }
public ForeignKeyConstraint(string? constraintName, System.Data.DataColumn parentColumn, System.Data.DataColumn childColumn) { }
public ForeignKeyConstraint(string? constraintName, System.Data.DataColumn[] parentColumns, System.Data.DataColumn[] childColumns) { }
[System.ComponentModel.BrowsableAttribute(false)]
public ForeignKeyConstraint(string? constraintName, string? parentTableName, string? parentTableNamespace, string[] parentColumnNames, string[] childColumnNames, System.Data.AcceptRejectRule acceptRejectRule, System.Data.Rule deleteRule, System.Data.Rule updateRule) { }
[System.ComponentModel.BrowsableAttribute(false)]
public ForeignKeyConstraint(string? constraintName, string? parentTableName, string[] parentColumnNames, string[] childColumnNames, System.Data.AcceptRejectRule acceptRejectRule, System.Data.Rule deleteRule, System.Data.Rule updateRule) { }
[System.ComponentModel.DefaultValueAttribute(System.Data.AcceptRejectRule.None)]
public virtual System.Data.AcceptRejectRule AcceptRejectRule { get { throw null; } set { } }
[System.ComponentModel.ReadOnlyAttribute(true)]
public virtual System.Data.DataColumn[] Columns { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute(System.Data.Rule.Cascade)]
public virtual System.Data.Rule DeleteRule { get { throw null; } set { } }
[System.ComponentModel.ReadOnlyAttribute(true)]
public virtual System.Data.DataColumn[] RelatedColumns { get { throw null; } }
[System.ComponentModel.ReadOnlyAttribute(true)]
public virtual System.Data.DataTable RelatedTable { get { throw null; } }
[System.ComponentModel.ReadOnlyAttribute(true)]
public override System.Data.DataTable? Table { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute(System.Data.Rule.Cascade)]
public virtual System.Data.Rule UpdateRule { get { throw null; } set { } }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? key) { throw null; }
public override int GetHashCode() { throw null; }
}
public partial interface IColumnMapping
{
string DataSetColumn { get; set; }
string SourceColumn { get; set; }
}
public partial interface IColumnMappingCollection : System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList
{
object this[string index] { get; set; }
System.Data.IColumnMapping Add(string sourceColumnName, string dataSetColumnName);
bool Contains(string? sourceColumnName);
System.Data.IColumnMapping GetByDataSetColumn(string dataSetColumnName);
int IndexOf(string? sourceColumnName);
void RemoveAt(string sourceColumnName);
}
public partial interface IDataAdapter
{
System.Data.MissingMappingAction MissingMappingAction { get; set; }
System.Data.MissingSchemaAction MissingSchemaAction { get; set; }
System.Data.ITableMappingCollection TableMappings { get; }
int Fill(System.Data.DataSet dataSet);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
System.Data.DataTable[] FillSchema(System.Data.DataSet dataSet, System.Data.SchemaType schemaType);
System.Data.IDataParameter[] GetFillParameters();
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
int Update(System.Data.DataSet dataSet);
}
public partial interface IDataParameter
{
System.Data.DbType DbType { get; set; }
System.Data.ParameterDirection Direction { get; set; }
bool IsNullable { get; }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
string ParameterName { get; set; }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
string SourceColumn { get; set; }
System.Data.DataRowVersion SourceVersion { get; set; }
object? Value { get; set; }
}
public partial interface IDataParameterCollection : System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList
{
object this[string parameterName] { get; set; }
bool Contains(string parameterName);
int IndexOf(string parameterName);
void RemoveAt(string parameterName);
}
public partial interface IDataReader : System.Data.IDataRecord, System.IDisposable
{
int Depth { get; }
bool IsClosed { get; }
int RecordsAffected { get; }
void Close();
System.Data.DataTable? GetSchemaTable();
bool NextResult();
bool Read();
}
public partial interface IDataRecord
{
int FieldCount { get; }
object this[int i] { get; }
object this[string name] { get; }
bool GetBoolean(int i);
byte GetByte(int i);
long GetBytes(int i, long fieldOffset, byte[]? buffer, int bufferoffset, int length);
char GetChar(int i);
long GetChars(int i, long fieldoffset, char[]? buffer, int bufferoffset, int length);
System.Data.IDataReader GetData(int i);
string GetDataTypeName(int i);
System.DateTime GetDateTime(int i);
decimal GetDecimal(int i);
double GetDouble(int i);
[return: System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)]
System.Type GetFieldType(int i);
float GetFloat(int i);
System.Guid GetGuid(int i);
short GetInt16(int i);
int GetInt32(int i);
long GetInt64(int i);
string GetName(int i);
int GetOrdinal(string name);
string GetString(int i);
object GetValue(int i);
int GetValues(object[] values);
bool IsDBNull(int i);
}
public partial interface IDbCommand : System.IDisposable
{
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
string CommandText { get; set; }
int CommandTimeout { get; set; }
System.Data.CommandType CommandType { get; set; }
System.Data.IDbConnection? Connection { get; set; }
System.Data.IDataParameterCollection Parameters { get; }
System.Data.IDbTransaction? Transaction { get; set; }
System.Data.UpdateRowSource UpdatedRowSource { get; set; }
void Cancel();
System.Data.IDbDataParameter CreateParameter();
int ExecuteNonQuery();
System.Data.IDataReader ExecuteReader();
System.Data.IDataReader ExecuteReader(System.Data.CommandBehavior behavior);
object? ExecuteScalar();
void Prepare();
}
public partial interface IDbConnection : System.IDisposable
{
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
string ConnectionString { get; set; }
int ConnectionTimeout { get; }
string Database { get; }
System.Data.ConnectionState State { get; }
System.Data.IDbTransaction BeginTransaction();
System.Data.IDbTransaction BeginTransaction(System.Data.IsolationLevel il);
void ChangeDatabase(string databaseName);
void Close();
System.Data.IDbCommand CreateCommand();
void Open();
}
public partial interface IDbDataAdapter : System.Data.IDataAdapter
{
System.Data.IDbCommand? DeleteCommand { get; set; }
System.Data.IDbCommand? InsertCommand { get; set; }
System.Data.IDbCommand? SelectCommand { get; set; }
System.Data.IDbCommand? UpdateCommand { get; set; }
}
public partial interface IDbDataParameter : System.Data.IDataParameter
{
byte Precision { get; set; }
byte Scale { get; set; }
int Size { get; set; }
}
public partial interface IDbTransaction : System.IDisposable
{
System.Data.IDbConnection? Connection { get; }
System.Data.IsolationLevel IsolationLevel { get; }
void Commit();
void Rollback();
}
public partial class InRowChangingEventException : System.Data.DataException
{
public InRowChangingEventException() { }
protected InRowChangingEventException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public InRowChangingEventException(string? s) { }
public InRowChangingEventException(string? message, System.Exception? innerException) { }
}
public partial class InternalDataCollectionBase : System.Collections.ICollection, System.Collections.IEnumerable
{
public InternalDataCollectionBase() { }
[System.ComponentModel.BrowsableAttribute(false)]
public virtual int Count { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool IsReadOnly { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool IsSynchronized { get { throw null; } }
protected virtual System.Collections.ArrayList List { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public object SyncRoot { get { throw null; } }
public virtual void CopyTo(System.Array ar, int index) { }
public virtual System.Collections.IEnumerator GetEnumerator() { throw null; }
}
public partial class InvalidConstraintException : System.Data.DataException
{
public InvalidConstraintException() { }
protected InvalidConstraintException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public InvalidConstraintException(string? s) { }
public InvalidConstraintException(string? message, System.Exception? innerException) { }
}
public partial class InvalidExpressionException : System.Data.DataException
{
public InvalidExpressionException() { }
protected InvalidExpressionException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public InvalidExpressionException(string? s) { }
public InvalidExpressionException(string? message, System.Exception? innerException) { }
}
public enum IsolationLevel
{
Unspecified = -1,
Chaos = 16,
ReadUncommitted = 256,
ReadCommitted = 4096,
RepeatableRead = 65536,
Serializable = 1048576,
Snapshot = 16777216,
}
public partial interface ITableMapping
{
System.Data.IColumnMappingCollection ColumnMappings { get; }
string DataSetTable { get; set; }
string SourceTable { get; set; }
}
public partial interface ITableMappingCollection : System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList
{
object this[string index] { get; set; }
System.Data.ITableMapping Add(string sourceTableName, string dataSetTableName);
bool Contains(string? sourceTableName);
System.Data.ITableMapping GetByDataSetTable(string dataSetTableName);
int IndexOf(string? sourceTableName);
void RemoveAt(string sourceTableName);
}
public enum KeyRestrictionBehavior
{
AllowOnly = 0,
PreventUsage = 1,
}
public enum LoadOption
{
OverwriteChanges = 1,
PreserveChanges = 2,
Upsert = 3,
}
public enum MappingType
{
Element = 1,
Attribute = 2,
SimpleContent = 3,
Hidden = 4,
}
public partial class MergeFailedEventArgs : System.EventArgs
{
public MergeFailedEventArgs(System.Data.DataTable? table, string conflict) { }
public string Conflict { get { throw null; } }
public System.Data.DataTable? Table { get { throw null; } }
}
public delegate void MergeFailedEventHandler(object sender, System.Data.MergeFailedEventArgs e);
public enum MissingMappingAction
{
Passthrough = 1,
Ignore = 2,
Error = 3,
}
public partial class MissingPrimaryKeyException : System.Data.DataException
{
public MissingPrimaryKeyException() { }
protected MissingPrimaryKeyException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public MissingPrimaryKeyException(string? s) { }
public MissingPrimaryKeyException(string? message, System.Exception? innerException) { }
}
public enum MissingSchemaAction
{
Add = 1,
Ignore = 2,
Error = 3,
AddWithKey = 4,
}
public partial class NoNullAllowedException : System.Data.DataException
{
public NoNullAllowedException() { }
protected NoNullAllowedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public NoNullAllowedException(string? s) { }
public NoNullAllowedException(string? message, System.Exception? innerException) { }
}
public sealed partial class OrderedEnumerableRowCollection<TRow> : System.Data.EnumerableRowCollection<TRow>
{
internal OrderedEnumerableRowCollection() { }
}
public enum ParameterDirection
{
Input = 1,
Output = 2,
InputOutput = 3,
ReturnValue = 6,
}
public partial class PropertyCollection : System.Collections.Hashtable, System.ICloneable
{
public PropertyCollection() { }
protected PropertyCollection(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public override object Clone() { throw null; }
}
public partial class ReadOnlyException : System.Data.DataException
{
public ReadOnlyException() { }
protected ReadOnlyException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public ReadOnlyException(string? s) { }
public ReadOnlyException(string? message, System.Exception? innerException) { }
}
public partial class RowNotInTableException : System.Data.DataException
{
public RowNotInTableException() { }
protected RowNotInTableException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public RowNotInTableException(string? s) { }
public RowNotInTableException(string? message, System.Exception? innerException) { }
}
public enum Rule
{
None = 0,
Cascade = 1,
SetNull = 2,
SetDefault = 3,
}
public enum SchemaSerializationMode
{
IncludeSchema = 1,
ExcludeSchema = 2,
}
public enum SchemaType
{
Source = 1,
Mapped = 2,
}
public enum SerializationFormat
{
Xml = 0,
Binary = 1,
}
public enum SqlDbType
{
BigInt = 0,
Binary = 1,
Bit = 2,
Char = 3,
DateTime = 4,
Decimal = 5,
Float = 6,
Image = 7,
Int = 8,
Money = 9,
NChar = 10,
NText = 11,
NVarChar = 12,
Real = 13,
UniqueIdentifier = 14,
SmallDateTime = 15,
SmallInt = 16,
SmallMoney = 17,
Text = 18,
Timestamp = 19,
TinyInt = 20,
VarBinary = 21,
VarChar = 22,
Variant = 23,
Xml = 25,
Udt = 29,
Structured = 30,
Date = 31,
Time = 32,
DateTime2 = 33,
DateTimeOffset = 34,
}
public sealed partial class StateChangeEventArgs : System.EventArgs
{
public StateChangeEventArgs(System.Data.ConnectionState originalState, System.Data.ConnectionState currentState) { }
public System.Data.ConnectionState CurrentState { get { throw null; } }
public System.Data.ConnectionState OriginalState { get { throw null; } }
}
public delegate void StateChangeEventHandler(object sender, System.Data.StateChangeEventArgs e);
public sealed partial class StatementCompletedEventArgs : System.EventArgs
{
public StatementCompletedEventArgs(int recordCount) { }
public int RecordCount { get { throw null; } }
}
public delegate void StatementCompletedEventHandler(object sender, System.Data.StatementCompletedEventArgs e);
public enum StatementType
{
Select = 0,
Insert = 1,
Update = 2,
Delete = 3,
Batch = 4,
}
public partial class StrongTypingException : System.Data.DataException
{
public StrongTypingException() { }
protected StrongTypingException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public StrongTypingException(string? message) { }
public StrongTypingException(string? s, System.Exception? innerException) { }
}
public partial class SyntaxErrorException : System.Data.InvalidExpressionException
{
public SyntaxErrorException() { }
protected SyntaxErrorException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public SyntaxErrorException(string? s) { }
public SyntaxErrorException(string? message, System.Exception? innerException) { }
}
public static partial class TypedTableBaseExtensions
{
public static System.Data.EnumerableRowCollection<TRow> AsEnumerable<TRow>(this System.Data.TypedTableBase<TRow> source) where TRow : System.Data.DataRow { throw null; }
public static TRow? ElementAtOrDefault<TRow>(this System.Data.TypedTableBase<TRow> source, int index) where TRow : System.Data.DataRow { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderByDescending<TRow, TKey>(this System.Data.TypedTableBase<TRow> source, System.Func<TRow, TKey> keySelector) where TRow : System.Data.DataRow { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderByDescending<TRow, TKey>(this System.Data.TypedTableBase<TRow> source, System.Func<TRow, TKey> keySelector, System.Collections.Generic.IComparer<TKey> comparer) where TRow : System.Data.DataRow { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderBy<TRow, TKey>(this System.Data.TypedTableBase<TRow> source, System.Func<TRow, TKey> keySelector) where TRow : System.Data.DataRow { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderBy<TRow, TKey>(this System.Data.TypedTableBase<TRow> source, System.Func<TRow, TKey> keySelector, System.Collections.Generic.IComparer<TKey> comparer) where TRow : System.Data.DataRow { throw null; }
public static System.Data.EnumerableRowCollection<S> Select<TRow, S>(this System.Data.TypedTableBase<TRow> source, System.Func<TRow, S> selector) where TRow : System.Data.DataRow { throw null; }
public static System.Data.EnumerableRowCollection<TRow> Where<TRow>(this System.Data.TypedTableBase<TRow> source, System.Func<TRow, bool> predicate) where TRow : System.Data.DataRow { throw null; }
}
public abstract partial class TypedTableBase<T> : System.Data.DataTable, System.Collections.Generic.IEnumerable<T>, System.Collections.IEnumerable where T : System.Data.DataRow
{
protected TypedTableBase() { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected TypedTableBase(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public System.Data.EnumerableRowCollection<TResult> Cast<TResult>() { throw null; }
public System.Collections.Generic.IEnumerator<T> GetEnumerator() { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
[System.ComponentModel.DefaultPropertyAttribute("ConstraintName")]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.UniqueConstraintEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public partial class UniqueConstraint : System.Data.Constraint
{
public UniqueConstraint(System.Data.DataColumn column) { }
public UniqueConstraint(System.Data.DataColumn column, bool isPrimaryKey) { }
public UniqueConstraint(System.Data.DataColumn[] columns) { }
public UniqueConstraint(System.Data.DataColumn[] columns, bool isPrimaryKey) { }
public UniqueConstraint(string? name, System.Data.DataColumn column) { }
public UniqueConstraint(string? name, System.Data.DataColumn column, bool isPrimaryKey) { }
public UniqueConstraint(string? name, System.Data.DataColumn[] columns) { }
public UniqueConstraint(string? name, System.Data.DataColumn[] columns, bool isPrimaryKey) { }
[System.ComponentModel.BrowsableAttribute(false)]
public UniqueConstraint(string? name, string[]? columnNames, bool isPrimaryKey) { }
[System.ComponentModel.ReadOnlyAttribute(true)]
public virtual System.Data.DataColumn[] Columns { get { throw null; } }
public bool IsPrimaryKey { get { throw null; } }
[System.ComponentModel.ReadOnlyAttribute(true)]
public override System.Data.DataTable? Table { get { throw null; } }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? key2) { throw null; }
public override int GetHashCode() { throw null; }
}
public enum UpdateRowSource
{
None = 0,
OutputParameters = 1,
FirstReturnedRecord = 2,
Both = 3,
}
public enum UpdateStatus
{
Continue = 0,
ErrorsOccurred = 1,
SkipCurrentRow = 2,
SkipAllRemainingRows = 3,
}
public partial class VersionNotFoundException : System.Data.DataException
{
public VersionNotFoundException() { }
protected VersionNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public VersionNotFoundException(string? s) { }
public VersionNotFoundException(string? message, System.Exception? innerException) { }
}
public enum XmlReadMode
{
Auto = 0,
ReadSchema = 1,
IgnoreSchema = 2,
InferSchema = 3,
DiffGram = 4,
Fragment = 5,
InferTypedSchema = 6,
}
public enum XmlWriteMode
{
WriteSchema = 0,
IgnoreSchema = 1,
DiffGram = 2,
}
}
namespace System.Data.Common
{
public enum CatalogLocation
{
Start = 1,
End = 2,
}
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
public partial class DataAdapter : System.ComponentModel.Component, System.Data.IDataAdapter
{
protected DataAdapter() { }
protected DataAdapter(System.Data.Common.DataAdapter from) { }
[System.ComponentModel.DefaultValueAttribute(true)]
public bool AcceptChangesDuringFill { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(true)]
public bool AcceptChangesDuringUpdate { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(false)]
public bool ContinueUpdateOnError { get { throw null; } set { } }
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public System.Data.LoadOption FillLoadOption { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Using LoadOption may cause members from types used in the expression column to be trimmed if not referenced directly.")] set { } }
[System.ComponentModel.DefaultValueAttribute(System.Data.MissingMappingAction.Passthrough)]
public System.Data.MissingMappingAction MissingMappingAction { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(System.Data.MissingSchemaAction.Add)]
public System.Data.MissingSchemaAction MissingSchemaAction { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(false)]
public virtual bool ReturnProviderSpecificTypes { get { throw null; } set { } }
System.Data.ITableMappingCollection System.Data.IDataAdapter.TableMappings { get { throw null; } }
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
public System.Data.Common.DataTableMappingCollection TableMappings { get { throw null; } }
public event System.Data.FillErrorEventHandler? FillError { add { } remove { } }
[System.ObsoleteAttribute("CloneInternals() has been deprecated. Use the DataAdapter(DataAdapter from) constructor instead.")]
protected virtual System.Data.Common.DataAdapter CloneInternals() { throw null; }
protected virtual System.Data.Common.DataTableMappingCollection CreateTableMappings() { throw null; }
protected override void Dispose(bool disposing) { }
public virtual int Fill(System.Data.DataSet dataSet) { throw null; }
protected virtual int Fill(System.Data.DataSet dataSet, string srcTable, System.Data.IDataReader dataReader, int startRecord, int maxRecords) { throw null; }
protected virtual int Fill(System.Data.DataTable dataTable, System.Data.IDataReader dataReader) { throw null; }
protected virtual int Fill(System.Data.DataTable[] dataTables, System.Data.IDataReader dataReader, int startRecord, int maxRecords) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
public virtual System.Data.DataTable[] FillSchema(System.Data.DataSet dataSet, System.Data.SchemaType schemaType) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("dataReader's schema table types cannot be statically analyzed.")]
protected virtual System.Data.DataTable[] FillSchema(System.Data.DataSet dataSet, System.Data.SchemaType schemaType, string srcTable, System.Data.IDataReader dataReader) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("dataReader's schema table types cannot be statically analyzed.")]
protected virtual System.Data.DataTable? FillSchema(System.Data.DataTable dataTable, System.Data.SchemaType schemaType, System.Data.IDataReader dataReader) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public virtual System.Data.IDataParameter[] GetFillParameters() { throw null; }
protected bool HasTableMappings() { throw null; }
protected virtual void OnFillError(System.Data.FillErrorEventArgs value) { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public void ResetFillLoadOption() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public virtual bool ShouldSerializeAcceptChangesDuringFill() { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public virtual bool ShouldSerializeFillLoadOption() { throw null; }
protected virtual bool ShouldSerializeTableMappings() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
public virtual int Update(System.Data.DataSet dataSet) { throw null; }
}
public sealed partial class DataColumnMapping : System.MarshalByRefObject, System.Data.IColumnMapping, System.ICloneable
{
public DataColumnMapping() { }
public DataColumnMapping(string? sourceColumn, string? dataSetColumn) { }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string DataSetColumn { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string SourceColumn { get { throw null; } set { } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public System.Data.DataColumn? GetDataColumnBySchemaAction(System.Data.DataTable dataTable, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type? dataType, System.Data.MissingSchemaAction schemaAction) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public static System.Data.DataColumn? GetDataColumnBySchemaAction(string? sourceColumn, string? dataSetColumn, System.Data.DataTable dataTable, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type? dataType, System.Data.MissingSchemaAction schemaAction) { throw null; }
object System.ICloneable.Clone() { throw null; }
public override string ToString() { throw null; }
}
public sealed partial class DataColumnMappingCollection : System.MarshalByRefObject, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.Data.IColumnMappingCollection
{
public DataColumnMappingCollection() { }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public int Count { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DataColumnMapping this[int index] { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DataColumnMapping this[string sourceColumn] { get { throw null; } set { } }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
bool System.Collections.IList.IsFixedSize { get { throw null; } }
bool System.Collections.IList.IsReadOnly { get { throw null; } }
object? System.Collections.IList.this[int index] { get { throw null; } set { } }
object System.Data.IColumnMappingCollection.this[string index] { get { throw null; } set { } }
public int Add(object? value) { throw null; }
public System.Data.Common.DataColumnMapping Add(string? sourceColumn, string? dataSetColumn) { throw null; }
public void AddRange(System.Array values) { }
public void AddRange(System.Data.Common.DataColumnMapping[] values) { }
public void Clear() { }
public bool Contains(object? value) { throw null; }
public bool Contains(string? value) { throw null; }
public void CopyTo(System.Array array, int index) { }
public void CopyTo(System.Data.Common.DataColumnMapping[] array, int index) { }
public System.Data.Common.DataColumnMapping GetByDataSetColumn(string value) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public static System.Data.Common.DataColumnMapping? GetColumnMappingBySchemaAction(System.Data.Common.DataColumnMappingCollection? columnMappings, string sourceColumn, System.Data.MissingMappingAction mappingAction) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public static System.Data.DataColumn? GetDataColumn(System.Data.Common.DataColumnMappingCollection? columnMappings, string sourceColumn, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type? dataType, System.Data.DataTable dataTable, System.Data.MissingMappingAction mappingAction, System.Data.MissingSchemaAction schemaAction) { throw null; }
public System.Collections.IEnumerator GetEnumerator() { throw null; }
public int IndexOf(object? value) { throw null; }
public int IndexOf(string? sourceColumn) { throw null; }
public int IndexOfDataSetColumn(string? dataSetColumn) { throw null; }
public void Insert(int index, System.Data.Common.DataColumnMapping value) { }
public void Insert(int index, object? value) { }
public void Remove(System.Data.Common.DataColumnMapping value) { }
public void Remove(object? value) { }
public void RemoveAt(int index) { }
public void RemoveAt(string sourceColumn) { }
System.Data.IColumnMapping System.Data.IColumnMappingCollection.Add(string? sourceColumnName, string? dataSetColumnName) { throw null; }
System.Data.IColumnMapping System.Data.IColumnMappingCollection.GetByDataSetColumn(string dataSetColumnName) { throw null; }
}
public sealed partial class DataTableMapping : System.MarshalByRefObject, System.Data.ITableMapping, System.ICloneable
{
public DataTableMapping() { }
public DataTableMapping(string? sourceTable, string? dataSetTable) { }
public DataTableMapping(string? sourceTable, string? dataSetTable, System.Data.Common.DataColumnMapping[]? columnMappings) { }
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
public System.Data.Common.DataColumnMappingCollection ColumnMappings { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string DataSetTable { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string SourceTable { get { throw null; } set { } }
System.Data.IColumnMappingCollection System.Data.ITableMapping.ColumnMappings { get { throw null; } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public System.Data.Common.DataColumnMapping? GetColumnMappingBySchemaAction(string sourceColumn, System.Data.MissingMappingAction mappingAction) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public System.Data.DataColumn? GetDataColumn(string sourceColumn, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type? dataType, System.Data.DataTable dataTable, System.Data.MissingMappingAction mappingAction, System.Data.MissingSchemaAction schemaAction) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public System.Data.DataTable? GetDataTableBySchemaAction(System.Data.DataSet dataSet, System.Data.MissingSchemaAction schemaAction) { throw null; }
object System.ICloneable.Clone() { throw null; }
public override string ToString() { throw null; }
}
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.DataTableMappingCollectionEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.ListBindableAttribute(false)]
public sealed partial class DataTableMappingCollection : System.MarshalByRefObject, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.Data.ITableMappingCollection
{
public DataTableMappingCollection() { }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public int Count { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DataTableMapping this[int index] { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DataTableMapping this[string sourceTable] { get { throw null; } set { } }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
bool System.Collections.IList.IsFixedSize { get { throw null; } }
bool System.Collections.IList.IsReadOnly { get { throw null; } }
object? System.Collections.IList.this[int index] { get { throw null; } set { } }
object System.Data.ITableMappingCollection.this[string index] { get { throw null; } set { } }
public int Add(object? value) { throw null; }
public System.Data.Common.DataTableMapping Add(string? sourceTable, string? dataSetTable) { throw null; }
public void AddRange(System.Array values) { }
public void AddRange(System.Data.Common.DataTableMapping[] values) { }
public void Clear() { }
public bool Contains(object? value) { throw null; }
public bool Contains(string? value) { throw null; }
public void CopyTo(System.Array array, int index) { }
public void CopyTo(System.Data.Common.DataTableMapping[] array, int index) { }
public System.Data.Common.DataTableMapping GetByDataSetTable(string dataSetTable) { throw null; }
public System.Collections.IEnumerator GetEnumerator() { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public static System.Data.Common.DataTableMapping? GetTableMappingBySchemaAction(System.Data.Common.DataTableMappingCollection? tableMappings, string sourceTable, string dataSetTable, System.Data.MissingMappingAction mappingAction) { throw null; }
public int IndexOf(object? value) { throw null; }
public int IndexOf(string? sourceTable) { throw null; }
public int IndexOfDataSetTable(string? dataSetTable) { throw null; }
public void Insert(int index, System.Data.Common.DataTableMapping value) { }
public void Insert(int index, object? value) { }
public void Remove(System.Data.Common.DataTableMapping value) { }
public void Remove(object? value) { }
public void RemoveAt(int index) { }
public void RemoveAt(string sourceTable) { }
System.Data.ITableMapping System.Data.ITableMappingCollection.Add(string sourceTableName, string dataSetTableName) { throw null; }
System.Data.ITableMapping System.Data.ITableMappingCollection.GetByDataSetTable(string dataSetTableName) { throw null; }
}
public abstract class DbBatch : System.IDisposable, System.IAsyncDisposable
{
public System.Data.Common.DbBatchCommandCollection BatchCommands { get { throw null; } }
protected abstract System.Data.Common.DbBatchCommandCollection DbBatchCommands { get; }
public abstract int Timeout { get; set; }
public System.Data.Common.DbConnection? Connection { get; set; }
protected abstract System.Data.Common.DbConnection? DbConnection { get; set; }
public System.Data.Common.DbTransaction? Transaction { get; set; }
protected abstract System.Data.Common.DbTransaction? DbTransaction { get; set; }
public System.Data.Common.DbDataReader ExecuteReader(System.Data.CommandBehavior behavior = System.Data.CommandBehavior.Default) { throw null; }
protected abstract System.Data.Common.DbDataReader ExecuteDbDataReader(System.Data.CommandBehavior behavior);
public System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteReaderAsync(System.Threading.CancellationToken cancellationToken = default) { throw null; }
public System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteReaderAsync(System.Data.CommandBehavior behavior, System.Threading.CancellationToken cancellationToken = default) { throw null; }
protected abstract System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteDbDataReaderAsync(System.Data.CommandBehavior behavior, System.Threading.CancellationToken cancellationToken);
public abstract int ExecuteNonQuery();
public abstract System.Threading.Tasks.Task<int> ExecuteNonQueryAsync(System.Threading.CancellationToken cancellationToken = default);
public abstract object? ExecuteScalar();
public abstract System.Threading.Tasks.Task<object?> ExecuteScalarAsync(System.Threading.CancellationToken cancellationToken = default);
public abstract void Prepare();
public abstract System.Threading.Tasks.Task PrepareAsync(System.Threading.CancellationToken cancellationToken = default);
public abstract void Cancel();
public System.Data.Common.DbBatchCommand CreateBatchCommand() { throw null; }
protected abstract System.Data.Common.DbBatchCommand CreateDbBatchCommand();
public virtual void Dispose() { throw null; }
public virtual System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
}
public abstract class DbBatchCommand
{
public abstract string CommandText { get; set; }
public abstract System.Data.CommandType CommandType { get; set; }
public abstract int RecordsAffected { get; }
public System.Data.Common.DbParameterCollection Parameters { get { throw null; } }
protected abstract System.Data.Common.DbParameterCollection DbParameterCollection { get; }
}
public abstract class DbBatchCommandCollection : System.Collections.Generic.IList<DbBatchCommand>
{
public abstract System.Collections.Generic.IEnumerator<System.Data.Common.DbBatchCommand> GetEnumerator();
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
public abstract void Add(System.Data.Common.DbBatchCommand item);
public abstract void Clear();
public abstract bool Contains(System.Data.Common.DbBatchCommand item);
public abstract void CopyTo(System.Data.Common.DbBatchCommand[] array, int arrayIndex);
public abstract bool Remove(System.Data.Common.DbBatchCommand item);
public abstract int Count { get; }
public abstract bool IsReadOnly { get; }
public abstract int IndexOf(DbBatchCommand item);
public abstract void Insert(int index, DbBatchCommand item);
public abstract void RemoveAt(int index);
public System.Data.Common.DbBatchCommand this[int index] { get { throw null; } set { throw null; } }
protected abstract System.Data.Common.DbBatchCommand GetBatchCommand(int index);
protected abstract void SetBatchCommand(int index, System.Data.Common.DbBatchCommand batchCommand);
}
public abstract partial class DbColumn
{
protected DbColumn() { }
public bool? AllowDBNull { get { throw null; } protected set { } }
public string? BaseCatalogName { get { throw null; } protected set { } }
public string? BaseColumnName { get { throw null; } protected set { } }
public string? BaseSchemaName { get { throw null; } protected set { } }
public string? BaseServerName { get { throw null; } protected set { } }
public string? BaseTableName { get { throw null; } protected set { } }
public string ColumnName { get { throw null; } protected set { } }
public int? ColumnOrdinal { get { throw null; } protected set { } }
public int? ColumnSize { get { throw null; } protected set { } }
public System.Type? DataType { get { throw null; } protected set { } }
public string? DataTypeName { get { throw null; } protected set { } }
public bool? IsAliased { get { throw null; } protected set { } }
public bool? IsAutoIncrement { get { throw null; } protected set { } }
public bool? IsExpression { get { throw null; } protected set { } }
public bool? IsHidden { get { throw null; } protected set { } }
public bool? IsIdentity { get { throw null; } protected set { } }
public bool? IsKey { get { throw null; } protected set { } }
public bool? IsLong { get { throw null; } protected set { } }
public bool? IsReadOnly { get { throw null; } protected set { } }
public bool? IsUnique { get { throw null; } protected set { } }
public virtual object? this[string property] { get { throw null; } }
public int? NumericPrecision { get { throw null; } protected set { } }
public int? NumericScale { get { throw null; } protected set { } }
public string? UdtAssemblyQualifiedName { get { throw null; } protected set { } }
}
public abstract partial class DbCommand : System.ComponentModel.Component, System.Data.IDbCommand, System.IDisposable, System.IAsyncDisposable
{
protected DbCommand() { }
[System.ComponentModel.DefaultValueAttribute("")]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public abstract string CommandText { get; set; }
public abstract int CommandTimeout { get; set; }
[System.ComponentModel.DefaultValueAttribute(System.Data.CommandType.Text)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public abstract System.Data.CommandType CommandType { get; set; }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DefaultValueAttribute(null)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DbConnection? Connection { get { throw null; } set { } }
protected abstract System.Data.Common.DbConnection? DbConnection { get; set; }
protected abstract System.Data.Common.DbParameterCollection DbParameterCollection { get; }
protected abstract System.Data.Common.DbTransaction? DbTransaction { get; set; }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DefaultValueAttribute(true)]
[System.ComponentModel.DesignOnlyAttribute(true)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public abstract bool DesignTimeVisible { get; set; }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DbParameterCollection Parameters { get { throw null; } }
System.Data.IDbConnection? System.Data.IDbCommand.Connection { get { throw null; } set { } }
System.Data.IDataParameterCollection System.Data.IDbCommand.Parameters { get { throw null; } }
System.Data.IDbTransaction? System.Data.IDbCommand.Transaction { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DefaultValueAttribute(null)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DbTransaction? Transaction { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(System.Data.UpdateRowSource.Both)]
public abstract System.Data.UpdateRowSource UpdatedRowSource { get; set; }
public abstract void Cancel();
protected abstract System.Data.Common.DbParameter CreateDbParameter();
public System.Data.Common.DbParameter CreateParameter() { throw null; }
public virtual System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
protected abstract System.Data.Common.DbDataReader ExecuteDbDataReader(System.Data.CommandBehavior behavior);
protected virtual System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteDbDataReaderAsync(System.Data.CommandBehavior behavior, System.Threading.CancellationToken cancellationToken) { throw null; }
public abstract int ExecuteNonQuery();
public System.Threading.Tasks.Task<int> ExecuteNonQueryAsync() { throw null; }
public virtual System.Threading.Tasks.Task<int> ExecuteNonQueryAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
public System.Data.Common.DbDataReader ExecuteReader() { throw null; }
public System.Data.Common.DbDataReader ExecuteReader(System.Data.CommandBehavior behavior) { throw null; }
public System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteReaderAsync() { throw null; }
public System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteReaderAsync(System.Data.CommandBehavior behavior) { throw null; }
public System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteReaderAsync(System.Data.CommandBehavior behavior, System.Threading.CancellationToken cancellationToken) { throw null; }
public System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteReaderAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
public abstract object? ExecuteScalar();
public System.Threading.Tasks.Task<object?> ExecuteScalarAsync() { throw null; }
public virtual System.Threading.Tasks.Task<object?> ExecuteScalarAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
public abstract void Prepare();
public virtual System.Threading.Tasks.Task PrepareAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
System.Data.IDbDataParameter System.Data.IDbCommand.CreateParameter() { throw null; }
System.Data.IDataReader System.Data.IDbCommand.ExecuteReader() { throw null; }
System.Data.IDataReader System.Data.IDbCommand.ExecuteReader(System.Data.CommandBehavior behavior) { throw null; }
}
public abstract partial class DbCommandBuilder : System.ComponentModel.Component
{
protected DbCommandBuilder() { }
[System.ComponentModel.DefaultValueAttribute(System.Data.Common.CatalogLocation.Start)]
public virtual System.Data.Common.CatalogLocation CatalogLocation { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(".")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public virtual string CatalogSeparator { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(System.Data.ConflictOption.CompareAllSearchableValues)]
public virtual System.Data.ConflictOption ConflictOption { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DbDataAdapter? DataAdapter { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public virtual string QuotePrefix { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public virtual string QuoteSuffix { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(".")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public virtual string SchemaSeparator { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(false)]
public bool SetAllValues { get { throw null; } set { } }
protected abstract void ApplyParameterInfo(System.Data.Common.DbParameter parameter, System.Data.DataRow row, System.Data.StatementType statementType, bool whereClause);
protected override void Dispose(bool disposing) { }
public System.Data.Common.DbCommand GetDeleteCommand() { throw null; }
public System.Data.Common.DbCommand GetDeleteCommand(bool useColumnsForParameterNames) { throw null; }
public System.Data.Common.DbCommand GetInsertCommand() { throw null; }
public System.Data.Common.DbCommand GetInsertCommand(bool useColumnsForParameterNames) { throw null; }
protected abstract string GetParameterName(int parameterOrdinal);
protected abstract string GetParameterName(string parameterName);
protected abstract string GetParameterPlaceholder(int parameterOrdinal);
protected virtual System.Data.DataTable? GetSchemaTable(System.Data.Common.DbCommand sourceCommand) { throw null; }
public System.Data.Common.DbCommand GetUpdateCommand() { throw null; }
public System.Data.Common.DbCommand GetUpdateCommand(bool useColumnsForParameterNames) { throw null; }
protected virtual System.Data.Common.DbCommand InitializeCommand(System.Data.Common.DbCommand? command) { throw null; }
public virtual string QuoteIdentifier(string unquotedIdentifier) { throw null; }
public virtual void RefreshSchema() { }
protected void RowUpdatingHandler(System.Data.Common.RowUpdatingEventArgs rowUpdatingEvent) { }
protected abstract void SetRowUpdatingHandler(System.Data.Common.DbDataAdapter adapter);
public virtual string UnquoteIdentifier(string quotedIdentifier) { throw null; }
}
public abstract partial class DbConnection : System.ComponentModel.Component, System.Data.IDbConnection, System.IDisposable, System.IAsyncDisposable
{
protected DbConnection() { }
[System.ComponentModel.DefaultValueAttribute("")]
[System.ComponentModel.RecommendedAsConfigurableAttribute(true)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
[System.ComponentModel.SettingsBindableAttribute(true)]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public abstract string ConnectionString { get; set; }
public virtual int ConnectionTimeout { get { throw null; } }
public abstract string Database { get; }
public abstract string DataSource { get; }
protected virtual System.Data.Common.DbProviderFactory? DbProviderFactory { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public abstract string ServerVersion { get; }
[System.ComponentModel.BrowsableAttribute(false)]
public abstract System.Data.ConnectionState State { get; }
public virtual event System.Data.StateChangeEventHandler? StateChange { add { } remove { } }
protected abstract System.Data.Common.DbTransaction BeginDbTransaction(System.Data.IsolationLevel isolationLevel);
protected virtual System.Threading.Tasks.ValueTask<System.Data.Common.DbTransaction> BeginDbTransactionAsync(System.Data.IsolationLevel isolationLevel, System.Threading.CancellationToken cancellationToken) { throw null; }
public System.Data.Common.DbTransaction BeginTransaction() { throw null; }
public System.Data.Common.DbTransaction BeginTransaction(System.Data.IsolationLevel isolationLevel) { throw null; }
public System.Threading.Tasks.ValueTask<System.Data.Common.DbTransaction> BeginTransactionAsync(System.Data.IsolationLevel isolationLevel, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public System.Threading.Tasks.ValueTask<System.Data.Common.DbTransaction> BeginTransactionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public abstract void ChangeDatabase(string databaseName);
public virtual System.Threading.Tasks.Task ChangeDatabaseAsync(string databaseName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public abstract void Close();
public virtual System.Threading.Tasks.Task CloseAsync() { throw null; }
public virtual bool CanCreateBatch { get { throw null; } }
public System.Data.Common.DbBatch CreateBatch() { throw null; }
protected virtual System.Data.Common.DbBatch CreateDbBatch() { throw null; }
public System.Data.Common.DbCommand CreateCommand() { throw null; }
protected abstract System.Data.Common.DbCommand CreateDbCommand();
public virtual System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
public virtual void EnlistTransaction(System.Transactions.Transaction? transaction) { }
public virtual System.Data.DataTable GetSchema() { throw null; }
public virtual System.Data.DataTable GetSchema(string collectionName) { throw null; }
public virtual System.Data.DataTable GetSchema(string collectionName, string?[] restrictionValues) { throw null; }
public virtual System.Threading.Tasks.Task<System.Data.DataTable> GetSchemaAsync(System.Threading.CancellationToken cancellationToken = default) { throw null; }
public virtual System.Threading.Tasks.Task<System.Data.DataTable> GetSchemaAsync(string collectionName, System.Threading.CancellationToken cancellationToken = default) { throw null; }
public virtual System.Threading.Tasks.Task<System.Data.DataTable> GetSchemaAsync(string collectionName, string?[] restrictionValues, System.Threading.CancellationToken cancellationToken = default) { throw null; }
protected virtual void OnStateChange(System.Data.StateChangeEventArgs stateChange) { }
public abstract void Open();
public System.Threading.Tasks.Task OpenAsync() { throw null; }
public virtual System.Threading.Tasks.Task OpenAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
System.Data.IDbTransaction System.Data.IDbConnection.BeginTransaction() { throw null; }
System.Data.IDbTransaction System.Data.IDbConnection.BeginTransaction(System.Data.IsolationLevel isolationLevel) { throw null; }
System.Data.IDbCommand System.Data.IDbConnection.CreateCommand() { throw null; }
}
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)]
public partial class DbConnectionStringBuilder : System.Collections.ICollection, System.Collections.IDictionary, System.Collections.IEnumerable, System.ComponentModel.ICustomTypeDescriptor
{
public DbConnectionStringBuilder() { }
public DbConnectionStringBuilder(bool useOdbcRules) { }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.DesignOnlyAttribute(true)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public bool BrowsableConnectionString { get { throw null; } set { } }
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string ConnectionString { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public virtual int Count { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public virtual bool IsFixedSize { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool IsReadOnly { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public virtual object this[string keyword] { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public virtual System.Collections.ICollection Keys { get { throw null; } }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
object? System.Collections.IDictionary.this[object keyword] { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public virtual System.Collections.ICollection Values { get { throw null; } }
public void Add(string keyword, object value) { }
public static void AppendKeyValuePair(System.Text.StringBuilder builder, string keyword, string? value) { }
public static void AppendKeyValuePair(System.Text.StringBuilder builder, string keyword, string? value, bool useOdbcRules) { }
public virtual void Clear() { }
protected internal void ClearPropertyDescriptors() { }
public virtual bool ContainsKey(string keyword) { throw null; }
public virtual bool EquivalentTo(System.Data.Common.DbConnectionStringBuilder connectionStringBuilder) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")]
protected virtual void GetProperties(System.Collections.Hashtable propertyDescriptors) { }
public virtual bool Remove(string keyword) { throw null; }
public virtual bool ShouldSerialize(string keyword) { throw null; }
void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
void System.Collections.IDictionary.Add(object keyword, object? value) { }
bool System.Collections.IDictionary.Contains(object keyword) { throw null; }
System.Collections.IDictionaryEnumerator System.Collections.IDictionary.GetEnumerator() { throw null; }
void System.Collections.IDictionary.Remove(object keyword) { }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
System.ComponentModel.AttributeCollection System.ComponentModel.ICustomTypeDescriptor.GetAttributes() { throw null; }
string? System.ComponentModel.ICustomTypeDescriptor.GetClassName() { throw null; }
string? System.ComponentModel.ICustomTypeDescriptor.GetComponentName() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
System.ComponentModel.TypeConverter System.ComponentModel.ICustomTypeDescriptor.GetConverter() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
System.ComponentModel.EventDescriptor? System.ComponentModel.ICustomTypeDescriptor.GetDefaultEvent() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")]
System.ComponentModel.PropertyDescriptor? System.ComponentModel.ICustomTypeDescriptor.GetDefaultProperty() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")]
object? System.ComponentModel.ICustomTypeDescriptor.GetEditor(System.Type editorBaseType) { throw null; }
System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents(System.Attribute[]? attributes) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")]
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties(System.Attribute[]? attributes) { throw null; }
object System.ComponentModel.ICustomTypeDescriptor.GetPropertyOwner(System.ComponentModel.PropertyDescriptor? pd) { throw null; }
public override string ToString() { throw null; }
public virtual bool TryGetValue(string keyword, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out object? value) { throw null; }
}
public abstract partial class DbDataAdapter : System.Data.Common.DataAdapter, System.Data.IDataAdapter, System.Data.IDbDataAdapter, System.ICloneable
{
public const string DefaultSourceTableName = "Table";
protected DbDataAdapter() { }
protected DbDataAdapter(System.Data.Common.DbDataAdapter adapter) { }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DbCommand? DeleteCommand { get { throw null; } set { } }
protected internal System.Data.CommandBehavior FillCommandBehavior { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DbCommand? InsertCommand { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DbCommand? SelectCommand { get { throw null; } set { } }
System.Data.IDbCommand? System.Data.IDbDataAdapter.DeleteCommand { get { throw null; } set { } }
System.Data.IDbCommand? System.Data.IDbDataAdapter.InsertCommand { get { throw null; } set { } }
System.Data.IDbCommand? System.Data.IDbDataAdapter.SelectCommand { get { throw null; } set { } }
System.Data.IDbCommand? System.Data.IDbDataAdapter.UpdateCommand { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(1)]
public virtual int UpdateBatchSize { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DbCommand? UpdateCommand { get { throw null; } set { } }
protected virtual int AddToBatch(System.Data.IDbCommand command) { throw null; }
protected virtual void ClearBatch() { }
protected virtual System.Data.Common.RowUpdatedEventArgs CreateRowUpdatedEvent(System.Data.DataRow dataRow, System.Data.IDbCommand? command, System.Data.StatementType statementType, System.Data.Common.DataTableMapping tableMapping) { throw null; }
protected virtual System.Data.Common.RowUpdatingEventArgs CreateRowUpdatingEvent(System.Data.DataRow dataRow, System.Data.IDbCommand? command, System.Data.StatementType statementType, System.Data.Common.DataTableMapping tableMapping) { throw null; }
protected override void Dispose(bool disposing) { }
protected virtual int ExecuteBatch() { throw null; }
public override int Fill(System.Data.DataSet dataSet) { throw null; }
public int Fill(System.Data.DataSet dataSet, int startRecord, int maxRecords, string srcTable) { throw null; }
protected virtual int Fill(System.Data.DataSet dataSet, int startRecord, int maxRecords, string srcTable, System.Data.IDbCommand command, System.Data.CommandBehavior behavior) { throw null; }
public int Fill(System.Data.DataSet dataSet, string srcTable) { throw null; }
public int Fill(System.Data.DataTable dataTable) { throw null; }
protected virtual int Fill(System.Data.DataTable dataTable, System.Data.IDbCommand command, System.Data.CommandBehavior behavior) { throw null; }
protected virtual int Fill(System.Data.DataTable[] dataTables, int startRecord, int maxRecords, System.Data.IDbCommand command, System.Data.CommandBehavior behavior) { throw null; }
public int Fill(int startRecord, int maxRecords, params System.Data.DataTable[] dataTables) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
public override System.Data.DataTable[] FillSchema(System.Data.DataSet dataSet, System.Data.SchemaType schemaType) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from command) schema table types cannot be statically analyzed.")]
protected virtual System.Data.DataTable[] FillSchema(System.Data.DataSet dataSet, System.Data.SchemaType schemaType, System.Data.IDbCommand command, string srcTable, System.Data.CommandBehavior behavior) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
public System.Data.DataTable[] FillSchema(System.Data.DataSet dataSet, System.Data.SchemaType schemaType, string srcTable) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
public System.Data.DataTable? FillSchema(System.Data.DataTable dataTable, System.Data.SchemaType schemaType) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from command) schema table types cannot be statically analyzed.")]
protected virtual System.Data.DataTable? FillSchema(System.Data.DataTable dataTable, System.Data.SchemaType schemaType, System.Data.IDbCommand command, System.Data.CommandBehavior behavior) { throw null; }
protected virtual System.Data.IDataParameter GetBatchedParameter(int commandIdentifier, int parameterIndex) { throw null; }
protected virtual bool GetBatchedRecordsAffected(int commandIdentifier, out int recordsAffected, out System.Exception? error) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public override System.Data.IDataParameter[] GetFillParameters() { throw null; }
protected virtual void InitializeBatching() { }
protected virtual void OnRowUpdated(System.Data.Common.RowUpdatedEventArgs value) { }
protected virtual void OnRowUpdating(System.Data.Common.RowUpdatingEventArgs value) { }
object System.ICloneable.Clone() { throw null; }
protected virtual void TerminateBatching() { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
public int Update(System.Data.DataRow[] dataRows) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
protected virtual int Update(System.Data.DataRow[] dataRows, System.Data.Common.DataTableMapping tableMapping) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
public override int Update(System.Data.DataSet dataSet) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
public int Update(System.Data.DataSet dataSet, string srcTable) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
public int Update(System.Data.DataTable dataTable) { throw null; }
}
public abstract partial class DbDataReader : System.MarshalByRefObject, System.Collections.IEnumerable, System.Data.IDataReader, System.Data.IDataRecord, System.IDisposable, System.IAsyncDisposable
{
protected DbDataReader() { }
public abstract int Depth { get; }
public abstract int FieldCount { get; }
public abstract bool HasRows { get; }
public abstract bool IsClosed { get; }
public abstract object this[int ordinal] { get; }
public abstract object this[string name] { get; }
public abstract int RecordsAffected { get; }
public virtual int VisibleFieldCount { get { throw null; } }
public virtual void Close() { }
public virtual System.Threading.Tasks.Task CloseAsync() { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public void Dispose() { }
protected virtual void Dispose(bool disposing) { }
public virtual System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
public abstract bool GetBoolean(int ordinal);
public abstract byte GetByte(int ordinal);
public abstract long GetBytes(int ordinal, long dataOffset, byte[]? buffer, int bufferOffset, int length);
public abstract char GetChar(int ordinal);
public abstract long GetChars(int ordinal, long dataOffset, char[]? buffer, int bufferOffset, int length);
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public System.Data.Common.DbDataReader GetData(int ordinal) { throw null; }
public abstract string GetDataTypeName(int ordinal);
public abstract System.DateTime GetDateTime(int ordinal);
protected virtual System.Data.Common.DbDataReader GetDbDataReader(int ordinal) { throw null; }
public abstract decimal GetDecimal(int ordinal);
public abstract double GetDouble(int ordinal);
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public abstract System.Collections.IEnumerator GetEnumerator();
public abstract System.Type GetFieldType(int ordinal);
public System.Threading.Tasks.Task<T> GetFieldValueAsync<T>(int ordinal) { throw null; }
public virtual System.Threading.Tasks.Task<T> GetFieldValueAsync<T>(int ordinal, System.Threading.CancellationToken cancellationToken) { throw null; }
public virtual T GetFieldValue<T>(int ordinal) { throw null; }
public abstract float GetFloat(int ordinal);
public abstract System.Guid GetGuid(int ordinal);
public abstract short GetInt16(int ordinal);
public abstract int GetInt32(int ordinal);
public abstract long GetInt64(int ordinal);
public abstract string GetName(int ordinal);
public abstract int GetOrdinal(string name);
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public virtual System.Type GetProviderSpecificFieldType(int ordinal) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public virtual object GetProviderSpecificValue(int ordinal) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public virtual int GetProviderSpecificValues(object[] values) { throw null; }
public virtual System.Data.DataTable? GetSchemaTable() { throw null; }
public virtual System.Threading.Tasks.Task<System.Data.DataTable?> GetSchemaTableAsync(System.Threading.CancellationToken cancellationToken = default) { throw null; }
public virtual System.Threading.Tasks.Task<System.Collections.ObjectModel.ReadOnlyCollection<System.Data.Common.DbColumn>> GetColumnSchemaAsync(System.Threading.CancellationToken cancellationToken = default) { throw null; }
public virtual System.IO.Stream GetStream(int ordinal) { throw null; }
public abstract string GetString(int ordinal);
public virtual System.IO.TextReader GetTextReader(int ordinal) { throw null; }
public abstract object GetValue(int ordinal);
public abstract int GetValues(object[] values);
public abstract bool IsDBNull(int ordinal);
public System.Threading.Tasks.Task<bool> IsDBNullAsync(int ordinal) { throw null; }
public virtual System.Threading.Tasks.Task<bool> IsDBNullAsync(int ordinal, System.Threading.CancellationToken cancellationToken) { throw null; }
public abstract bool NextResult();
public System.Threading.Tasks.Task<bool> NextResultAsync() { throw null; }
public virtual System.Threading.Tasks.Task<bool> NextResultAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
public abstract bool Read();
public System.Threading.Tasks.Task<bool> ReadAsync() { throw null; }
public virtual System.Threading.Tasks.Task<bool> ReadAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
System.Data.IDataReader System.Data.IDataRecord.GetData(int ordinal) { throw null; }
}
public static partial class DbDataReaderExtensions
{
public static bool CanGetColumnSchema(this System.Data.Common.DbDataReader reader) { throw null; }
public static System.Collections.ObjectModel.ReadOnlyCollection<System.Data.Common.DbColumn> GetColumnSchema(this System.Data.Common.DbDataReader reader) { throw null; }
}
public abstract partial class DbDataRecord : System.ComponentModel.ICustomTypeDescriptor, System.Data.IDataRecord
{
protected DbDataRecord() { }
public abstract int FieldCount { get; }
public abstract object this[int i] { get; }
public abstract object this[string name] { get; }
public abstract bool GetBoolean(int i);
public abstract byte GetByte(int i);
public abstract long GetBytes(int i, long dataIndex, byte[]? buffer, int bufferIndex, int length);
public abstract char GetChar(int i);
public abstract long GetChars(int i, long dataIndex, char[]? buffer, int bufferIndex, int length);
public System.Data.IDataReader GetData(int i) { throw null; }
public abstract string GetDataTypeName(int i);
public abstract System.DateTime GetDateTime(int i);
protected virtual System.Data.Common.DbDataReader GetDbDataReader(int i) { throw null; }
public abstract decimal GetDecimal(int i);
public abstract double GetDouble(int i);
public abstract System.Type GetFieldType(int i);
public abstract float GetFloat(int i);
public abstract System.Guid GetGuid(int i);
public abstract short GetInt16(int i);
public abstract int GetInt32(int i);
public abstract long GetInt64(int i);
public abstract string GetName(int i);
public abstract int GetOrdinal(string name);
public abstract string GetString(int i);
public abstract object GetValue(int i);
public abstract int GetValues(object[] values);
public abstract bool IsDBNull(int i);
System.ComponentModel.AttributeCollection System.ComponentModel.ICustomTypeDescriptor.GetAttributes() { throw null; }
string System.ComponentModel.ICustomTypeDescriptor.GetClassName() { throw null; }
string System.ComponentModel.ICustomTypeDescriptor.GetComponentName() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
System.ComponentModel.TypeConverter System.ComponentModel.ICustomTypeDescriptor.GetConverter() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
System.ComponentModel.EventDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultEvent() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")]
System.ComponentModel.PropertyDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultProperty() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")]
object System.ComponentModel.ICustomTypeDescriptor.GetEditor(System.Type editorBaseType) { throw null; }
System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents(System.Attribute[]? attributes) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")]
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties(System.Attribute[]? attributes) { throw null; }
object System.ComponentModel.ICustomTypeDescriptor.GetPropertyOwner(System.ComponentModel.PropertyDescriptor? pd) { throw null; }
}
public abstract partial class DbDataSourceEnumerator
{
protected DbDataSourceEnumerator() { }
public abstract System.Data.DataTable GetDataSources();
}
public partial class DbEnumerator : System.Collections.IEnumerator
{
public DbEnumerator(System.Data.Common.DbDataReader reader) { }
public DbEnumerator(System.Data.Common.DbDataReader reader, bool closeReader) { }
public DbEnumerator(System.Data.IDataReader reader) { }
public DbEnumerator(System.Data.IDataReader reader, bool closeReader) { }
public object Current { get { throw null; } }
public bool MoveNext() { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public void Reset() { }
}
public abstract partial class DbException : System.Runtime.InteropServices.ExternalException
{
protected DbException() { }
protected DbException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
protected DbException(string? message) { }
protected DbException(string? message, System.Exception? innerException) { }
protected DbException(string? message, int errorCode) { }
public virtual bool IsTransient { get { throw null; } }
public virtual string? SqlState { get { throw null; } }
public System.Data.Common.DbBatchCommand? BatchCommand { get { throw null; } }
protected virtual System.Data.Common.DbBatchCommand? DbBatchCommand { get { throw null; } }
}
public static partial class DbMetaDataCollectionNames
{
public static readonly string DataSourceInformation;
public static readonly string DataTypes;
public static readonly string MetaDataCollections;
public static readonly string ReservedWords;
public static readonly string Restrictions;
}
public static partial class DbMetaDataColumnNames
{
public static readonly string CollectionName;
public static readonly string ColumnSize;
public static readonly string CompositeIdentifierSeparatorPattern;
public static readonly string CreateFormat;
public static readonly string CreateParameters;
public static readonly string DataSourceProductName;
public static readonly string DataSourceProductVersion;
public static readonly string DataSourceProductVersionNormalized;
public static readonly string DataType;
public static readonly string GroupByBehavior;
public static readonly string IdentifierCase;
public static readonly string IdentifierPattern;
public static readonly string IsAutoIncrementable;
public static readonly string IsBestMatch;
public static readonly string IsCaseSensitive;
public static readonly string IsConcurrencyType;
public static readonly string IsFixedLength;
public static readonly string IsFixedPrecisionScale;
public static readonly string IsLiteralSupported;
public static readonly string IsLong;
public static readonly string IsNullable;
public static readonly string IsSearchable;
public static readonly string IsSearchableWithLike;
public static readonly string IsUnsigned;
public static readonly string LiteralPrefix;
public static readonly string LiteralSuffix;
public static readonly string MaximumScale;
public static readonly string MinimumScale;
public static readonly string NumberOfIdentifierParts;
public static readonly string NumberOfRestrictions;
public static readonly string OrderByColumnsInSelect;
public static readonly string ParameterMarkerFormat;
public static readonly string ParameterMarkerPattern;
public static readonly string ParameterNameMaxLength;
public static readonly string ParameterNamePattern;
public static readonly string ProviderDbType;
public static readonly string QuotedIdentifierCase;
public static readonly string QuotedIdentifierPattern;
public static readonly string ReservedWord;
public static readonly string StatementSeparatorPattern;
public static readonly string StringLiteralPattern;
public static readonly string SupportedJoinOperators;
public static readonly string TypeName;
}
public abstract partial class DbParameter : System.MarshalByRefObject, System.Data.IDataParameter, System.Data.IDbDataParameter
{
protected DbParameter() { }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public abstract System.Data.DbType DbType { get; set; }
[System.ComponentModel.DefaultValueAttribute(System.Data.ParameterDirection.Input)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public abstract System.Data.ParameterDirection Direction { get; set; }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignOnlyAttribute(true)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public abstract bool IsNullable { get; set; }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public abstract string ParameterName { get; set; }
public virtual byte Precision { get { throw null; } set { } }
public virtual byte Scale { get { throw null; } set { } }
public abstract int Size { get; set; }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public abstract string SourceColumn { get; set; }
[System.ComponentModel.DefaultValueAttribute(false)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public abstract bool SourceColumnNullMapping { get; set; }
[System.ComponentModel.DefaultValueAttribute(System.Data.DataRowVersion.Current)]
public virtual System.Data.DataRowVersion SourceVersion { get { throw null; } set { } }
byte System.Data.IDbDataParameter.Precision { get { throw null; } set { } }
byte System.Data.IDbDataParameter.Scale { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(null)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public abstract object? Value { get; set; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public abstract void ResetDbType();
}
public abstract partial class DbParameterCollection : System.MarshalByRefObject, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.Data.IDataParameterCollection
{
protected DbParameterCollection() { }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public abstract int Count { get; }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public virtual bool IsFixedSize { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public virtual bool IsReadOnly { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public virtual bool IsSynchronized { get { throw null; } }
public System.Data.Common.DbParameter this[int index] { get { throw null; } set { } }
public System.Data.Common.DbParameter this[string parameterName] { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public abstract object SyncRoot { get; }
object? System.Collections.IList.this[int index] { get { throw null; } set { } }
object System.Data.IDataParameterCollection.this[string parameterName] { get { throw null; } set { } }
int System.Collections.IList.Add(object? value) { throw null; }
public abstract int Add(object value);
public abstract void AddRange(System.Array values);
public abstract void Clear();
bool System.Collections.IList.Contains(object? value) { throw null; }
public abstract bool Contains(object value);
public abstract bool Contains(string value);
public abstract void CopyTo(System.Array array, int index);
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public abstract System.Collections.IEnumerator GetEnumerator();
protected abstract System.Data.Common.DbParameter GetParameter(int index);
protected abstract System.Data.Common.DbParameter GetParameter(string parameterName);
int System.Collections.IList.IndexOf(object? value) { throw null; }
public abstract int IndexOf(object value);
public abstract int IndexOf(string parameterName);
void System.Collections.IList.Insert(int index, object? value) { throw null; }
public abstract void Insert(int index, object value);
void System.Collections.IList.Remove(object? value) { throw null; }
public abstract void Remove(object value);
public abstract void RemoveAt(int index);
public abstract void RemoveAt(string parameterName);
protected abstract void SetParameter(int index, System.Data.Common.DbParameter value);
protected abstract void SetParameter(string parameterName, System.Data.Common.DbParameter value);
}
public static partial class DbProviderFactories
{
public static System.Data.Common.DbProviderFactory? GetFactory(System.Data.Common.DbConnection connection) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Provider type and its members might be trimmed if not referenced directly.")]
public static System.Data.Common.DbProviderFactory GetFactory(System.Data.DataRow providerRow) { throw null; }
public static System.Data.Common.DbProviderFactory GetFactory(string providerInvariantName) { throw null; }
public static System.Data.DataTable GetFactoryClasses() { throw null; }
public static System.Collections.Generic.IEnumerable<string> GetProviderInvariantNames() { throw null; }
public static void RegisterFactory(string providerInvariantName, System.Data.Common.DbProviderFactory factory) { }
public static void RegisterFactory(string providerInvariantName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] string factoryTypeAssemblyQualifiedName) { }
public static void RegisterFactory(string providerInvariantName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type providerFactoryClass) { }
public static bool TryGetFactory(string providerInvariantName, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Data.Common.DbProviderFactory? factory) { throw null; }
public static bool UnregisterFactory(string providerInvariantName) { throw null; }
}
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)]
public abstract partial class DbProviderFactory
{
protected DbProviderFactory() { }
public virtual bool CanCreateBatch { get { throw null; } }
public virtual bool CanCreateCommandBuilder { get { throw null; } }
public virtual bool CanCreateDataAdapter { get { throw null; } }
public virtual bool CanCreateDataSourceEnumerator { get { throw null; } }
public virtual System.Data.Common.DbBatch CreateBatch() { throw null; }
public virtual System.Data.Common.DbBatchCommand CreateBatchCommand() { throw null; }
public virtual System.Data.Common.DbCommand? CreateCommand() { throw null; }
public virtual System.Data.Common.DbCommandBuilder? CreateCommandBuilder() { throw null; }
public virtual System.Data.Common.DbConnection? CreateConnection() { throw null; }
public virtual System.Data.Common.DbConnectionStringBuilder? CreateConnectionStringBuilder() { throw null; }
public virtual System.Data.Common.DbDataAdapter? CreateDataAdapter() { throw null; }
public virtual System.Data.Common.DbDataSourceEnumerator? CreateDataSourceEnumerator() { throw null; }
public virtual System.Data.Common.DbParameter? CreateParameter() { throw null; }
}
[System.AttributeUsageAttribute(System.AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public sealed partial class DbProviderSpecificTypePropertyAttribute : System.Attribute
{
public DbProviderSpecificTypePropertyAttribute(bool isProviderSpecificTypeProperty) { }
public bool IsProviderSpecificTypeProperty { get { throw null; } }
}
public abstract partial class DbTransaction : System.MarshalByRefObject, System.Data.IDbTransaction, System.IDisposable, System.IAsyncDisposable
{
protected DbTransaction() { }
public System.Data.Common.DbConnection? Connection { get { throw null; } }
protected abstract System.Data.Common.DbConnection? DbConnection { get; }
public abstract System.Data.IsolationLevel IsolationLevel { get; }
System.Data.IDbConnection? System.Data.IDbTransaction.Connection { get { throw null; } }
public abstract void Commit();
public virtual System.Threading.Tasks.Task CommitAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public void Dispose() { }
protected virtual void Dispose(bool disposing) { }
public virtual System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
public abstract void Rollback();
public virtual System.Threading.Tasks.Task RollbackAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual bool SupportsSavepoints { get { throw null; } }
public virtual System.Threading.Tasks.Task SaveAsync(string savepointName, System.Threading.CancellationToken cancellationToken = default) { throw null; }
public virtual System.Threading.Tasks.Task RollbackAsync(string savepointName, System.Threading.CancellationToken cancellationToken = default) { throw null; }
public virtual System.Threading.Tasks.Task ReleaseAsync(string savepointName, System.Threading.CancellationToken cancellationToken = default) { throw null; }
public virtual void Save(string savepointName) { throw null; }
public virtual void Rollback(string savepointName) { throw null; }
public virtual void Release(string savepointName) { throw null; }
}
public enum GroupByBehavior
{
Unknown = 0,
NotSupported = 1,
Unrelated = 2,
MustContainAll = 3,
ExactMatch = 4,
}
public partial interface IDbColumnSchemaGenerator
{
System.Collections.ObjectModel.ReadOnlyCollection<System.Data.Common.DbColumn> GetColumnSchema();
}
public enum IdentifierCase
{
Unknown = 0,
Insensitive = 1,
Sensitive = 2,
}
public partial class RowUpdatedEventArgs : System.EventArgs
{
public RowUpdatedEventArgs(System.Data.DataRow dataRow, System.Data.IDbCommand? command, System.Data.StatementType statementType, System.Data.Common.DataTableMapping tableMapping) { }
public System.Data.IDbCommand? Command { get { throw null; } }
public System.Exception? Errors { get { throw null; } set { } }
public int RecordsAffected { get { throw null; } }
public System.Data.DataRow Row { get { throw null; } }
public int RowCount { get { throw null; } }
public System.Data.StatementType StatementType { get { throw null; } }
public System.Data.UpdateStatus Status { get { throw null; } set { } }
public System.Data.Common.DataTableMapping TableMapping { get { throw null; } }
public void CopyToRows(System.Data.DataRow[] array) { }
public void CopyToRows(System.Data.DataRow[] array, int arrayIndex) { }
}
public partial class RowUpdatingEventArgs : System.EventArgs
{
public RowUpdatingEventArgs(System.Data.DataRow dataRow, System.Data.IDbCommand? command, System.Data.StatementType statementType, System.Data.Common.DataTableMapping tableMapping) { }
protected virtual System.Data.IDbCommand? BaseCommand { get { throw null; } set { } }
public System.Data.IDbCommand? Command { get { throw null; } set { } }
public System.Exception? Errors { get { throw null; } set { } }
public System.Data.DataRow Row { get { throw null; } }
public System.Data.StatementType StatementType { get { throw null; } }
public System.Data.UpdateStatus Status { get { throw null; } set { } }
public System.Data.Common.DataTableMapping TableMapping { get { throw null; } }
}
public static partial class SchemaTableColumn
{
public static readonly string AllowDBNull;
public static readonly string BaseColumnName;
public static readonly string BaseSchemaName;
public static readonly string BaseTableName;
public static readonly string ColumnName;
public static readonly string ColumnOrdinal;
public static readonly string ColumnSize;
public static readonly string DataType;
public static readonly string IsAliased;
public static readonly string IsExpression;
public static readonly string IsKey;
public static readonly string IsLong;
public static readonly string IsUnique;
public static readonly string NonVersionedProviderType;
public static readonly string NumericPrecision;
public static readonly string NumericScale;
public static readonly string ProviderType;
}
public static partial class SchemaTableOptionalColumn
{
public static readonly string AutoIncrementSeed;
public static readonly string AutoIncrementStep;
public static readonly string BaseCatalogName;
public static readonly string BaseColumnNamespace;
public static readonly string BaseServerName;
public static readonly string BaseTableNamespace;
public static readonly string ColumnMapping;
public static readonly string DefaultValue;
public static readonly string Expression;
public static readonly string IsAutoIncrement;
public static readonly string IsHidden;
public static readonly string IsReadOnly;
public static readonly string IsRowVersion;
public static readonly string ProviderSpecificDataType;
}
[System.FlagsAttribute]
public enum SupportedJoinOperators
{
None = 0,
Inner = 1,
LeftOuter = 2,
RightOuter = 4,
FullOuter = 8,
}
}
namespace System.Data.SqlTypes
{
public partial interface INullable
{
bool IsNull { get; }
}
public sealed partial class SqlAlreadyFilledException : System.Data.SqlTypes.SqlTypeException
{
public SqlAlreadyFilledException() { }
public SqlAlreadyFilledException(string? message) { }
public SqlAlreadyFilledException(string? message, System.Exception? e) { }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlBinary : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlBinary>
{
private object _dummy;
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlBinary Null;
public SqlBinary(byte[]? value) { throw null; }
public bool IsNull { get { throw null; } }
public byte this[int index] { get { throw null; } }
public int Length { get { throw null; } }
public byte[] Value { get { throw null; } }
public static System.Data.SqlTypes.SqlBinary Add(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlBinary value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlBinary Concat(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlBinary other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBinary operator +(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static explicit operator byte[]?(System.Data.SqlTypes.SqlBinary x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBinary(System.Data.SqlTypes.SqlGuid x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlBinary(byte[] x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlGuid ToSqlGuid() { throw null; }
public override string ToString() { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlBoolean : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlBoolean>
{
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlBoolean False;
public static readonly System.Data.SqlTypes.SqlBoolean Null;
public static readonly System.Data.SqlTypes.SqlBoolean One;
public static readonly System.Data.SqlTypes.SqlBoolean True;
public static readonly System.Data.SqlTypes.SqlBoolean Zero;
public SqlBoolean(bool value) { throw null; }
public SqlBoolean(int value) { throw null; }
public byte ByteValue { get { throw null; } }
public bool IsFalse { get { throw null; } }
public bool IsNull { get { throw null; } }
public bool IsTrue { get { throw null; } }
public bool Value { get { throw null; } }
public static System.Data.SqlTypes.SqlBoolean And(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlBoolean value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlBoolean other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEquals(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEquals(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean OnesComplement(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator &(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator |(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ^(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static explicit operator bool(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlByte x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlString x) { throw null; }
public static bool operator false(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlBoolean(bool x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ~(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static bool operator true(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Or(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Parse(string s) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlByte ToSqlByte() { throw null; }
public System.Data.SqlTypes.SqlDecimal ToSqlDecimal() { throw null; }
public System.Data.SqlTypes.SqlDouble ToSqlDouble() { throw null; }
public System.Data.SqlTypes.SqlInt16 ToSqlInt16() { throw null; }
public System.Data.SqlTypes.SqlInt32 ToSqlInt32() { throw null; }
public System.Data.SqlTypes.SqlInt64 ToSqlInt64() { throw null; }
public System.Data.SqlTypes.SqlMoney ToSqlMoney() { throw null; }
public System.Data.SqlTypes.SqlSingle ToSqlSingle() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
public static System.Data.SqlTypes.SqlBoolean Xor(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlByte : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlByte>
{
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlByte MaxValue;
public static readonly System.Data.SqlTypes.SqlByte MinValue;
public static readonly System.Data.SqlTypes.SqlByte Null;
public static readonly System.Data.SqlTypes.SqlByte Zero;
public SqlByte(byte value) { throw null; }
public bool IsNull { get { throw null; } }
public byte Value { get { throw null; } }
public static System.Data.SqlTypes.SqlByte Add(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte BitwiseAnd(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte BitwiseOr(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlByte value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlByte Divide(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlByte other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte Mod(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte Modulus(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte Multiply(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte OnesComplement(System.Data.SqlTypes.SqlByte x) { throw null; }
public static System.Data.SqlTypes.SqlByte operator +(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte operator &(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte operator |(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte operator /(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte operator ^(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator byte(System.Data.SqlTypes.SqlByte x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlString x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlByte(byte x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte operator %(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte operator *(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte operator ~(System.Data.SqlTypes.SqlByte x) { throw null; }
public static System.Data.SqlTypes.SqlByte operator -(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte Parse(string s) { throw null; }
public static System.Data.SqlTypes.SqlByte Subtract(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
System.Xml.Schema.XmlSchema System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlBoolean ToSqlBoolean() { throw null; }
public System.Data.SqlTypes.SqlDecimal ToSqlDecimal() { throw null; }
public System.Data.SqlTypes.SqlDouble ToSqlDouble() { throw null; }
public System.Data.SqlTypes.SqlInt16 ToSqlInt16() { throw null; }
public System.Data.SqlTypes.SqlInt32 ToSqlInt32() { throw null; }
public System.Data.SqlTypes.SqlInt64 ToSqlInt64() { throw null; }
public System.Data.SqlTypes.SqlMoney ToSqlMoney() { throw null; }
public System.Data.SqlTypes.SqlSingle ToSqlSingle() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
public static System.Data.SqlTypes.SqlByte Xor(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public sealed partial class SqlBytes : System.Data.SqlTypes.INullable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
{
public SqlBytes() { }
public SqlBytes(byte[]? buffer) { }
public SqlBytes(System.Data.SqlTypes.SqlBinary value) { }
public SqlBytes(System.IO.Stream? s) { }
public byte[]? Buffer { get { throw null; } }
public bool IsNull { get { throw null; } }
public byte this[long offset] { get { throw null; } set { } }
public long Length { get { throw null; } }
public long MaxLength { get { throw null; } }
public static System.Data.SqlTypes.SqlBytes Null { get { throw null; } }
public System.Data.SqlTypes.StorageState Storage { get { throw null; } }
public System.IO.Stream Stream { get { throw null; } set { } }
public byte[] Value { get { throw null; } }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBytes(System.Data.SqlTypes.SqlBinary value) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBinary(System.Data.SqlTypes.SqlBytes value) { throw null; }
public long Read(long offset, byte[] buffer, int offsetInBuffer, int count) { throw null; }
public void SetLength(long value) { }
public void SetNull() { }
void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader r) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlBinary ToSqlBinary() { throw null; }
public void Write(long offset, byte[] buffer, int offsetInBuffer, int count) { }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public sealed partial class SqlChars : System.Data.SqlTypes.INullable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
{
public SqlChars() { }
public SqlChars(char[]? buffer) { }
public SqlChars(System.Data.SqlTypes.SqlString value) { }
public char[]? Buffer { get { throw null; } }
public bool IsNull { get { throw null; } }
public char this[long offset] { get { throw null; } set { } }
public long Length { get { throw null; } }
public long MaxLength { get { throw null; } }
public static System.Data.SqlTypes.SqlChars Null { get { throw null; } }
public System.Data.SqlTypes.StorageState Storage { get { throw null; } }
public char[] Value { get { throw null; } }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlChars value) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlChars(System.Data.SqlTypes.SqlString value) { throw null; }
public long Read(long offset, char[] buffer, int offsetInBuffer, int count) { throw null; }
public void SetLength(long value) { }
public void SetNull() { }
void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader r) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public void Write(long offset, char[] buffer, int offsetInBuffer, int count) { }
}
[System.FlagsAttribute]
public enum SqlCompareOptions
{
None = 0,
IgnoreCase = 1,
IgnoreNonSpace = 2,
IgnoreKanaType = 8,
IgnoreWidth = 16,
BinarySort2 = 16384,
BinarySort = 32768,
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlDateTime : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlDateTime>
{
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlDateTime MaxValue;
public static readonly System.Data.SqlTypes.SqlDateTime MinValue;
public static readonly System.Data.SqlTypes.SqlDateTime Null;
public static readonly int SQLTicksPerHour;
public static readonly int SQLTicksPerMinute;
public static readonly int SQLTicksPerSecond;
public SqlDateTime(System.DateTime value) { throw null; }
public SqlDateTime(int dayTicks, int timeTicks) { throw null; }
public SqlDateTime(int year, int month, int day) { throw null; }
public SqlDateTime(int year, int month, int day, int hour, int minute, int second) { throw null; }
public SqlDateTime(int year, int month, int day, int hour, int minute, int second, double millisecond) { throw null; }
public SqlDateTime(int year, int month, int day, int hour, int minute, int second, int bilisecond) { throw null; }
public int DayTicks { get { throw null; } }
public bool IsNull { get { throw null; } }
public int TimeTicks { get { throw null; } }
public System.DateTime Value { get { throw null; } }
public static System.Data.SqlTypes.SqlDateTime Add(System.Data.SqlTypes.SqlDateTime x, System.TimeSpan t) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlDateTime value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlDateTime other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static System.Data.SqlTypes.SqlDateTime operator +(System.Data.SqlTypes.SqlDateTime x, System.TimeSpan t) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static explicit operator System.DateTime(System.Data.SqlTypes.SqlDateTime x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlDateTime(System.Data.SqlTypes.SqlString x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDateTime(System.DateTime value) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static System.Data.SqlTypes.SqlDateTime operator -(System.Data.SqlTypes.SqlDateTime x, System.TimeSpan t) { throw null; }
public static System.Data.SqlTypes.SqlDateTime Parse(string s) { throw null; }
public static System.Data.SqlTypes.SqlDateTime Subtract(System.Data.SqlTypes.SqlDateTime x, System.TimeSpan t) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlDecimal : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlDecimal>
{
private int _dummyPrimitive;
public static readonly byte MaxPrecision;
public static readonly byte MaxScale;
public static readonly System.Data.SqlTypes.SqlDecimal MaxValue;
public static readonly System.Data.SqlTypes.SqlDecimal MinValue;
public static readonly System.Data.SqlTypes.SqlDecimal Null;
public SqlDecimal(byte bPrecision, byte bScale, bool fPositive, int data1, int data2, int data3, int data4) { throw null; }
public SqlDecimal(byte bPrecision, byte bScale, bool fPositive, int[] bits) { throw null; }
public SqlDecimal(decimal value) { throw null; }
public SqlDecimal(double dVal) { throw null; }
public SqlDecimal(int value) { throw null; }
public SqlDecimal(long value) { throw null; }
public byte[] BinData { get { throw null; } }
public int[] Data { get { throw null; } }
public bool IsNull { get { throw null; } }
public bool IsPositive { get { throw null; } }
public byte Precision { get { throw null; } }
public byte Scale { get { throw null; } }
public decimal Value { get { throw null; } }
public static System.Data.SqlTypes.SqlDecimal Abs(System.Data.SqlTypes.SqlDecimal n) { throw null; }
public static System.Data.SqlTypes.SqlDecimal Add(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlDecimal AdjustScale(System.Data.SqlTypes.SqlDecimal n, int digits, bool fRound) { throw null; }
public static System.Data.SqlTypes.SqlDecimal Ceiling(System.Data.SqlTypes.SqlDecimal n) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlDecimal value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlDecimal ConvertToPrecScale(System.Data.SqlTypes.SqlDecimal n, int precision, int scale) { throw null; }
public static System.Data.SqlTypes.SqlDecimal Divide(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlDecimal other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public static System.Data.SqlTypes.SqlDecimal Floor(System.Data.SqlTypes.SqlDecimal n) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlDecimal Multiply(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlDecimal operator +(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlDecimal operator /(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator decimal(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlString x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlDecimal(double x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlByte x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDecimal(decimal x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDecimal(long x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlDecimal operator *(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlDecimal operator -(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlDecimal operator -(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static System.Data.SqlTypes.SqlDecimal Parse(string s) { throw null; }
public static System.Data.SqlTypes.SqlDecimal Power(System.Data.SqlTypes.SqlDecimal n, double exp) { throw null; }
public static System.Data.SqlTypes.SqlDecimal Round(System.Data.SqlTypes.SqlDecimal n, int position) { throw null; }
public static System.Data.SqlTypes.SqlInt32 Sign(System.Data.SqlTypes.SqlDecimal n) { throw null; }
public static System.Data.SqlTypes.SqlDecimal Subtract(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public double ToDouble() { throw null; }
public System.Data.SqlTypes.SqlBoolean ToSqlBoolean() { throw null; }
public System.Data.SqlTypes.SqlByte ToSqlByte() { throw null; }
public System.Data.SqlTypes.SqlDouble ToSqlDouble() { throw null; }
public System.Data.SqlTypes.SqlInt16 ToSqlInt16() { throw null; }
public System.Data.SqlTypes.SqlInt32 ToSqlInt32() { throw null; }
public System.Data.SqlTypes.SqlInt64 ToSqlInt64() { throw null; }
public System.Data.SqlTypes.SqlMoney ToSqlMoney() { throw null; }
public System.Data.SqlTypes.SqlSingle ToSqlSingle() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
public static System.Data.SqlTypes.SqlDecimal Truncate(System.Data.SqlTypes.SqlDecimal n, int position) { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlDouble : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlDouble>
{
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlDouble MaxValue;
public static readonly System.Data.SqlTypes.SqlDouble MinValue;
public static readonly System.Data.SqlTypes.SqlDouble Null;
public static readonly System.Data.SqlTypes.SqlDouble Zero;
public SqlDouble(double value) { throw null; }
public bool IsNull { get { throw null; } }
public double Value { get { throw null; } }
public static System.Data.SqlTypes.SqlDouble Add(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlDouble value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlDouble Divide(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlDouble other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlDouble Multiply(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlDouble operator +(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlDouble operator /(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator double(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlString x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlByte x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDouble(double x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlDouble operator *(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlDouble operator -(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlDouble operator -(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static System.Data.SqlTypes.SqlDouble Parse(string s) { throw null; }
public static System.Data.SqlTypes.SqlDouble Subtract(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlBoolean ToSqlBoolean() { throw null; }
public System.Data.SqlTypes.SqlByte ToSqlByte() { throw null; }
public System.Data.SqlTypes.SqlDecimal ToSqlDecimal() { throw null; }
public System.Data.SqlTypes.SqlInt16 ToSqlInt16() { throw null; }
public System.Data.SqlTypes.SqlInt32 ToSqlInt32() { throw null; }
public System.Data.SqlTypes.SqlInt64 ToSqlInt64() { throw null; }
public System.Data.SqlTypes.SqlMoney ToSqlMoney() { throw null; }
public System.Data.SqlTypes.SqlSingle ToSqlSingle() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlGuid : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlGuid>
{
private object _dummy;
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlGuid Null;
public SqlGuid(byte[] value) { throw null; }
public SqlGuid(System.Guid g) { throw null; }
public SqlGuid(int a, short b, short c, byte d, byte e, byte f, byte g, byte h, byte i, byte j, byte k) { throw null; }
public SqlGuid(string s) { throw null; }
public bool IsNull { get { throw null; } }
public System.Guid Value { get { throw null; } }
public int CompareTo(System.Data.SqlTypes.SqlGuid value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlGuid other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlGuid(System.Data.SqlTypes.SqlBinary x) { throw null; }
public static explicit operator System.Guid(System.Data.SqlTypes.SqlGuid x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlGuid(System.Data.SqlTypes.SqlString x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlGuid(System.Guid x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static System.Data.SqlTypes.SqlGuid Parse(string s) { throw null; }
System.Xml.Schema.XmlSchema System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public byte[]? ToByteArray() { throw null; }
public System.Data.SqlTypes.SqlBinary ToSqlBinary() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlInt16 : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlInt16>
{
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlInt16 MaxValue;
public static readonly System.Data.SqlTypes.SqlInt16 MinValue;
public static readonly System.Data.SqlTypes.SqlInt16 Null;
public static readonly System.Data.SqlTypes.SqlInt16 Zero;
public SqlInt16(short value) { throw null; }
public bool IsNull { get { throw null; } }
public short Value { get { throw null; } }
public static System.Data.SqlTypes.SqlInt16 Add(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 BitwiseAnd(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 BitwiseOr(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlInt16 value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlInt16 Divide(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlInt16 other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 Mod(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 Modulus(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 Multiply(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 OnesComplement(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator +(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator &(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator |(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator /(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator ^(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator short(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlString x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlByte x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlInt16(short x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator %(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator *(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator ~(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator -(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator -(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static System.Data.SqlTypes.SqlInt16 Parse(string s) { throw null; }
public static System.Data.SqlTypes.SqlInt16 Subtract(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlBoolean ToSqlBoolean() { throw null; }
public System.Data.SqlTypes.SqlByte ToSqlByte() { throw null; }
public System.Data.SqlTypes.SqlDecimal ToSqlDecimal() { throw null; }
public System.Data.SqlTypes.SqlDouble ToSqlDouble() { throw null; }
public System.Data.SqlTypes.SqlInt32 ToSqlInt32() { throw null; }
public System.Data.SqlTypes.SqlInt64 ToSqlInt64() { throw null; }
public System.Data.SqlTypes.SqlMoney ToSqlMoney() { throw null; }
public System.Data.SqlTypes.SqlSingle ToSqlSingle() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
public static System.Data.SqlTypes.SqlInt16 Xor(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlInt32 : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlInt32>
{
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlInt32 MaxValue;
public static readonly System.Data.SqlTypes.SqlInt32 MinValue;
public static readonly System.Data.SqlTypes.SqlInt32 Null;
public static readonly System.Data.SqlTypes.SqlInt32 Zero;
public SqlInt32(int value) { throw null; }
public bool IsNull { get { throw null; } }
public int Value { get { throw null; } }
public static System.Data.SqlTypes.SqlInt32 Add(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 BitwiseAnd(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 BitwiseOr(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlInt32 value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlInt32 Divide(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlInt32 other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 Mod(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 Modulus(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 Multiply(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 OnesComplement(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator +(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator &(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator |(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator /(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator ^(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator int(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlString x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlByte x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlInt32(int x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator %(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator *(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator ~(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator -(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator -(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static System.Data.SqlTypes.SqlInt32 Parse(string s) { throw null; }
public static System.Data.SqlTypes.SqlInt32 Subtract(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlBoolean ToSqlBoolean() { throw null; }
public System.Data.SqlTypes.SqlByte ToSqlByte() { throw null; }
public System.Data.SqlTypes.SqlDecimal ToSqlDecimal() { throw null; }
public System.Data.SqlTypes.SqlDouble ToSqlDouble() { throw null; }
public System.Data.SqlTypes.SqlInt16 ToSqlInt16() { throw null; }
public System.Data.SqlTypes.SqlInt64 ToSqlInt64() { throw null; }
public System.Data.SqlTypes.SqlMoney ToSqlMoney() { throw null; }
public System.Data.SqlTypes.SqlSingle ToSqlSingle() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
public static System.Data.SqlTypes.SqlInt32 Xor(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlInt64 : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlInt64>
{
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlInt64 MaxValue;
public static readonly System.Data.SqlTypes.SqlInt64 MinValue;
public static readonly System.Data.SqlTypes.SqlInt64 Null;
public static readonly System.Data.SqlTypes.SqlInt64 Zero;
public SqlInt64(long value) { throw null; }
public bool IsNull { get { throw null; } }
public long Value { get { throw null; } }
public static System.Data.SqlTypes.SqlInt64 Add(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 BitwiseAnd(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 BitwiseOr(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlInt64 value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlInt64 Divide(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlInt64 other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 Mod(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 Modulus(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 Multiply(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 OnesComplement(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator +(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator &(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator |(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator /(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator ^(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator long(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlString x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlByte x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlInt64(long x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator %(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator *(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator ~(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator -(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator -(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static System.Data.SqlTypes.SqlInt64 Parse(string s) { throw null; }
public static System.Data.SqlTypes.SqlInt64 Subtract(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlBoolean ToSqlBoolean() { throw null; }
public System.Data.SqlTypes.SqlByte ToSqlByte() { throw null; }
public System.Data.SqlTypes.SqlDecimal ToSqlDecimal() { throw null; }
public System.Data.SqlTypes.SqlDouble ToSqlDouble() { throw null; }
public System.Data.SqlTypes.SqlInt16 ToSqlInt16() { throw null; }
public System.Data.SqlTypes.SqlInt32 ToSqlInt32() { throw null; }
public System.Data.SqlTypes.SqlMoney ToSqlMoney() { throw null; }
public System.Data.SqlTypes.SqlSingle ToSqlSingle() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
public static System.Data.SqlTypes.SqlInt64 Xor(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlMoney : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlMoney>
{
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlMoney MaxValue;
public static readonly System.Data.SqlTypes.SqlMoney MinValue;
public static readonly System.Data.SqlTypes.SqlMoney Null;
public static readonly System.Data.SqlTypes.SqlMoney Zero;
public SqlMoney(decimal value) { throw null; }
public SqlMoney(double value) { throw null; }
public SqlMoney(int value) { throw null; }
public SqlMoney(long value) { throw null; }
public bool IsNull { get { throw null; } }
public decimal Value { get { throw null; } }
public static System.Data.SqlTypes.SqlMoney Add(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlMoney value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlMoney Divide(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlMoney other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlMoney Multiply(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlMoney operator +(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlMoney operator /(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator decimal(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlString x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlMoney(double x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlByte x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlMoney(decimal x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlMoney(long x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlMoney operator *(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlMoney operator -(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlMoney operator -(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static System.Data.SqlTypes.SqlMoney Parse(string s) { throw null; }
public static System.Data.SqlTypes.SqlMoney Subtract(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public decimal ToDecimal() { throw null; }
public double ToDouble() { throw null; }
public int ToInt32() { throw null; }
public long ToInt64() { throw null; }
public System.Data.SqlTypes.SqlBoolean ToSqlBoolean() { throw null; }
public System.Data.SqlTypes.SqlByte ToSqlByte() { throw null; }
public System.Data.SqlTypes.SqlDecimal ToSqlDecimal() { throw null; }
public System.Data.SqlTypes.SqlDouble ToSqlDouble() { throw null; }
public System.Data.SqlTypes.SqlInt16 ToSqlInt16() { throw null; }
public System.Data.SqlTypes.SqlInt32 ToSqlInt32() { throw null; }
public System.Data.SqlTypes.SqlInt64 ToSqlInt64() { throw null; }
public System.Data.SqlTypes.SqlSingle ToSqlSingle() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
}
public sealed partial class SqlNotFilledException : System.Data.SqlTypes.SqlTypeException
{
public SqlNotFilledException() { }
public SqlNotFilledException(string? message) { }
public SqlNotFilledException(string? message, System.Exception? e) { }
}
public sealed partial class SqlNullValueException : System.Data.SqlTypes.SqlTypeException
{
public SqlNullValueException() { }
public SqlNullValueException(string? message) { }
public SqlNullValueException(string? message, System.Exception? e) { }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlSingle : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlSingle>
{
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlSingle MaxValue;
public static readonly System.Data.SqlTypes.SqlSingle MinValue;
public static readonly System.Data.SqlTypes.SqlSingle Null;
public static readonly System.Data.SqlTypes.SqlSingle Zero;
public SqlSingle(double value) { throw null; }
public SqlSingle(float value) { throw null; }
public bool IsNull { get { throw null; } }
public float Value { get { throw null; } }
public static System.Data.SqlTypes.SqlSingle Add(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlSingle value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlSingle Divide(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlSingle other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlSingle Multiply(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlSingle operator +(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlSingle operator /(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator float(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlString x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlByte x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlSingle(float x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlSingle operator *(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlSingle operator -(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlSingle operator -(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static System.Data.SqlTypes.SqlSingle Parse(string s) { throw null; }
public static System.Data.SqlTypes.SqlSingle Subtract(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlBoolean ToSqlBoolean() { throw null; }
public System.Data.SqlTypes.SqlByte ToSqlByte() { throw null; }
public System.Data.SqlTypes.SqlDecimal ToSqlDecimal() { throw null; }
public System.Data.SqlTypes.SqlDouble ToSqlDouble() { throw null; }
public System.Data.SqlTypes.SqlInt16 ToSqlInt16() { throw null; }
public System.Data.SqlTypes.SqlInt32 ToSqlInt32() { throw null; }
public System.Data.SqlTypes.SqlInt64 ToSqlInt64() { throw null; }
public System.Data.SqlTypes.SqlMoney ToSqlMoney() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlString : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlString>
{
private object _dummy;
private int _dummyPrimitive;
public static readonly int BinarySort;
public static readonly int BinarySort2;
public static readonly int IgnoreCase;
public static readonly int IgnoreKanaType;
public static readonly int IgnoreNonSpace;
public static readonly int IgnoreWidth;
public static readonly System.Data.SqlTypes.SqlString Null;
public SqlString(int lcid, System.Data.SqlTypes.SqlCompareOptions compareOptions, byte[] data) { throw null; }
public SqlString(int lcid, System.Data.SqlTypes.SqlCompareOptions compareOptions, byte[] data, bool fUnicode) { throw null; }
public SqlString(int lcid, System.Data.SqlTypes.SqlCompareOptions compareOptions, byte[]? data, int index, int count) { throw null; }
public SqlString(int lcid, System.Data.SqlTypes.SqlCompareOptions compareOptions, byte[]? data, int index, int count, bool fUnicode) { throw null; }
public SqlString(string? data) { throw null; }
public SqlString(string? data, int lcid) { throw null; }
public SqlString(string? data, int lcid, System.Data.SqlTypes.SqlCompareOptions compareOptions) { throw null; }
public System.Globalization.CompareInfo CompareInfo { get { throw null; } }
public System.Globalization.CultureInfo CultureInfo { get { throw null; } }
public bool IsNull { get { throw null; } }
public int LCID { get { throw null; } }
public System.Data.SqlTypes.SqlCompareOptions SqlCompareOptions { get { throw null; } }
public string Value { get { throw null; } }
public static System.Data.SqlTypes.SqlString Add(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public System.Data.SqlTypes.SqlString Clone() { throw null; }
public static System.Globalization.CompareOptions CompareOptionsFromSqlCompareOptions(System.Data.SqlTypes.SqlCompareOptions compareOptions) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlString value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlString Concat(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlString other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public byte[]? GetNonUnicodeBytes() { throw null; }
public byte[]? GetUnicodeBytes() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlString operator +(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlByte x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlDateTime x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlGuid x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static explicit operator string(System.Data.SqlTypes.SqlString x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlString(string x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
System.Xml.Schema.XmlSchema System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlBoolean ToSqlBoolean() { throw null; }
public System.Data.SqlTypes.SqlByte ToSqlByte() { throw null; }
public System.Data.SqlTypes.SqlDateTime ToSqlDateTime() { throw null; }
public System.Data.SqlTypes.SqlDecimal ToSqlDecimal() { throw null; }
public System.Data.SqlTypes.SqlDouble ToSqlDouble() { throw null; }
public System.Data.SqlTypes.SqlGuid ToSqlGuid() { throw null; }
public System.Data.SqlTypes.SqlInt16 ToSqlInt16() { throw null; }
public System.Data.SqlTypes.SqlInt32 ToSqlInt32() { throw null; }
public System.Data.SqlTypes.SqlInt64 ToSqlInt64() { throw null; }
public System.Data.SqlTypes.SqlMoney ToSqlMoney() { throw null; }
public System.Data.SqlTypes.SqlSingle ToSqlSingle() { throw null; }
public override string ToString() { throw null; }
}
public sealed partial class SqlTruncateException : System.Data.SqlTypes.SqlTypeException
{
public SqlTruncateException() { }
public SqlTruncateException(string? message) { }
public SqlTruncateException(string? message, System.Exception? e) { }
}
public partial class SqlTypeException : System.SystemException
{
public SqlTypeException() { }
protected SqlTypeException(System.Runtime.Serialization.SerializationInfo si, System.Runtime.Serialization.StreamingContext sc) { }
public SqlTypeException(string? message) { }
public SqlTypeException(string? message, System.Exception? e) { }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public sealed partial class SqlXml : System.Data.SqlTypes.INullable, System.Xml.Serialization.IXmlSerializable
{
public SqlXml() { }
public SqlXml(System.IO.Stream? value) { }
public SqlXml(System.Xml.XmlReader? value) { }
public bool IsNull { get { throw null; } }
public static System.Data.SqlTypes.SqlXml Null { get { throw null; } }
public string Value { get { throw null; } }
public System.Xml.XmlReader CreateReader() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader r) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
}
public enum StorageState
{
Buffer = 0,
Stream = 1,
UnmanagedBuffer = 2,
}
}
namespace System.Xml
{
[System.ObsoleteAttribute("XmlDataDocument has been deprecated and is not supported.")]
public partial class XmlDataDocument : System.Xml.XmlDocument
{
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("XmlDataDocument is used for serialization and deserialization. Members from serialized types may be trimmed if not referenced directly.")]
public XmlDataDocument() { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("XmlDataDocument is used for serialization and deserialization. Members from serialized types may be trimmed if not referenced directly.")]
public XmlDataDocument(System.Data.DataSet dataset) { }
public System.Data.DataSet DataSet { get { throw null; } }
public override System.Xml.XmlNode CloneNode(bool deep) { throw null; }
public override System.Xml.XmlElement CreateElement(string? prefix, string localName, string? namespaceURI) { throw null; }
public override System.Xml.XmlEntityReference CreateEntityReference(string name) { throw null; }
protected override System.Xml.XPath.XPathNavigator? CreateNavigator(System.Xml.XmlNode node) { throw null; }
public override System.Xml.XmlElement? GetElementById(string elemId) { throw null; }
public System.Xml.XmlElement GetElementFromRow(System.Data.DataRow r) { throw null; }
public override System.Xml.XmlNodeList GetElementsByTagName(string name) { throw null; }
public System.Data.DataRow? GetRowFromElement(System.Xml.XmlElement? e) { throw null; }
public override void Load(System.IO.Stream inStream) { }
public override void Load(System.IO.TextReader txtReader) { }
public override void Load(string filename) { }
public override void Load(System.Xml.XmlReader reader) { }
}
}
| // 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.Data
{
public enum AcceptRejectRule
{
None = 0,
Cascade = 1,
}
[System.FlagsAttribute]
public enum CommandBehavior
{
Default = 0,
SingleResult = 1,
SchemaOnly = 2,
KeyInfo = 4,
SingleRow = 8,
SequentialAccess = 16,
CloseConnection = 32,
}
public enum CommandType
{
Text = 1,
StoredProcedure = 4,
TableDirect = 512,
}
public enum ConflictOption
{
CompareAllSearchableValues = 1,
CompareRowVersion = 2,
OverwriteChanges = 3,
}
[System.FlagsAttribute]
public enum ConnectionState
{
Closed = 0,
Open = 1,
Connecting = 2,
Executing = 4,
Fetching = 8,
Broken = 16,
}
[System.ComponentModel.DefaultPropertyAttribute("ConstraintName")]
public abstract partial class Constraint
{
internal Constraint() { }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public virtual string ConstraintName { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.PropertyCollection ExtendedProperties { get { throw null; } }
public abstract System.Data.DataTable? Table { get; }
[System.CLSCompliantAttribute(false)]
protected virtual System.Data.DataSet? _DataSet { get { throw null; } }
protected void CheckStateForProperty() { }
protected internal void SetDataSet(System.Data.DataSet dataSet) { }
public override string ToString() { throw null; }
}
[System.ComponentModel.DefaultEventAttribute("CollectionChanged")]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.ConstraintsCollectionEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public sealed partial class ConstraintCollection : System.Data.InternalDataCollectionBase
{
internal ConstraintCollection() { }
public System.Data.Constraint this[int index] { get { throw null; } }
public System.Data.Constraint? this[string? name] { get { throw null; } }
protected override System.Collections.ArrayList List { get { throw null; } }
public event System.ComponentModel.CollectionChangeEventHandler? CollectionChanged { add { } remove { } }
public void Add(System.Data.Constraint constraint) { }
public System.Data.Constraint Add(string? name, System.Data.DataColumn column, bool primaryKey) { throw null; }
public System.Data.Constraint Add(string? name, System.Data.DataColumn primaryKeyColumn, System.Data.DataColumn foreignKeyColumn) { throw null; }
public System.Data.Constraint Add(string? name, System.Data.DataColumn[] columns, bool primaryKey) { throw null; }
public System.Data.Constraint Add(string? name, System.Data.DataColumn[] primaryKeyColumns, System.Data.DataColumn[] foreignKeyColumns) { throw null; }
public void AddRange(System.Data.Constraint[]? constraints) { }
public bool CanRemove(System.Data.Constraint constraint) { throw null; }
public void Clear() { }
public bool Contains(string? name) { throw null; }
public void CopyTo(System.Data.Constraint[] array, int index) { }
public int IndexOf(System.Data.Constraint? constraint) { throw null; }
public int IndexOf(string? constraintName) { throw null; }
public void Remove(System.Data.Constraint constraint) { }
public void Remove(string name) { }
public void RemoveAt(int index) { }
}
public partial class ConstraintException : System.Data.DataException
{
public ConstraintException() { }
protected ConstraintException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public ConstraintException(string? s) { }
public ConstraintException(string? message, System.Exception? innerException) { }
}
[System.ComponentModel.DefaultPropertyAttribute("ColumnName")]
[System.ComponentModel.DesignTimeVisibleAttribute(false)]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.DataColumnEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.ToolboxItemAttribute(false)]
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
public partial class DataColumn : System.ComponentModel.MarshalByValueComponent
{
public DataColumn() { }
public DataColumn(string? columnName) { }
public DataColumn(string? columnName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type dataType) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types or types used in expressions may be trimmed if not referenced directly.")]
public DataColumn(string? columnName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type dataType, string? expr) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types or types used in expressions may be trimmed if not referenced directly.")]
public DataColumn(string? columnName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type dataType, string? expr, System.Data.MappingType type) { }
[System.ComponentModel.DefaultValueAttribute(true)]
public bool AllowDBNull { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(false)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public bool AutoIncrement { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute((long)0)]
public long AutoIncrementSeed { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute((long)1)]
public long AutoIncrementStep { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Caption { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(System.Data.MappingType.Element)]
public virtual System.Data.MappingType ColumnMapping { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string ColumnName { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(System.Data.DataSetDateTime.UnspecifiedLocal)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public System.Data.DataSetDateTime DateTimeMode { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Expression { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from types used in the expressions may be trimmed if not referenced directly.")] set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.PropertyCollection ExtendedProperties { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute(-1)]
public int MaxLength { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Namespace { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public int Ordinal { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Prefix { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(false)]
public bool ReadOnly { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.DataTable? Table { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public bool Unique { get { throw null; } set { } }
protected internal void CheckNotAllowNull() { }
protected void CheckUnique() { }
protected virtual void OnPropertyChanging(System.ComponentModel.PropertyChangedEventArgs pcevent) { }
protected internal void RaisePropertyChanging(string name) { }
public void SetOrdinal(int ordinal) { }
public override string ToString() { throw null; }
}
public partial class DataColumnChangeEventArgs : System.EventArgs
{
public DataColumnChangeEventArgs(System.Data.DataRow row, System.Data.DataColumn? column, object? value) { }
public System.Data.DataColumn? Column { get { throw null; } }
public object? ProposedValue { get { throw null; } set { } }
public System.Data.DataRow Row { get { throw null; } }
}
public delegate void DataColumnChangeEventHandler(object sender, System.Data.DataColumnChangeEventArgs e);
[System.ComponentModel.DefaultEventAttribute("CollectionChanged")]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.ColumnsCollectionEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public sealed partial class DataColumnCollection : System.Data.InternalDataCollectionBase
{
internal DataColumnCollection() { }
public System.Data.DataColumn this[int index] { get { throw null; } }
public System.Data.DataColumn? this[string name] { get { throw null; } }
protected override System.Collections.ArrayList List { get { throw null; } }
public event System.ComponentModel.CollectionChangeEventHandler? CollectionChanged { add { } remove { } }
public System.Data.DataColumn Add() { throw null; }
public void Add(System.Data.DataColumn column) { }
public System.Data.DataColumn Add(string? columnName) { throw null; }
public System.Data.DataColumn Add(string? columnName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type type) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members might be trimmed for some data types or expressions.")]
public System.Data.DataColumn Add(string? columnName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type type, string expression) { throw null; }
public void AddRange(System.Data.DataColumn[] columns) { }
public bool CanRemove(System.Data.DataColumn? column) { throw null; }
public void Clear() { }
public bool Contains(string name) { throw null; }
public void CopyTo(System.Data.DataColumn[] array, int index) { }
public int IndexOf(System.Data.DataColumn? column) { throw null; }
public int IndexOf(string? columnName) { throw null; }
public void Remove(System.Data.DataColumn column) { }
public void Remove(string name) { }
public void RemoveAt(int index) { }
}
public partial class DataException : System.SystemException
{
public DataException() { }
protected DataException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public DataException(string? s) { }
public DataException(string? s, System.Exception? innerException) { }
}
public static partial class DataReaderExtensions
{
public static bool GetBoolean(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static byte GetByte(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static long GetBytes(this System.Data.Common.DbDataReader reader, string name, long dataOffset, byte[] buffer, int bufferOffset, int length) { throw null; }
public static char GetChar(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static long GetChars(this System.Data.Common.DbDataReader reader, string name, long dataOffset, char[] buffer, int bufferOffset, int length) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static System.Data.Common.DbDataReader GetData(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static string GetDataTypeName(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static System.DateTime GetDateTime(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static decimal GetDecimal(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static double GetDouble(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static System.Type GetFieldType(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static System.Threading.Tasks.Task<T> GetFieldValueAsync<T>(this System.Data.Common.DbDataReader reader, string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public static T GetFieldValue<T>(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static float GetFloat(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static System.Guid GetGuid(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static short GetInt16(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static int GetInt32(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static long GetInt64(this System.Data.Common.DbDataReader reader, string name) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static System.Type GetProviderSpecificFieldType(this System.Data.Common.DbDataReader reader, string name) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static object GetProviderSpecificValue(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static System.IO.Stream GetStream(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static string GetString(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static System.IO.TextReader GetTextReader(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static object GetValue(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static bool IsDBNull(this System.Data.Common.DbDataReader reader, string name) { throw null; }
public static System.Threading.Tasks.Task<bool> IsDBNullAsync(this System.Data.Common.DbDataReader reader, string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
[System.ComponentModel.DefaultPropertyAttribute("RelationName")]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.DataRelationEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public partial class DataRelation
{
public DataRelation(string? relationName, System.Data.DataColumn parentColumn, System.Data.DataColumn childColumn) { }
public DataRelation(string? relationName, System.Data.DataColumn parentColumn, System.Data.DataColumn childColumn, bool createConstraints) { }
public DataRelation(string? relationName, System.Data.DataColumn[] parentColumns, System.Data.DataColumn[] childColumns) { }
public DataRelation(string? relationName, System.Data.DataColumn[] parentColumns, System.Data.DataColumn[] childColumns, bool createConstraints) { }
[System.ComponentModel.BrowsableAttribute(false)]
public DataRelation(string relationName, string? parentTableName, string? parentTableNamespace, string? childTableName, string? childTableNamespace, string[]? parentColumnNames, string[]? childColumnNames, bool nested) { }
[System.ComponentModel.BrowsableAttribute(false)]
public DataRelation(string relationName, string? parentTableName, string? childTableName, string[]? parentColumnNames, string[]? childColumnNames, bool nested) { }
public virtual System.Data.DataColumn[] ChildColumns { get { throw null; } }
public virtual System.Data.ForeignKeyConstraint? ChildKeyConstraint { get { throw null; } }
public virtual System.Data.DataTable ChildTable { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public virtual System.Data.DataSet? DataSet { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.PropertyCollection ExtendedProperties { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute(false)]
public virtual bool Nested { get { throw null; } set { } }
public virtual System.Data.DataColumn[] ParentColumns { get { throw null; } }
public virtual System.Data.UniqueConstraint? ParentKeyConstraint { get { throw null; } }
public virtual System.Data.DataTable ParentTable { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public virtual string RelationName { get { throw null; } set { } }
protected void CheckStateForProperty() { }
protected internal void OnPropertyChanging(System.ComponentModel.PropertyChangedEventArgs pcevent) { }
protected internal void RaisePropertyChanging(string name) { }
public override string ToString() { throw null; }
}
[System.ComponentModel.DefaultEventAttribute("CollectionChanged")]
[System.ComponentModel.DefaultPropertyAttribute("Table")]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.DataRelationCollectionEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public abstract partial class DataRelationCollection : System.Data.InternalDataCollectionBase
{
protected DataRelationCollection() { }
public abstract System.Data.DataRelation this[int index] { get; }
public abstract System.Data.DataRelation? this[string? name] { get; }
public event System.ComponentModel.CollectionChangeEventHandler? CollectionChanged { add { } remove { } }
public virtual System.Data.DataRelation Add(System.Data.DataColumn parentColumn, System.Data.DataColumn childColumn) { throw null; }
public virtual System.Data.DataRelation Add(System.Data.DataColumn[] parentColumns, System.Data.DataColumn[] childColumns) { throw null; }
public void Add(System.Data.DataRelation relation) { }
public virtual System.Data.DataRelation Add(string? name, System.Data.DataColumn parentColumn, System.Data.DataColumn childColumn) { throw null; }
public virtual System.Data.DataRelation Add(string? name, System.Data.DataColumn parentColumn, System.Data.DataColumn childColumn, bool createConstraints) { throw null; }
public virtual System.Data.DataRelation Add(string? name, System.Data.DataColumn[] parentColumns, System.Data.DataColumn[] childColumns) { throw null; }
public virtual System.Data.DataRelation Add(string? name, System.Data.DataColumn[] parentColumns, System.Data.DataColumn[] childColumns, bool createConstraints) { throw null; }
protected virtual void AddCore(System.Data.DataRelation relation) { }
public virtual void AddRange(System.Data.DataRelation[]? relations) { }
public virtual bool CanRemove(System.Data.DataRelation? relation) { throw null; }
public virtual void Clear() { }
public virtual bool Contains(string? name) { throw null; }
public void CopyTo(System.Data.DataRelation[] array, int index) { }
protected abstract System.Data.DataSet GetDataSet();
public virtual int IndexOf(System.Data.DataRelation? relation) { throw null; }
public virtual int IndexOf(string? relationName) { throw null; }
protected virtual void OnCollectionChanged(System.ComponentModel.CollectionChangeEventArgs ccevent) { }
protected virtual void OnCollectionChanging(System.ComponentModel.CollectionChangeEventArgs ccevent) { }
public void Remove(System.Data.DataRelation relation) { }
public void Remove(string name) { }
public void RemoveAt(int index) { }
protected virtual void RemoveCore(System.Data.DataRelation relation) { }
}
public partial class DataRow
{
protected internal DataRow(System.Data.DataRowBuilder builder) { }
public bool HasErrors { get { throw null; } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public object this[System.Data.DataColumn column] { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public object this[System.Data.DataColumn column, System.Data.DataRowVersion version] { get { throw null; } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public object this[int columnIndex] { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public object this[int columnIndex, System.Data.DataRowVersion version] { get { throw null; } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public object this[string columnName] { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public object this[string columnName, System.Data.DataRowVersion version] { get { throw null; } }
public object?[] ItemArray { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string RowError { get { throw null; } set { } }
public System.Data.DataRowState RowState { get { throw null; } }
public System.Data.DataTable Table { get { throw null; } }
public void AcceptChanges() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public void BeginEdit() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public void CancelEdit() { }
public void ClearErrors() { }
public void Delete() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public void EndEdit() { }
public System.Data.DataRow[] GetChildRows(System.Data.DataRelation? relation) { throw null; }
public System.Data.DataRow[] GetChildRows(System.Data.DataRelation? relation, System.Data.DataRowVersion version) { throw null; }
public System.Data.DataRow[] GetChildRows(string? relationName) { throw null; }
public System.Data.DataRow[] GetChildRows(string? relationName, System.Data.DataRowVersion version) { throw null; }
public string GetColumnError(System.Data.DataColumn column) { throw null; }
public string GetColumnError(int columnIndex) { throw null; }
public string GetColumnError(string columnName) { throw null; }
public System.Data.DataColumn[] GetColumnsInError() { throw null; }
public System.Data.DataRow? GetParentRow(System.Data.DataRelation? relation) { throw null; }
public System.Data.DataRow? GetParentRow(System.Data.DataRelation? relation, System.Data.DataRowVersion version) { throw null; }
public System.Data.DataRow? GetParentRow(string? relationName) { throw null; }
public System.Data.DataRow? GetParentRow(string? relationName, System.Data.DataRowVersion version) { throw null; }
public System.Data.DataRow[] GetParentRows(System.Data.DataRelation? relation) { throw null; }
public System.Data.DataRow[] GetParentRows(System.Data.DataRelation? relation, System.Data.DataRowVersion version) { throw null; }
public System.Data.DataRow[] GetParentRows(string? relationName) { throw null; }
public System.Data.DataRow[] GetParentRows(string? relationName, System.Data.DataRowVersion version) { throw null; }
public bool HasVersion(System.Data.DataRowVersion version) { throw null; }
public bool IsNull(System.Data.DataColumn column) { throw null; }
public bool IsNull(System.Data.DataColumn column, System.Data.DataRowVersion version) { throw null; }
public bool IsNull(int columnIndex) { throw null; }
public bool IsNull(string columnName) { throw null; }
public void RejectChanges() { }
public void SetAdded() { }
public void SetColumnError(System.Data.DataColumn column, string? error) { }
public void SetColumnError(int columnIndex, string? error) { }
public void SetColumnError(string columnName, string? error) { }
public void SetModified() { }
protected void SetNull(System.Data.DataColumn column) { }
public void SetParentRow(System.Data.DataRow? parentRow) { }
public void SetParentRow(System.Data.DataRow? parentRow, System.Data.DataRelation? relation) { }
}
[System.FlagsAttribute]
public enum DataRowAction
{
Nothing = 0,
Delete = 1,
Change = 2,
Rollback = 4,
Commit = 8,
Add = 16,
ChangeOriginal = 32,
ChangeCurrentAndOriginal = 64,
}
public sealed partial class DataRowBuilder
{
internal DataRowBuilder() { }
}
public partial class DataRowChangeEventArgs : System.EventArgs
{
public DataRowChangeEventArgs(System.Data.DataRow row, System.Data.DataRowAction action) { }
public System.Data.DataRowAction Action { get { throw null; } }
public System.Data.DataRow Row { get { throw null; } }
}
public delegate void DataRowChangeEventHandler(object sender, System.Data.DataRowChangeEventArgs e);
public sealed partial class DataRowCollection : System.Data.InternalDataCollectionBase
{
internal DataRowCollection() { }
public override int Count { get { throw null; } }
public System.Data.DataRow this[int index] { get { throw null; } }
public void Add(System.Data.DataRow row) { }
public System.Data.DataRow Add(params object?[] values) { throw null; }
public void Clear() { }
public bool Contains(object? key) { throw null; }
public bool Contains(object?[] keys) { throw null; }
public override void CopyTo(System.Array ar, int index) { }
public void CopyTo(System.Data.DataRow[] array, int index) { }
public System.Data.DataRow? Find(object? key) { throw null; }
public System.Data.DataRow? Find(object?[] keys) { throw null; }
public override System.Collections.IEnumerator GetEnumerator() { throw null; }
public int IndexOf(System.Data.DataRow? row) { throw null; }
public void InsertAt(System.Data.DataRow row, int pos) { }
public void Remove(System.Data.DataRow row) { }
public void RemoveAt(int index) { }
}
public static partial class DataRowComparer
{
public static System.Data.DataRowComparer<System.Data.DataRow> Default { get { throw null; } }
}
public sealed partial class DataRowComparer<TRow> : System.Collections.Generic.IEqualityComparer<TRow> where TRow : System.Data.DataRow
{
internal DataRowComparer() { }
public static System.Data.DataRowComparer<TRow> Default { get { throw null; } }
public bool Equals(TRow? leftRow, TRow? rightRow) { throw null; }
public int GetHashCode(TRow row) { throw null; }
}
public static partial class DataRowExtensions
{
public static T? Field<T>(this System.Data.DataRow row, System.Data.DataColumn column) { throw null; }
public static T? Field<T>(this System.Data.DataRow row, System.Data.DataColumn column, System.Data.DataRowVersion version) { throw null; }
public static T? Field<T>(this System.Data.DataRow row, int columnIndex) { throw null; }
public static T? Field<T>(this System.Data.DataRow row, int columnIndex, System.Data.DataRowVersion version) { throw null; }
public static T? Field<T>(this System.Data.DataRow row, string columnName) { throw null; }
public static T? Field<T>(this System.Data.DataRow row, string columnName, System.Data.DataRowVersion version) { throw null; }
public static void SetField<T>(this System.Data.DataRow row, System.Data.DataColumn column, T? value) { }
public static void SetField<T>(this System.Data.DataRow row, int columnIndex, T? value) { }
public static void SetField<T>(this System.Data.DataRow row, string columnName, T? value) { }
}
[System.FlagsAttribute]
public enum DataRowState
{
Detached = 1,
Unchanged = 2,
Added = 4,
Deleted = 8,
Modified = 16,
}
public enum DataRowVersion
{
Original = 256,
Current = 512,
Proposed = 1024,
Default = 1536,
}
public partial class DataRowView : System.ComponentModel.ICustomTypeDescriptor, System.ComponentModel.IDataErrorInfo, System.ComponentModel.IEditableObject, System.ComponentModel.INotifyPropertyChanged
{
internal DataRowView() { }
public System.Data.DataView DataView { get { throw null; } }
public bool IsEdit { get { throw null; } }
public bool IsNew { get { throw null; } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public object this[int ndx] { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public object this[string property] { get { throw null; } set { } }
public System.Data.DataRow Row { get { throw null; } }
public System.Data.DataRowVersion RowVersion { get { throw null; } }
string System.ComponentModel.IDataErrorInfo.Error { get { throw null; } }
string System.ComponentModel.IDataErrorInfo.this[string colName] { get { throw null; } }
public event System.ComponentModel.PropertyChangedEventHandler? PropertyChanged { add { } remove { } }
public void BeginEdit() { }
public void CancelEdit() { }
public System.Data.DataView CreateChildView(System.Data.DataRelation relation) { throw null; }
public System.Data.DataView CreateChildView(System.Data.DataRelation relation, bool followParent) { throw null; }
public System.Data.DataView CreateChildView(string relationName) { throw null; }
public System.Data.DataView CreateChildView(string relationName, bool followParent) { throw null; }
public void Delete() { }
public void EndEdit() { }
public override bool Equals(object? other) { throw null; }
public override int GetHashCode() { throw null; }
System.ComponentModel.AttributeCollection System.ComponentModel.ICustomTypeDescriptor.GetAttributes() { throw null; }
string System.ComponentModel.ICustomTypeDescriptor.GetClassName() { throw null; }
string System.ComponentModel.ICustomTypeDescriptor.GetComponentName() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
System.ComponentModel.TypeConverter System.ComponentModel.ICustomTypeDescriptor.GetConverter() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
System.ComponentModel.EventDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultEvent() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")]
System.ComponentModel.PropertyDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultProperty() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")]
object System.ComponentModel.ICustomTypeDescriptor.GetEditor(System.Type editorBaseType) { throw null; }
System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents(System.Attribute[]? attributes) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")]
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties(System.Attribute[]? attributes) { throw null; }
object System.ComponentModel.ICustomTypeDescriptor.GetPropertyOwner(System.ComponentModel.PropertyDescriptor? pd) { throw null; }
}
[System.ComponentModel.DefaultPropertyAttribute("DataSetName")]
[System.ComponentModel.DesignerAttribute("Microsoft.VSDesigner.Data.VS.DataSetDesigner, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.ToolboxItemAttribute("Microsoft.VSDesigner.Data.VS.DataSetToolboxItem, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.Xml.Serialization.XmlRootAttribute("DataSet")]
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetDataSetSchema")]
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors)]
public partial class DataSet : System.ComponentModel.MarshalByValueComponent, System.ComponentModel.IListSource, System.ComponentModel.ISupportInitialize, System.ComponentModel.ISupportInitializeNotification, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
{
public DataSet() { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected DataSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected DataSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context, bool ConstructSchema) { }
public DataSet(string dataSetName) { }
[System.ComponentModel.DefaultValueAttribute(false)]
public bool CaseSensitive { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
public string DataSetName { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.DataViewManager DefaultViewManager { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute(true)]
public bool EnforceConstraints { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.PropertyCollection ExtendedProperties { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool HasErrors { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool IsInitialized { get { throw null; } }
public System.Globalization.CultureInfo Locale { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Namespace { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Prefix { get { throw null; } set { } }
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
public System.Data.DataRelationCollection Relations { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute(System.Data.SerializationFormat.Xml)]
public System.Data.SerializationFormat RemotingFormat { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public virtual System.Data.SchemaSerializationMode SchemaSerializationMode { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public override System.ComponentModel.ISite? Site { get { throw null; } set { } }
bool System.ComponentModel.IListSource.ContainsListCollection { get { throw null; } }
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
public System.Data.DataTableCollection Tables { get { throw null; } }
public event System.EventHandler? Initialized { add { } remove { } }
public event System.Data.MergeFailedEventHandler? MergeFailed { add { } remove { } }
public void AcceptChanges() { }
public void BeginInit() { }
public void Clear() { }
public virtual System.Data.DataSet Clone() { throw null; }
public System.Data.DataSet Copy() { throw null; }
public System.Data.DataTableReader CreateDataReader() { throw null; }
public System.Data.DataTableReader CreateDataReader(params System.Data.DataTable[] dataTables) { throw null; }
protected System.Data.SchemaSerializationMode DetermineSchemaSerializationMode(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { throw null; }
protected System.Data.SchemaSerializationMode DetermineSchemaSerializationMode(System.Xml.XmlReader reader) { throw null; }
public void EndInit() { }
public System.Data.DataSet? GetChanges() { throw null; }
public System.Data.DataSet? GetChanges(System.Data.DataRowState rowStates) { throw null; }
public static System.Xml.Schema.XmlSchemaComplexType GetDataSetSchema(System.Xml.Schema.XmlSchemaSet? schemaSet) { throw null; }
public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
protected virtual System.Xml.Schema.XmlSchema? GetSchemaSerializable() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected void GetSerializationData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public string GetXml() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public string GetXmlSchema() { throw null; }
public bool HasChanges() { throw null; }
public bool HasChanges(System.Data.DataRowState rowStates) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void InferXmlSchema(System.IO.Stream? stream, string[]? nsArray) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void InferXmlSchema(System.IO.TextReader? reader, string[]? nsArray) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void InferXmlSchema(string fileName, string[]? nsArray) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void InferXmlSchema(System.Xml.XmlReader? reader, string[]? nsArray) { }
protected virtual void InitializeDerivedDataSet() { }
protected bool IsBinarySerialized(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Using LoadOption may cause members from types used in the expression column to be trimmed if not referenced directly.")]
public void Load(System.Data.IDataReader reader, System.Data.LoadOption loadOption, params System.Data.DataTable[] tables) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Using LoadOption may cause members from types used in the expression column to be trimmed if not referenced directly.")]
public virtual void Load(System.Data.IDataReader reader, System.Data.LoadOption loadOption, System.Data.FillErrorEventHandler? errorHandler, params System.Data.DataTable[] tables) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Using LoadOption may cause members from types used in the expression column to be trimmed if not referenced directly.")]
public void Load(System.Data.IDataReader reader, System.Data.LoadOption loadOption, params string[] tables) { }
public void Merge(System.Data.DataRow[] rows) { }
public void Merge(System.Data.DataRow[] rows, bool preserveChanges, System.Data.MissingSchemaAction missingSchemaAction) { }
public void Merge(System.Data.DataSet dataSet) { }
public void Merge(System.Data.DataSet dataSet, bool preserveChanges) { }
public void Merge(System.Data.DataSet dataSet, bool preserveChanges, System.Data.MissingSchemaAction missingSchemaAction) { }
public void Merge(System.Data.DataTable table) { }
public void Merge(System.Data.DataTable table, bool preserveChanges, System.Data.MissingSchemaAction missingSchemaAction) { }
protected virtual void OnPropertyChanging(System.ComponentModel.PropertyChangedEventArgs pcevent) { }
protected virtual void OnRemoveRelation(System.Data.DataRelation relation) { }
protected internal virtual void OnRemoveTable(System.Data.DataTable table) { }
protected internal void RaisePropertyChanging(string name) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(System.IO.Stream? stream) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(System.IO.Stream? stream, System.Data.XmlReadMode mode) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(System.IO.TextReader? reader) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(System.IO.TextReader? reader, System.Data.XmlReadMode mode) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(string fileName) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(string fileName, System.Data.XmlReadMode mode) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(System.Xml.XmlReader? reader) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(System.Xml.XmlReader? reader, System.Data.XmlReadMode mode) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void ReadXmlSchema(System.IO.Stream? stream) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void ReadXmlSchema(System.IO.TextReader? reader) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void ReadXmlSchema(string fileName) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void ReadXmlSchema(System.Xml.XmlReader? reader) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected virtual void ReadXmlSerializable(System.Xml.XmlReader reader) { }
public virtual void RejectChanges() { }
public virtual void Reset() { }
protected virtual bool ShouldSerializeRelations() { throw null; }
protected virtual bool ShouldSerializeTables() { throw null; }
System.Collections.IList System.ComponentModel.IListSource.GetList() { throw null; }
System.Xml.Schema.XmlSchema System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.Stream? stream) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.Stream? stream, System.Data.XmlWriteMode mode) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.TextWriter? writer) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.TextWriter? writer, System.Data.XmlWriteMode mode) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(string fileName) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(string fileName, System.Data.XmlWriteMode mode) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.Xml.XmlWriter? writer) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.Xml.XmlWriter? writer, System.Data.XmlWriteMode mode) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.IO.Stream? stream) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.IO.Stream? stream, System.Converter<System.Type, string> multipleTargetConverter) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.IO.TextWriter? writer) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.IO.TextWriter? writer, System.Converter<System.Type, string> multipleTargetConverter) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(string fileName) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(string fileName, System.Converter<System.Type, string> multipleTargetConverter) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.Xml.XmlWriter? writer) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.Xml.XmlWriter? writer, System.Converter<System.Type, string> multipleTargetConverter) { }
}
public enum DataSetDateTime
{
Local = 1,
Unspecified = 2,
UnspecifiedLocal = 3,
Utc = 4,
}
[System.AttributeUsageAttribute(System.AttributeTargets.All)]
[System.ObsoleteAttribute("DataSysDescriptionAttribute has been deprecated and is not supported.")]
public partial class DataSysDescriptionAttribute : System.ComponentModel.DescriptionAttribute
{
[System.ObsoleteAttribute("DataSysDescriptionAttribute has been deprecated and is not supported.")]
public DataSysDescriptionAttribute(string description) { }
public override string Description { get { throw null; } }
}
[System.ComponentModel.DefaultEventAttribute("RowChanging")]
[System.ComponentModel.DefaultPropertyAttribute("TableName")]
[System.ComponentModel.DesignTimeVisibleAttribute(false)]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.DataTableEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.ToolboxItemAttribute(false)]
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetDataTableSchema")]
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors)]
public partial class DataTable : System.ComponentModel.MarshalByValueComponent, System.ComponentModel.IListSource, System.ComponentModel.ISupportInitialize, System.ComponentModel.ISupportInitializeNotification, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
{
protected internal bool fInitInProgress;
public DataTable() { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected DataTable(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public DataTable(string? tableName) { }
public DataTable(string? tableName, string? tableNamespace) { }
public bool CaseSensitive { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.DataRelationCollection ChildRelations { get { throw null; } }
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
public System.Data.DataColumnCollection Columns { get { throw null; } }
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
public System.Data.ConstraintCollection Constraints { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.DataSet? DataSet { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.DataView DefaultView { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string DisplayExpression { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from types used in the expressions may be trimmed if not referenced directly.")] set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.PropertyCollection ExtendedProperties { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool HasErrors { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool IsInitialized { get { throw null; } }
public System.Globalization.CultureInfo Locale { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(50)]
public int MinimumCapacity { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Namespace { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.DataRelationCollection ParentRelations { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Prefix { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(System.Data.SerializationFormat.Xml)]
public System.Data.SerializationFormat RemotingFormat { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.DataRowCollection Rows { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public override System.ComponentModel.ISite? Site { get { throw null; } set { } }
bool System.ComponentModel.IListSource.ContainsListCollection { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string TableName { get { throw null; } set { } }
public event System.Data.DataColumnChangeEventHandler? ColumnChanged { add { } remove { } }
public event System.Data.DataColumnChangeEventHandler? ColumnChanging { add { } remove { } }
public event System.EventHandler? Initialized { add { } remove { } }
public event System.Data.DataRowChangeEventHandler? RowChanged { add { } remove { } }
public event System.Data.DataRowChangeEventHandler? RowChanging { add { } remove { } }
public event System.Data.DataRowChangeEventHandler? RowDeleted { add { } remove { } }
public event System.Data.DataRowChangeEventHandler? RowDeleting { add { } remove { } }
public event System.Data.DataTableClearEventHandler? TableCleared { add { } remove { } }
public event System.Data.DataTableClearEventHandler? TableClearing { add { } remove { } }
public event System.Data.DataTableNewRowEventHandler? TableNewRow { add { } remove { } }
public void AcceptChanges() { }
public virtual void BeginInit() { }
public void BeginLoadData() { }
public void Clear() { }
public virtual System.Data.DataTable Clone() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter or expression might be trimmed.")]
public object Compute(string? expression, string? filter) { throw null; }
public System.Data.DataTable Copy() { throw null; }
public System.Data.DataTableReader CreateDataReader() { throw null; }
protected virtual System.Data.DataTable CreateInstance() { throw null; }
public virtual void EndInit() { }
public void EndLoadData() { }
public System.Data.DataTable? GetChanges() { throw null; }
public System.Data.DataTable? GetChanges(System.Data.DataRowState rowStates) { throw null; }
public static System.Xml.Schema.XmlSchemaComplexType GetDataTableSchema(System.Xml.Schema.XmlSchemaSet? schemaSet) { throw null; }
public System.Data.DataRow[] GetErrors() { throw null; }
public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
protected virtual System.Type GetRowType() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected virtual System.Xml.Schema.XmlSchema? GetSchema() { throw null; }
public void ImportRow(System.Data.DataRow? row) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from types used in the expression column to be trimmed if not referenced directly.")]
public void Load(System.Data.IDataReader reader) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Using LoadOption may cause members from types used in the expression column to be trimmed if not referenced directly.")]
public void Load(System.Data.IDataReader reader, System.Data.LoadOption loadOption) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Using LoadOption may cause members from types used in the expression column to be trimmed if not referenced directly.")]
public virtual void Load(System.Data.IDataReader reader, System.Data.LoadOption loadOption, System.Data.FillErrorEventHandler? errorHandler) { }
public System.Data.DataRow LoadDataRow(object?[] values, bool fAcceptChanges) { throw null; }
public System.Data.DataRow LoadDataRow(object?[] values, System.Data.LoadOption loadOption) { throw null; }
public void Merge(System.Data.DataTable table) { }
public void Merge(System.Data.DataTable table, bool preserveChanges) { }
public void Merge(System.Data.DataTable table, bool preserveChanges, System.Data.MissingSchemaAction missingSchemaAction) { }
public System.Data.DataRow NewRow() { throw null; }
protected internal System.Data.DataRow[] NewRowArray(int size) { throw null; }
protected virtual System.Data.DataRow NewRowFromBuilder(System.Data.DataRowBuilder builder) { throw null; }
protected internal virtual void OnColumnChanged(System.Data.DataColumnChangeEventArgs e) { }
protected internal virtual void OnColumnChanging(System.Data.DataColumnChangeEventArgs e) { }
protected virtual void OnPropertyChanging(System.ComponentModel.PropertyChangedEventArgs pcevent) { }
protected virtual void OnRemoveColumn(System.Data.DataColumn column) { }
protected virtual void OnRowChanged(System.Data.DataRowChangeEventArgs e) { }
protected virtual void OnRowChanging(System.Data.DataRowChangeEventArgs e) { }
protected virtual void OnRowDeleted(System.Data.DataRowChangeEventArgs e) { }
protected virtual void OnRowDeleting(System.Data.DataRowChangeEventArgs e) { }
protected virtual void OnTableCleared(System.Data.DataTableClearEventArgs e) { }
protected virtual void OnTableClearing(System.Data.DataTableClearEventArgs e) { }
protected virtual void OnTableNewRow(System.Data.DataTableNewRowEventArgs e) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(System.IO.Stream? stream) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(System.IO.TextReader? reader) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(string fileName) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public System.Data.XmlReadMode ReadXml(System.Xml.XmlReader? reader) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void ReadXmlSchema(System.IO.Stream? stream) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void ReadXmlSchema(System.IO.TextReader? reader) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void ReadXmlSchema(string fileName) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void ReadXmlSchema(System.Xml.XmlReader? reader) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected virtual void ReadXmlSerializable(System.Xml.XmlReader? reader) { }
public void RejectChanges() { }
public virtual void Reset() { }
public System.Data.DataRow[] Select() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")]
public System.Data.DataRow[] Select(string? filterExpression) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")]
public System.Data.DataRow[] Select(string? filterExpression, string? sort) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")]
public System.Data.DataRow[] Select(string? filterExpression, string? sort, System.Data.DataViewRowState recordStates) { throw null; }
System.Collections.IList System.ComponentModel.IListSource.GetList() { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public override string ToString() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.Stream? stream) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.Stream? stream, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.Stream? stream, System.Data.XmlWriteMode mode) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.Stream? stream, System.Data.XmlWriteMode mode, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.TextWriter? writer) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.TextWriter? writer, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.TextWriter? writer, System.Data.XmlWriteMode mode) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.IO.TextWriter? writer, System.Data.XmlWriteMode mode, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(string fileName) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(string fileName, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(string fileName, System.Data.XmlWriteMode mode) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(string fileName, System.Data.XmlWriteMode mode, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.Xml.XmlWriter? writer) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.Xml.XmlWriter? writer, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.Xml.XmlWriter? writer, System.Data.XmlWriteMode mode) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXml(System.Xml.XmlWriter? writer, System.Data.XmlWriteMode mode, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.IO.Stream? stream) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.IO.Stream? stream, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.IO.TextWriter? writer) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.IO.TextWriter? writer, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(string fileName) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(string fileName, bool writeHierarchy) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.Xml.XmlWriter? writer) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
public void WriteXmlSchema(System.Xml.XmlWriter? writer, bool writeHierarchy) { }
}
public sealed partial class DataTableClearEventArgs : System.EventArgs
{
public DataTableClearEventArgs(System.Data.DataTable dataTable) { }
public System.Data.DataTable Table { get { throw null; } }
public string TableName { get { throw null; } }
public string TableNamespace { get { throw null; } }
}
public delegate void DataTableClearEventHandler(object sender, System.Data.DataTableClearEventArgs e);
[System.ComponentModel.DefaultEventAttribute("CollectionChanged")]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.TablesCollectionEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.ListBindableAttribute(false)]
public sealed partial class DataTableCollection : System.Data.InternalDataCollectionBase
{
internal DataTableCollection() { }
public System.Data.DataTable this[int index] { get { throw null; } }
public System.Data.DataTable? this[string? name] { get { throw null; } }
public System.Data.DataTable? this[string? name, string tableNamespace] { get { throw null; } }
protected override System.Collections.ArrayList List { get { throw null; } }
public event System.ComponentModel.CollectionChangeEventHandler? CollectionChanged { add { } remove { } }
public event System.ComponentModel.CollectionChangeEventHandler? CollectionChanging { add { } remove { } }
public System.Data.DataTable Add() { throw null; }
public void Add(System.Data.DataTable table) { }
public System.Data.DataTable Add(string? name) { throw null; }
public System.Data.DataTable Add(string? name, string? tableNamespace) { throw null; }
public void AddRange(System.Data.DataTable?[]? tables) { }
public bool CanRemove(System.Data.DataTable? table) { throw null; }
public void Clear() { }
public bool Contains(string? name) { throw null; }
public bool Contains(string name, string tableNamespace) { throw null; }
public void CopyTo(System.Data.DataTable[] array, int index) { }
public int IndexOf(System.Data.DataTable? table) { throw null; }
public int IndexOf(string? tableName) { throw null; }
public int IndexOf(string tableName, string tableNamespace) { throw null; }
public void Remove(System.Data.DataTable table) { }
public void Remove(string name) { }
public void Remove(string name, string tableNamespace) { }
public void RemoveAt(int index) { }
}
public static partial class DataTableExtensions
{
public static System.Data.DataView AsDataView(this System.Data.DataTable table) { throw null; }
public static System.Data.DataView AsDataView<T>(this System.Data.EnumerableRowCollection<T> source) where T : System.Data.DataRow { throw null; }
public static System.Data.EnumerableRowCollection<System.Data.DataRow> AsEnumerable(this System.Data.DataTable source) { throw null; }
public static System.Data.DataTable CopyToDataTable<T>(this System.Collections.Generic.IEnumerable<T> source) where T : System.Data.DataRow { throw null; }
public static void CopyToDataTable<T>(this System.Collections.Generic.IEnumerable<T> source, System.Data.DataTable table, System.Data.LoadOption options) where T : System.Data.DataRow { }
public static void CopyToDataTable<T>(this System.Collections.Generic.IEnumerable<T> source, System.Data.DataTable table, System.Data.LoadOption options, System.Data.FillErrorEventHandler? errorHandler) where T : System.Data.DataRow { }
}
public sealed partial class DataTableNewRowEventArgs : System.EventArgs
{
public DataTableNewRowEventArgs(System.Data.DataRow dataRow) { }
public System.Data.DataRow Row { get { throw null; } }
}
public delegate void DataTableNewRowEventHandler(object sender, System.Data.DataTableNewRowEventArgs e);
public sealed partial class DataTableReader : System.Data.Common.DbDataReader
{
public DataTableReader(System.Data.DataTable dataTable) { }
public DataTableReader(System.Data.DataTable[] dataTables) { }
public override int Depth { get { throw null; } }
public override int FieldCount { get { throw null; } }
public override bool HasRows { get { throw null; } }
public override bool IsClosed { get { throw null; } }
public override object this[int ordinal] { get { throw null; } }
public override object this[string name] { get { throw null; } }
public override int RecordsAffected { get { throw null; } }
public override void Close() { }
public override bool GetBoolean(int ordinal) { throw null; }
public override byte GetByte(int ordinal) { throw null; }
public override long GetBytes(int ordinal, long dataIndex, byte[]? buffer, int bufferIndex, int length) { throw null; }
public override char GetChar(int ordinal) { throw null; }
public override long GetChars(int ordinal, long dataIndex, char[]? buffer, int bufferIndex, int length) { throw null; }
public override string GetDataTypeName(int ordinal) { throw null; }
public override System.DateTime GetDateTime(int ordinal) { throw null; }
public override decimal GetDecimal(int ordinal) { throw null; }
public override double GetDouble(int ordinal) { throw null; }
public override System.Collections.IEnumerator GetEnumerator() { throw null; }
public override System.Type GetFieldType(int ordinal) { throw null; }
public override float GetFloat(int ordinal) { throw null; }
public override System.Guid GetGuid(int ordinal) { throw null; }
public override short GetInt16(int ordinal) { throw null; }
public override int GetInt32(int ordinal) { throw null; }
public override long GetInt64(int ordinal) { throw null; }
public override string GetName(int ordinal) { throw null; }
public override int GetOrdinal(string name) { throw null; }
public override System.Type GetProviderSpecificFieldType(int ordinal) { throw null; }
public override object GetProviderSpecificValue(int ordinal) { throw null; }
public override int GetProviderSpecificValues(object[] values) { throw null; }
public override System.Data.DataTable GetSchemaTable() { throw null; }
public override string GetString(int ordinal) { throw null; }
public override object GetValue(int ordinal) { throw null; }
public override int GetValues(object[] values) { throw null; }
public override bool IsDBNull(int ordinal) { throw null; }
public override bool NextResult() { throw null; }
public override bool Read() { throw null; }
}
[System.ComponentModel.DesignerAttribute("Microsoft.VSDesigner.Data.VS.DataViewDesigner, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.DefaultEventAttribute("PositionChanged")]
[System.ComponentModel.DefaultPropertyAttribute("Table")]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.DataSourceEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public partial class DataView : System.ComponentModel.MarshalByValueComponent, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.ComponentModel.IBindingList, System.ComponentModel.IBindingListView, System.ComponentModel.ISupportInitialize, System.ComponentModel.ISupportInitializeNotification, System.ComponentModel.ITypedList
{
public DataView() { }
public DataView(System.Data.DataTable? table) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")]
public DataView(System.Data.DataTable table, string? RowFilter, string? Sort, System.Data.DataViewRowState RowState) { }
[System.ComponentModel.DefaultValueAttribute(true)]
public bool AllowDelete { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(true)]
public bool AllowEdit { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(true)]
public bool AllowNew { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(false)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public bool ApplyDefaultSort { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public int Count { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.DataViewManager? DataViewManager { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool IsInitialized { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
protected bool IsOpen { get { throw null; } }
public System.Data.DataRowView this[int recordIndex] { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute("")]
public virtual string? RowFilter { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")] set { } }
[System.ComponentModel.DefaultValueAttribute(System.Data.DataViewRowState.CurrentRows)]
public System.Data.DataViewRowState RowStateFilter { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Sort { get { throw null; } set { } }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
bool System.Collections.IList.IsFixedSize { get { throw null; } }
bool System.Collections.IList.IsReadOnly { get { throw null; } }
object? System.Collections.IList.this[int recordIndex] { get { throw null; } set { } }
bool System.ComponentModel.IBindingList.AllowEdit { get { throw null; } }
bool System.ComponentModel.IBindingList.AllowNew { get { throw null; } }
bool System.ComponentModel.IBindingList.AllowRemove { get { throw null; } }
bool System.ComponentModel.IBindingList.IsSorted { get { throw null; } }
System.ComponentModel.ListSortDirection System.ComponentModel.IBindingList.SortDirection { get { throw null; } }
System.ComponentModel.PropertyDescriptor? System.ComponentModel.IBindingList.SortProperty { get { throw null; } }
bool System.ComponentModel.IBindingList.SupportsChangeNotification { get { throw null; } }
bool System.ComponentModel.IBindingList.SupportsSearching { get { throw null; } }
bool System.ComponentModel.IBindingList.SupportsSorting { get { throw null; } }
string? System.ComponentModel.IBindingListView.Filter { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")] set { } }
System.ComponentModel.ListSortDescriptionCollection System.ComponentModel.IBindingListView.SortDescriptions { get { throw null; } }
bool System.ComponentModel.IBindingListView.SupportsAdvancedSorting { get { throw null; } }
bool System.ComponentModel.IBindingListView.SupportsFiltering { get { throw null; } }
public event System.EventHandler? Initialized { add { } remove { } }
public event System.ComponentModel.ListChangedEventHandler? ListChanged { add { } remove { } }
public virtual System.Data.DataRowView AddNew() { throw null; }
public void BeginInit() { }
protected void Close() { }
protected virtual void ColumnCollectionChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e) { }
public void CopyTo(System.Array array, int index) { }
public void Delete(int index) { }
protected override void Dispose(bool disposing) { }
public void EndInit() { }
public virtual bool Equals(System.Data.DataView? view) { throw null; }
public int Find(object? key) { throw null; }
public int Find(object?[] key) { throw null; }
public System.Data.DataRowView[] FindRows(object? key) { throw null; }
public System.Data.DataRowView[] FindRows(object?[] key) { throw null; }
public System.Collections.IEnumerator GetEnumerator() { throw null; }
protected virtual void IndexListChanged(object sender, System.ComponentModel.ListChangedEventArgs e) { }
protected virtual void OnListChanged(System.ComponentModel.ListChangedEventArgs e) { }
protected void Open() { }
protected void Reset() { }
int System.Collections.IList.Add(object? value) { throw null; }
void System.Collections.IList.Clear() { }
bool System.Collections.IList.Contains(object? value) { throw null; }
int System.Collections.IList.IndexOf(object? value) { throw null; }
void System.Collections.IList.Insert(int index, object? value) { }
void System.Collections.IList.Remove(object? value) { }
void System.Collections.IList.RemoveAt(int index) { }
void System.ComponentModel.IBindingList.AddIndex(System.ComponentModel.PropertyDescriptor property) { }
object? System.ComponentModel.IBindingList.AddNew() { throw null; }
void System.ComponentModel.IBindingList.ApplySort(System.ComponentModel.PropertyDescriptor property, System.ComponentModel.ListSortDirection direction) { }
int System.ComponentModel.IBindingList.Find(System.ComponentModel.PropertyDescriptor property, object key) { throw null; }
void System.ComponentModel.IBindingList.RemoveIndex(System.ComponentModel.PropertyDescriptor property) { }
void System.ComponentModel.IBindingList.RemoveSort() { }
void System.ComponentModel.IBindingListView.ApplySort(System.ComponentModel.ListSortDescriptionCollection sorts) { }
void System.ComponentModel.IBindingListView.RemoveFilter() { }
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ITypedList.GetItemProperties(System.ComponentModel.PropertyDescriptor[] listAccessors) { throw null; }
string System.ComponentModel.ITypedList.GetListName(System.ComponentModel.PropertyDescriptor[] listAccessors) { throw null; }
public System.Data.DataTable ToTable() { throw null; }
public System.Data.DataTable ToTable(bool distinct, params string[] columnNames) { throw null; }
public System.Data.DataTable ToTable(string? tableName) { throw null; }
public System.Data.DataTable ToTable(string? tableName, bool distinct, params string[] columnNames) { throw null; }
protected void UpdateIndex() { }
protected virtual void UpdateIndex(bool force) { }
}
[System.ComponentModel.DesignerAttribute("Microsoft.VSDesigner.Data.VS.DataViewManagerDesigner, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public partial class DataViewManager : System.ComponentModel.MarshalByValueComponent, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.ComponentModel.IBindingList, System.ComponentModel.ITypedList
{
public DataViewManager() { }
public DataViewManager(System.Data.DataSet? dataSet) { }
[System.ComponentModel.DefaultValueAttribute(null)]
[System.Diagnostics.CodeAnalysis.DisallowNullAttribute]
public System.Data.DataSet? DataSet { get { throw null; } set { } }
public string DataViewSettingCollectionString { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Members of types used in the RowFilter expression might be trimmed.")] set { } }
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
public System.Data.DataViewSettingCollection DataViewSettings { get { throw null; } }
int System.Collections.ICollection.Count { get { throw null; } }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
bool System.Collections.IList.IsFixedSize { get { throw null; } }
bool System.Collections.IList.IsReadOnly { get { throw null; } }
object? System.Collections.IList.this[int index] { get { throw null; } set { } }
bool System.ComponentModel.IBindingList.AllowEdit { get { throw null; } }
bool System.ComponentModel.IBindingList.AllowNew { get { throw null; } }
bool System.ComponentModel.IBindingList.AllowRemove { get { throw null; } }
bool System.ComponentModel.IBindingList.IsSorted { get { throw null; } }
System.ComponentModel.ListSortDirection System.ComponentModel.IBindingList.SortDirection { get { throw null; } }
System.ComponentModel.PropertyDescriptor? System.ComponentModel.IBindingList.SortProperty { get { throw null; } }
bool System.ComponentModel.IBindingList.SupportsChangeNotification { get { throw null; } }
bool System.ComponentModel.IBindingList.SupportsSearching { get { throw null; } }
bool System.ComponentModel.IBindingList.SupportsSorting { get { throw null; } }
public event System.ComponentModel.ListChangedEventHandler? ListChanged { add { } remove { } }
public System.Data.DataView CreateDataView(System.Data.DataTable table) { throw null; }
protected virtual void OnListChanged(System.ComponentModel.ListChangedEventArgs e) { }
protected virtual void RelationCollectionChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e) { }
void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
int System.Collections.IList.Add(object? value) { throw null; }
void System.Collections.IList.Clear() { }
bool System.Collections.IList.Contains(object? value) { throw null; }
int System.Collections.IList.IndexOf(object? value) { throw null; }
void System.Collections.IList.Insert(int index, object? value) { }
void System.Collections.IList.Remove(object? value) { }
void System.Collections.IList.RemoveAt(int index) { }
void System.ComponentModel.IBindingList.AddIndex(System.ComponentModel.PropertyDescriptor property) { }
object? System.ComponentModel.IBindingList.AddNew() { throw null; }
void System.ComponentModel.IBindingList.ApplySort(System.ComponentModel.PropertyDescriptor property, System.ComponentModel.ListSortDirection direction) { }
int System.ComponentModel.IBindingList.Find(System.ComponentModel.PropertyDescriptor property, object key) { throw null; }
void System.ComponentModel.IBindingList.RemoveIndex(System.ComponentModel.PropertyDescriptor property) { }
void System.ComponentModel.IBindingList.RemoveSort() { }
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ITypedList.GetItemProperties(System.ComponentModel.PropertyDescriptor[] listAccessors) { throw null; }
string System.ComponentModel.ITypedList.GetListName(System.ComponentModel.PropertyDescriptor[] listAccessors) { throw null; }
protected virtual void TableCollectionChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e) { }
}
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.DataViewRowStateEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.FlagsAttribute]
public enum DataViewRowState
{
None = 0,
Unchanged = 2,
Added = 4,
Deleted = 8,
ModifiedCurrent = 16,
CurrentRows = 22,
ModifiedOriginal = 32,
OriginalRows = 42,
}
[System.ComponentModel.TypeConverterAttribute(typeof(System.ComponentModel.ExpandableObjectConverter))]
public partial class DataViewSetting
{
internal DataViewSetting() { }
public bool ApplyDefaultSort { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.DataViewManager? DataViewManager { get { throw null; } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string RowFilter { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members of types used in the filter expression might be trimmed.")] set { } }
public System.Data.DataViewRowState RowStateFilter { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string Sort { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public System.Data.DataTable? Table { get { throw null; } }
}
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.DataViewSettingsCollectionEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public partial class DataViewSettingCollection : System.Collections.ICollection, System.Collections.IEnumerable
{
internal DataViewSettingCollection() { }
[System.ComponentModel.BrowsableAttribute(false)]
public virtual int Count { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool IsReadOnly { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool IsSynchronized { get { throw null; } }
public virtual System.Data.DataViewSetting this[System.Data.DataTable table] { get { throw null; } set { } }
[System.Diagnostics.CodeAnalysis.DisallowNullAttribute]
public virtual System.Data.DataViewSetting? this[int index] { get { throw null; } set { } }
public virtual System.Data.DataViewSetting? this[string tableName] { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public object SyncRoot { get { throw null; } }
public void CopyTo(System.Array ar, int index) { }
public void CopyTo(System.Data.DataViewSetting[] ar, int index) { }
public System.Collections.IEnumerator GetEnumerator() { throw null; }
}
public sealed partial class DBConcurrencyException : System.SystemException
{
public DBConcurrencyException() { }
public DBConcurrencyException(string? message) { }
public DBConcurrencyException(string? message, System.Exception? inner) { }
public DBConcurrencyException(string? message, System.Exception? inner, System.Data.DataRow[]? dataRows) { }
[System.Diagnostics.CodeAnalysis.DisallowNullAttribute]
public System.Data.DataRow? Row { get { throw null; } set { } }
public int RowCount { get { throw null; } }
public void CopyToRows(System.Data.DataRow[] array) { }
public void CopyToRows(System.Data.DataRow[] array, int arrayIndex) { }
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
}
public enum DbType
{
AnsiString = 0,
Binary = 1,
Byte = 2,
Boolean = 3,
Currency = 4,
Date = 5,
DateTime = 6,
Decimal = 7,
Double = 8,
Guid = 9,
Int16 = 10,
Int32 = 11,
Int64 = 12,
Object = 13,
SByte = 14,
Single = 15,
String = 16,
Time = 17,
UInt16 = 18,
UInt32 = 19,
UInt64 = 20,
VarNumeric = 21,
AnsiStringFixedLength = 22,
StringFixedLength = 23,
Xml = 25,
DateTime2 = 26,
DateTimeOffset = 27,
}
public partial class DeletedRowInaccessibleException : System.Data.DataException
{
public DeletedRowInaccessibleException() { }
protected DeletedRowInaccessibleException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public DeletedRowInaccessibleException(string? s) { }
public DeletedRowInaccessibleException(string? message, System.Exception? innerException) { }
}
public partial class DuplicateNameException : System.Data.DataException
{
public DuplicateNameException() { }
protected DuplicateNameException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public DuplicateNameException(string? s) { }
public DuplicateNameException(string? message, System.Exception? innerException) { }
}
public abstract partial class EnumerableRowCollection : System.Collections.IEnumerable
{
internal EnumerableRowCollection() { }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
public static partial class EnumerableRowCollectionExtensions
{
public static System.Data.EnumerableRowCollection<TResult> Cast<TResult>(this System.Data.EnumerableRowCollection source) { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderByDescending<TRow, TKey>(this System.Data.EnumerableRowCollection<TRow> source, System.Func<TRow, TKey> keySelector) { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderByDescending<TRow, TKey>(this System.Data.EnumerableRowCollection<TRow> source, System.Func<TRow, TKey> keySelector, System.Collections.Generic.IComparer<TKey> comparer) { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderBy<TRow, TKey>(this System.Data.EnumerableRowCollection<TRow> source, System.Func<TRow, TKey> keySelector) { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderBy<TRow, TKey>(this System.Data.EnumerableRowCollection<TRow> source, System.Func<TRow, TKey> keySelector, System.Collections.Generic.IComparer<TKey> comparer) { throw null; }
public static System.Data.EnumerableRowCollection<S> Select<TRow, S>(this System.Data.EnumerableRowCollection<TRow> source, System.Func<TRow, S> selector) { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> ThenByDescending<TRow, TKey>(this System.Data.OrderedEnumerableRowCollection<TRow> source, System.Func<TRow, TKey> keySelector) { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> ThenByDescending<TRow, TKey>(this System.Data.OrderedEnumerableRowCollection<TRow> source, System.Func<TRow, TKey> keySelector, System.Collections.Generic.IComparer<TKey> comparer) { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> ThenBy<TRow, TKey>(this System.Data.OrderedEnumerableRowCollection<TRow> source, System.Func<TRow, TKey> keySelector) { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> ThenBy<TRow, TKey>(this System.Data.OrderedEnumerableRowCollection<TRow> source, System.Func<TRow, TKey> keySelector, System.Collections.Generic.IComparer<TKey> comparer) { throw null; }
public static System.Data.EnumerableRowCollection<TRow> Where<TRow>(this System.Data.EnumerableRowCollection<TRow> source, System.Func<TRow, bool> predicate) { throw null; }
}
public partial class EnumerableRowCollection<TRow> : System.Data.EnumerableRowCollection, System.Collections.Generic.IEnumerable<TRow>, System.Collections.IEnumerable
{
internal EnumerableRowCollection() { }
public System.Collections.Generic.IEnumerator<TRow> GetEnumerator() { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
public partial class EvaluateException : System.Data.InvalidExpressionException
{
public EvaluateException() { }
protected EvaluateException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public EvaluateException(string? s) { }
public EvaluateException(string? message, System.Exception? innerException) { }
}
public partial class FillErrorEventArgs : System.EventArgs
{
public FillErrorEventArgs(System.Data.DataTable? dataTable, object?[]? values) { }
public bool Continue { get { throw null; } set { } }
public System.Data.DataTable? DataTable { get { throw null; } }
public System.Exception? Errors { get { throw null; } set { } }
public object?[] Values { get { throw null; } }
}
public delegate void FillErrorEventHandler(object sender, System.Data.FillErrorEventArgs e);
[System.ComponentModel.DefaultPropertyAttribute("ConstraintName")]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.ForeignKeyConstraintEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public partial class ForeignKeyConstraint : System.Data.Constraint
{
public ForeignKeyConstraint(System.Data.DataColumn parentColumn, System.Data.DataColumn childColumn) { }
public ForeignKeyConstraint(System.Data.DataColumn[] parentColumns, System.Data.DataColumn[] childColumns) { }
public ForeignKeyConstraint(string? constraintName, System.Data.DataColumn parentColumn, System.Data.DataColumn childColumn) { }
public ForeignKeyConstraint(string? constraintName, System.Data.DataColumn[] parentColumns, System.Data.DataColumn[] childColumns) { }
[System.ComponentModel.BrowsableAttribute(false)]
public ForeignKeyConstraint(string? constraintName, string? parentTableName, string? parentTableNamespace, string[] parentColumnNames, string[] childColumnNames, System.Data.AcceptRejectRule acceptRejectRule, System.Data.Rule deleteRule, System.Data.Rule updateRule) { }
[System.ComponentModel.BrowsableAttribute(false)]
public ForeignKeyConstraint(string? constraintName, string? parentTableName, string[] parentColumnNames, string[] childColumnNames, System.Data.AcceptRejectRule acceptRejectRule, System.Data.Rule deleteRule, System.Data.Rule updateRule) { }
[System.ComponentModel.DefaultValueAttribute(System.Data.AcceptRejectRule.None)]
public virtual System.Data.AcceptRejectRule AcceptRejectRule { get { throw null; } set { } }
[System.ComponentModel.ReadOnlyAttribute(true)]
public virtual System.Data.DataColumn[] Columns { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute(System.Data.Rule.Cascade)]
public virtual System.Data.Rule DeleteRule { get { throw null; } set { } }
[System.ComponentModel.ReadOnlyAttribute(true)]
public virtual System.Data.DataColumn[] RelatedColumns { get { throw null; } }
[System.ComponentModel.ReadOnlyAttribute(true)]
public virtual System.Data.DataTable RelatedTable { get { throw null; } }
[System.ComponentModel.ReadOnlyAttribute(true)]
public override System.Data.DataTable? Table { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute(System.Data.Rule.Cascade)]
public virtual System.Data.Rule UpdateRule { get { throw null; } set { } }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? key) { throw null; }
public override int GetHashCode() { throw null; }
}
public partial interface IColumnMapping
{
string DataSetColumn { get; set; }
string SourceColumn { get; set; }
}
public partial interface IColumnMappingCollection : System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList
{
object this[string index] { get; set; }
System.Data.IColumnMapping Add(string sourceColumnName, string dataSetColumnName);
bool Contains(string? sourceColumnName);
System.Data.IColumnMapping GetByDataSetColumn(string dataSetColumnName);
int IndexOf(string? sourceColumnName);
void RemoveAt(string sourceColumnName);
}
public partial interface IDataAdapter
{
System.Data.MissingMappingAction MissingMappingAction { get; set; }
System.Data.MissingSchemaAction MissingSchemaAction { get; set; }
System.Data.ITableMappingCollection TableMappings { get; }
int Fill(System.Data.DataSet dataSet);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
System.Data.DataTable[] FillSchema(System.Data.DataSet dataSet, System.Data.SchemaType schemaType);
System.Data.IDataParameter[] GetFillParameters();
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
int Update(System.Data.DataSet dataSet);
}
public partial interface IDataParameter
{
System.Data.DbType DbType { get; set; }
System.Data.ParameterDirection Direction { get; set; }
bool IsNullable { get; }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
string ParameterName { get; set; }
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
string SourceColumn { get; set; }
System.Data.DataRowVersion SourceVersion { get; set; }
object? Value { get; set; }
}
public partial interface IDataParameterCollection : System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList
{
object this[string parameterName] { get; set; }
bool Contains(string parameterName);
int IndexOf(string parameterName);
void RemoveAt(string parameterName);
}
public partial interface IDataReader : System.Data.IDataRecord, System.IDisposable
{
int Depth { get; }
bool IsClosed { get; }
int RecordsAffected { get; }
void Close();
System.Data.DataTable? GetSchemaTable();
bool NextResult();
bool Read();
}
public partial interface IDataRecord
{
int FieldCount { get; }
object this[int i] { get; }
object this[string name] { get; }
bool GetBoolean(int i);
byte GetByte(int i);
long GetBytes(int i, long fieldOffset, byte[]? buffer, int bufferoffset, int length);
char GetChar(int i);
long GetChars(int i, long fieldoffset, char[]? buffer, int bufferoffset, int length);
System.Data.IDataReader GetData(int i);
string GetDataTypeName(int i);
System.DateTime GetDateTime(int i);
decimal GetDecimal(int i);
double GetDouble(int i);
[return: System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)]
System.Type GetFieldType(int i);
float GetFloat(int i);
System.Guid GetGuid(int i);
short GetInt16(int i);
int GetInt32(int i);
long GetInt64(int i);
string GetName(int i);
int GetOrdinal(string name);
string GetString(int i);
object GetValue(int i);
int GetValues(object[] values);
bool IsDBNull(int i);
}
public partial interface IDbCommand : System.IDisposable
{
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
string CommandText { get; set; }
int CommandTimeout { get; set; }
System.Data.CommandType CommandType { get; set; }
System.Data.IDbConnection? Connection { get; set; }
System.Data.IDataParameterCollection Parameters { get; }
System.Data.IDbTransaction? Transaction { get; set; }
System.Data.UpdateRowSource UpdatedRowSource { get; set; }
void Cancel();
System.Data.IDbDataParameter CreateParameter();
int ExecuteNonQuery();
System.Data.IDataReader ExecuteReader();
System.Data.IDataReader ExecuteReader(System.Data.CommandBehavior behavior);
object? ExecuteScalar();
void Prepare();
}
public partial interface IDbConnection : System.IDisposable
{
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
string ConnectionString { get; set; }
int ConnectionTimeout { get; }
string Database { get; }
System.Data.ConnectionState State { get; }
System.Data.IDbTransaction BeginTransaction();
System.Data.IDbTransaction BeginTransaction(System.Data.IsolationLevel il);
void ChangeDatabase(string databaseName);
void Close();
System.Data.IDbCommand CreateCommand();
void Open();
}
public partial interface IDbDataAdapter : System.Data.IDataAdapter
{
System.Data.IDbCommand? DeleteCommand { get; set; }
System.Data.IDbCommand? InsertCommand { get; set; }
System.Data.IDbCommand? SelectCommand { get; set; }
System.Data.IDbCommand? UpdateCommand { get; set; }
}
public partial interface IDbDataParameter : System.Data.IDataParameter
{
byte Precision { get; set; }
byte Scale { get; set; }
int Size { get; set; }
}
public partial interface IDbTransaction : System.IDisposable
{
System.Data.IDbConnection? Connection { get; }
System.Data.IsolationLevel IsolationLevel { get; }
void Commit();
void Rollback();
}
public partial class InRowChangingEventException : System.Data.DataException
{
public InRowChangingEventException() { }
protected InRowChangingEventException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public InRowChangingEventException(string? s) { }
public InRowChangingEventException(string? message, System.Exception? innerException) { }
}
public partial class InternalDataCollectionBase : System.Collections.ICollection, System.Collections.IEnumerable
{
public InternalDataCollectionBase() { }
[System.ComponentModel.BrowsableAttribute(false)]
public virtual int Count { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool IsReadOnly { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool IsSynchronized { get { throw null; } }
protected virtual System.Collections.ArrayList List { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public object SyncRoot { get { throw null; } }
public virtual void CopyTo(System.Array ar, int index) { }
public virtual System.Collections.IEnumerator GetEnumerator() { throw null; }
}
public partial class InvalidConstraintException : System.Data.DataException
{
public InvalidConstraintException() { }
protected InvalidConstraintException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public InvalidConstraintException(string? s) { }
public InvalidConstraintException(string? message, System.Exception? innerException) { }
}
public partial class InvalidExpressionException : System.Data.DataException
{
public InvalidExpressionException() { }
protected InvalidExpressionException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public InvalidExpressionException(string? s) { }
public InvalidExpressionException(string? message, System.Exception? innerException) { }
}
public enum IsolationLevel
{
Unspecified = -1,
Chaos = 16,
ReadUncommitted = 256,
ReadCommitted = 4096,
RepeatableRead = 65536,
Serializable = 1048576,
Snapshot = 16777216,
}
public partial interface ITableMapping
{
System.Data.IColumnMappingCollection ColumnMappings { get; }
string DataSetTable { get; set; }
string SourceTable { get; set; }
}
public partial interface ITableMappingCollection : System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList
{
object this[string index] { get; set; }
System.Data.ITableMapping Add(string sourceTableName, string dataSetTableName);
bool Contains(string? sourceTableName);
System.Data.ITableMapping GetByDataSetTable(string dataSetTableName);
int IndexOf(string? sourceTableName);
void RemoveAt(string sourceTableName);
}
public enum KeyRestrictionBehavior
{
AllowOnly = 0,
PreventUsage = 1,
}
public enum LoadOption
{
OverwriteChanges = 1,
PreserveChanges = 2,
Upsert = 3,
}
public enum MappingType
{
Element = 1,
Attribute = 2,
SimpleContent = 3,
Hidden = 4,
}
public partial class MergeFailedEventArgs : System.EventArgs
{
public MergeFailedEventArgs(System.Data.DataTable? table, string conflict) { }
public string Conflict { get { throw null; } }
public System.Data.DataTable? Table { get { throw null; } }
}
public delegate void MergeFailedEventHandler(object sender, System.Data.MergeFailedEventArgs e);
public enum MissingMappingAction
{
Passthrough = 1,
Ignore = 2,
Error = 3,
}
public partial class MissingPrimaryKeyException : System.Data.DataException
{
public MissingPrimaryKeyException() { }
protected MissingPrimaryKeyException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public MissingPrimaryKeyException(string? s) { }
public MissingPrimaryKeyException(string? message, System.Exception? innerException) { }
}
public enum MissingSchemaAction
{
Add = 1,
Ignore = 2,
Error = 3,
AddWithKey = 4,
}
public partial class NoNullAllowedException : System.Data.DataException
{
public NoNullAllowedException() { }
protected NoNullAllowedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public NoNullAllowedException(string? s) { }
public NoNullAllowedException(string? message, System.Exception? innerException) { }
}
public sealed partial class OrderedEnumerableRowCollection<TRow> : System.Data.EnumerableRowCollection<TRow>
{
internal OrderedEnumerableRowCollection() { }
}
public enum ParameterDirection
{
Input = 1,
Output = 2,
InputOutput = 3,
ReturnValue = 6,
}
public partial class PropertyCollection : System.Collections.Hashtable, System.ICloneable
{
public PropertyCollection() { }
protected PropertyCollection(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public override object Clone() { throw null; }
}
public partial class ReadOnlyException : System.Data.DataException
{
public ReadOnlyException() { }
protected ReadOnlyException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public ReadOnlyException(string? s) { }
public ReadOnlyException(string? message, System.Exception? innerException) { }
}
public partial class RowNotInTableException : System.Data.DataException
{
public RowNotInTableException() { }
protected RowNotInTableException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public RowNotInTableException(string? s) { }
public RowNotInTableException(string? message, System.Exception? innerException) { }
}
public enum Rule
{
None = 0,
Cascade = 1,
SetNull = 2,
SetDefault = 3,
}
public enum SchemaSerializationMode
{
IncludeSchema = 1,
ExcludeSchema = 2,
}
public enum SchemaType
{
Source = 1,
Mapped = 2,
}
public enum SerializationFormat
{
Xml = 0,
Binary = 1,
}
public enum SqlDbType
{
BigInt = 0,
Binary = 1,
Bit = 2,
Char = 3,
DateTime = 4,
Decimal = 5,
Float = 6,
Image = 7,
Int = 8,
Money = 9,
NChar = 10,
NText = 11,
NVarChar = 12,
Real = 13,
UniqueIdentifier = 14,
SmallDateTime = 15,
SmallInt = 16,
SmallMoney = 17,
Text = 18,
Timestamp = 19,
TinyInt = 20,
VarBinary = 21,
VarChar = 22,
Variant = 23,
Xml = 25,
Udt = 29,
Structured = 30,
Date = 31,
Time = 32,
DateTime2 = 33,
DateTimeOffset = 34,
}
public sealed partial class StateChangeEventArgs : System.EventArgs
{
public StateChangeEventArgs(System.Data.ConnectionState originalState, System.Data.ConnectionState currentState) { }
public System.Data.ConnectionState CurrentState { get { throw null; } }
public System.Data.ConnectionState OriginalState { get { throw null; } }
}
public delegate void StateChangeEventHandler(object sender, System.Data.StateChangeEventArgs e);
public sealed partial class StatementCompletedEventArgs : System.EventArgs
{
public StatementCompletedEventArgs(int recordCount) { }
public int RecordCount { get { throw null; } }
}
public delegate void StatementCompletedEventHandler(object sender, System.Data.StatementCompletedEventArgs e);
public enum StatementType
{
Select = 0,
Insert = 1,
Update = 2,
Delete = 3,
Batch = 4,
}
public partial class StrongTypingException : System.Data.DataException
{
public StrongTypingException() { }
protected StrongTypingException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public StrongTypingException(string? message) { }
public StrongTypingException(string? s, System.Exception? innerException) { }
}
public partial class SyntaxErrorException : System.Data.InvalidExpressionException
{
public SyntaxErrorException() { }
protected SyntaxErrorException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public SyntaxErrorException(string? s) { }
public SyntaxErrorException(string? message, System.Exception? innerException) { }
}
public static partial class TypedTableBaseExtensions
{
public static System.Data.EnumerableRowCollection<TRow> AsEnumerable<TRow>(this System.Data.TypedTableBase<TRow> source) where TRow : System.Data.DataRow { throw null; }
public static TRow? ElementAtOrDefault<TRow>(this System.Data.TypedTableBase<TRow> source, int index) where TRow : System.Data.DataRow { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderByDescending<TRow, TKey>(this System.Data.TypedTableBase<TRow> source, System.Func<TRow, TKey> keySelector) where TRow : System.Data.DataRow { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderByDescending<TRow, TKey>(this System.Data.TypedTableBase<TRow> source, System.Func<TRow, TKey> keySelector, System.Collections.Generic.IComparer<TKey> comparer) where TRow : System.Data.DataRow { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderBy<TRow, TKey>(this System.Data.TypedTableBase<TRow> source, System.Func<TRow, TKey> keySelector) where TRow : System.Data.DataRow { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderBy<TRow, TKey>(this System.Data.TypedTableBase<TRow> source, System.Func<TRow, TKey> keySelector, System.Collections.Generic.IComparer<TKey> comparer) where TRow : System.Data.DataRow { throw null; }
public static System.Data.EnumerableRowCollection<S> Select<TRow, S>(this System.Data.TypedTableBase<TRow> source, System.Func<TRow, S> selector) where TRow : System.Data.DataRow { throw null; }
public static System.Data.EnumerableRowCollection<TRow> Where<TRow>(this System.Data.TypedTableBase<TRow> source, System.Func<TRow, bool> predicate) where TRow : System.Data.DataRow { throw null; }
}
public abstract partial class TypedTableBase<T> : System.Data.DataTable, System.Collections.Generic.IEnumerable<T>, System.Collections.IEnumerable where T : System.Data.DataRow
{
protected TypedTableBase() { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected TypedTableBase(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public System.Data.EnumerableRowCollection<TResult> Cast<TResult>() { throw null; }
public System.Collections.Generic.IEnumerator<T> GetEnumerator() { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
[System.ComponentModel.DefaultPropertyAttribute("ConstraintName")]
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.UniqueConstraintEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public partial class UniqueConstraint : System.Data.Constraint
{
public UniqueConstraint(System.Data.DataColumn column) { }
public UniqueConstraint(System.Data.DataColumn column, bool isPrimaryKey) { }
public UniqueConstraint(System.Data.DataColumn[] columns) { }
public UniqueConstraint(System.Data.DataColumn[] columns, bool isPrimaryKey) { }
public UniqueConstraint(string? name, System.Data.DataColumn column) { }
public UniqueConstraint(string? name, System.Data.DataColumn column, bool isPrimaryKey) { }
public UniqueConstraint(string? name, System.Data.DataColumn[] columns) { }
public UniqueConstraint(string? name, System.Data.DataColumn[] columns, bool isPrimaryKey) { }
[System.ComponentModel.BrowsableAttribute(false)]
public UniqueConstraint(string? name, string[]? columnNames, bool isPrimaryKey) { }
[System.ComponentModel.ReadOnlyAttribute(true)]
public virtual System.Data.DataColumn[] Columns { get { throw null; } }
public bool IsPrimaryKey { get { throw null; } }
[System.ComponentModel.ReadOnlyAttribute(true)]
public override System.Data.DataTable? Table { get { throw null; } }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? key2) { throw null; }
public override int GetHashCode() { throw null; }
}
public enum UpdateRowSource
{
None = 0,
OutputParameters = 1,
FirstReturnedRecord = 2,
Both = 3,
}
public enum UpdateStatus
{
Continue = 0,
ErrorsOccurred = 1,
SkipCurrentRow = 2,
SkipAllRemainingRows = 3,
}
public partial class VersionNotFoundException : System.Data.DataException
{
public VersionNotFoundException() { }
protected VersionNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public VersionNotFoundException(string? s) { }
public VersionNotFoundException(string? message, System.Exception? innerException) { }
}
public enum XmlReadMode
{
Auto = 0,
ReadSchema = 1,
IgnoreSchema = 2,
InferSchema = 3,
DiffGram = 4,
Fragment = 5,
InferTypedSchema = 6,
}
public enum XmlWriteMode
{
WriteSchema = 0,
IgnoreSchema = 1,
DiffGram = 2,
}
}
namespace System.Data.Common
{
public enum CatalogLocation
{
Start = 1,
End = 2,
}
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
public partial class DataAdapter : System.ComponentModel.Component, System.Data.IDataAdapter
{
protected DataAdapter() { }
protected DataAdapter(System.Data.Common.DataAdapter from) { }
[System.ComponentModel.DefaultValueAttribute(true)]
public bool AcceptChangesDuringFill { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(true)]
public bool AcceptChangesDuringUpdate { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(false)]
public bool ContinueUpdateOnError { get { throw null; } set { } }
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public System.Data.LoadOption FillLoadOption { get { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Using LoadOption may cause members from types used in the expression column to be trimmed if not referenced directly.")] set { } }
[System.ComponentModel.DefaultValueAttribute(System.Data.MissingMappingAction.Passthrough)]
public System.Data.MissingMappingAction MissingMappingAction { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(System.Data.MissingSchemaAction.Add)]
public System.Data.MissingSchemaAction MissingSchemaAction { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(false)]
public virtual bool ReturnProviderSpecificTypes { get { throw null; } set { } }
System.Data.ITableMappingCollection System.Data.IDataAdapter.TableMappings { get { throw null; } }
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
public System.Data.Common.DataTableMappingCollection TableMappings { get { throw null; } }
public event System.Data.FillErrorEventHandler? FillError { add { } remove { } }
[System.ObsoleteAttribute("CloneInternals() has been deprecated. Use the DataAdapter(DataAdapter from) constructor instead.")]
protected virtual System.Data.Common.DataAdapter CloneInternals() { throw null; }
protected virtual System.Data.Common.DataTableMappingCollection CreateTableMappings() { throw null; }
protected override void Dispose(bool disposing) { }
public virtual int Fill(System.Data.DataSet dataSet) { throw null; }
protected virtual int Fill(System.Data.DataSet dataSet, string srcTable, System.Data.IDataReader dataReader, int startRecord, int maxRecords) { throw null; }
protected virtual int Fill(System.Data.DataTable dataTable, System.Data.IDataReader dataReader) { throw null; }
protected virtual int Fill(System.Data.DataTable[] dataTables, System.Data.IDataReader dataReader, int startRecord, int maxRecords) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
public virtual System.Data.DataTable[] FillSchema(System.Data.DataSet dataSet, System.Data.SchemaType schemaType) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("dataReader's schema table types cannot be statically analyzed.")]
protected virtual System.Data.DataTable[] FillSchema(System.Data.DataSet dataSet, System.Data.SchemaType schemaType, string srcTable, System.Data.IDataReader dataReader) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("dataReader's schema table types cannot be statically analyzed.")]
protected virtual System.Data.DataTable? FillSchema(System.Data.DataTable dataTable, System.Data.SchemaType schemaType, System.Data.IDataReader dataReader) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public virtual System.Data.IDataParameter[] GetFillParameters() { throw null; }
protected bool HasTableMappings() { throw null; }
protected virtual void OnFillError(System.Data.FillErrorEventArgs value) { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public void ResetFillLoadOption() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public virtual bool ShouldSerializeAcceptChangesDuringFill() { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public virtual bool ShouldSerializeFillLoadOption() { throw null; }
protected virtual bool ShouldSerializeTableMappings() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
public virtual int Update(System.Data.DataSet dataSet) { throw null; }
}
public sealed partial class DataColumnMapping : System.MarshalByRefObject, System.Data.IColumnMapping, System.ICloneable
{
public DataColumnMapping() { }
public DataColumnMapping(string? sourceColumn, string? dataSetColumn) { }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string DataSetColumn { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string SourceColumn { get { throw null; } set { } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public System.Data.DataColumn? GetDataColumnBySchemaAction(System.Data.DataTable dataTable, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type? dataType, System.Data.MissingSchemaAction schemaAction) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public static System.Data.DataColumn? GetDataColumnBySchemaAction(string? sourceColumn, string? dataSetColumn, System.Data.DataTable dataTable, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type? dataType, System.Data.MissingSchemaAction schemaAction) { throw null; }
object System.ICloneable.Clone() { throw null; }
public override string ToString() { throw null; }
}
public sealed partial class DataColumnMappingCollection : System.MarshalByRefObject, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.Data.IColumnMappingCollection
{
public DataColumnMappingCollection() { }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public int Count { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DataColumnMapping this[int index] { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DataColumnMapping this[string sourceColumn] { get { throw null; } set { } }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
bool System.Collections.IList.IsFixedSize { get { throw null; } }
bool System.Collections.IList.IsReadOnly { get { throw null; } }
object? System.Collections.IList.this[int index] { get { throw null; } set { } }
object System.Data.IColumnMappingCollection.this[string index] { get { throw null; } set { } }
public int Add(object? value) { throw null; }
public System.Data.Common.DataColumnMapping Add(string? sourceColumn, string? dataSetColumn) { throw null; }
public void AddRange(System.Array values) { }
public void AddRange(System.Data.Common.DataColumnMapping[] values) { }
public void Clear() { }
public bool Contains(object? value) { throw null; }
public bool Contains(string? value) { throw null; }
public void CopyTo(System.Array array, int index) { }
public void CopyTo(System.Data.Common.DataColumnMapping[] array, int index) { }
public System.Data.Common.DataColumnMapping GetByDataSetColumn(string value) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public static System.Data.Common.DataColumnMapping? GetColumnMappingBySchemaAction(System.Data.Common.DataColumnMappingCollection? columnMappings, string sourceColumn, System.Data.MissingMappingAction mappingAction) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public static System.Data.DataColumn? GetDataColumn(System.Data.Common.DataColumnMappingCollection? columnMappings, string sourceColumn, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type? dataType, System.Data.DataTable dataTable, System.Data.MissingMappingAction mappingAction, System.Data.MissingSchemaAction schemaAction) { throw null; }
public System.Collections.IEnumerator GetEnumerator() { throw null; }
public int IndexOf(object? value) { throw null; }
public int IndexOf(string? sourceColumn) { throw null; }
public int IndexOfDataSetColumn(string? dataSetColumn) { throw null; }
public void Insert(int index, System.Data.Common.DataColumnMapping value) { }
public void Insert(int index, object? value) { }
public void Remove(System.Data.Common.DataColumnMapping value) { }
public void Remove(object? value) { }
public void RemoveAt(int index) { }
public void RemoveAt(string sourceColumn) { }
System.Data.IColumnMapping System.Data.IColumnMappingCollection.Add(string? sourceColumnName, string? dataSetColumnName) { throw null; }
System.Data.IColumnMapping System.Data.IColumnMappingCollection.GetByDataSetColumn(string dataSetColumnName) { throw null; }
}
public sealed partial class DataTableMapping : System.MarshalByRefObject, System.Data.ITableMapping, System.ICloneable
{
public DataTableMapping() { }
public DataTableMapping(string? sourceTable, string? dataSetTable) { }
public DataTableMapping(string? sourceTable, string? dataSetTable, System.Data.Common.DataColumnMapping[]? columnMappings) { }
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
public System.Data.Common.DataColumnMappingCollection ColumnMappings { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string DataSetTable { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string SourceTable { get { throw null; } set { } }
System.Data.IColumnMappingCollection System.Data.ITableMapping.ColumnMappings { get { throw null; } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public System.Data.Common.DataColumnMapping? GetColumnMappingBySchemaAction(string sourceColumn, System.Data.MissingMappingAction mappingAction) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public System.Data.DataColumn? GetDataColumn(string sourceColumn, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type? dataType, System.Data.DataTable dataTable, System.Data.MissingMappingAction mappingAction, System.Data.MissingSchemaAction schemaAction) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public System.Data.DataTable? GetDataTableBySchemaAction(System.Data.DataSet dataSet, System.Data.MissingSchemaAction schemaAction) { throw null; }
object System.ICloneable.Clone() { throw null; }
public override string ToString() { throw null; }
}
[System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.Design.DataTableMappingCollectionEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.ListBindableAttribute(false)]
public sealed partial class DataTableMappingCollection : System.MarshalByRefObject, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.Data.ITableMappingCollection
{
public DataTableMappingCollection() { }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public int Count { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DataTableMapping this[int index] { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DataTableMapping this[string sourceTable] { get { throw null; } set { } }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
bool System.Collections.IList.IsFixedSize { get { throw null; } }
bool System.Collections.IList.IsReadOnly { get { throw null; } }
object? System.Collections.IList.this[int index] { get { throw null; } set { } }
object System.Data.ITableMappingCollection.this[string index] { get { throw null; } set { } }
public int Add(object? value) { throw null; }
public System.Data.Common.DataTableMapping Add(string? sourceTable, string? dataSetTable) { throw null; }
public void AddRange(System.Array values) { }
public void AddRange(System.Data.Common.DataTableMapping[] values) { }
public void Clear() { }
public bool Contains(object? value) { throw null; }
public bool Contains(string? value) { throw null; }
public void CopyTo(System.Array array, int index) { }
public void CopyTo(System.Data.Common.DataTableMapping[] array, int index) { }
public System.Data.Common.DataTableMapping GetByDataSetTable(string dataSetTable) { throw null; }
public System.Collections.IEnumerator GetEnumerator() { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public static System.Data.Common.DataTableMapping? GetTableMappingBySchemaAction(System.Data.Common.DataTableMappingCollection? tableMappings, string sourceTable, string dataSetTable, System.Data.MissingMappingAction mappingAction) { throw null; }
public int IndexOf(object? value) { throw null; }
public int IndexOf(string? sourceTable) { throw null; }
public int IndexOfDataSetTable(string? dataSetTable) { throw null; }
public void Insert(int index, System.Data.Common.DataTableMapping value) { }
public void Insert(int index, object? value) { }
public void Remove(System.Data.Common.DataTableMapping value) { }
public void Remove(object? value) { }
public void RemoveAt(int index) { }
public void RemoveAt(string sourceTable) { }
System.Data.ITableMapping System.Data.ITableMappingCollection.Add(string sourceTableName, string dataSetTableName) { throw null; }
System.Data.ITableMapping System.Data.ITableMappingCollection.GetByDataSetTable(string dataSetTableName) { throw null; }
}
public abstract class DbBatch : System.IDisposable, System.IAsyncDisposable
{
public System.Data.Common.DbBatchCommandCollection BatchCommands { get { throw null; } }
protected abstract System.Data.Common.DbBatchCommandCollection DbBatchCommands { get; }
public abstract int Timeout { get; set; }
public System.Data.Common.DbConnection? Connection { get; set; }
protected abstract System.Data.Common.DbConnection? DbConnection { get; set; }
public System.Data.Common.DbTransaction? Transaction { get; set; }
protected abstract System.Data.Common.DbTransaction? DbTransaction { get; set; }
public System.Data.Common.DbDataReader ExecuteReader(System.Data.CommandBehavior behavior = System.Data.CommandBehavior.Default) { throw null; }
protected abstract System.Data.Common.DbDataReader ExecuteDbDataReader(System.Data.CommandBehavior behavior);
public System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteReaderAsync(System.Threading.CancellationToken cancellationToken = default) { throw null; }
public System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteReaderAsync(System.Data.CommandBehavior behavior, System.Threading.CancellationToken cancellationToken = default) { throw null; }
protected abstract System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteDbDataReaderAsync(System.Data.CommandBehavior behavior, System.Threading.CancellationToken cancellationToken);
public abstract int ExecuteNonQuery();
public abstract System.Threading.Tasks.Task<int> ExecuteNonQueryAsync(System.Threading.CancellationToken cancellationToken = default);
public abstract object? ExecuteScalar();
public abstract System.Threading.Tasks.Task<object?> ExecuteScalarAsync(System.Threading.CancellationToken cancellationToken = default);
public abstract void Prepare();
public abstract System.Threading.Tasks.Task PrepareAsync(System.Threading.CancellationToken cancellationToken = default);
public abstract void Cancel();
public System.Data.Common.DbBatchCommand CreateBatchCommand() { throw null; }
protected abstract System.Data.Common.DbBatchCommand CreateDbBatchCommand();
public virtual void Dispose() { throw null; }
public virtual System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
}
public abstract class DbBatchCommand
{
public abstract string CommandText { get; set; }
public abstract System.Data.CommandType CommandType { get; set; }
public abstract int RecordsAffected { get; }
public System.Data.Common.DbParameterCollection Parameters { get { throw null; } }
protected abstract System.Data.Common.DbParameterCollection DbParameterCollection { get; }
}
public abstract class DbBatchCommandCollection : System.Collections.Generic.IList<DbBatchCommand>
{
public abstract System.Collections.Generic.IEnumerator<System.Data.Common.DbBatchCommand> GetEnumerator();
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
public abstract void Add(System.Data.Common.DbBatchCommand item);
public abstract void Clear();
public abstract bool Contains(System.Data.Common.DbBatchCommand item);
public abstract void CopyTo(System.Data.Common.DbBatchCommand[] array, int arrayIndex);
public abstract bool Remove(System.Data.Common.DbBatchCommand item);
public abstract int Count { get; }
public abstract bool IsReadOnly { get; }
public abstract int IndexOf(DbBatchCommand item);
public abstract void Insert(int index, DbBatchCommand item);
public abstract void RemoveAt(int index);
public System.Data.Common.DbBatchCommand this[int index] { get { throw null; } set { throw null; } }
protected abstract System.Data.Common.DbBatchCommand GetBatchCommand(int index);
protected abstract void SetBatchCommand(int index, System.Data.Common.DbBatchCommand batchCommand);
}
public abstract partial class DbColumn
{
protected DbColumn() { }
public bool? AllowDBNull { get { throw null; } protected set { } }
public string? BaseCatalogName { get { throw null; } protected set { } }
public string? BaseColumnName { get { throw null; } protected set { } }
public string? BaseSchemaName { get { throw null; } protected set { } }
public string? BaseServerName { get { throw null; } protected set { } }
public string? BaseTableName { get { throw null; } protected set { } }
public string ColumnName { get { throw null; } protected set { } }
public int? ColumnOrdinal { get { throw null; } protected set { } }
public int? ColumnSize { get { throw null; } protected set { } }
public System.Type? DataType { get { throw null; } protected set { } }
public string? DataTypeName { get { throw null; } protected set { } }
public bool? IsAliased { get { throw null; } protected set { } }
public bool? IsAutoIncrement { get { throw null; } protected set { } }
public bool? IsExpression { get { throw null; } protected set { } }
public bool? IsHidden { get { throw null; } protected set { } }
public bool? IsIdentity { get { throw null; } protected set { } }
public bool? IsKey { get { throw null; } protected set { } }
public bool? IsLong { get { throw null; } protected set { } }
public bool? IsReadOnly { get { throw null; } protected set { } }
public bool? IsUnique { get { throw null; } protected set { } }
public virtual object? this[string property] { get { throw null; } }
public int? NumericPrecision { get { throw null; } protected set { } }
public int? NumericScale { get { throw null; } protected set { } }
public string? UdtAssemblyQualifiedName { get { throw null; } protected set { } }
}
public abstract partial class DbCommand : System.ComponentModel.Component, System.Data.IDbCommand, System.IDisposable, System.IAsyncDisposable
{
protected DbCommand() { }
[System.ComponentModel.DefaultValueAttribute("")]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public abstract string CommandText { get; set; }
public abstract int CommandTimeout { get; set; }
[System.ComponentModel.DefaultValueAttribute(System.Data.CommandType.Text)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public abstract System.Data.CommandType CommandType { get; set; }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DefaultValueAttribute(null)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DbConnection? Connection { get { throw null; } set { } }
protected abstract System.Data.Common.DbConnection? DbConnection { get; set; }
protected abstract System.Data.Common.DbParameterCollection DbParameterCollection { get; }
protected abstract System.Data.Common.DbTransaction? DbTransaction { get; set; }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DefaultValueAttribute(true)]
[System.ComponentModel.DesignOnlyAttribute(true)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public abstract bool DesignTimeVisible { get; set; }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DbParameterCollection Parameters { get { throw null; } }
System.Data.IDbConnection? System.Data.IDbCommand.Connection { get { throw null; } set { } }
System.Data.IDataParameterCollection System.Data.IDbCommand.Parameters { get { throw null; } }
System.Data.IDbTransaction? System.Data.IDbCommand.Transaction { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DefaultValueAttribute(null)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DbTransaction? Transaction { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(System.Data.UpdateRowSource.Both)]
public abstract System.Data.UpdateRowSource UpdatedRowSource { get; set; }
public abstract void Cancel();
protected abstract System.Data.Common.DbParameter CreateDbParameter();
public System.Data.Common.DbParameter CreateParameter() { throw null; }
public virtual System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
protected abstract System.Data.Common.DbDataReader ExecuteDbDataReader(System.Data.CommandBehavior behavior);
protected virtual System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteDbDataReaderAsync(System.Data.CommandBehavior behavior, System.Threading.CancellationToken cancellationToken) { throw null; }
public abstract int ExecuteNonQuery();
public System.Threading.Tasks.Task<int> ExecuteNonQueryAsync() { throw null; }
public virtual System.Threading.Tasks.Task<int> ExecuteNonQueryAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
public System.Data.Common.DbDataReader ExecuteReader() { throw null; }
public System.Data.Common.DbDataReader ExecuteReader(System.Data.CommandBehavior behavior) { throw null; }
public System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteReaderAsync() { throw null; }
public System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteReaderAsync(System.Data.CommandBehavior behavior) { throw null; }
public System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteReaderAsync(System.Data.CommandBehavior behavior, System.Threading.CancellationToken cancellationToken) { throw null; }
public System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteReaderAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
public abstract object? ExecuteScalar();
public System.Threading.Tasks.Task<object?> ExecuteScalarAsync() { throw null; }
public virtual System.Threading.Tasks.Task<object?> ExecuteScalarAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
public abstract void Prepare();
public virtual System.Threading.Tasks.Task PrepareAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
System.Data.IDbDataParameter System.Data.IDbCommand.CreateParameter() { throw null; }
System.Data.IDataReader System.Data.IDbCommand.ExecuteReader() { throw null; }
System.Data.IDataReader System.Data.IDbCommand.ExecuteReader(System.Data.CommandBehavior behavior) { throw null; }
}
public abstract partial class DbCommandBuilder : System.ComponentModel.Component
{
protected DbCommandBuilder() { }
[System.ComponentModel.DefaultValueAttribute(System.Data.Common.CatalogLocation.Start)]
public virtual System.Data.Common.CatalogLocation CatalogLocation { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(".")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public virtual string CatalogSeparator { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(System.Data.ConflictOption.CompareAllSearchableValues)]
public virtual System.Data.ConflictOption ConflictOption { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DbDataAdapter? DataAdapter { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public virtual string QuotePrefix { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public virtual string QuoteSuffix { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(".")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public virtual string SchemaSeparator { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(false)]
public bool SetAllValues { get { throw null; } set { } }
protected abstract void ApplyParameterInfo(System.Data.Common.DbParameter parameter, System.Data.DataRow row, System.Data.StatementType statementType, bool whereClause);
protected override void Dispose(bool disposing) { }
public System.Data.Common.DbCommand GetDeleteCommand() { throw null; }
public System.Data.Common.DbCommand GetDeleteCommand(bool useColumnsForParameterNames) { throw null; }
public System.Data.Common.DbCommand GetInsertCommand() { throw null; }
public System.Data.Common.DbCommand GetInsertCommand(bool useColumnsForParameterNames) { throw null; }
protected abstract string GetParameterName(int parameterOrdinal);
protected abstract string GetParameterName(string parameterName);
protected abstract string GetParameterPlaceholder(int parameterOrdinal);
protected virtual System.Data.DataTable? GetSchemaTable(System.Data.Common.DbCommand sourceCommand) { throw null; }
public System.Data.Common.DbCommand GetUpdateCommand() { throw null; }
public System.Data.Common.DbCommand GetUpdateCommand(bool useColumnsForParameterNames) { throw null; }
protected virtual System.Data.Common.DbCommand InitializeCommand(System.Data.Common.DbCommand? command) { throw null; }
public virtual string QuoteIdentifier(string unquotedIdentifier) { throw null; }
public virtual void RefreshSchema() { }
protected void RowUpdatingHandler(System.Data.Common.RowUpdatingEventArgs rowUpdatingEvent) { }
protected abstract void SetRowUpdatingHandler(System.Data.Common.DbDataAdapter adapter);
public virtual string UnquoteIdentifier(string quotedIdentifier) { throw null; }
}
public abstract partial class DbConnection : System.ComponentModel.Component, System.Data.IDbConnection, System.IDisposable, System.IAsyncDisposable
{
protected DbConnection() { }
[System.ComponentModel.DefaultValueAttribute("")]
[System.ComponentModel.RecommendedAsConfigurableAttribute(true)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
[System.ComponentModel.SettingsBindableAttribute(true)]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public abstract string ConnectionString { get; set; }
public virtual int ConnectionTimeout { get { throw null; } }
public abstract string Database { get; }
public abstract string DataSource { get; }
protected virtual System.Data.Common.DbProviderFactory? DbProviderFactory { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public abstract string ServerVersion { get; }
[System.ComponentModel.BrowsableAttribute(false)]
public abstract System.Data.ConnectionState State { get; }
public virtual event System.Data.StateChangeEventHandler? StateChange { add { } remove { } }
protected abstract System.Data.Common.DbTransaction BeginDbTransaction(System.Data.IsolationLevel isolationLevel);
protected virtual System.Threading.Tasks.ValueTask<System.Data.Common.DbTransaction> BeginDbTransactionAsync(System.Data.IsolationLevel isolationLevel, System.Threading.CancellationToken cancellationToken) { throw null; }
public System.Data.Common.DbTransaction BeginTransaction() { throw null; }
public System.Data.Common.DbTransaction BeginTransaction(System.Data.IsolationLevel isolationLevel) { throw null; }
public System.Threading.Tasks.ValueTask<System.Data.Common.DbTransaction> BeginTransactionAsync(System.Data.IsolationLevel isolationLevel, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public System.Threading.Tasks.ValueTask<System.Data.Common.DbTransaction> BeginTransactionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public abstract void ChangeDatabase(string databaseName);
public virtual System.Threading.Tasks.Task ChangeDatabaseAsync(string databaseName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public abstract void Close();
public virtual System.Threading.Tasks.Task CloseAsync() { throw null; }
public virtual bool CanCreateBatch { get { throw null; } }
public System.Data.Common.DbBatch CreateBatch() { throw null; }
protected virtual System.Data.Common.DbBatch CreateDbBatch() { throw null; }
public System.Data.Common.DbCommand CreateCommand() { throw null; }
protected abstract System.Data.Common.DbCommand CreateDbCommand();
public virtual System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
public virtual void EnlistTransaction(System.Transactions.Transaction? transaction) { }
public virtual System.Data.DataTable GetSchema() { throw null; }
public virtual System.Data.DataTable GetSchema(string collectionName) { throw null; }
public virtual System.Data.DataTable GetSchema(string collectionName, string?[] restrictionValues) { throw null; }
public virtual System.Threading.Tasks.Task<System.Data.DataTable> GetSchemaAsync(System.Threading.CancellationToken cancellationToken = default) { throw null; }
public virtual System.Threading.Tasks.Task<System.Data.DataTable> GetSchemaAsync(string collectionName, System.Threading.CancellationToken cancellationToken = default) { throw null; }
public virtual System.Threading.Tasks.Task<System.Data.DataTable> GetSchemaAsync(string collectionName, string?[] restrictionValues, System.Threading.CancellationToken cancellationToken = default) { throw null; }
protected virtual void OnStateChange(System.Data.StateChangeEventArgs stateChange) { }
public abstract void Open();
public System.Threading.Tasks.Task OpenAsync() { throw null; }
public virtual System.Threading.Tasks.Task OpenAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
System.Data.IDbTransaction System.Data.IDbConnection.BeginTransaction() { throw null; }
System.Data.IDbTransaction System.Data.IDbConnection.BeginTransaction(System.Data.IsolationLevel isolationLevel) { throw null; }
System.Data.IDbCommand System.Data.IDbConnection.CreateCommand() { throw null; }
}
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)]
public partial class DbConnectionStringBuilder : System.Collections.ICollection, System.Collections.IDictionary, System.Collections.IEnumerable, System.ComponentModel.ICustomTypeDescriptor
{
public DbConnectionStringBuilder() { }
public DbConnectionStringBuilder(bool useOdbcRules) { }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.DesignOnlyAttribute(true)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public bool BrowsableConnectionString { get { throw null; } set { } }
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public string ConnectionString { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public virtual int Count { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public virtual bool IsFixedSize { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public bool IsReadOnly { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public virtual object this[string keyword] { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public virtual System.Collections.ICollection Keys { get { throw null; } }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
object? System.Collections.IDictionary.this[object keyword] { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
public virtual System.Collections.ICollection Values { get { throw null; } }
public void Add(string keyword, object value) { }
public static void AppendKeyValuePair(System.Text.StringBuilder builder, string keyword, string? value) { }
public static void AppendKeyValuePair(System.Text.StringBuilder builder, string keyword, string? value, bool useOdbcRules) { }
public virtual void Clear() { }
protected internal void ClearPropertyDescriptors() { }
public virtual bool ContainsKey(string keyword) { throw null; }
public virtual bool EquivalentTo(System.Data.Common.DbConnectionStringBuilder connectionStringBuilder) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")]
protected virtual void GetProperties(System.Collections.Hashtable propertyDescriptors) { }
public virtual bool Remove(string keyword) { throw null; }
public virtual bool ShouldSerialize(string keyword) { throw null; }
void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
void System.Collections.IDictionary.Add(object keyword, object? value) { }
bool System.Collections.IDictionary.Contains(object keyword) { throw null; }
System.Collections.IDictionaryEnumerator System.Collections.IDictionary.GetEnumerator() { throw null; }
void System.Collections.IDictionary.Remove(object keyword) { }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
System.ComponentModel.AttributeCollection System.ComponentModel.ICustomTypeDescriptor.GetAttributes() { throw null; }
string? System.ComponentModel.ICustomTypeDescriptor.GetClassName() { throw null; }
string? System.ComponentModel.ICustomTypeDescriptor.GetComponentName() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
System.ComponentModel.TypeConverter System.ComponentModel.ICustomTypeDescriptor.GetConverter() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
System.ComponentModel.EventDescriptor? System.ComponentModel.ICustomTypeDescriptor.GetDefaultEvent() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")]
System.ComponentModel.PropertyDescriptor? System.ComponentModel.ICustomTypeDescriptor.GetDefaultProperty() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")]
object? System.ComponentModel.ICustomTypeDescriptor.GetEditor(System.Type editorBaseType) { throw null; }
System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents(System.Attribute[]? attributes) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")]
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties(System.Attribute[]? attributes) { throw null; }
object System.ComponentModel.ICustomTypeDescriptor.GetPropertyOwner(System.ComponentModel.PropertyDescriptor? pd) { throw null; }
public override string ToString() { throw null; }
public virtual bool TryGetValue(string keyword, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out object? value) { throw null; }
}
public abstract partial class DbDataAdapter : System.Data.Common.DataAdapter, System.Data.IDataAdapter, System.Data.IDbDataAdapter, System.ICloneable
{
public const string DefaultSourceTableName = "Table";
protected DbDataAdapter() { }
protected DbDataAdapter(System.Data.Common.DbDataAdapter adapter) { }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DbCommand? DeleteCommand { get { throw null; } set { } }
protected internal System.Data.CommandBehavior FillCommandBehavior { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DbCommand? InsertCommand { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DbCommand? SelectCommand { get { throw null; } set { } }
System.Data.IDbCommand? System.Data.IDbDataAdapter.DeleteCommand { get { throw null; } set { } }
System.Data.IDbCommand? System.Data.IDbDataAdapter.InsertCommand { get { throw null; } set { } }
System.Data.IDbCommand? System.Data.IDbDataAdapter.SelectCommand { get { throw null; } set { } }
System.Data.IDbCommand? System.Data.IDbDataAdapter.UpdateCommand { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(1)]
public virtual int UpdateBatchSize { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Data.Common.DbCommand? UpdateCommand { get { throw null; } set { } }
protected virtual int AddToBatch(System.Data.IDbCommand command) { throw null; }
protected virtual void ClearBatch() { }
protected virtual System.Data.Common.RowUpdatedEventArgs CreateRowUpdatedEvent(System.Data.DataRow dataRow, System.Data.IDbCommand? command, System.Data.StatementType statementType, System.Data.Common.DataTableMapping tableMapping) { throw null; }
protected virtual System.Data.Common.RowUpdatingEventArgs CreateRowUpdatingEvent(System.Data.DataRow dataRow, System.Data.IDbCommand? command, System.Data.StatementType statementType, System.Data.Common.DataTableMapping tableMapping) { throw null; }
protected override void Dispose(bool disposing) { }
protected virtual int ExecuteBatch() { throw null; }
public override int Fill(System.Data.DataSet dataSet) { throw null; }
public int Fill(System.Data.DataSet dataSet, int startRecord, int maxRecords, string srcTable) { throw null; }
protected virtual int Fill(System.Data.DataSet dataSet, int startRecord, int maxRecords, string srcTable, System.Data.IDbCommand command, System.Data.CommandBehavior behavior) { throw null; }
public int Fill(System.Data.DataSet dataSet, string srcTable) { throw null; }
public int Fill(System.Data.DataTable dataTable) { throw null; }
protected virtual int Fill(System.Data.DataTable dataTable, System.Data.IDbCommand command, System.Data.CommandBehavior behavior) { throw null; }
protected virtual int Fill(System.Data.DataTable[] dataTables, int startRecord, int maxRecords, System.Data.IDbCommand command, System.Data.CommandBehavior behavior) { throw null; }
public int Fill(int startRecord, int maxRecords, params System.Data.DataTable[] dataTables) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
public override System.Data.DataTable[] FillSchema(System.Data.DataSet dataSet, System.Data.SchemaType schemaType) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from command) schema table types cannot be statically analyzed.")]
protected virtual System.Data.DataTable[] FillSchema(System.Data.DataSet dataSet, System.Data.SchemaType schemaType, System.Data.IDbCommand command, string srcTable, System.Data.CommandBehavior behavior) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
public System.Data.DataTable[] FillSchema(System.Data.DataSet dataSet, System.Data.SchemaType schemaType, string srcTable) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
public System.Data.DataTable? FillSchema(System.Data.DataTable dataTable, System.Data.SchemaType schemaType) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from command) schema table types cannot be statically analyzed.")]
protected virtual System.Data.DataTable? FillSchema(System.Data.DataTable dataTable, System.Data.SchemaType schemaType, System.Data.IDbCommand command, System.Data.CommandBehavior behavior) { throw null; }
protected virtual System.Data.IDataParameter GetBatchedParameter(int commandIdentifier, int parameterIndex) { throw null; }
protected virtual bool GetBatchedRecordsAffected(int commandIdentifier, out int recordsAffected, out System.Exception? error) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public override System.Data.IDataParameter[] GetFillParameters() { throw null; }
protected virtual void InitializeBatching() { }
protected virtual void OnRowUpdated(System.Data.Common.RowUpdatedEventArgs value) { }
protected virtual void OnRowUpdating(System.Data.Common.RowUpdatingEventArgs value) { }
object System.ICloneable.Clone() { throw null; }
protected virtual void TerminateBatching() { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
public int Update(System.Data.DataRow[] dataRows) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
protected virtual int Update(System.Data.DataRow[] dataRows, System.Data.Common.DataTableMapping tableMapping) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
public override int Update(System.Data.DataSet dataSet) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
public int Update(System.Data.DataSet dataSet, string srcTable) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("IDataReader's (built from adapter commands) schema table types cannot be statically analyzed.")]
public int Update(System.Data.DataTable dataTable) { throw null; }
}
public abstract partial class DbDataReader : System.MarshalByRefObject, System.Collections.IEnumerable, System.Data.IDataReader, System.Data.IDataRecord, System.IDisposable, System.IAsyncDisposable
{
protected DbDataReader() { }
public abstract int Depth { get; }
public abstract int FieldCount { get; }
public abstract bool HasRows { get; }
public abstract bool IsClosed { get; }
public abstract object this[int ordinal] { get; }
public abstract object this[string name] { get; }
public abstract int RecordsAffected { get; }
public virtual int VisibleFieldCount { get { throw null; } }
public virtual void Close() { }
public virtual System.Threading.Tasks.Task CloseAsync() { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public void Dispose() { }
protected virtual void Dispose(bool disposing) { }
public virtual System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
public abstract bool GetBoolean(int ordinal);
public abstract byte GetByte(int ordinal);
public abstract long GetBytes(int ordinal, long dataOffset, byte[]? buffer, int bufferOffset, int length);
public abstract char GetChar(int ordinal);
public abstract long GetChars(int ordinal, long dataOffset, char[]? buffer, int bufferOffset, int length);
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public System.Data.Common.DbDataReader GetData(int ordinal) { throw null; }
public abstract string GetDataTypeName(int ordinal);
public abstract System.DateTime GetDateTime(int ordinal);
protected virtual System.Data.Common.DbDataReader GetDbDataReader(int ordinal) { throw null; }
public abstract decimal GetDecimal(int ordinal);
public abstract double GetDouble(int ordinal);
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public abstract System.Collections.IEnumerator GetEnumerator();
public abstract System.Type GetFieldType(int ordinal);
public System.Threading.Tasks.Task<T> GetFieldValueAsync<T>(int ordinal) { throw null; }
public virtual System.Threading.Tasks.Task<T> GetFieldValueAsync<T>(int ordinal, System.Threading.CancellationToken cancellationToken) { throw null; }
public virtual T GetFieldValue<T>(int ordinal) { throw null; }
public abstract float GetFloat(int ordinal);
public abstract System.Guid GetGuid(int ordinal);
public abstract short GetInt16(int ordinal);
public abstract int GetInt32(int ordinal);
public abstract long GetInt64(int ordinal);
public abstract string GetName(int ordinal);
public abstract int GetOrdinal(string name);
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public virtual System.Type GetProviderSpecificFieldType(int ordinal) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public virtual object GetProviderSpecificValue(int ordinal) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public virtual int GetProviderSpecificValues(object[] values) { throw null; }
public virtual System.Data.DataTable? GetSchemaTable() { throw null; }
public virtual System.Threading.Tasks.Task<System.Data.DataTable?> GetSchemaTableAsync(System.Threading.CancellationToken cancellationToken = default) { throw null; }
public virtual System.Threading.Tasks.Task<System.Collections.ObjectModel.ReadOnlyCollection<System.Data.Common.DbColumn>> GetColumnSchemaAsync(System.Threading.CancellationToken cancellationToken = default) { throw null; }
public virtual System.IO.Stream GetStream(int ordinal) { throw null; }
public abstract string GetString(int ordinal);
public virtual System.IO.TextReader GetTextReader(int ordinal) { throw null; }
public abstract object GetValue(int ordinal);
public abstract int GetValues(object[] values);
public abstract bool IsDBNull(int ordinal);
public System.Threading.Tasks.Task<bool> IsDBNullAsync(int ordinal) { throw null; }
public virtual System.Threading.Tasks.Task<bool> IsDBNullAsync(int ordinal, System.Threading.CancellationToken cancellationToken) { throw null; }
public abstract bool NextResult();
public System.Threading.Tasks.Task<bool> NextResultAsync() { throw null; }
public virtual System.Threading.Tasks.Task<bool> NextResultAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
public abstract bool Read();
public System.Threading.Tasks.Task<bool> ReadAsync() { throw null; }
public virtual System.Threading.Tasks.Task<bool> ReadAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
System.Data.IDataReader System.Data.IDataRecord.GetData(int ordinal) { throw null; }
}
public static partial class DbDataReaderExtensions
{
public static bool CanGetColumnSchema(this System.Data.Common.DbDataReader reader) { throw null; }
public static System.Collections.ObjectModel.ReadOnlyCollection<System.Data.Common.DbColumn> GetColumnSchema(this System.Data.Common.DbDataReader reader) { throw null; }
}
public abstract partial class DbDataRecord : System.ComponentModel.ICustomTypeDescriptor, System.Data.IDataRecord
{
protected DbDataRecord() { }
public abstract int FieldCount { get; }
public abstract object this[int i] { get; }
public abstract object this[string name] { get; }
public abstract bool GetBoolean(int i);
public abstract byte GetByte(int i);
public abstract long GetBytes(int i, long dataIndex, byte[]? buffer, int bufferIndex, int length);
public abstract char GetChar(int i);
public abstract long GetChars(int i, long dataIndex, char[]? buffer, int bufferIndex, int length);
public System.Data.IDataReader GetData(int i) { throw null; }
public abstract string GetDataTypeName(int i);
public abstract System.DateTime GetDateTime(int i);
protected virtual System.Data.Common.DbDataReader GetDbDataReader(int i) { throw null; }
public abstract decimal GetDecimal(int i);
public abstract double GetDouble(int i);
public abstract System.Type GetFieldType(int i);
public abstract float GetFloat(int i);
public abstract System.Guid GetGuid(int i);
public abstract short GetInt16(int i);
public abstract int GetInt32(int i);
public abstract long GetInt64(int i);
public abstract string GetName(int i);
public abstract int GetOrdinal(string name);
public abstract string GetString(int i);
public abstract object GetValue(int i);
public abstract int GetValues(object[] values);
public abstract bool IsDBNull(int i);
System.ComponentModel.AttributeCollection System.ComponentModel.ICustomTypeDescriptor.GetAttributes() { throw null; }
string System.ComponentModel.ICustomTypeDescriptor.GetClassName() { throw null; }
string System.ComponentModel.ICustomTypeDescriptor.GetComponentName() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
System.ComponentModel.TypeConverter System.ComponentModel.ICustomTypeDescriptor.GetConverter() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
System.ComponentModel.EventDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultEvent() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")]
System.ComponentModel.PropertyDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultProperty() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")]
object System.ComponentModel.ICustomTypeDescriptor.GetEditor(System.Type editorBaseType) { throw null; }
System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
System.ComponentModel.EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents(System.Attribute[]? attributes) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered.")]
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
System.ComponentModel.PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties(System.Attribute[]? attributes) { throw null; }
object System.ComponentModel.ICustomTypeDescriptor.GetPropertyOwner(System.ComponentModel.PropertyDescriptor? pd) { throw null; }
}
public abstract partial class DbDataSourceEnumerator
{
protected DbDataSourceEnumerator() { }
public abstract System.Data.DataTable GetDataSources();
}
public partial class DbEnumerator : System.Collections.IEnumerator
{
public DbEnumerator(System.Data.Common.DbDataReader reader) { }
public DbEnumerator(System.Data.Common.DbDataReader reader, bool closeReader) { }
public DbEnumerator(System.Data.IDataReader reader) { }
public DbEnumerator(System.Data.IDataReader reader, bool closeReader) { }
public object Current { get { throw null; } }
public bool MoveNext() { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public void Reset() { }
}
public abstract partial class DbException : System.Runtime.InteropServices.ExternalException
{
protected DbException() { }
protected DbException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
protected DbException(string? message) { }
protected DbException(string? message, System.Exception? innerException) { }
protected DbException(string? message, int errorCode) { }
public virtual bool IsTransient { get { throw null; } }
public virtual string? SqlState { get { throw null; } }
public System.Data.Common.DbBatchCommand? BatchCommand { get { throw null; } }
protected virtual System.Data.Common.DbBatchCommand? DbBatchCommand { get { throw null; } }
}
public static partial class DbMetaDataCollectionNames
{
public static readonly string DataSourceInformation;
public static readonly string DataTypes;
public static readonly string MetaDataCollections;
public static readonly string ReservedWords;
public static readonly string Restrictions;
}
public static partial class DbMetaDataColumnNames
{
public static readonly string CollectionName;
public static readonly string ColumnSize;
public static readonly string CompositeIdentifierSeparatorPattern;
public static readonly string CreateFormat;
public static readonly string CreateParameters;
public static readonly string DataSourceProductName;
public static readonly string DataSourceProductVersion;
public static readonly string DataSourceProductVersionNormalized;
public static readonly string DataType;
public static readonly string GroupByBehavior;
public static readonly string IdentifierCase;
public static readonly string IdentifierPattern;
public static readonly string IsAutoIncrementable;
public static readonly string IsBestMatch;
public static readonly string IsCaseSensitive;
public static readonly string IsConcurrencyType;
public static readonly string IsFixedLength;
public static readonly string IsFixedPrecisionScale;
public static readonly string IsLiteralSupported;
public static readonly string IsLong;
public static readonly string IsNullable;
public static readonly string IsSearchable;
public static readonly string IsSearchableWithLike;
public static readonly string IsUnsigned;
public static readonly string LiteralPrefix;
public static readonly string LiteralSuffix;
public static readonly string MaximumScale;
public static readonly string MinimumScale;
public static readonly string NumberOfIdentifierParts;
public static readonly string NumberOfRestrictions;
public static readonly string OrderByColumnsInSelect;
public static readonly string ParameterMarkerFormat;
public static readonly string ParameterMarkerPattern;
public static readonly string ParameterNameMaxLength;
public static readonly string ParameterNamePattern;
public static readonly string ProviderDbType;
public static readonly string QuotedIdentifierCase;
public static readonly string QuotedIdentifierPattern;
public static readonly string ReservedWord;
public static readonly string StatementSeparatorPattern;
public static readonly string StringLiteralPattern;
public static readonly string SupportedJoinOperators;
public static readonly string TypeName;
}
public abstract partial class DbParameter : System.MarshalByRefObject, System.Data.IDataParameter, System.Data.IDbDataParameter
{
protected DbParameter() { }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public abstract System.Data.DbType DbType { get; set; }
[System.ComponentModel.DefaultValueAttribute(System.Data.ParameterDirection.Input)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public abstract System.Data.ParameterDirection Direction { get; set; }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignOnlyAttribute(true)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public abstract bool IsNullable { get; set; }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public abstract string ParameterName { get; set; }
public virtual byte Precision { get { throw null; } set { } }
public virtual byte Scale { get { throw null; } set { } }
public abstract int Size { get; set; }
[System.ComponentModel.DefaultValueAttribute("")]
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
public abstract string SourceColumn { get; set; }
[System.ComponentModel.DefaultValueAttribute(false)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public abstract bool SourceColumnNullMapping { get; set; }
[System.ComponentModel.DefaultValueAttribute(System.Data.DataRowVersion.Current)]
public virtual System.Data.DataRowVersion SourceVersion { get { throw null; } set { } }
byte System.Data.IDbDataParameter.Precision { get { throw null; } set { } }
byte System.Data.IDbDataParameter.Scale { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(null)]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public abstract object? Value { get; set; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public abstract void ResetDbType();
}
public abstract partial class DbParameterCollection : System.MarshalByRefObject, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.Data.IDataParameterCollection
{
protected DbParameterCollection() { }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public abstract int Count { get; }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public virtual bool IsFixedSize { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public virtual bool IsReadOnly { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public virtual bool IsSynchronized { get { throw null; } }
public System.Data.Common.DbParameter this[int index] { get { throw null; } set { } }
public System.Data.Common.DbParameter this[string parameterName] { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public abstract object SyncRoot { get; }
object? System.Collections.IList.this[int index] { get { throw null; } set { } }
object System.Data.IDataParameterCollection.this[string parameterName] { get { throw null; } set { } }
int System.Collections.IList.Add(object? value) { throw null; }
public abstract int Add(object value);
public abstract void AddRange(System.Array values);
public abstract void Clear();
bool System.Collections.IList.Contains(object? value) { throw null; }
public abstract bool Contains(object value);
public abstract bool Contains(string value);
public abstract void CopyTo(System.Array array, int index);
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public abstract System.Collections.IEnumerator GetEnumerator();
protected abstract System.Data.Common.DbParameter GetParameter(int index);
protected abstract System.Data.Common.DbParameter GetParameter(string parameterName);
int System.Collections.IList.IndexOf(object? value) { throw null; }
public abstract int IndexOf(object value);
public abstract int IndexOf(string parameterName);
void System.Collections.IList.Insert(int index, object? value) { throw null; }
public abstract void Insert(int index, object value);
void System.Collections.IList.Remove(object? value) { throw null; }
public abstract void Remove(object value);
public abstract void RemoveAt(int index);
public abstract void RemoveAt(string parameterName);
protected abstract void SetParameter(int index, System.Data.Common.DbParameter value);
protected abstract void SetParameter(string parameterName, System.Data.Common.DbParameter value);
}
public static partial class DbProviderFactories
{
public static System.Data.Common.DbProviderFactory? GetFactory(System.Data.Common.DbConnection connection) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Provider type and its members might be trimmed if not referenced directly.")]
public static System.Data.Common.DbProviderFactory GetFactory(System.Data.DataRow providerRow) { throw null; }
public static System.Data.Common.DbProviderFactory GetFactory(string providerInvariantName) { throw null; }
public static System.Data.DataTable GetFactoryClasses() { throw null; }
public static System.Collections.Generic.IEnumerable<string> GetProviderInvariantNames() { throw null; }
public static void RegisterFactory(string providerInvariantName, System.Data.Common.DbProviderFactory factory) { }
public static void RegisterFactory(string providerInvariantName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] string factoryTypeAssemblyQualifiedName) { }
public static void RegisterFactory(string providerInvariantName, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)] System.Type providerFactoryClass) { }
public static bool TryGetFactory(string providerInvariantName, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Data.Common.DbProviderFactory? factory) { throw null; }
public static bool UnregisterFactory(string providerInvariantName) { throw null; }
}
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields)]
public abstract partial class DbProviderFactory
{
protected DbProviderFactory() { }
public virtual bool CanCreateBatch { get { throw null; } }
public virtual bool CanCreateCommandBuilder { get { throw null; } }
public virtual bool CanCreateDataAdapter { get { throw null; } }
public virtual bool CanCreateDataSourceEnumerator { get { throw null; } }
public virtual System.Data.Common.DbBatch CreateBatch() { throw null; }
public virtual System.Data.Common.DbBatchCommand CreateBatchCommand() { throw null; }
public virtual System.Data.Common.DbCommand? CreateCommand() { throw null; }
public virtual System.Data.Common.DbCommandBuilder? CreateCommandBuilder() { throw null; }
public virtual System.Data.Common.DbConnection? CreateConnection() { throw null; }
public virtual System.Data.Common.DbConnectionStringBuilder? CreateConnectionStringBuilder() { throw null; }
public virtual System.Data.Common.DbDataAdapter? CreateDataAdapter() { throw null; }
public virtual System.Data.Common.DbDataSourceEnumerator? CreateDataSourceEnumerator() { throw null; }
public virtual System.Data.Common.DbParameter? CreateParameter() { throw null; }
}
[System.AttributeUsageAttribute(System.AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public sealed partial class DbProviderSpecificTypePropertyAttribute : System.Attribute
{
public DbProviderSpecificTypePropertyAttribute(bool isProviderSpecificTypeProperty) { }
public bool IsProviderSpecificTypeProperty { get { throw null; } }
}
public abstract partial class DbTransaction : System.MarshalByRefObject, System.Data.IDbTransaction, System.IDisposable, System.IAsyncDisposable
{
protected DbTransaction() { }
public System.Data.Common.DbConnection? Connection { get { throw null; } }
protected abstract System.Data.Common.DbConnection? DbConnection { get; }
public abstract System.Data.IsolationLevel IsolationLevel { get; }
System.Data.IDbConnection? System.Data.IDbTransaction.Connection { get { throw null; } }
public abstract void Commit();
public virtual System.Threading.Tasks.Task CommitAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public void Dispose() { }
protected virtual void Dispose(bool disposing) { }
public virtual System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
public abstract void Rollback();
public virtual System.Threading.Tasks.Task RollbackAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual bool SupportsSavepoints { get { throw null; } }
public virtual System.Threading.Tasks.Task SaveAsync(string savepointName, System.Threading.CancellationToken cancellationToken = default) { throw null; }
public virtual System.Threading.Tasks.Task RollbackAsync(string savepointName, System.Threading.CancellationToken cancellationToken = default) { throw null; }
public virtual System.Threading.Tasks.Task ReleaseAsync(string savepointName, System.Threading.CancellationToken cancellationToken = default) { throw null; }
public virtual void Save(string savepointName) { throw null; }
public virtual void Rollback(string savepointName) { throw null; }
public virtual void Release(string savepointName) { throw null; }
}
public enum GroupByBehavior
{
Unknown = 0,
NotSupported = 1,
Unrelated = 2,
MustContainAll = 3,
ExactMatch = 4,
}
public partial interface IDbColumnSchemaGenerator
{
System.Collections.ObjectModel.ReadOnlyCollection<System.Data.Common.DbColumn> GetColumnSchema();
}
public enum IdentifierCase
{
Unknown = 0,
Insensitive = 1,
Sensitive = 2,
}
public partial class RowUpdatedEventArgs : System.EventArgs
{
public RowUpdatedEventArgs(System.Data.DataRow dataRow, System.Data.IDbCommand? command, System.Data.StatementType statementType, System.Data.Common.DataTableMapping tableMapping) { }
public System.Data.IDbCommand? Command { get { throw null; } }
public System.Exception? Errors { get { throw null; } set { } }
public int RecordsAffected { get { throw null; } }
public System.Data.DataRow Row { get { throw null; } }
public int RowCount { get { throw null; } }
public System.Data.StatementType StatementType { get { throw null; } }
public System.Data.UpdateStatus Status { get { throw null; } set { } }
public System.Data.Common.DataTableMapping TableMapping { get { throw null; } }
public void CopyToRows(System.Data.DataRow[] array) { }
public void CopyToRows(System.Data.DataRow[] array, int arrayIndex) { }
}
public partial class RowUpdatingEventArgs : System.EventArgs
{
public RowUpdatingEventArgs(System.Data.DataRow dataRow, System.Data.IDbCommand? command, System.Data.StatementType statementType, System.Data.Common.DataTableMapping tableMapping) { }
protected virtual System.Data.IDbCommand? BaseCommand { get { throw null; } set { } }
public System.Data.IDbCommand? Command { get { throw null; } set { } }
public System.Exception? Errors { get { throw null; } set { } }
public System.Data.DataRow Row { get { throw null; } }
public System.Data.StatementType StatementType { get { throw null; } }
public System.Data.UpdateStatus Status { get { throw null; } set { } }
public System.Data.Common.DataTableMapping TableMapping { get { throw null; } }
}
public static partial class SchemaTableColumn
{
public static readonly string AllowDBNull;
public static readonly string BaseColumnName;
public static readonly string BaseSchemaName;
public static readonly string BaseTableName;
public static readonly string ColumnName;
public static readonly string ColumnOrdinal;
public static readonly string ColumnSize;
public static readonly string DataType;
public static readonly string IsAliased;
public static readonly string IsExpression;
public static readonly string IsKey;
public static readonly string IsLong;
public static readonly string IsUnique;
public static readonly string NonVersionedProviderType;
public static readonly string NumericPrecision;
public static readonly string NumericScale;
public static readonly string ProviderType;
}
public static partial class SchemaTableOptionalColumn
{
public static readonly string AutoIncrementSeed;
public static readonly string AutoIncrementStep;
public static readonly string BaseCatalogName;
public static readonly string BaseColumnNamespace;
public static readonly string BaseServerName;
public static readonly string BaseTableNamespace;
public static readonly string ColumnMapping;
public static readonly string DefaultValue;
public static readonly string Expression;
public static readonly string IsAutoIncrement;
public static readonly string IsHidden;
public static readonly string IsReadOnly;
public static readonly string IsRowVersion;
public static readonly string ProviderSpecificDataType;
}
[System.FlagsAttribute]
public enum SupportedJoinOperators
{
None = 0,
Inner = 1,
LeftOuter = 2,
RightOuter = 4,
FullOuter = 8,
}
}
namespace System.Data.SqlTypes
{
public partial interface INullable
{
bool IsNull { get; }
}
public sealed partial class SqlAlreadyFilledException : System.Data.SqlTypes.SqlTypeException
{
public SqlAlreadyFilledException() { }
public SqlAlreadyFilledException(string? message) { }
public SqlAlreadyFilledException(string? message, System.Exception? e) { }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlBinary : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlBinary>
{
private object _dummy;
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlBinary Null;
public SqlBinary(byte[]? value) { throw null; }
public bool IsNull { get { throw null; } }
public byte this[int index] { get { throw null; } }
public int Length { get { throw null; } }
public byte[] Value { get { throw null; } }
public static System.Data.SqlTypes.SqlBinary Add(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlBinary value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlBinary Concat(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlBinary other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBinary operator +(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static explicit operator byte[]?(System.Data.SqlTypes.SqlBinary x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBinary(System.Data.SqlTypes.SqlGuid x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlBinary(byte[] x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlGuid ToSqlGuid() { throw null; }
public override string ToString() { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlBoolean : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlBoolean>
{
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlBoolean False;
public static readonly System.Data.SqlTypes.SqlBoolean Null;
public static readonly System.Data.SqlTypes.SqlBoolean One;
public static readonly System.Data.SqlTypes.SqlBoolean True;
public static readonly System.Data.SqlTypes.SqlBoolean Zero;
public SqlBoolean(bool value) { throw null; }
public SqlBoolean(int value) { throw null; }
public byte ByteValue { get { throw null; } }
public bool IsFalse { get { throw null; } }
public bool IsNull { get { throw null; } }
public bool IsTrue { get { throw null; } }
public bool Value { get { throw null; } }
public static System.Data.SqlTypes.SqlBoolean And(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlBoolean value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlBoolean other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEquals(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEquals(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean OnesComplement(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator &(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator |(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ^(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static explicit operator bool(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlByte x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBoolean(System.Data.SqlTypes.SqlString x) { throw null; }
public static bool operator false(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlBoolean(bool x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ~(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static bool operator true(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Or(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Parse(string s) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlByte ToSqlByte() { throw null; }
public System.Data.SqlTypes.SqlDecimal ToSqlDecimal() { throw null; }
public System.Data.SqlTypes.SqlDouble ToSqlDouble() { throw null; }
public System.Data.SqlTypes.SqlInt16 ToSqlInt16() { throw null; }
public System.Data.SqlTypes.SqlInt32 ToSqlInt32() { throw null; }
public System.Data.SqlTypes.SqlInt64 ToSqlInt64() { throw null; }
public System.Data.SqlTypes.SqlMoney ToSqlMoney() { throw null; }
public System.Data.SqlTypes.SqlSingle ToSqlSingle() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
public static System.Data.SqlTypes.SqlBoolean Xor(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlByte : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlByte>
{
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlByte MaxValue;
public static readonly System.Data.SqlTypes.SqlByte MinValue;
public static readonly System.Data.SqlTypes.SqlByte Null;
public static readonly System.Data.SqlTypes.SqlByte Zero;
public SqlByte(byte value) { throw null; }
public bool IsNull { get { throw null; } }
public byte Value { get { throw null; } }
public static System.Data.SqlTypes.SqlByte Add(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte BitwiseAnd(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte BitwiseOr(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlByte value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlByte Divide(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlByte other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte Mod(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte Modulus(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte Multiply(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte OnesComplement(System.Data.SqlTypes.SqlByte x) { throw null; }
public static System.Data.SqlTypes.SqlByte operator +(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte operator &(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte operator |(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte operator /(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte operator ^(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator byte(System.Data.SqlTypes.SqlByte x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlByte(System.Data.SqlTypes.SqlString x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlByte(byte x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte operator %(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte operator *(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte operator ~(System.Data.SqlTypes.SqlByte x) { throw null; }
public static System.Data.SqlTypes.SqlByte operator -(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
public static System.Data.SqlTypes.SqlByte Parse(string s) { throw null; }
public static System.Data.SqlTypes.SqlByte Subtract(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
System.Xml.Schema.XmlSchema System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlBoolean ToSqlBoolean() { throw null; }
public System.Data.SqlTypes.SqlDecimal ToSqlDecimal() { throw null; }
public System.Data.SqlTypes.SqlDouble ToSqlDouble() { throw null; }
public System.Data.SqlTypes.SqlInt16 ToSqlInt16() { throw null; }
public System.Data.SqlTypes.SqlInt32 ToSqlInt32() { throw null; }
public System.Data.SqlTypes.SqlInt64 ToSqlInt64() { throw null; }
public System.Data.SqlTypes.SqlMoney ToSqlMoney() { throw null; }
public System.Data.SqlTypes.SqlSingle ToSqlSingle() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
public static System.Data.SqlTypes.SqlByte Xor(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public sealed partial class SqlBytes : System.Data.SqlTypes.INullable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
{
public SqlBytes() { }
public SqlBytes(byte[]? buffer) { }
public SqlBytes(System.Data.SqlTypes.SqlBinary value) { }
public SqlBytes(System.IO.Stream? s) { }
public byte[]? Buffer { get { throw null; } }
public bool IsNull { get { throw null; } }
public byte this[long offset] { get { throw null; } set { } }
public long Length { get { throw null; } }
public long MaxLength { get { throw null; } }
public static System.Data.SqlTypes.SqlBytes Null { get { throw null; } }
public System.Data.SqlTypes.StorageState Storage { get { throw null; } }
public System.IO.Stream Stream { get { throw null; } set { } }
public byte[] Value { get { throw null; } }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBytes(System.Data.SqlTypes.SqlBinary value) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlBinary(System.Data.SqlTypes.SqlBytes value) { throw null; }
public long Read(long offset, byte[] buffer, int offsetInBuffer, int count) { throw null; }
public void SetLength(long value) { }
public void SetNull() { }
void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader r) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlBinary ToSqlBinary() { throw null; }
public void Write(long offset, byte[] buffer, int offsetInBuffer, int count) { }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public sealed partial class SqlChars : System.Data.SqlTypes.INullable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
{
public SqlChars() { }
public SqlChars(char[]? buffer) { }
public SqlChars(System.Data.SqlTypes.SqlString value) { }
public char[]? Buffer { get { throw null; } }
public bool IsNull { get { throw null; } }
public char this[long offset] { get { throw null; } set { } }
public long Length { get { throw null; } }
public long MaxLength { get { throw null; } }
public static System.Data.SqlTypes.SqlChars Null { get { throw null; } }
public System.Data.SqlTypes.StorageState Storage { get { throw null; } }
public char[] Value { get { throw null; } }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlChars value) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlChars(System.Data.SqlTypes.SqlString value) { throw null; }
public long Read(long offset, char[] buffer, int offsetInBuffer, int count) { throw null; }
public void SetLength(long value) { }
public void SetNull() { }
void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader r) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public void Write(long offset, char[] buffer, int offsetInBuffer, int count) { }
}
[System.FlagsAttribute]
public enum SqlCompareOptions
{
None = 0,
IgnoreCase = 1,
IgnoreNonSpace = 2,
IgnoreKanaType = 8,
IgnoreWidth = 16,
BinarySort2 = 16384,
BinarySort = 32768,
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlDateTime : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlDateTime>
{
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlDateTime MaxValue;
public static readonly System.Data.SqlTypes.SqlDateTime MinValue;
public static readonly System.Data.SqlTypes.SqlDateTime Null;
public static readonly int SQLTicksPerHour;
public static readonly int SQLTicksPerMinute;
public static readonly int SQLTicksPerSecond;
public SqlDateTime(System.DateTime value) { throw null; }
public SqlDateTime(int dayTicks, int timeTicks) { throw null; }
public SqlDateTime(int year, int month, int day) { throw null; }
public SqlDateTime(int year, int month, int day, int hour, int minute, int second) { throw null; }
public SqlDateTime(int year, int month, int day, int hour, int minute, int second, double millisecond) { throw null; }
public SqlDateTime(int year, int month, int day, int hour, int minute, int second, int bilisecond) { throw null; }
public int DayTicks { get { throw null; } }
public bool IsNull { get { throw null; } }
public int TimeTicks { get { throw null; } }
public System.DateTime Value { get { throw null; } }
public static System.Data.SqlTypes.SqlDateTime Add(System.Data.SqlTypes.SqlDateTime x, System.TimeSpan t) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlDateTime value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlDateTime other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static System.Data.SqlTypes.SqlDateTime operator +(System.Data.SqlTypes.SqlDateTime x, System.TimeSpan t) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static explicit operator System.DateTime(System.Data.SqlTypes.SqlDateTime x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlDateTime(System.Data.SqlTypes.SqlString x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDateTime(System.DateTime value) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; }
public static System.Data.SqlTypes.SqlDateTime operator -(System.Data.SqlTypes.SqlDateTime x, System.TimeSpan t) { throw null; }
public static System.Data.SqlTypes.SqlDateTime Parse(string s) { throw null; }
public static System.Data.SqlTypes.SqlDateTime Subtract(System.Data.SqlTypes.SqlDateTime x, System.TimeSpan t) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlDecimal : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlDecimal>
{
private int _dummyPrimitive;
public static readonly byte MaxPrecision;
public static readonly byte MaxScale;
public static readonly System.Data.SqlTypes.SqlDecimal MaxValue;
public static readonly System.Data.SqlTypes.SqlDecimal MinValue;
public static readonly System.Data.SqlTypes.SqlDecimal Null;
public SqlDecimal(byte bPrecision, byte bScale, bool fPositive, int data1, int data2, int data3, int data4) { throw null; }
public SqlDecimal(byte bPrecision, byte bScale, bool fPositive, int[] bits) { throw null; }
public SqlDecimal(decimal value) { throw null; }
public SqlDecimal(double dVal) { throw null; }
public SqlDecimal(int value) { throw null; }
public SqlDecimal(long value) { throw null; }
public byte[] BinData { get { throw null; } }
public int[] Data { get { throw null; } }
public bool IsNull { get { throw null; } }
public bool IsPositive { get { throw null; } }
public byte Precision { get { throw null; } }
public byte Scale { get { throw null; } }
public decimal Value { get { throw null; } }
public static System.Data.SqlTypes.SqlDecimal Abs(System.Data.SqlTypes.SqlDecimal n) { throw null; }
public static System.Data.SqlTypes.SqlDecimal Add(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlDecimal AdjustScale(System.Data.SqlTypes.SqlDecimal n, int digits, bool fRound) { throw null; }
public static System.Data.SqlTypes.SqlDecimal Ceiling(System.Data.SqlTypes.SqlDecimal n) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlDecimal value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlDecimal ConvertToPrecScale(System.Data.SqlTypes.SqlDecimal n, int precision, int scale) { throw null; }
public static System.Data.SqlTypes.SqlDecimal Divide(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlDecimal other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public static System.Data.SqlTypes.SqlDecimal Floor(System.Data.SqlTypes.SqlDecimal n) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlDecimal Multiply(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlDecimal operator +(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlDecimal operator /(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator decimal(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlString x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlDecimal(double x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlByte x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDecimal(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDecimal(decimal x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDecimal(long x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlDecimal operator *(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlDecimal operator -(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
public static System.Data.SqlTypes.SqlDecimal operator -(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static System.Data.SqlTypes.SqlDecimal Parse(string s) { throw null; }
public static System.Data.SqlTypes.SqlDecimal Power(System.Data.SqlTypes.SqlDecimal n, double exp) { throw null; }
public static System.Data.SqlTypes.SqlDecimal Round(System.Data.SqlTypes.SqlDecimal n, int position) { throw null; }
public static System.Data.SqlTypes.SqlInt32 Sign(System.Data.SqlTypes.SqlDecimal n) { throw null; }
public static System.Data.SqlTypes.SqlDecimal Subtract(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public double ToDouble() { throw null; }
public System.Data.SqlTypes.SqlBoolean ToSqlBoolean() { throw null; }
public System.Data.SqlTypes.SqlByte ToSqlByte() { throw null; }
public System.Data.SqlTypes.SqlDouble ToSqlDouble() { throw null; }
public System.Data.SqlTypes.SqlInt16 ToSqlInt16() { throw null; }
public System.Data.SqlTypes.SqlInt32 ToSqlInt32() { throw null; }
public System.Data.SqlTypes.SqlInt64 ToSqlInt64() { throw null; }
public System.Data.SqlTypes.SqlMoney ToSqlMoney() { throw null; }
public System.Data.SqlTypes.SqlSingle ToSqlSingle() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
public static System.Data.SqlTypes.SqlDecimal Truncate(System.Data.SqlTypes.SqlDecimal n, int position) { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlDouble : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlDouble>
{
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlDouble MaxValue;
public static readonly System.Data.SqlTypes.SqlDouble MinValue;
public static readonly System.Data.SqlTypes.SqlDouble Null;
public static readonly System.Data.SqlTypes.SqlDouble Zero;
public SqlDouble(double value) { throw null; }
public bool IsNull { get { throw null; } }
public double Value { get { throw null; } }
public static System.Data.SqlTypes.SqlDouble Add(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlDouble value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlDouble Divide(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlDouble other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlDouble Multiply(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlDouble operator +(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlDouble operator /(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator double(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlString x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlByte x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDouble(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlDouble(double x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlDouble operator *(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlDouble operator -(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
public static System.Data.SqlTypes.SqlDouble operator -(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static System.Data.SqlTypes.SqlDouble Parse(string s) { throw null; }
public static System.Data.SqlTypes.SqlDouble Subtract(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlBoolean ToSqlBoolean() { throw null; }
public System.Data.SqlTypes.SqlByte ToSqlByte() { throw null; }
public System.Data.SqlTypes.SqlDecimal ToSqlDecimal() { throw null; }
public System.Data.SqlTypes.SqlInt16 ToSqlInt16() { throw null; }
public System.Data.SqlTypes.SqlInt32 ToSqlInt32() { throw null; }
public System.Data.SqlTypes.SqlInt64 ToSqlInt64() { throw null; }
public System.Data.SqlTypes.SqlMoney ToSqlMoney() { throw null; }
public System.Data.SqlTypes.SqlSingle ToSqlSingle() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlGuid : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlGuid>
{
private object _dummy;
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlGuid Null;
public SqlGuid(byte[] value) { throw null; }
public SqlGuid(System.Guid g) { throw null; }
public SqlGuid(int a, short b, short c, byte d, byte e, byte f, byte g, byte h, byte i, byte j, byte k) { throw null; }
public SqlGuid(string s) { throw null; }
public bool IsNull { get { throw null; } }
public System.Guid Value { get { throw null; } }
public int CompareTo(System.Data.SqlTypes.SqlGuid value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlGuid other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlGuid(System.Data.SqlTypes.SqlBinary x) { throw null; }
public static explicit operator System.Guid(System.Data.SqlTypes.SqlGuid x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlGuid(System.Data.SqlTypes.SqlString x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlGuid(System.Guid x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; }
public static System.Data.SqlTypes.SqlGuid Parse(string s) { throw null; }
System.Xml.Schema.XmlSchema System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public byte[]? ToByteArray() { throw null; }
public System.Data.SqlTypes.SqlBinary ToSqlBinary() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlInt16 : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlInt16>
{
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlInt16 MaxValue;
public static readonly System.Data.SqlTypes.SqlInt16 MinValue;
public static readonly System.Data.SqlTypes.SqlInt16 Null;
public static readonly System.Data.SqlTypes.SqlInt16 Zero;
public SqlInt16(short value) { throw null; }
public bool IsNull { get { throw null; } }
public short Value { get { throw null; } }
public static System.Data.SqlTypes.SqlInt16 Add(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 BitwiseAnd(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 BitwiseOr(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlInt16 value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlInt16 Divide(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlInt16 other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 Mod(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 Modulus(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 Multiply(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 OnesComplement(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator +(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator &(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator |(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator /(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator ^(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator short(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlString x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlInt16(System.Data.SqlTypes.SqlByte x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlInt16(short x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator %(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator *(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator ~(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator -(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
public static System.Data.SqlTypes.SqlInt16 operator -(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static System.Data.SqlTypes.SqlInt16 Parse(string s) { throw null; }
public static System.Data.SqlTypes.SqlInt16 Subtract(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlBoolean ToSqlBoolean() { throw null; }
public System.Data.SqlTypes.SqlByte ToSqlByte() { throw null; }
public System.Data.SqlTypes.SqlDecimal ToSqlDecimal() { throw null; }
public System.Data.SqlTypes.SqlDouble ToSqlDouble() { throw null; }
public System.Data.SqlTypes.SqlInt32 ToSqlInt32() { throw null; }
public System.Data.SqlTypes.SqlInt64 ToSqlInt64() { throw null; }
public System.Data.SqlTypes.SqlMoney ToSqlMoney() { throw null; }
public System.Data.SqlTypes.SqlSingle ToSqlSingle() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
public static System.Data.SqlTypes.SqlInt16 Xor(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlInt32 : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlInt32>
{
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlInt32 MaxValue;
public static readonly System.Data.SqlTypes.SqlInt32 MinValue;
public static readonly System.Data.SqlTypes.SqlInt32 Null;
public static readonly System.Data.SqlTypes.SqlInt32 Zero;
public SqlInt32(int value) { throw null; }
public bool IsNull { get { throw null; } }
public int Value { get { throw null; } }
public static System.Data.SqlTypes.SqlInt32 Add(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 BitwiseAnd(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 BitwiseOr(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlInt32 value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlInt32 Divide(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlInt32 other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 Mod(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 Modulus(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 Multiply(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 OnesComplement(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator +(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator &(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator |(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator /(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator ^(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator int(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlString x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlByte x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlInt32(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlInt32(int x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator %(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator *(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator ~(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator -(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
public static System.Data.SqlTypes.SqlInt32 operator -(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static System.Data.SqlTypes.SqlInt32 Parse(string s) { throw null; }
public static System.Data.SqlTypes.SqlInt32 Subtract(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlBoolean ToSqlBoolean() { throw null; }
public System.Data.SqlTypes.SqlByte ToSqlByte() { throw null; }
public System.Data.SqlTypes.SqlDecimal ToSqlDecimal() { throw null; }
public System.Data.SqlTypes.SqlDouble ToSqlDouble() { throw null; }
public System.Data.SqlTypes.SqlInt16 ToSqlInt16() { throw null; }
public System.Data.SqlTypes.SqlInt64 ToSqlInt64() { throw null; }
public System.Data.SqlTypes.SqlMoney ToSqlMoney() { throw null; }
public System.Data.SqlTypes.SqlSingle ToSqlSingle() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
public static System.Data.SqlTypes.SqlInt32 Xor(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlInt64 : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlInt64>
{
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlInt64 MaxValue;
public static readonly System.Data.SqlTypes.SqlInt64 MinValue;
public static readonly System.Data.SqlTypes.SqlInt64 Null;
public static readonly System.Data.SqlTypes.SqlInt64 Zero;
public SqlInt64(long value) { throw null; }
public bool IsNull { get { throw null; } }
public long Value { get { throw null; } }
public static System.Data.SqlTypes.SqlInt64 Add(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 BitwiseAnd(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 BitwiseOr(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlInt64 value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlInt64 Divide(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlInt64 other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 Mod(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 Modulus(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 Multiply(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 OnesComplement(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator +(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator &(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator |(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator /(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator ^(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator long(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlString x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlByte x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlInt64(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlInt64(long x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator %(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator *(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator ~(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator -(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
public static System.Data.SqlTypes.SqlInt64 operator -(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static System.Data.SqlTypes.SqlInt64 Parse(string s) { throw null; }
public static System.Data.SqlTypes.SqlInt64 Subtract(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlBoolean ToSqlBoolean() { throw null; }
public System.Data.SqlTypes.SqlByte ToSqlByte() { throw null; }
public System.Data.SqlTypes.SqlDecimal ToSqlDecimal() { throw null; }
public System.Data.SqlTypes.SqlDouble ToSqlDouble() { throw null; }
public System.Data.SqlTypes.SqlInt16 ToSqlInt16() { throw null; }
public System.Data.SqlTypes.SqlInt32 ToSqlInt32() { throw null; }
public System.Data.SqlTypes.SqlMoney ToSqlMoney() { throw null; }
public System.Data.SqlTypes.SqlSingle ToSqlSingle() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
public static System.Data.SqlTypes.SqlInt64 Xor(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlMoney : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlMoney>
{
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlMoney MaxValue;
public static readonly System.Data.SqlTypes.SqlMoney MinValue;
public static readonly System.Data.SqlTypes.SqlMoney Null;
public static readonly System.Data.SqlTypes.SqlMoney Zero;
public SqlMoney(decimal value) { throw null; }
public SqlMoney(double value) { throw null; }
public SqlMoney(int value) { throw null; }
public SqlMoney(long value) { throw null; }
public bool IsNull { get { throw null; } }
public decimal Value { get { throw null; } }
public static System.Data.SqlTypes.SqlMoney Add(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlMoney value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlMoney Divide(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlMoney other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlMoney Multiply(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlMoney operator +(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlMoney operator /(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator decimal(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlString x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlMoney(double x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlByte x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlMoney(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlMoney(decimal x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlMoney(long x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlMoney operator *(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlMoney operator -(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
public static System.Data.SqlTypes.SqlMoney operator -(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static System.Data.SqlTypes.SqlMoney Parse(string s) { throw null; }
public static System.Data.SqlTypes.SqlMoney Subtract(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public decimal ToDecimal() { throw null; }
public double ToDouble() { throw null; }
public int ToInt32() { throw null; }
public long ToInt64() { throw null; }
public System.Data.SqlTypes.SqlBoolean ToSqlBoolean() { throw null; }
public System.Data.SqlTypes.SqlByte ToSqlByte() { throw null; }
public System.Data.SqlTypes.SqlDecimal ToSqlDecimal() { throw null; }
public System.Data.SqlTypes.SqlDouble ToSqlDouble() { throw null; }
public System.Data.SqlTypes.SqlInt16 ToSqlInt16() { throw null; }
public System.Data.SqlTypes.SqlInt32 ToSqlInt32() { throw null; }
public System.Data.SqlTypes.SqlInt64 ToSqlInt64() { throw null; }
public System.Data.SqlTypes.SqlSingle ToSqlSingle() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
}
public sealed partial class SqlNotFilledException : System.Data.SqlTypes.SqlTypeException
{
public SqlNotFilledException() { }
public SqlNotFilledException(string? message) { }
public SqlNotFilledException(string? message, System.Exception? e) { }
}
public sealed partial class SqlNullValueException : System.Data.SqlTypes.SqlTypeException
{
public SqlNullValueException() { }
public SqlNullValueException(string? message) { }
public SqlNullValueException(string? message, System.Exception? e) { }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlSingle : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlSingle>
{
private int _dummyPrimitive;
public static readonly System.Data.SqlTypes.SqlSingle MaxValue;
public static readonly System.Data.SqlTypes.SqlSingle MinValue;
public static readonly System.Data.SqlTypes.SqlSingle Null;
public static readonly System.Data.SqlTypes.SqlSingle Zero;
public SqlSingle(double value) { throw null; }
public SqlSingle(float value) { throw null; }
public bool IsNull { get { throw null; } }
public float Value { get { throw null; } }
public static System.Data.SqlTypes.SqlSingle Add(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlSingle value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlSingle Divide(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlSingle other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlSingle Multiply(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlSingle operator +(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlSingle operator /(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator float(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlString x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlByte x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlSingle(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlSingle(float x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlSingle operator *(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlSingle operator -(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
public static System.Data.SqlTypes.SqlSingle operator -(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static System.Data.SqlTypes.SqlSingle Parse(string s) { throw null; }
public static System.Data.SqlTypes.SqlSingle Subtract(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlBoolean ToSqlBoolean() { throw null; }
public System.Data.SqlTypes.SqlByte ToSqlByte() { throw null; }
public System.Data.SqlTypes.SqlDecimal ToSqlDecimal() { throw null; }
public System.Data.SqlTypes.SqlDouble ToSqlDouble() { throw null; }
public System.Data.SqlTypes.SqlInt16 ToSqlInt16() { throw null; }
public System.Data.SqlTypes.SqlInt32 ToSqlInt32() { throw null; }
public System.Data.SqlTypes.SqlInt64 ToSqlInt64() { throw null; }
public System.Data.SqlTypes.SqlMoney ToSqlMoney() { throw null; }
public System.Data.SqlTypes.SqlString ToSqlString() { throw null; }
public override string ToString() { throw null; }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public partial struct SqlString : System.Data.SqlTypes.INullable, System.IComparable, System.Xml.Serialization.IXmlSerializable, System.IEquatable<System.Data.SqlTypes.SqlString>
{
private object _dummy;
private int _dummyPrimitive;
public static readonly int BinarySort;
public static readonly int BinarySort2;
public static readonly int IgnoreCase;
public static readonly int IgnoreKanaType;
public static readonly int IgnoreNonSpace;
public static readonly int IgnoreWidth;
public static readonly System.Data.SqlTypes.SqlString Null;
public SqlString(int lcid, System.Data.SqlTypes.SqlCompareOptions compareOptions, byte[] data) { throw null; }
public SqlString(int lcid, System.Data.SqlTypes.SqlCompareOptions compareOptions, byte[] data, bool fUnicode) { throw null; }
public SqlString(int lcid, System.Data.SqlTypes.SqlCompareOptions compareOptions, byte[]? data, int index, int count) { throw null; }
public SqlString(int lcid, System.Data.SqlTypes.SqlCompareOptions compareOptions, byte[]? data, int index, int count, bool fUnicode) { throw null; }
public SqlString(string? data) { throw null; }
public SqlString(string? data, int lcid) { throw null; }
public SqlString(string? data, int lcid, System.Data.SqlTypes.SqlCompareOptions compareOptions) { throw null; }
public System.Globalization.CompareInfo CompareInfo { get { throw null; } }
public System.Globalization.CultureInfo CultureInfo { get { throw null; } }
public bool IsNull { get { throw null; } }
public int LCID { get { throw null; } }
public System.Data.SqlTypes.SqlCompareOptions SqlCompareOptions { get { throw null; } }
public string Value { get { throw null; } }
public static System.Data.SqlTypes.SqlString Add(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public System.Data.SqlTypes.SqlString Clone() { throw null; }
public static System.Globalization.CompareOptions CompareOptionsFromSqlCompareOptions(System.Data.SqlTypes.SqlCompareOptions compareOptions) { throw null; }
public int CompareTo(System.Data.SqlTypes.SqlString value) { throw null; }
public int CompareTo(object? value) { throw null; }
public static System.Data.SqlTypes.SqlString Concat(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public bool Equals(System.Data.SqlTypes.SqlString other) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public byte[]? GetNonUnicodeBytes() { throw null; }
public byte[]? GetUnicodeBytes() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean GreaterThanOrEqual(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThan(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean LessThanOrEqual(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean NotEquals(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlString operator +(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator ==(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlBoolean x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlByte x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlDateTime x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlDecimal x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlDouble x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlGuid x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlInt16 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlInt32 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlInt64 x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlMoney x) { throw null; }
public static explicit operator System.Data.SqlTypes.SqlString(System.Data.SqlTypes.SqlSingle x) { throw null; }
public static explicit operator string(System.Data.SqlTypes.SqlString x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator >=(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static implicit operator System.Data.SqlTypes.SqlString(string x) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator !=(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
public static System.Data.SqlTypes.SqlBoolean operator <=(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; }
System.Xml.Schema.XmlSchema System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
public System.Data.SqlTypes.SqlBoolean ToSqlBoolean() { throw null; }
public System.Data.SqlTypes.SqlByte ToSqlByte() { throw null; }
public System.Data.SqlTypes.SqlDateTime ToSqlDateTime() { throw null; }
public System.Data.SqlTypes.SqlDecimal ToSqlDecimal() { throw null; }
public System.Data.SqlTypes.SqlDouble ToSqlDouble() { throw null; }
public System.Data.SqlTypes.SqlGuid ToSqlGuid() { throw null; }
public System.Data.SqlTypes.SqlInt16 ToSqlInt16() { throw null; }
public System.Data.SqlTypes.SqlInt32 ToSqlInt32() { throw null; }
public System.Data.SqlTypes.SqlInt64 ToSqlInt64() { throw null; }
public System.Data.SqlTypes.SqlMoney ToSqlMoney() { throw null; }
public System.Data.SqlTypes.SqlSingle ToSqlSingle() { throw null; }
public override string ToString() { throw null; }
}
public sealed partial class SqlTruncateException : System.Data.SqlTypes.SqlTypeException
{
public SqlTruncateException() { }
public SqlTruncateException(string? message) { }
public SqlTruncateException(string? message, System.Exception? e) { }
}
public partial class SqlTypeException : System.SystemException
{
public SqlTypeException() { }
protected SqlTypeException(System.Runtime.Serialization.SerializationInfo si, System.Runtime.Serialization.StreamingContext sc) { }
public SqlTypeException(string? message) { }
public SqlTypeException(string? message, System.Exception? e) { }
}
[System.Xml.Serialization.XmlSchemaProviderAttribute("GetXsdType")]
public sealed partial class SqlXml : System.Data.SqlTypes.INullable, System.Xml.Serialization.IXmlSerializable
{
public SqlXml() { }
public SqlXml(System.IO.Stream? value) { }
public SqlXml(System.Xml.XmlReader? value) { }
public bool IsNull { get { throw null; } }
public static System.Data.SqlTypes.SqlXml Null { get { throw null; } }
public string Value { get { throw null; } }
public System.Xml.XmlReader CreateReader() { throw null; }
public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; }
System.Xml.Schema.XmlSchema? System.Xml.Serialization.IXmlSerializable.GetSchema() { throw null; }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader r) { }
void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { }
}
public enum StorageState
{
Buffer = 0,
Stream = 1,
UnmanagedBuffer = 2,
}
}
namespace System.Xml
{
[System.ObsoleteAttribute("XmlDataDocument has been deprecated and is not supported.")]
public partial class XmlDataDocument : System.Xml.XmlDocument
{
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("XmlDataDocument is used for serialization and deserialization. Members from serialized types may be trimmed if not referenced directly.")]
public XmlDataDocument() { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("XmlDataDocument is used for serialization and deserialization. Members from serialized types may be trimmed if not referenced directly.")]
public XmlDataDocument(System.Data.DataSet dataset) { }
public System.Data.DataSet DataSet { get { throw null; } }
public override System.Xml.XmlNode CloneNode(bool deep) { throw null; }
public override System.Xml.XmlElement CreateElement(string? prefix, string localName, string? namespaceURI) { throw null; }
public override System.Xml.XmlEntityReference CreateEntityReference(string name) { throw null; }
protected override System.Xml.XPath.XPathNavigator? CreateNavigator(System.Xml.XmlNode node) { throw null; }
public override System.Xml.XmlElement? GetElementById(string elemId) { throw null; }
public System.Xml.XmlElement GetElementFromRow(System.Data.DataRow r) { throw null; }
public override System.Xml.XmlNodeList GetElementsByTagName(string name) { throw null; }
public System.Data.DataRow? GetRowFromElement(System.Xml.XmlElement? e) { throw null; }
public override void Load(System.IO.Stream inStream) { }
public override void Load(System.IO.TextReader txtReader) { }
public override void Load(string filename) { }
public override void Load(System.Xml.XmlReader reader) { }
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.IO.MemoryMappedFiles/src/Microsoft/Win32/SafeMemoryMappedFileHandle.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;
namespace Microsoft.Win32.SafeHandles
{
public sealed partial class SafeMemoryMappedFileHandle : SafeHandleZeroOrMinusOneIsInvalid
{
/// <summary>
/// Creates a <see cref="T:Microsoft.Win32.SafeHandles.SafeMemoryMappedFileHandle" />.
/// </summary>
public SafeMemoryMappedFileHandle()
: base(true)
{
}
}
}
| // 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;
namespace Microsoft.Win32.SafeHandles
{
public sealed partial class SafeMemoryMappedFileHandle : SafeHandleZeroOrMinusOneIsInvalid
{
/// <summary>
/// Creates a <see cref="T:Microsoft.Win32.SafeHandles.SafeMemoryMappedFileHandle" />.
/// </summary>
public SafeMemoryMappedFileHandle()
: base(true)
{
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/Loader/classloader/generics/GenericMethods/method006.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;
struct Foo<U>
{
public string Function<T>(U u,T t)
{
return u.ToString()+t.ToString();
}
}
public class Test_method006
{
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()
{
Eval(new Foo<int>().Function<int>(1,1).Equals("11"));
Eval(new Foo<string>().Function<int>("string",1).Equals("string1"));
Eval(new Foo<int>().Function<string>(1,"string").Equals("1string"));
Eval(new Foo<string>().Function<string>("string1","string2").Equals("string1string2"));
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;
struct Foo<U>
{
public string Function<T>(U u,T t)
{
return u.ToString()+t.ToString();
}
}
public class Test_method006
{
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()
{
Eval(new Foo<int>().Function<int>(1,1).Equals("11"));
Eval(new Foo<string>().Function<int>("string",1).Equals("string1"));
Eval(new Foo<int>().Function<string>(1,"string").Equals("1string"));
Eval(new Foo<string>().Function<string>("string1","string2").Equals("string1string2"));
if (result)
{
Console.WriteLine("Test Passed");
return 100;
}
else
{
Console.WriteLine("Test Failed");
return 1;
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/Interop/WinRT/Program.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices.WindowsRuntime;
using Xunit;
namespace WinRT
{
[WindowsRuntimeImport]
interface I {}
class Program
{
[MethodImpl(MethodImplOptions.NoInlining)]
private static bool ObjectIsI(object o) => o is I;
public static int Main(string[] args)
{
try
{
Assert.Throws<TypeLoadException>(() => ObjectIsI(new object()));
}
catch (System.Exception ex)
{
Console.WriteLine(ex);
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.Runtime.CompilerServices;
using System.Runtime.InteropServices.WindowsRuntime;
using Xunit;
namespace WinRT
{
[WindowsRuntimeImport]
interface I {}
class Program
{
[MethodImpl(MethodImplOptions.NoInlining)]
private static bool ObjectIsI(object o) => o is I;
public static int Main(string[] args)
{
try
{
Assert.Throws<TypeLoadException>(() => ObjectIsI(new object()));
}
catch (System.Exception ex)
{
Console.WriteLine(ex);
return 101;
}
return 100;
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.ComponentModel.TypeConverter/src/Resources/Strings.resx | <?xml version="1.0" encoding="utf-8"?>
<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="Array" xml:space="preserve">
<value>{0} Array</value>
</data>
<data name="Collection" xml:space="preserve">
<value>(Collection)</value>
</data>
<data name="ConvertFromException" xml:space="preserve">
<value>{0} cannot convert from {1}.</value>
</data>
<data name="ConvertInvalidPrimitive" xml:space="preserve">
<value>{0} is not a valid value for {1}.</value>
</data>
<data name="ConvertToException" xml:space="preserve">
<value>'{0}' is unable to convert '{1}' to '{2}'.</value>
</data>
<data name="EnumConverterInvalidValue" xml:space="preserve">
<value>The value '{0}' is not a valid value for the enum '{1}'.</value>
</data>
<data name="ErrorInvalidEventHandler" xml:space="preserve">
<value>Invalid event handler for the {0} event.</value>
</data>
<data name="ErrorInvalidEventType" xml:space="preserve">
<value>Invalid type for the {0} event.</value>
</data>
<data name="ErrorInvalidPropertyType" xml:space="preserve">
<value>Invalid type for the {0} property</value>
</data>
<data name="ErrorMissingEventAccessors" xml:space="preserve">
<value>Accessor methods for the {0} event are missing.</value>
</data>
<data name="ErrorMissingPropertyAccessors" xml:space="preserve">
<value>Accessor methods for the {0} property are missing.</value>
</data>
<data name="InvalidMemberName" xml:space="preserve">
<value>Invalid member name</value>
</data>
<data name="none" xml:space="preserve">
<value>(none)</value>
</data>
<data name="Null" xml:space="preserve">
<value>(null)</value>
</data>
<data name="NullableConverterBadCtorArg" xml:space="preserve">
<value>The specified type is not a nullable type.</value>
</data>
<data name="Text" xml:space="preserve">
<value>(Text)</value>
</data>
<data name="TypeDescriptorAlreadyAssociated" xml:space="preserve">
<value>The primary and secondary objects are already associated with each other.</value>
</data>
<data name="TypeDescriptorArgsCountMismatch" xml:space="preserve">
<value>The number of elements in the Type and Object arrays must match.</value>
</data>
<data name="TypeDescriptorProviderError" xml:space="preserve">
<value>The type description provider {0} has returned null from {1} which is illegal.</value>
</data>
<data name="TypeDescriptorExpectedElementType" xml:space="preserve">
<value>Expected types in the collection to be of type {0}.</value>
</data>
<data name="TypeDescriptorSameAssociation" xml:space="preserve">
<value>Cannot create an association when the primary and secondary objects are the same.</value>
</data>
<data name="InvalidColor" xml:space="preserve">
<value>Color '{0}' is not valid.</value>
</data>
<data name="TextParseFailedFormat" xml:space="preserve">
<value>Text "{0}" cannot be parsed. The expected text format is "{1}".</value>
</data>
<data name="PropertyValueInvalidEntry" xml:space="preserve">
<value>IDictionary parameter contains at least one entry that is not valid. Ensure all values are consistent with the object's properties.</value>
</data>
<data name="InvalidParameter" xml:space="preserve">
<value>Invalid value '{1}' for parameter '{0}'.</value>
</data>
<data name="TimerAutoReset" xml:space="preserve">
<value>Indicates whether the timer will be restarted when it is enabled.</value>
</data>
<data name="TimerEnabled" xml:space="preserve">
<value>Indicates whether the timer is enabled to fire events at a defined interval.</value>
</data>
<data name="TimerInterval" xml:space="preserve">
<value>The number of milliseconds between timer events.</value>
</data>
<data name="TimerIntervalElapsed" xml:space="preserve">
<value>Occurs when the Interval has elapsed.</value>
</data>
<data name="TimerInvalidInterval" xml:space="preserve">
<value>'{0}' is not a valid value for 'Interval'. 'Interval' must be greater than {1}.</value>
</data>
<data name="TimerSynchronizingObject" xml:space="preserve">
<value>The object used to marshal the event handler calls issued when an interval has elapsed.</value>
</data>
<data name="ToolboxItemAttributeFailedGetType" xml:space="preserve">
<value>Failed to create ToolboxItem of type: {0}</value>
</data>
<data name="PropertyTabAttributeBadPropertyTabScope" xml:space="preserve">
<value>Scope must be PropertyTabScope.Document or PropertyTabScope.Component</value>
</data>
<data name="PropertyTabAttributeTypeLoadException" xml:space="preserve">
<value>Couldn't find type {0}</value>
</data>
<data name="PropertyTabAttributeArrayLengthMismatch" xml:space="preserve">
<value>tabClasses must have the same number of items as tabScopes</value>
</data>
<data name="PropertyTabAttributeParamsBothNull" xml:space="preserve">
<value>An array of tab type names or tab types must be specified</value>
</data>
<data name="CultureInfoConverterDefaultCultureString" xml:space="preserve">
<value>(Default)</value>
</data>
<data name="CultureInfoConverterInvalidCulture" xml:space="preserve">
<value>The {0} culture cannot be converted to a CultureInfo object on this computer.</value>
</data>
<data name="ErrorInvalidServiceInstance" xml:space="preserve">
<value>The service instance must derive from or implement {0}.</value>
</data>
<data name="ErrorServiceExists" xml:space="preserve">
<value>The service {0} already exists in the service container.</value>
</data>
<data name="InvalidArgumentValue" xml:space="preserve">
<value>Value of '{0}' cannot be empty.</value>
</data>
<data name="InvalidNullArgument" xml:space="preserve">
<value>Null is not a valid value for {0}.</value>
</data>
<data name="DuplicateComponentName" xml:space="preserve">
<value>Duplicate component name '{0}'. Component names must be unique and case-insensitive.</value>
</data>
<data name="MaskedTextProviderPasswordAndPromptCharError" xml:space="preserve">
<value>The PasswordChar and PromptChar values cannot be the same.</value>
</data>
<data name="MaskedTextProviderInvalidCharError" xml:space="preserve">
<value>The specified character value is not allowed for this property.</value>
</data>
<data name="MaskedTextProviderMaskInvalidChar" xml:space="preserve">
<value>The specified mask contains invalid characters.</value>
</data>
<data name="InstanceDescriptorCannotBeStatic" xml:space="preserve">
<value>Parameter cannot be static.</value>
</data>
<data name="InstanceDescriptorMustBeStatic" xml:space="preserve">
<value>Parameter must be static.</value>
</data>
<data name="InstanceDescriptorMustBeReadable" xml:space="preserve">
<value>Parameter must be readable.</value>
</data>
<data name="InstanceDescriptorLengthMismatch" xml:space="preserve">
<value>Length mismatch.</value>
</data>
<data name="MetaExtenderName" xml:space="preserve">
<value>{0} on {1}</value>
</data>
<data name="CantModifyListSortDescriptionCollection" xml:space="preserve">
<value>Once a ListSortDescriptionCollection has been created it can't be modified.</value>
</data>
<data name="LicExceptionTypeOnly" xml:space="preserve">
<value>A valid license cannot be granted for the type {0}. Contact the manufacturer of the component for more information.</value>
</data>
<data name="LicExceptionTypeAndInstance" xml:space="preserve">
<value>An instance of type '{1}' was being created, and a valid license could not be granted for the type '{0}'. Please, contact the manufacturer of the component for more information.</value>
</data>
<data name="LicMgrContextCannotBeChanged" xml:space="preserve">
<value>The CurrentContext property of the LicenseManager is currently locked and cannot be changed.</value>
</data>
<data name="LicMgrAlreadyLocked" xml:space="preserve">
<value>The CurrentContext property of the LicenseManager is already locked by another user.</value>
</data>
<data name="LicMgrDifferentUser" xml:space="preserve">
<value>The CurrentContext property of the LicenseManager can only be unlocked with the same contextUser.</value>
</data>
<data name="CollectionConverterText" xml:space="preserve">
<value>(Collection)</value>
</data>
<data name="InstanceCreationEditorDefaultText" xml:space="preserve">
<value>(New...)</value>
</data>
<data name="ErrorPropertyAccessorException" xml:space="preserve">
<value>Property accessor '{0}' on object '{1}' threw the following exception:'{2}'</value>
</data>
<data name="CHECKOUTCanceled" xml:space="preserve">
<value>The checkout was canceled by the user.</value>
</data>
<data name="toStringNone" xml:space="preserve">
<value>(none)</value>
</data>
<data name="MemberRelationshipService_RelationshipNotSupported" xml:space="preserve">
<value>Relationships between {0}.{1} and {2}.{3} are not supported.</value>
</data>
<data name="BinaryFormatterMessage" xml:space="preserve">
<value>BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.</value>
</data>
</root>
| <?xml version="1.0" encoding="utf-8"?>
<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="Array" xml:space="preserve">
<value>{0} Array</value>
</data>
<data name="Collection" xml:space="preserve">
<value>(Collection)</value>
</data>
<data name="ConvertFromException" xml:space="preserve">
<value>{0} cannot convert from {1}.</value>
</data>
<data name="ConvertInvalidPrimitive" xml:space="preserve">
<value>{0} is not a valid value for {1}.</value>
</data>
<data name="ConvertToException" xml:space="preserve">
<value>'{0}' is unable to convert '{1}' to '{2}'.</value>
</data>
<data name="EnumConverterInvalidValue" xml:space="preserve">
<value>The value '{0}' is not a valid value for the enum '{1}'.</value>
</data>
<data name="ErrorInvalidEventHandler" xml:space="preserve">
<value>Invalid event handler for the {0} event.</value>
</data>
<data name="ErrorInvalidEventType" xml:space="preserve">
<value>Invalid type for the {0} event.</value>
</data>
<data name="ErrorInvalidPropertyType" xml:space="preserve">
<value>Invalid type for the {0} property</value>
</data>
<data name="ErrorMissingEventAccessors" xml:space="preserve">
<value>Accessor methods for the {0} event are missing.</value>
</data>
<data name="ErrorMissingPropertyAccessors" xml:space="preserve">
<value>Accessor methods for the {0} property are missing.</value>
</data>
<data name="InvalidMemberName" xml:space="preserve">
<value>Invalid member name</value>
</data>
<data name="none" xml:space="preserve">
<value>(none)</value>
</data>
<data name="Null" xml:space="preserve">
<value>(null)</value>
</data>
<data name="NullableConverterBadCtorArg" xml:space="preserve">
<value>The specified type is not a nullable type.</value>
</data>
<data name="Text" xml:space="preserve">
<value>(Text)</value>
</data>
<data name="TypeDescriptorAlreadyAssociated" xml:space="preserve">
<value>The primary and secondary objects are already associated with each other.</value>
</data>
<data name="TypeDescriptorArgsCountMismatch" xml:space="preserve">
<value>The number of elements in the Type and Object arrays must match.</value>
</data>
<data name="TypeDescriptorProviderError" xml:space="preserve">
<value>The type description provider {0} has returned null from {1} which is illegal.</value>
</data>
<data name="TypeDescriptorExpectedElementType" xml:space="preserve">
<value>Expected types in the collection to be of type {0}.</value>
</data>
<data name="TypeDescriptorSameAssociation" xml:space="preserve">
<value>Cannot create an association when the primary and secondary objects are the same.</value>
</data>
<data name="InvalidColor" xml:space="preserve">
<value>Color '{0}' is not valid.</value>
</data>
<data name="TextParseFailedFormat" xml:space="preserve">
<value>Text "{0}" cannot be parsed. The expected text format is "{1}".</value>
</data>
<data name="PropertyValueInvalidEntry" xml:space="preserve">
<value>IDictionary parameter contains at least one entry that is not valid. Ensure all values are consistent with the object's properties.</value>
</data>
<data name="InvalidParameter" xml:space="preserve">
<value>Invalid value '{1}' for parameter '{0}'.</value>
</data>
<data name="TimerAutoReset" xml:space="preserve">
<value>Indicates whether the timer will be restarted when it is enabled.</value>
</data>
<data name="TimerEnabled" xml:space="preserve">
<value>Indicates whether the timer is enabled to fire events at a defined interval.</value>
</data>
<data name="TimerInterval" xml:space="preserve">
<value>The number of milliseconds between timer events.</value>
</data>
<data name="TimerIntervalElapsed" xml:space="preserve">
<value>Occurs when the Interval has elapsed.</value>
</data>
<data name="TimerInvalidInterval" xml:space="preserve">
<value>'{0}' is not a valid value for 'Interval'. 'Interval' must be greater than {1}.</value>
</data>
<data name="TimerSynchronizingObject" xml:space="preserve">
<value>The object used to marshal the event handler calls issued when an interval has elapsed.</value>
</data>
<data name="ToolboxItemAttributeFailedGetType" xml:space="preserve">
<value>Failed to create ToolboxItem of type: {0}</value>
</data>
<data name="PropertyTabAttributeBadPropertyTabScope" xml:space="preserve">
<value>Scope must be PropertyTabScope.Document or PropertyTabScope.Component</value>
</data>
<data name="PropertyTabAttributeTypeLoadException" xml:space="preserve">
<value>Couldn't find type {0}</value>
</data>
<data name="PropertyTabAttributeArrayLengthMismatch" xml:space="preserve">
<value>tabClasses must have the same number of items as tabScopes</value>
</data>
<data name="PropertyTabAttributeParamsBothNull" xml:space="preserve">
<value>An array of tab type names or tab types must be specified</value>
</data>
<data name="CultureInfoConverterDefaultCultureString" xml:space="preserve">
<value>(Default)</value>
</data>
<data name="CultureInfoConverterInvalidCulture" xml:space="preserve">
<value>The {0} culture cannot be converted to a CultureInfo object on this computer.</value>
</data>
<data name="ErrorInvalidServiceInstance" xml:space="preserve">
<value>The service instance must derive from or implement {0}.</value>
</data>
<data name="ErrorServiceExists" xml:space="preserve">
<value>The service {0} already exists in the service container.</value>
</data>
<data name="InvalidArgumentValue" xml:space="preserve">
<value>Value of '{0}' cannot be empty.</value>
</data>
<data name="InvalidNullArgument" xml:space="preserve">
<value>Null is not a valid value for {0}.</value>
</data>
<data name="DuplicateComponentName" xml:space="preserve">
<value>Duplicate component name '{0}'. Component names must be unique and case-insensitive.</value>
</data>
<data name="MaskedTextProviderPasswordAndPromptCharError" xml:space="preserve">
<value>The PasswordChar and PromptChar values cannot be the same.</value>
</data>
<data name="MaskedTextProviderInvalidCharError" xml:space="preserve">
<value>The specified character value is not allowed for this property.</value>
</data>
<data name="MaskedTextProviderMaskInvalidChar" xml:space="preserve">
<value>The specified mask contains invalid characters.</value>
</data>
<data name="InstanceDescriptorCannotBeStatic" xml:space="preserve">
<value>Parameter cannot be static.</value>
</data>
<data name="InstanceDescriptorMustBeStatic" xml:space="preserve">
<value>Parameter must be static.</value>
</data>
<data name="InstanceDescriptorMustBeReadable" xml:space="preserve">
<value>Parameter must be readable.</value>
</data>
<data name="InstanceDescriptorLengthMismatch" xml:space="preserve">
<value>Length mismatch.</value>
</data>
<data name="MetaExtenderName" xml:space="preserve">
<value>{0} on {1}</value>
</data>
<data name="CantModifyListSortDescriptionCollection" xml:space="preserve">
<value>Once a ListSortDescriptionCollection has been created it can't be modified.</value>
</data>
<data name="LicExceptionTypeOnly" xml:space="preserve">
<value>A valid license cannot be granted for the type {0}. Contact the manufacturer of the component for more information.</value>
</data>
<data name="LicExceptionTypeAndInstance" xml:space="preserve">
<value>An instance of type '{1}' was being created, and a valid license could not be granted for the type '{0}'. Please, contact the manufacturer of the component for more information.</value>
</data>
<data name="LicMgrContextCannotBeChanged" xml:space="preserve">
<value>The CurrentContext property of the LicenseManager is currently locked and cannot be changed.</value>
</data>
<data name="LicMgrAlreadyLocked" xml:space="preserve">
<value>The CurrentContext property of the LicenseManager is already locked by another user.</value>
</data>
<data name="LicMgrDifferentUser" xml:space="preserve">
<value>The CurrentContext property of the LicenseManager can only be unlocked with the same contextUser.</value>
</data>
<data name="CollectionConverterText" xml:space="preserve">
<value>(Collection)</value>
</data>
<data name="InstanceCreationEditorDefaultText" xml:space="preserve">
<value>(New...)</value>
</data>
<data name="ErrorPropertyAccessorException" xml:space="preserve">
<value>Property accessor '{0}' on object '{1}' threw the following exception:'{2}'</value>
</data>
<data name="CHECKOUTCanceled" xml:space="preserve">
<value>The checkout was canceled by the user.</value>
</data>
<data name="toStringNone" xml:space="preserve">
<value>(none)</value>
</data>
<data name="MemberRelationshipService_RelationshipNotSupported" xml:space="preserve">
<value>Relationships between {0}.{1} and {2}.{3} are not supported.</value>
</data>
<data name="BinaryFormatterMessage" xml:space="preserve">
<value>BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.</value>
</data>
</root>
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Binary/JoinQueryOperator.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
//
// JoinQueryOperator.cs
//
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
namespace System.Linq.Parallel
{
/// <summary>
/// A join operator takes a left query tree and a right query tree, and then yields the
/// matching pairs between the two. LINQ supports equi-key-based joins. Hence, a key-
/// selection function for the left and right data types will yield keys of the same
/// type for both. We then merely have to match elements from the left with elements from
/// the right that have the same exact key. Note that this is an inner join. In other
/// words, outer elements with no matching inner elements do not appear in the output.
///
/// Hash-joins work in two phases:
///
/// (1) Building - we build a hash-table from one of the data sources. In the case
/// of this specific operator, the table is built from the hash-codes of
/// keys selected via the key selector function. Because elements may share
/// the same key, the table must support one-key-to-many-values.
/// (2) Probing - for each element in the data source not used for building, we
/// use its key to look into the hash-table. If we find elements under this
/// key, we just enumerate all of them, yielding them as join matches.
///
/// Because hash-tables exhibit on average O(1) lookup, we turn what would have been
/// an O(n*m) algorithm -- in the case of nested loops joins -- into an O(n) algorithm.
/// We of course require some additional storage to do so, but in general this pays.
/// </summary>
/// <typeparam name="TLeftInput"></typeparam>
/// <typeparam name="TRightInput"></typeparam>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TOutput"></typeparam>
internal sealed class JoinQueryOperator<TLeftInput, TRightInput, TKey, TOutput> : BinaryQueryOperator<TLeftInput, TRightInput, TOutput>
{
private readonly Func<TLeftInput, TKey> _leftKeySelector; // The key selection routine for the outer (left) data source.
private readonly Func<TRightInput, TKey> _rightKeySelector; // The key selection routine for the inner (right) data source.
private readonly Func<TLeftInput, TRightInput, TOutput> _resultSelector; // The result selection routine.
private readonly IEqualityComparer<TKey>? _keyComparer; // An optional key comparison object.
//---------------------------------------------------------------------------------------
// Constructs a new join operator.
//
internal JoinQueryOperator(ParallelQuery<TLeftInput> left, ParallelQuery<TRightInput> right,
Func<TLeftInput, TKey> leftKeySelector,
Func<TRightInput, TKey> rightKeySelector,
Func<TLeftInput, TRightInput, TOutput> resultSelector,
IEqualityComparer<TKey>? keyComparer)
: base(left, right)
{
Debug.Assert(left != null && right != null, "child data sources cannot be null");
Debug.Assert(leftKeySelector != null, "left key selector must not be null");
Debug.Assert(rightKeySelector != null, "right key selector must not be null");
Debug.Assert(resultSelector != null, "need a result selector function");
_leftKeySelector = leftKeySelector;
_rightKeySelector = rightKeySelector;
_resultSelector = resultSelector;
_keyComparer = keyComparer;
_outputOrdered = LeftChild.OutputOrdered;
SetOrdinalIndex(OrdinalIndexState.Shuffled);
}
public override void WrapPartitionedStream<TLeftKey, TRightKey>(
PartitionedStream<TLeftInput, TLeftKey> leftStream, PartitionedStream<TRightInput, TRightKey> rightStream,
IPartitionedStreamRecipient<TOutput> outputRecipient, bool preferStriping, QuerySettings settings)
{
Debug.Assert(rightStream.PartitionCount == leftStream.PartitionCount);
if (LeftChild.OutputOrdered)
{
if (ExchangeUtilities.IsWorseThan(LeftChild.OrdinalIndexState, OrdinalIndexState.Increasing))
{
PartitionedStream<TLeftInput, int> leftStreamInt =
QueryOperator<TLeftInput>.ExecuteAndCollectResults(leftStream, leftStream.PartitionCount, OutputOrdered, preferStriping, settings)
.GetPartitionedStream();
WrapPartitionedStreamHelper<int, TRightKey>(
ExchangeUtilities.HashRepartitionOrdered(leftStreamInt, _leftKeySelector, _keyComparer, null, settings.CancellationState.MergedCancellationToken),
rightStream, outputRecipient, settings.CancellationState.MergedCancellationToken);
}
else
{
WrapPartitionedStreamHelper<TLeftKey, TRightKey>(
ExchangeUtilities.HashRepartitionOrdered(leftStream, _leftKeySelector, _keyComparer, null, settings.CancellationState.MergedCancellationToken),
rightStream, outputRecipient, settings.CancellationState.MergedCancellationToken);
}
}
else
{
WrapPartitionedStreamHelper<int, TRightKey>(
ExchangeUtilities.HashRepartition(leftStream, _leftKeySelector, _keyComparer, null, settings.CancellationState.MergedCancellationToken),
rightStream, outputRecipient, settings.CancellationState.MergedCancellationToken);
}
}
//---------------------------------------------------------------------------------------
// This is a helper method. WrapPartitionedStream decides what type TLeftKey is going
// to be, and then call this method with that key as a generic parameter.
//
private void WrapPartitionedStreamHelper<TLeftKey, TRightKey>(
PartitionedStream<Pair<TLeftInput, TKey>, TLeftKey> leftHashStream, PartitionedStream<TRightInput, TRightKey> rightPartitionedStream,
IPartitionedStreamRecipient<TOutput> outputRecipient, CancellationToken cancellationToken)
{
if (RightChild.OutputOrdered && LeftChild.OutputOrdered)
{
PairOutputKeyBuilder<TLeftKey, TRightKey> outputKeyBuilder = new PairOutputKeyBuilder<TLeftKey, TRightKey>();
IComparer<Pair<TLeftKey, TRightKey>> outputKeyComparer =
new PairComparer<TLeftKey, TRightKey>(leftHashStream.KeyComparer, rightPartitionedStream.KeyComparer);
WrapPartitionedStreamHelper<TLeftKey, TRightKey, Pair<TLeftKey, TRightKey>>(leftHashStream,
ExchangeUtilities.HashRepartitionOrdered(rightPartitionedStream, _rightKeySelector, _keyComparer, null, cancellationToken),
outputKeyBuilder, outputKeyComparer, outputRecipient, cancellationToken);
}
else
{
LeftKeyOutputKeyBuilder<TLeftKey, int> outputKeyBuilder = new LeftKeyOutputKeyBuilder<TLeftKey, int>();
WrapPartitionedStreamHelper<TLeftKey, int, TLeftKey>(leftHashStream,
ExchangeUtilities.HashRepartition(rightPartitionedStream, _rightKeySelector, _keyComparer, null, cancellationToken),
outputKeyBuilder, leftHashStream.KeyComparer, outputRecipient, cancellationToken);
}
}
private void WrapPartitionedStreamHelper<TLeftKey, TRightKey, TOutputKey>(
PartitionedStream<Pair<TLeftInput, TKey>, TLeftKey> leftHashStream, PartitionedStream<Pair<TRightInput, TKey>, TRightKey> rightHashStream,
HashJoinOutputKeyBuilder<TLeftKey, TRightKey, TOutputKey> outputKeyBuilder, IComparer<TOutputKey> outputKeyComparer,
IPartitionedStreamRecipient<TOutput> outputRecipient, CancellationToken cancellationToken)
{
int partitionCount = leftHashStream.PartitionCount;
PartitionedStream<TOutput, TOutputKey> outputStream =
new PartitionedStream<TOutput, TOutputKey>(partitionCount, outputKeyComparer, OrdinalIndexState);
for (int i = 0; i < partitionCount; i++)
{
JoinHashLookupBuilder<TRightInput, TRightKey, TKey> rightLookupBuilder =
new JoinHashLookupBuilder<TRightInput, TRightKey, TKey>(rightHashStream[i], _keyComparer);
outputStream[i] = new HashJoinQueryOperatorEnumerator<TLeftInput, TLeftKey, TRightInput, TRightKey, TKey, TOutput, TOutputKey>(
leftHashStream[i], rightLookupBuilder, _resultSelector, outputKeyBuilder, cancellationToken);
}
outputRecipient.Receive(outputStream);
}
internal override QueryResults<TOutput> Open(QuerySettings settings, bool preferStriping)
{
QueryResults<TLeftInput> leftResults = LeftChild.Open(settings, false);
QueryResults<TRightInput> rightResults = RightChild.Open(settings, false);
return new BinaryQueryOperatorResults(leftResults, rightResults, this, settings, false);
}
//---------------------------------------------------------------------------------------
// Returns an enumerable that represents the query executing sequentially.
//
internal override IEnumerable<TOutput> AsSequentialQuery(CancellationToken token)
{
IEnumerable<TLeftInput> wrappedLeftChild = CancellableEnumerable.Wrap(LeftChild.AsSequentialQuery(token), token);
IEnumerable<TRightInput> wrappedRightChild = CancellableEnumerable.Wrap(RightChild.AsSequentialQuery(token), token);
return wrappedLeftChild.Join(
wrappedRightChild, _leftKeySelector, _rightKeySelector, _resultSelector, _keyComparer);
}
//---------------------------------------------------------------------------------------
// Whether this operator performs a premature merge that would not be performed in
// a similar sequential operation (i.e., in LINQ to Objects).
//
internal override bool LimitsParallelism
{
get { return false; }
}
}
/// <summary>
/// Class to build a HashJoinHashLookup of right elements for use in Join operations.
/// </summary>
/// <typeparam name="TElement"></typeparam>
/// <typeparam name="TOrderKey"></typeparam>
/// <typeparam name="THashKey"></typeparam>
internal sealed class JoinHashLookupBuilder<TElement, TOrderKey, THashKey> : HashLookupBuilder<TElement, TOrderKey, THashKey>
{
private readonly QueryOperatorEnumerator<Pair<TElement, THashKey>, TOrderKey> _dataSource; // data source. For building.
private readonly IEqualityComparer<THashKey>? _keyComparer; // An optional key comparison object.
internal JoinHashLookupBuilder(QueryOperatorEnumerator<Pair<TElement, THashKey>, TOrderKey> dataSource, IEqualityComparer<THashKey>? keyComparer)
{
Debug.Assert(dataSource != null);
_dataSource = dataSource;
_keyComparer = keyComparer;
}
public override HashJoinHashLookup<THashKey, TElement, TOrderKey> BuildHashLookup(CancellationToken cancellationToken)
{
HashLookup<THashKey, HashLookupValueList<TElement, TOrderKey>> lookup =
new HashLookup<THashKey, HashLookupValueList<TElement, TOrderKey>>(_keyComparer);
JoinBaseHashBuilder baseHashBuilder = new JoinBaseHashBuilder(lookup);
BuildBaseHashLookup(_dataSource, baseHashBuilder, cancellationToken);
return new JoinHashLookup(lookup);
}
protected override void Dispose(bool disposing)
{
Debug.Assert(_dataSource != null);
_dataSource.Dispose();
}
/// <summary>
/// Adds TElement,TOrderKey values to a HashLookup of HashLookupValueLists.
/// </summary>
private struct JoinBaseHashBuilder : IBaseHashBuilder<TElement, TOrderKey>
{
private readonly HashLookup<THashKey, HashLookupValueList<TElement, TOrderKey>> _base;
public JoinBaseHashBuilder(HashLookup<THashKey, HashLookupValueList<TElement, TOrderKey>> baseLookup)
{
Debug.Assert(baseLookup != null);
_base = baseLookup;
}
public bool Add(THashKey hashKey, TElement element, TOrderKey orderKey)
{
HashLookupValueList<TElement, TOrderKey> currentValue = default(HashLookupValueList<TElement, TOrderKey>);
if (!_base.TryGetValue(hashKey, ref currentValue))
{
currentValue = new HashLookupValueList<TElement, TOrderKey>(element, orderKey);
_base.Add(hashKey, currentValue);
return false;
}
else
{
if (currentValue.Add(element, orderKey))
{
// We need to re-store this element because the pair is a value type.
_base[hashKey] = currentValue;
}
return true;
}
}
}
/// <summary>
/// A wrapper for the HashLookup returned by JoinHashLookupBuilder.
///
/// Since Join operations do not require a default, this just passes the call on to the base lookup.
/// </summary>
private sealed class JoinHashLookup : HashJoinHashLookup<THashKey, TElement, TOrderKey>
{
private readonly HashLookup<THashKey, HashLookupValueList<TElement, TOrderKey>> _base;
internal JoinHashLookup(HashLookup<THashKey, HashLookupValueList<TElement, TOrderKey>> baseLookup)
{
Debug.Assert(baseLookup != null);
_base = baseLookup;
}
public override bool TryGetValue(THashKey key, ref HashLookupValueList<TElement, TOrderKey> value)
{
return _base.TryGetValue(key, ref value);
}
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
//
// JoinQueryOperator.cs
//
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
namespace System.Linq.Parallel
{
/// <summary>
/// A join operator takes a left query tree and a right query tree, and then yields the
/// matching pairs between the two. LINQ supports equi-key-based joins. Hence, a key-
/// selection function for the left and right data types will yield keys of the same
/// type for both. We then merely have to match elements from the left with elements from
/// the right that have the same exact key. Note that this is an inner join. In other
/// words, outer elements with no matching inner elements do not appear in the output.
///
/// Hash-joins work in two phases:
///
/// (1) Building - we build a hash-table from one of the data sources. In the case
/// of this specific operator, the table is built from the hash-codes of
/// keys selected via the key selector function. Because elements may share
/// the same key, the table must support one-key-to-many-values.
/// (2) Probing - for each element in the data source not used for building, we
/// use its key to look into the hash-table. If we find elements under this
/// key, we just enumerate all of them, yielding them as join matches.
///
/// Because hash-tables exhibit on average O(1) lookup, we turn what would have been
/// an O(n*m) algorithm -- in the case of nested loops joins -- into an O(n) algorithm.
/// We of course require some additional storage to do so, but in general this pays.
/// </summary>
/// <typeparam name="TLeftInput"></typeparam>
/// <typeparam name="TRightInput"></typeparam>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TOutput"></typeparam>
internal sealed class JoinQueryOperator<TLeftInput, TRightInput, TKey, TOutput> : BinaryQueryOperator<TLeftInput, TRightInput, TOutput>
{
private readonly Func<TLeftInput, TKey> _leftKeySelector; // The key selection routine for the outer (left) data source.
private readonly Func<TRightInput, TKey> _rightKeySelector; // The key selection routine for the inner (right) data source.
private readonly Func<TLeftInput, TRightInput, TOutput> _resultSelector; // The result selection routine.
private readonly IEqualityComparer<TKey>? _keyComparer; // An optional key comparison object.
//---------------------------------------------------------------------------------------
// Constructs a new join operator.
//
internal JoinQueryOperator(ParallelQuery<TLeftInput> left, ParallelQuery<TRightInput> right,
Func<TLeftInput, TKey> leftKeySelector,
Func<TRightInput, TKey> rightKeySelector,
Func<TLeftInput, TRightInput, TOutput> resultSelector,
IEqualityComparer<TKey>? keyComparer)
: base(left, right)
{
Debug.Assert(left != null && right != null, "child data sources cannot be null");
Debug.Assert(leftKeySelector != null, "left key selector must not be null");
Debug.Assert(rightKeySelector != null, "right key selector must not be null");
Debug.Assert(resultSelector != null, "need a result selector function");
_leftKeySelector = leftKeySelector;
_rightKeySelector = rightKeySelector;
_resultSelector = resultSelector;
_keyComparer = keyComparer;
_outputOrdered = LeftChild.OutputOrdered;
SetOrdinalIndex(OrdinalIndexState.Shuffled);
}
public override void WrapPartitionedStream<TLeftKey, TRightKey>(
PartitionedStream<TLeftInput, TLeftKey> leftStream, PartitionedStream<TRightInput, TRightKey> rightStream,
IPartitionedStreamRecipient<TOutput> outputRecipient, bool preferStriping, QuerySettings settings)
{
Debug.Assert(rightStream.PartitionCount == leftStream.PartitionCount);
if (LeftChild.OutputOrdered)
{
if (ExchangeUtilities.IsWorseThan(LeftChild.OrdinalIndexState, OrdinalIndexState.Increasing))
{
PartitionedStream<TLeftInput, int> leftStreamInt =
QueryOperator<TLeftInput>.ExecuteAndCollectResults(leftStream, leftStream.PartitionCount, OutputOrdered, preferStriping, settings)
.GetPartitionedStream();
WrapPartitionedStreamHelper<int, TRightKey>(
ExchangeUtilities.HashRepartitionOrdered(leftStreamInt, _leftKeySelector, _keyComparer, null, settings.CancellationState.MergedCancellationToken),
rightStream, outputRecipient, settings.CancellationState.MergedCancellationToken);
}
else
{
WrapPartitionedStreamHelper<TLeftKey, TRightKey>(
ExchangeUtilities.HashRepartitionOrdered(leftStream, _leftKeySelector, _keyComparer, null, settings.CancellationState.MergedCancellationToken),
rightStream, outputRecipient, settings.CancellationState.MergedCancellationToken);
}
}
else
{
WrapPartitionedStreamHelper<int, TRightKey>(
ExchangeUtilities.HashRepartition(leftStream, _leftKeySelector, _keyComparer, null, settings.CancellationState.MergedCancellationToken),
rightStream, outputRecipient, settings.CancellationState.MergedCancellationToken);
}
}
//---------------------------------------------------------------------------------------
// This is a helper method. WrapPartitionedStream decides what type TLeftKey is going
// to be, and then call this method with that key as a generic parameter.
//
private void WrapPartitionedStreamHelper<TLeftKey, TRightKey>(
PartitionedStream<Pair<TLeftInput, TKey>, TLeftKey> leftHashStream, PartitionedStream<TRightInput, TRightKey> rightPartitionedStream,
IPartitionedStreamRecipient<TOutput> outputRecipient, CancellationToken cancellationToken)
{
if (RightChild.OutputOrdered && LeftChild.OutputOrdered)
{
PairOutputKeyBuilder<TLeftKey, TRightKey> outputKeyBuilder = new PairOutputKeyBuilder<TLeftKey, TRightKey>();
IComparer<Pair<TLeftKey, TRightKey>> outputKeyComparer =
new PairComparer<TLeftKey, TRightKey>(leftHashStream.KeyComparer, rightPartitionedStream.KeyComparer);
WrapPartitionedStreamHelper<TLeftKey, TRightKey, Pair<TLeftKey, TRightKey>>(leftHashStream,
ExchangeUtilities.HashRepartitionOrdered(rightPartitionedStream, _rightKeySelector, _keyComparer, null, cancellationToken),
outputKeyBuilder, outputKeyComparer, outputRecipient, cancellationToken);
}
else
{
LeftKeyOutputKeyBuilder<TLeftKey, int> outputKeyBuilder = new LeftKeyOutputKeyBuilder<TLeftKey, int>();
WrapPartitionedStreamHelper<TLeftKey, int, TLeftKey>(leftHashStream,
ExchangeUtilities.HashRepartition(rightPartitionedStream, _rightKeySelector, _keyComparer, null, cancellationToken),
outputKeyBuilder, leftHashStream.KeyComparer, outputRecipient, cancellationToken);
}
}
private void WrapPartitionedStreamHelper<TLeftKey, TRightKey, TOutputKey>(
PartitionedStream<Pair<TLeftInput, TKey>, TLeftKey> leftHashStream, PartitionedStream<Pair<TRightInput, TKey>, TRightKey> rightHashStream,
HashJoinOutputKeyBuilder<TLeftKey, TRightKey, TOutputKey> outputKeyBuilder, IComparer<TOutputKey> outputKeyComparer,
IPartitionedStreamRecipient<TOutput> outputRecipient, CancellationToken cancellationToken)
{
int partitionCount = leftHashStream.PartitionCount;
PartitionedStream<TOutput, TOutputKey> outputStream =
new PartitionedStream<TOutput, TOutputKey>(partitionCount, outputKeyComparer, OrdinalIndexState);
for (int i = 0; i < partitionCount; i++)
{
JoinHashLookupBuilder<TRightInput, TRightKey, TKey> rightLookupBuilder =
new JoinHashLookupBuilder<TRightInput, TRightKey, TKey>(rightHashStream[i], _keyComparer);
outputStream[i] = new HashJoinQueryOperatorEnumerator<TLeftInput, TLeftKey, TRightInput, TRightKey, TKey, TOutput, TOutputKey>(
leftHashStream[i], rightLookupBuilder, _resultSelector, outputKeyBuilder, cancellationToken);
}
outputRecipient.Receive(outputStream);
}
internal override QueryResults<TOutput> Open(QuerySettings settings, bool preferStriping)
{
QueryResults<TLeftInput> leftResults = LeftChild.Open(settings, false);
QueryResults<TRightInput> rightResults = RightChild.Open(settings, false);
return new BinaryQueryOperatorResults(leftResults, rightResults, this, settings, false);
}
//---------------------------------------------------------------------------------------
// Returns an enumerable that represents the query executing sequentially.
//
internal override IEnumerable<TOutput> AsSequentialQuery(CancellationToken token)
{
IEnumerable<TLeftInput> wrappedLeftChild = CancellableEnumerable.Wrap(LeftChild.AsSequentialQuery(token), token);
IEnumerable<TRightInput> wrappedRightChild = CancellableEnumerable.Wrap(RightChild.AsSequentialQuery(token), token);
return wrappedLeftChild.Join(
wrappedRightChild, _leftKeySelector, _rightKeySelector, _resultSelector, _keyComparer);
}
//---------------------------------------------------------------------------------------
// Whether this operator performs a premature merge that would not be performed in
// a similar sequential operation (i.e., in LINQ to Objects).
//
internal override bool LimitsParallelism
{
get { return false; }
}
}
/// <summary>
/// Class to build a HashJoinHashLookup of right elements for use in Join operations.
/// </summary>
/// <typeparam name="TElement"></typeparam>
/// <typeparam name="TOrderKey"></typeparam>
/// <typeparam name="THashKey"></typeparam>
internal sealed class JoinHashLookupBuilder<TElement, TOrderKey, THashKey> : HashLookupBuilder<TElement, TOrderKey, THashKey>
{
private readonly QueryOperatorEnumerator<Pair<TElement, THashKey>, TOrderKey> _dataSource; // data source. For building.
private readonly IEqualityComparer<THashKey>? _keyComparer; // An optional key comparison object.
internal JoinHashLookupBuilder(QueryOperatorEnumerator<Pair<TElement, THashKey>, TOrderKey> dataSource, IEqualityComparer<THashKey>? keyComparer)
{
Debug.Assert(dataSource != null);
_dataSource = dataSource;
_keyComparer = keyComparer;
}
public override HashJoinHashLookup<THashKey, TElement, TOrderKey> BuildHashLookup(CancellationToken cancellationToken)
{
HashLookup<THashKey, HashLookupValueList<TElement, TOrderKey>> lookup =
new HashLookup<THashKey, HashLookupValueList<TElement, TOrderKey>>(_keyComparer);
JoinBaseHashBuilder baseHashBuilder = new JoinBaseHashBuilder(lookup);
BuildBaseHashLookup(_dataSource, baseHashBuilder, cancellationToken);
return new JoinHashLookup(lookup);
}
protected override void Dispose(bool disposing)
{
Debug.Assert(_dataSource != null);
_dataSource.Dispose();
}
/// <summary>
/// Adds TElement,TOrderKey values to a HashLookup of HashLookupValueLists.
/// </summary>
private struct JoinBaseHashBuilder : IBaseHashBuilder<TElement, TOrderKey>
{
private readonly HashLookup<THashKey, HashLookupValueList<TElement, TOrderKey>> _base;
public JoinBaseHashBuilder(HashLookup<THashKey, HashLookupValueList<TElement, TOrderKey>> baseLookup)
{
Debug.Assert(baseLookup != null);
_base = baseLookup;
}
public bool Add(THashKey hashKey, TElement element, TOrderKey orderKey)
{
HashLookupValueList<TElement, TOrderKey> currentValue = default(HashLookupValueList<TElement, TOrderKey>);
if (!_base.TryGetValue(hashKey, ref currentValue))
{
currentValue = new HashLookupValueList<TElement, TOrderKey>(element, orderKey);
_base.Add(hashKey, currentValue);
return false;
}
else
{
if (currentValue.Add(element, orderKey))
{
// We need to re-store this element because the pair is a value type.
_base[hashKey] = currentValue;
}
return true;
}
}
}
/// <summary>
/// A wrapper for the HashLookup returned by JoinHashLookupBuilder.
///
/// Since Join operations do not require a default, this just passes the call on to the base lookup.
/// </summary>
private sealed class JoinHashLookup : HashJoinHashLookup<THashKey, TElement, TOrderKey>
{
private readonly HashLookup<THashKey, HashLookupValueList<TElement, TOrderKey>> _base;
internal JoinHashLookup(HashLookup<THashKey, HashLookupValueList<TElement, TOrderKey>> baseLookup)
{
Debug.Assert(baseLookup != null);
_base = baseLookup;
}
public override bool TryGetValue(THashKey key, ref HashLookupValueList<TElement, TOrderKey> value)
{
return _base.TryGetValue(key, ref value);
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/opt/Inline/tests/UnsafeBlockCopy.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;
class Test_UnsafeBlockCopy
{
static int SIZE = 100;
public static unsafe int Main()
{
byte* source = stackalloc byte[SIZE];
byte* dest = stackalloc byte[SIZE];
for (int i = 0; i < SIZE; i++)
{
source[i] = (byte)(i % 255);
dest[i] = 0;
}
Unsafe.CopyBlock(dest, source, (uint) SIZE);
bool result = true;
for (int i = 0; i < SIZE; i++)
{
result &= (source[i] == dest[i]);
}
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;
class Test_UnsafeBlockCopy
{
static int SIZE = 100;
public static unsafe int Main()
{
byte* source = stackalloc byte[SIZE];
byte* dest = stackalloc byte[SIZE];
for (int i = 0; i < SIZE; i++)
{
source[i] = (byte)(i % 255);
dest[i] = 0;
}
Unsafe.CopyBlock(dest, source, (uint) SIZE);
bool result = true;
for (int i = 0; i < SIZE; i++)
{
result &= (source[i] == dest[i]);
}
return (result ? 100 : -1);
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/UnaryExpression.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 System.Dynamic.Utils;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace System.Linq.Expressions
{
/// <summary>
/// Represents an expression that has a unary operator.
/// </summary>
[DebuggerTypeProxy(typeof(UnaryExpressionProxy))]
public sealed class UnaryExpression : Expression
{
internal UnaryExpression(ExpressionType nodeType, Expression expression, Type type, MethodInfo? method)
{
Operand = expression;
Method = method;
NodeType = nodeType;
Type = type;
}
/// <summary>
/// Gets the static type of the expression that this <see cref="Expression"/> represents. (Inherited from <see cref="Expression"/>.)
/// </summary>
/// <returns>The <see cref="System.Type"/> that represents the static type of the expression.</returns>
public sealed override Type Type { get; }
/// <summary>
/// Returns the node type of this <see cref="Expression"/>. (Inherited from <see cref="Expression"/>.)
/// </summary>
/// <returns>The <see cref="ExpressionType"/> that represents this expression.</returns>
public sealed override ExpressionType NodeType { get; }
/// <summary>
/// Gets the operand of the unary operation.
/// </summary>
/// <returns> An <see cref="Expression"/> that represents the operand of the unary operation. Returns null if node type is <see cref="ExpressionType.Throw"/> with no operand.</returns>
public Expression Operand { get; }
/// <summary>
/// Gets the implementing method for the unary operation.
/// </summary>
/// <returns>The <see cref="MethodInfo"/> that represents the implementing method.</returns>
public MethodInfo? Method { get; }
/// <summary>
/// Gets a value that indicates whether the expression tree node represents a lifted call to an operator.
/// </summary>
/// <returns>true if the node represents a lifted call; otherwise, false.</returns>
public bool IsLifted
{
get
{
if (NodeType == ExpressionType.TypeAs || NodeType == ExpressionType.Quote || NodeType == ExpressionType.Throw)
{
return false;
}
bool operandIsNullable = Operand.Type.IsNullableType();
bool resultIsNullable = this.Type.IsNullableType();
if (Method != null)
{
return (operandIsNullable && !TypeUtils.AreEquivalent(Method.GetParametersCached()[0].ParameterType, Operand.Type)) ||
(resultIsNullable && !TypeUtils.AreEquivalent(Method.ReturnType, this.Type));
}
return operandIsNullable || resultIsNullable;
}
}
/// <summary>
/// Gets a value that indicates whether the expression tree node represents a lifted call to an operator whose return type is lifted to a nullable type.
/// </summary>
/// <returns>true if the operator's return type is lifted to a nullable type; otherwise, false.</returns>
public bool IsLiftedToNull => IsLifted && this.Type.IsNullableType();
/// <summary>
/// Dispatches to the specific visit method for this node type.
/// </summary>
protected internal override Expression Accept(ExpressionVisitor visitor)
{
return visitor.VisitUnary(this);
}
/// <summary>
/// Gets a value that indicates whether the expression tree node can be reduced.
/// </summary>
public override bool CanReduce
{
get
{
switch (NodeType)
{
case ExpressionType.PreIncrementAssign:
case ExpressionType.PreDecrementAssign:
case ExpressionType.PostIncrementAssign:
case ExpressionType.PostDecrementAssign:
return true;
}
return false;
}
}
/// <summary>
/// Reduces the expression node to a simpler expression.
/// If CanReduce returns true, this should return a valid expression.
/// This method is allowed to return another node which itself
/// must be reduced.
/// </summary>
/// <returns>The reduced expression.</returns>
public override Expression Reduce()
{
if (CanReduce)
{
switch (Operand.NodeType)
{
case ExpressionType.Index:
return ReduceIndex();
case ExpressionType.MemberAccess:
return ReduceMember();
default:
Debug.Assert(Operand.NodeType == ExpressionType.Parameter);
return ReduceVariable();
}
}
return this;
}
private bool IsPrefix
{
get { return NodeType == ExpressionType.PreIncrementAssign || NodeType == ExpressionType.PreDecrementAssign; }
}
private UnaryExpression FunctionalOp(Expression operand)
{
ExpressionType functional;
if (NodeType == ExpressionType.PreIncrementAssign || NodeType == ExpressionType.PostIncrementAssign)
{
functional = ExpressionType.Increment;
}
else
{
Debug.Assert(NodeType == ExpressionType.PreDecrementAssign || NodeType == ExpressionType.PostDecrementAssign);
functional = ExpressionType.Decrement;
}
return new UnaryExpression(functional, operand, operand.Type, Method);
}
private Expression ReduceVariable()
{
if (IsPrefix)
{
// (op) var
// ... is reduced into ...
// var = op(var)
return Assign(Operand, FunctionalOp(Operand));
}
// var (op)
// ... is reduced into ...
// temp = var
// var = op(var)
// temp
ParameterExpression temp = Parameter(Operand.Type, name: null);
return Block(
new TrueReadOnlyCollection<ParameterExpression>(temp),
new TrueReadOnlyCollection<Expression>(
Assign(temp, Operand),
Assign(Operand, FunctionalOp(temp)),
temp
)
);
}
private Expression ReduceMember()
{
var member = (MemberExpression)Operand;
if (member.Expression == null)
{
//static member, reduce the same as variable
return ReduceVariable();
}
else
{
ParameterExpression temp1 = Parameter(member.Expression.Type, name: null);
BinaryExpression initTemp1 = Assign(temp1, member.Expression);
member = MakeMemberAccess(temp1, member.Member);
if (IsPrefix)
{
// (op) value.member
// ... is reduced into ...
// temp1 = value
// temp1.member = op(temp1.member)
return Block(
new TrueReadOnlyCollection<ParameterExpression>(temp1),
new TrueReadOnlyCollection<Expression>(
initTemp1,
Assign(member, FunctionalOp(member))
)
);
}
// value.member (op)
// ... is reduced into ...
// temp1 = value
// temp2 = temp1.member
// temp1.member = op(temp2)
// temp2
ParameterExpression temp2 = Parameter(member.Type, name: null);
return Block(
new TrueReadOnlyCollection<ParameterExpression>(temp1, temp2),
new TrueReadOnlyCollection<Expression>(
initTemp1,
Assign(temp2, member),
Assign(member, FunctionalOp(temp2)),
temp2
)
);
}
}
private Expression ReduceIndex()
{
// left[a0, a1, ... aN] (op)
//
// ... is reduced into ...
//
// tempObj = left
// tempArg0 = a0
// ...
// tempArgN = aN
// tempValue = tempObj[tempArg0, ... tempArgN]
// tempObj[tempArg0, ... tempArgN] = op(tempValue)
// tempValue
bool prefix = IsPrefix;
var index = (IndexExpression)Operand;
int count = index.ArgumentCount;
var block = new Expression[count + (prefix ? 2 : 4)];
var temps = new ParameterExpression[count + (prefix ? 1 : 2)];
var args = new ParameterExpression[count];
int i = 0;
temps[i] = Parameter(index.Object!.Type, name: null);
block[i] = Assign(temps[i], index.Object);
i++;
while (i <= count)
{
Expression arg = index.GetArgument(i - 1);
args[i - 1] = temps[i] = Parameter(arg.Type, name: null);
block[i] = Assign(temps[i], arg);
i++;
}
index = MakeIndex(temps[0], index.Indexer, new TrueReadOnlyCollection<Expression>(args));
if (!prefix)
{
ParameterExpression lastTemp = temps[i] = Parameter(index.Type, name: null);
block[i] = Assign(temps[i], index);
i++;
Debug.Assert(i == temps.Length);
block[i++] = Assign(index, FunctionalOp(lastTemp));
block[i++] = lastTemp;
}
else
{
Debug.Assert(i == temps.Length);
block[i++] = Assign(index, FunctionalOp(index));
}
Debug.Assert(i == block.Length);
return Block(new TrueReadOnlyCollection<ParameterExpression>(temps), new TrueReadOnlyCollection<Expression>(block));
}
/// <summary>
/// Creates a new expression that is like this one, but using the
/// supplied children. If all of the children are the same, it will
/// return this expression.
/// </summary>
/// <param name="operand">The <see cref="Operand"/> property of the result.</param>
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
public UnaryExpression Update(Expression operand)
{
if (operand == Operand)
{
return this;
}
return Expression.MakeUnary(NodeType, operand, Type, Method);
}
}
public partial class Expression
{
/// <summary>
/// Creates a <see cref="UnaryExpression"/>, given an operand, by calling the appropriate factory method.
/// </summary>
/// <param name="unaryType">The <see cref="ExpressionType"/> that specifies the type of unary operation.</param>
/// <param name="operand">An <see cref="Expression"/> that represents the operand.</param>
/// <param name="type">The <see cref="Type"/> that specifies the type to be converted to (pass null if not applicable).</param>
/// <returns>The <see cref="UnaryExpression"/> that results from calling the appropriate factory method.</returns>
/// <exception cref="ArgumentException">Thrown when <paramref name="unaryType"/> does not correspond to a unary expression.</exception>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="operand"/> is null.</exception>
public static UnaryExpression MakeUnary(ExpressionType unaryType, Expression operand, Type type)
{
return MakeUnary(unaryType, operand, type, method: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/>, given an operand and implementing method, by calling the appropriate factory method.
/// </summary>
/// <param name="unaryType">The <see cref="ExpressionType"/> that specifies the type of unary operation.</param>
/// <param name="operand">An <see cref="Expression"/> that represents the operand.</param>
/// <param name="type">The <see cref="Type"/> that specifies the type to be converted to (pass null if not applicable).</param>
/// <param name="method">The <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>The <see cref="UnaryExpression"/> that results from calling the appropriate factory method.</returns>
/// <exception cref="ArgumentException">Thrown when <paramref name="unaryType"/> does not correspond to a unary expression.</exception>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="operand"/> is null.</exception>
public static UnaryExpression MakeUnary(ExpressionType unaryType, Expression operand, Type type, MethodInfo? method) =>
unaryType switch
{
ExpressionType.Negate => Negate(operand, method),
ExpressionType.NegateChecked => NegateChecked(operand, method),
ExpressionType.Not => Not(operand, method),
ExpressionType.IsFalse => IsFalse(operand, method),
ExpressionType.IsTrue => IsTrue(operand, method),
ExpressionType.OnesComplement => OnesComplement(operand, method),
ExpressionType.ArrayLength => ArrayLength(operand),
ExpressionType.Convert => Convert(operand, type, method),
ExpressionType.ConvertChecked => ConvertChecked(operand, type, method),
ExpressionType.Throw => Throw(operand, type),
ExpressionType.TypeAs => TypeAs(operand, type),
ExpressionType.Quote => Quote(operand),
ExpressionType.UnaryPlus => UnaryPlus(operand, method),
ExpressionType.Unbox => Unbox(operand, type),
ExpressionType.Increment => Increment(operand, method),
ExpressionType.Decrement => Decrement(operand, method),
ExpressionType.PreIncrementAssign => PreIncrementAssign(operand, method),
ExpressionType.PostIncrementAssign => PostIncrementAssign(operand, method),
ExpressionType.PreDecrementAssign => PreDecrementAssign(operand, method),
ExpressionType.PostDecrementAssign => PostDecrementAssign(operand, method),
_ => throw Error.UnhandledUnary(unaryType, nameof(unaryType)),
};
private static UnaryExpression GetUserDefinedUnaryOperatorOrThrow(ExpressionType unaryType, string name, Expression operand)
{
UnaryExpression? u = GetUserDefinedUnaryOperator(unaryType, name, operand);
if (u != null)
{
ValidateParamswithOperandsOrThrow(u.Method!.GetParametersCached()[0].ParameterType, operand.Type, unaryType, name);
return u;
}
throw Error.UnaryOperatorNotDefined(unaryType, operand.Type);
}
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2072:UnrecognizedReflectionPattern",
Justification = "The trimmer doesn't remove operators when System.Linq.Expressions is used. See https://github.com/mono/linker/pull/2125.")]
private static UnaryExpression? GetUserDefinedUnaryOperator(ExpressionType unaryType, string name, Expression operand)
{
Type operandType = operand.Type;
Type[] types = new Type[] { operandType };
Type nnOperandType = operandType.GetNonNullableType();
MethodInfo? method = nnOperandType.GetAnyStaticMethodValidated(name, types);
if (method != null)
{
return new UnaryExpression(unaryType, operand, method.ReturnType, method);
}
// try lifted call
if (operandType.IsNullableType())
{
types[0] = nnOperandType;
method = nnOperandType.GetAnyStaticMethodValidated(name, types);
if (method != null && method.ReturnType.IsValueType && !method.ReturnType.IsNullableType())
{
return new UnaryExpression(unaryType, operand, method.ReturnType.GetNullableType(), method);
}
}
return null;
}
private static UnaryExpression GetMethodBasedUnaryOperator(ExpressionType unaryType, Expression operand, MethodInfo method)
{
Debug.Assert(method != null);
ValidateOperator(method);
ParameterInfo[] pms = method.GetParametersCached();
if (pms.Length != 1)
throw Error.IncorrectNumberOfMethodCallArguments(method, nameof(method));
if (ParameterIsAssignable(pms[0], operand.Type))
{
ValidateParamswithOperandsOrThrow(pms[0].ParameterType, operand.Type, unaryType, method.Name);
return new UnaryExpression(unaryType, operand, method.ReturnType, method);
}
// check for lifted call
if (operand.Type.IsNullableType() &&
ParameterIsAssignable(pms[0], operand.Type.GetNonNullableType()) &&
method.ReturnType.IsValueType && !method.ReturnType.IsNullableType())
{
return new UnaryExpression(unaryType, operand, method.ReturnType.GetNullableType(), method);
}
throw Error.OperandTypesDoNotMatchParameters(unaryType, method.Name);
}
private static UnaryExpression GetUserDefinedCoercionOrThrow(ExpressionType coercionType, Expression expression, Type convertToType)
{
UnaryExpression? u = GetUserDefinedCoercion(coercionType, expression, convertToType);
if (u != null)
{
return u;
}
throw Error.CoercionOperatorNotDefined(expression.Type, convertToType);
}
private static UnaryExpression? GetUserDefinedCoercion(ExpressionType coercionType, Expression expression, Type convertToType)
{
MethodInfo? method = TypeUtils.GetUserDefinedCoercionMethod(expression.Type, convertToType);
if (method != null)
{
return new UnaryExpression(coercionType, expression, convertToType, method);
}
else
{
return null;
}
}
private static UnaryExpression GetMethodBasedCoercionOperator(ExpressionType unaryType, Expression operand, Type convertToType, MethodInfo method)
{
Debug.Assert(method != null);
ValidateOperator(method);
ParameterInfo[] pms = method.GetParametersCached();
if (pms.Length != 1)
{
throw Error.IncorrectNumberOfMethodCallArguments(method, nameof(method));
}
if (ParameterIsAssignable(pms[0], operand.Type) && TypeUtils.AreEquivalent(method.ReturnType, convertToType))
{
return new UnaryExpression(unaryType, operand, method.ReturnType, method);
}
// check for lifted call
if ((operand.Type.IsNullableType() || convertToType.IsNullableType()) &&
ParameterIsAssignable(pms[0], operand.Type.GetNonNullableType()) &&
(TypeUtils.AreEquivalent(method.ReturnType, convertToType.GetNonNullableType()) ||
TypeUtils.AreEquivalent(method.ReturnType, convertToType)))
{
return new UnaryExpression(unaryType, operand, convertToType, method);
}
throw Error.OperandTypesDoNotMatchParameters(unaryType, method.Name);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents an arithmetic negation operation.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.Negate"/> and the <see cref="UnaryExpression.Operand"/> properties set to the specified value.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="expression"/> is null.</exception>
/// <exception cref="InvalidOperationException">Thrown when the unary minus operator is not defined for <paramref name="expression"/>.Type.</exception>
public static UnaryExpression Negate(Expression expression)
{
return Negate(expression, method: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents an arithmetic negation operation.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <param name="method">A <see cref="MethodInfo"/> to set the <see cref="UnaryExpression.Method"/> property equal to.</param>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.Negate"/> and the <see cref="UnaryExpression.Operand"/> and <see cref="UnaryExpression.Method"/> properties set to the specified value.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="expression"/> is null.</exception>
/// <exception cref="ArgumentException">Thrown when <paramref name="method"/> is not null and the method it represents returns void, is not static (Shared in Visual Basic), or does not take exactly one argument.</exception>
/// <exception cref="InvalidOperationException">Thrown when <paramref name="method"/> is null and the unary minus operator is not defined for <paramref name="expression"/>.Type (or its corresponding non-nullable type if it is a nullable value type) is not assignable to the argument type of the method represented by method.</exception>
public static UnaryExpression Negate(Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsArithmetic() && !expression.Type.IsUnsignedInt())
{
return new UnaryExpression(ExpressionType.Negate, expression, expression.Type, null);
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.Negate, "op_UnaryNegation", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.Negate, expression, method);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents a unary plus operation.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.UnaryPlus"/> and the <see cref="UnaryExpression.Operand"/> property set to the specified value.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="expression"/> is null.</exception>
/// <exception cref="InvalidOperationException">Thrown when the unary minus operator is not defined for <paramref name="expression"/>.Type.</exception>
public static UnaryExpression UnaryPlus(Expression expression)
{
return UnaryPlus(expression, method: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents a unary plus operation.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <param name="method">A <see cref="MethodInfo"/> to set the <see cref="UnaryExpression.Method"/> property equal to.</param>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.UnaryPlus"/> and the <see cref="UnaryExpression.Operand"/> and <see cref="UnaryExpression.Method"/>property set to the specified value.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="expression"/> is null.</exception>
/// <exception cref="ArgumentException">Thrown when <paramref name="method"/> is not null and the method it represents returns void, is not static (Shared in Visual Basic), or does not take exactly one argument.</exception>
/// <exception cref="InvalidOperationException">Thrown when <paramref name="method"/> is null and the unary minus operator is not defined for <paramref name="expression"/>.Type (or its corresponding non-nullable type if it is a nullable value type) is not assignable to the argument type of the method represented by method.</exception>
public static UnaryExpression UnaryPlus(Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsArithmetic())
{
return new UnaryExpression(ExpressionType.UnaryPlus, expression, expression.Type, null);
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.UnaryPlus, "op_UnaryPlus", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.UnaryPlus, expression, method);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents an arithmetic negation operation that has overflow checking.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.NegateChecked"/> and the <see cref="UnaryExpression.Operand"/> property set to the specified value.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="expression"/> is null.</exception>
/// <exception cref="InvalidOperationException">Thrown when the unary minus operator is not defined for <paramref name="expression"/>.Type.</exception>
public static UnaryExpression NegateChecked(Expression expression)
{
return NegateChecked(expression, method: null);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents an arithmetic negation operation that has overflow checking. The implementing method can be specified.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.NegateChecked"/> and the <see cref="UnaryExpression.Operand"/> and <see cref="UnaryExpression.Method"/> properties set to the specified values.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <param name="method">A <see cref="MethodInfo"/> to set the <see cref="UnaryExpression.Method"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> is null.</exception>
/// <exception cref="ArgumentException">
/// <paramref name="method"/> is not null and the method it represents returns void, is not static (Shared in Visual Basic), or does not take exactly one argument.</exception>
/// <exception cref="InvalidOperationException">
/// <paramref name="method"/> is null and the unary minus operator is not defined for <paramref name="expression"/>.Type.-or-<paramref name="expression"/>.Type (or its corresponding non-nullable type if it is a nullable value type) is not assignable to the argument type of the method represented by <paramref name="method"/>.</exception>
public static UnaryExpression NegateChecked(Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsArithmetic() && !expression.Type.IsUnsignedInt())
{
return new UnaryExpression(ExpressionType.NegateChecked, expression, expression.Type, null);
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.NegateChecked, "op_UnaryNegation", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.NegateChecked, expression, method);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents a bitwise complement operation.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.Not"/> and the <see cref="UnaryExpression.Operand"/> property set to the specified value.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> is null.</exception>
/// <exception cref="InvalidOperationException">The unary not operator is not defined for <paramref name="expression"/>.Type.</exception>
public static UnaryExpression Not(Expression expression)
{
return Not(expression, method: null);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents a bitwise complement operation. The implementing method can be specified.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.Not"/> and the <see cref="UnaryExpression.Operand"/> and <see cref="UnaryExpression.Method"/> properties set to the specified values.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <param name="method">A <see cref="MethodInfo"/> to set the <see cref="UnaryExpression.Method"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> is null.</exception>
/// <exception cref="ArgumentException">
/// <paramref name="method"/> is not null and the method it represents returns void, is not static (Shared in Visual Basic), or does not take exactly one argument.</exception>
/// <exception cref="InvalidOperationException">
/// <paramref name="method"/> is null and the unary not operator is not defined for <paramref name="expression"/>.Type.-or-<paramref name="expression"/>.Type (or its corresponding non-nullable type if it is a nullable value type) is not assignable to the argument type of the method represented by <paramref name="method"/>.</exception>
public static UnaryExpression Not(Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsIntegerOrBool())
{
return new UnaryExpression(ExpressionType.Not, expression, expression.Type, null);
}
UnaryExpression? u = GetUserDefinedUnaryOperator(ExpressionType.Not, "op_LogicalNot", expression);
if (u != null)
{
return u;
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.Not, "op_OnesComplement", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.Not, expression, method);
}
/// <summary>
/// Returns whether the expression evaluates to false.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to evaluate.</param>
/// <returns>An instance of <see cref="UnaryExpression"/>.</returns>
public static UnaryExpression IsFalse(Expression expression)
{
return IsFalse(expression, method: null);
}
/// <summary>
/// Returns whether the expression evaluates to false.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to evaluate.</param>
/// <param name="method">A <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>An instance of <see cref="UnaryExpression"/>.</returns>
public static UnaryExpression IsFalse(Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsBool())
{
return new UnaryExpression(ExpressionType.IsFalse, expression, expression.Type, null);
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.IsFalse, "op_False", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.IsFalse, expression, method);
}
/// <summary>
/// Returns whether the expression evaluates to true.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to evaluate.</param>
/// <returns>An instance of <see cref="UnaryExpression"/>.</returns>
public static UnaryExpression IsTrue(Expression expression)
{
return IsTrue(expression, method: null);
}
/// <summary>
/// Returns whether the expression evaluates to true.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to evaluate.</param>
/// <param name="method">A <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>An instance of <see cref="UnaryExpression"/>.</returns>
public static UnaryExpression IsTrue(Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsBool())
{
return new UnaryExpression(ExpressionType.IsTrue, expression, expression.Type, null);
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.IsTrue, "op_True", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.IsTrue, expression, method);
}
/// <summary>
/// Returns the expression representing the ones complement.
/// </summary>
/// <param name="expression">An <see cref="Expression"/>.</param>
/// <returns>An instance of <see cref="UnaryExpression"/>.</returns>
public static UnaryExpression OnesComplement(Expression expression)
{
return OnesComplement(expression, method: null);
}
/// <summary>
/// Returns the expression representing the ones complement.
/// </summary>
/// <param name="expression">An <see cref="Expression"/>.</param>
/// <param name="method">A <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>An instance of <see cref="UnaryExpression"/>.</returns>
public static UnaryExpression OnesComplement(Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsInteger())
{
return new UnaryExpression(ExpressionType.OnesComplement, expression, expression.Type, null);
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.OnesComplement, "op_OnesComplement", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.OnesComplement, expression, method);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents an explicit reference or boxing conversion where null is supplied if the conversion fails.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.TypeAs"/> and the <see cref="UnaryExpression.Operand"/> and <see cref="Expression.Type"/> properties set to the specified values.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="Type"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> or <paramref name="type"/> is null.</exception>
public static UnaryExpression TypeAs(Expression expression, Type type)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
ContractUtils.RequiresNotNull(type, nameof(type));
TypeUtils.ValidateType(type, nameof(type));
if (type.IsValueType && !type.IsNullableType())
{
throw Error.IncorrectTypeForTypeAs(type, nameof(type));
}
return new UnaryExpression(ExpressionType.TypeAs, expression, type, null);
}
/// <summary>
/// <summary>Creates a <see cref="UnaryExpression"/> that represents an explicit unboxing.</summary>
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to unbox.</param>
/// <param name="type">The new <see cref="System.Type"/> of the expression.</param>
/// <returns>An instance of <see cref="UnaryExpression"/>.</returns>
public static UnaryExpression Unbox(Expression expression, Type type)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
ContractUtils.RequiresNotNull(type, nameof(type));
if (!expression.Type.IsInterface && expression.Type != typeof(object))
{
throw Error.InvalidUnboxType(nameof(expression));
}
if (!type.IsValueType) throw Error.InvalidUnboxType(nameof(type));
TypeUtils.ValidateType(type, nameof(type));
return new UnaryExpression(ExpressionType.Unbox, expression, type, null);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents a conversion operation.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.Convert"/> and the <see cref="UnaryExpression.Operand"/> and <see cref="Expression.Type"/> properties set to the specified values.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="Type"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> or <paramref name="type"/> is null.</exception>
/// <exception cref="InvalidOperationException">No conversion operator is defined between <paramref name="expression"/>.Type and <paramref name="type"/>.</exception>
public static UnaryExpression Convert(Expression expression, Type type)
{
return Convert(expression, type, method: null);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents a conversion operation for which the implementing method is specified.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.Convert"/> and the <see cref="UnaryExpression.Operand"/>, <see cref="Expression.Type"/>, and <see cref="UnaryExpression.Method"/> properties set to the specified values.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="Type"/> property equal to.</param>
/// <param name="method">A <see cref="MethodInfo"/> to set the <see cref="UnaryExpression.Method"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> or <paramref name="type"/> is null.</exception>
/// <exception cref="ArgumentException">
/// <paramref name="method"/> is not null and the method it represents returns void, is not static (Shared in Visual Basic), or does not take exactly one argument.</exception>
/// <exception cref="AmbiguousMatchException">More than one method that matches the <paramref name="method"/> description was found.</exception>
/// <exception cref="InvalidOperationException">No conversion operator is defined between <paramref name="expression"/>.Type and <paramref name="type"/>.-or-<paramref name="expression"/>.Type is not assignable to the argument type of the method represented by <paramref name="method"/>.-or-The return type of the method represented by <paramref name="method"/> is not assignable to <paramref name="type"/>.-or-<paramref name="expression"/>.Type or <paramref name="type"/> is a nullable value type and the corresponding non-nullable value type does not equal the argument type or the return type, respectively, of the method represented by <paramref name="method"/>.</exception>
public static UnaryExpression Convert(Expression expression, Type type, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
ContractUtils.RequiresNotNull(type, nameof(type));
TypeUtils.ValidateType(type, nameof(type));
if (method == null)
{
if (expression.Type.HasIdentityPrimitiveOrNullableConversionTo(type) ||
expression.Type.HasReferenceConversionTo(type))
{
return new UnaryExpression(ExpressionType.Convert, expression, type, null);
}
return GetUserDefinedCoercionOrThrow(ExpressionType.Convert, expression, type);
}
return GetMethodBasedCoercionOperator(ExpressionType.Convert, expression, type, method);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents a conversion operation that throws an exception if the target type is overflowed.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.ConvertChecked"/> and the <see cref="UnaryExpression.Operand"/> and <see cref="Expression.Type"/> properties set to the specified values.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="Type"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> or <paramref name="type"/> is null.</exception>
/// <exception cref="InvalidOperationException">No conversion operator is defined between <paramref name="expression"/>.Type and <paramref name="type"/>.</exception>
public static UnaryExpression ConvertChecked(Expression expression, Type type)
{
return ConvertChecked(expression, type, method: null);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents a conversion operation that throws an exception if the target type is overflowed and for which the implementing method is specified.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.ConvertChecked"/> and the <see cref="UnaryExpression.Operand"/>, <see cref="Expression.Type"/>, and <see cref="UnaryExpression.Method"/> properties set to the specified values.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="Type"/> property equal to.</param>
/// <param name="method">A <see cref="MethodInfo"/> to set the <see cref="UnaryExpression.Method"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> or <paramref name="type"/> is null.</exception>
/// <exception cref="ArgumentException">
/// <paramref name="method"/> is not null and the method it represents returns void, is not static (Shared in Visual Basic), or does not take exactly one argument.</exception>
/// <exception cref="AmbiguousMatchException">More than one method that matches the <paramref name="method"/> description was found.</exception>
/// <exception cref="InvalidOperationException">No conversion operator is defined between <paramref name="expression"/>.Type and <paramref name="type"/>.-or-<paramref name="expression"/>.Type is not assignable to the argument type of the method represented by <paramref name="method"/>.-or-The return type of the method represented by <paramref name="method"/> is not assignable to <paramref name="type"/>.-or-<paramref name="expression"/>.Type or <paramref name="type"/> is a nullable value type and the corresponding non-nullable value type does not equal the argument type or the return type, respectively, of the method represented by <paramref name="method"/>.</exception>
public static UnaryExpression ConvertChecked(Expression expression, Type type, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
ContractUtils.RequiresNotNull(type, nameof(type));
TypeUtils.ValidateType(type, nameof(type));
if (method == null)
{
if (expression.Type.HasIdentityPrimitiveOrNullableConversionTo(type))
{
return new UnaryExpression(ExpressionType.ConvertChecked, expression, type, null);
}
if (expression.Type.HasReferenceConversionTo(type))
{
return new UnaryExpression(ExpressionType.Convert, expression, type, null);
}
return GetUserDefinedCoercionOrThrow(ExpressionType.ConvertChecked, expression, type);
}
return GetMethodBasedCoercionOperator(ExpressionType.ConvertChecked, expression, type, method);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents getting the length of a one-dimensional, zero-based array.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.ArrayLength"/> and the <see cref="UnaryExpression.Operand"/> property equal to <paramref name="array"/>.</returns>
/// <param name="array">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="array"/> is null.</exception>
/// <exception cref="ArgumentException">
/// <paramref name="array"/>.Type does not represent a single-dimensional, zero-based array type.</exception>
public static UnaryExpression ArrayLength(Expression array)
{
ExpressionUtils.RequiresCanRead(array, nameof(array));
if (!array.Type.IsSZArray)
{
if (!array.Type.IsArray || !typeof(Array).IsAssignableFrom(array.Type))
{
throw Error.ArgumentMustBeArray(nameof(array));
}
throw Error.ArgumentMustBeSingleDimensionalArrayType(nameof(array));
}
return new UnaryExpression(ExpressionType.ArrayLength, array, typeof(int), null);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents an expression that has a constant value of type <see cref="Expression"/>.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.Quote"/> and the <see cref="UnaryExpression.Operand"/> property set to the specified value.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> is null.</exception>
public static UnaryExpression Quote(Expression expression)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
LambdaExpression? lambda = expression as LambdaExpression;
if (lambda == null)
{
throw Error.QuotedExpressionMustBeLambda(nameof(expression));
}
return new UnaryExpression(ExpressionType.Quote, lambda, lambda.PublicType, null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents a rethrowing of an exception.
/// </summary>
/// <returns>A <see cref="UnaryExpression"/> that represents a rethrowing of an exception.</returns>
public static UnaryExpression Rethrow()
{
return Throw(value: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents a rethrowing of an exception with a given type.
/// </summary>
/// <param name="type">The new <see cref="Type"/> of the expression.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents a rethrowing of an exception.</returns>
public static UnaryExpression Rethrow(Type type)
{
return Throw(null, type);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents a throwing of an exception.
/// </summary>
/// <param name="value">An <see cref="Expression"/>.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the exception.</returns>
public static UnaryExpression Throw(Expression? value)
{
return Throw(value, typeof(void));
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents a throwing of a value with a given type.
/// </summary>
/// <param name="value">An <see cref="Expression"/>.</param>
/// <param name="type">The new <see cref="Type"/> of the expression.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the exception.</returns>
public static UnaryExpression Throw(Expression? value, Type type)
{
ContractUtils.RequiresNotNull(type, nameof(type));
TypeUtils.ValidateType(type, nameof(type));
if (value != null)
{
ExpressionUtils.RequiresCanRead(value, nameof(value));
if (value.Type.IsValueType) throw Error.ArgumentMustNotHaveValueType(nameof(value));
}
return new UnaryExpression(ExpressionType.Throw, value!, type, null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents the incrementing of the expression by 1.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to increment.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the incremented expression.</returns>
public static UnaryExpression Increment(Expression expression)
{
return Increment(expression, method: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents the incrementing of the expression by 1.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to increment.</param>
/// <param name="method">A <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the incremented expression.</returns>
public static UnaryExpression Increment(Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsArithmetic())
{
return new UnaryExpression(ExpressionType.Increment, expression, expression.Type, null);
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.Increment, "op_Increment", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.Increment, expression, method);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents the decrementing of the expression by 1.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to decrement.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the decremented expression.</returns>
public static UnaryExpression Decrement(Expression expression)
{
return Decrement(expression, method: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents the decrementing of the expression by 1.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to decrement.</param>
/// <param name="method">A <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the decremented expression.</returns>
public static UnaryExpression Decrement(Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsArithmetic())
{
return new UnaryExpression(ExpressionType.Decrement, expression, expression.Type, null);
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.Decrement, "op_Decrement", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.Decrement, expression, method);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that increments the expression by 1
/// and assigns the result back to the expression.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the resultant expression.</returns>
public static UnaryExpression PreIncrementAssign(Expression expression)
{
return MakeOpAssignUnary(ExpressionType.PreIncrementAssign, expression, method: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that increments the expression by 1
/// and assigns the result back to the expression.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param>
/// <param name="method">A <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the resultant expression.</returns>
public static UnaryExpression PreIncrementAssign(Expression expression, MethodInfo? method)
{
return MakeOpAssignUnary(ExpressionType.PreIncrementAssign, expression, method);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that decrements the expression by 1
/// and assigns the result back to the expression.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the resultant expression.</returns>
public static UnaryExpression PreDecrementAssign(Expression expression)
{
return MakeOpAssignUnary(ExpressionType.PreDecrementAssign, expression, method: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that decrements the expression by 1
/// and assigns the result back to the expression.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param>
/// <param name="method">A <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the resultant expression.</returns>
public static UnaryExpression PreDecrementAssign(Expression expression, MethodInfo? method)
{
return MakeOpAssignUnary(ExpressionType.PreDecrementAssign, expression, method);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents the assignment of the expression
/// followed by a subsequent increment by 1 of the original expression.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the resultant expression.</returns>
public static UnaryExpression PostIncrementAssign(Expression expression)
{
return MakeOpAssignUnary(ExpressionType.PostIncrementAssign, expression, method: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents the assignment of the expression
/// followed by a subsequent increment by 1 of the original expression.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param>
/// <param name="method">A <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the resultant expression.</returns>
public static UnaryExpression PostIncrementAssign(Expression expression, MethodInfo? method)
{
return MakeOpAssignUnary(ExpressionType.PostIncrementAssign, expression, method);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents the assignment of the expression
/// followed by a subsequent decrement by 1 of the original expression.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the resultant expression.</returns>
public static UnaryExpression PostDecrementAssign(Expression expression)
{
return MakeOpAssignUnary(ExpressionType.PostDecrementAssign, expression, method: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents the assignment of the expression
/// followed by a subsequent decrement by 1 of the original expression.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param>
/// <param name="method">A <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the resultant expression.</returns>
public static UnaryExpression PostDecrementAssign(Expression expression, MethodInfo? method)
{
return MakeOpAssignUnary(ExpressionType.PostDecrementAssign, expression, method);
}
private static UnaryExpression MakeOpAssignUnary(ExpressionType kind, Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
RequiresCanWrite(expression, nameof(expression));
UnaryExpression result;
if (method == null)
{
if (expression.Type.IsArithmetic())
{
return new UnaryExpression(kind, expression, expression.Type, null);
}
string name;
if (kind == ExpressionType.PreIncrementAssign || kind == ExpressionType.PostIncrementAssign)
{
name = "op_Increment";
}
else
{
Debug.Assert(kind == ExpressionType.PreDecrementAssign || kind == ExpressionType.PostDecrementAssign);
name = "op_Decrement";
}
result = GetUserDefinedUnaryOperatorOrThrow(kind, name, expression);
}
else
{
result = GetMethodBasedUnaryOperator(kind, expression, method);
}
// return type must be assignable back to the operand type
if (!TypeUtils.AreReferenceAssignable(expression.Type, result.Type))
{
throw Error.UserDefinedOpMustHaveValidReturnType(kind, method!.Name);
}
return result;
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Dynamic.Utils;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace System.Linq.Expressions
{
/// <summary>
/// Represents an expression that has a unary operator.
/// </summary>
[DebuggerTypeProxy(typeof(UnaryExpressionProxy))]
public sealed class UnaryExpression : Expression
{
internal UnaryExpression(ExpressionType nodeType, Expression expression, Type type, MethodInfo? method)
{
Operand = expression;
Method = method;
NodeType = nodeType;
Type = type;
}
/// <summary>
/// Gets the static type of the expression that this <see cref="Expression"/> represents. (Inherited from <see cref="Expression"/>.)
/// </summary>
/// <returns>The <see cref="System.Type"/> that represents the static type of the expression.</returns>
public sealed override Type Type { get; }
/// <summary>
/// Returns the node type of this <see cref="Expression"/>. (Inherited from <see cref="Expression"/>.)
/// </summary>
/// <returns>The <see cref="ExpressionType"/> that represents this expression.</returns>
public sealed override ExpressionType NodeType { get; }
/// <summary>
/// Gets the operand of the unary operation.
/// </summary>
/// <returns> An <see cref="Expression"/> that represents the operand of the unary operation. Returns null if node type is <see cref="ExpressionType.Throw"/> with no operand.</returns>
public Expression Operand { get; }
/// <summary>
/// Gets the implementing method for the unary operation.
/// </summary>
/// <returns>The <see cref="MethodInfo"/> that represents the implementing method.</returns>
public MethodInfo? Method { get; }
/// <summary>
/// Gets a value that indicates whether the expression tree node represents a lifted call to an operator.
/// </summary>
/// <returns>true if the node represents a lifted call; otherwise, false.</returns>
public bool IsLifted
{
get
{
if (NodeType == ExpressionType.TypeAs || NodeType == ExpressionType.Quote || NodeType == ExpressionType.Throw)
{
return false;
}
bool operandIsNullable = Operand.Type.IsNullableType();
bool resultIsNullable = this.Type.IsNullableType();
if (Method != null)
{
return (operandIsNullable && !TypeUtils.AreEquivalent(Method.GetParametersCached()[0].ParameterType, Operand.Type)) ||
(resultIsNullable && !TypeUtils.AreEquivalent(Method.ReturnType, this.Type));
}
return operandIsNullable || resultIsNullable;
}
}
/// <summary>
/// Gets a value that indicates whether the expression tree node represents a lifted call to an operator whose return type is lifted to a nullable type.
/// </summary>
/// <returns>true if the operator's return type is lifted to a nullable type; otherwise, false.</returns>
public bool IsLiftedToNull => IsLifted && this.Type.IsNullableType();
/// <summary>
/// Dispatches to the specific visit method for this node type.
/// </summary>
protected internal override Expression Accept(ExpressionVisitor visitor)
{
return visitor.VisitUnary(this);
}
/// <summary>
/// Gets a value that indicates whether the expression tree node can be reduced.
/// </summary>
public override bool CanReduce
{
get
{
switch (NodeType)
{
case ExpressionType.PreIncrementAssign:
case ExpressionType.PreDecrementAssign:
case ExpressionType.PostIncrementAssign:
case ExpressionType.PostDecrementAssign:
return true;
}
return false;
}
}
/// <summary>
/// Reduces the expression node to a simpler expression.
/// If CanReduce returns true, this should return a valid expression.
/// This method is allowed to return another node which itself
/// must be reduced.
/// </summary>
/// <returns>The reduced expression.</returns>
public override Expression Reduce()
{
if (CanReduce)
{
switch (Operand.NodeType)
{
case ExpressionType.Index:
return ReduceIndex();
case ExpressionType.MemberAccess:
return ReduceMember();
default:
Debug.Assert(Operand.NodeType == ExpressionType.Parameter);
return ReduceVariable();
}
}
return this;
}
private bool IsPrefix
{
get { return NodeType == ExpressionType.PreIncrementAssign || NodeType == ExpressionType.PreDecrementAssign; }
}
private UnaryExpression FunctionalOp(Expression operand)
{
ExpressionType functional;
if (NodeType == ExpressionType.PreIncrementAssign || NodeType == ExpressionType.PostIncrementAssign)
{
functional = ExpressionType.Increment;
}
else
{
Debug.Assert(NodeType == ExpressionType.PreDecrementAssign || NodeType == ExpressionType.PostDecrementAssign);
functional = ExpressionType.Decrement;
}
return new UnaryExpression(functional, operand, operand.Type, Method);
}
private Expression ReduceVariable()
{
if (IsPrefix)
{
// (op) var
// ... is reduced into ...
// var = op(var)
return Assign(Operand, FunctionalOp(Operand));
}
// var (op)
// ... is reduced into ...
// temp = var
// var = op(var)
// temp
ParameterExpression temp = Parameter(Operand.Type, name: null);
return Block(
new TrueReadOnlyCollection<ParameterExpression>(temp),
new TrueReadOnlyCollection<Expression>(
Assign(temp, Operand),
Assign(Operand, FunctionalOp(temp)),
temp
)
);
}
private Expression ReduceMember()
{
var member = (MemberExpression)Operand;
if (member.Expression == null)
{
//static member, reduce the same as variable
return ReduceVariable();
}
else
{
ParameterExpression temp1 = Parameter(member.Expression.Type, name: null);
BinaryExpression initTemp1 = Assign(temp1, member.Expression);
member = MakeMemberAccess(temp1, member.Member);
if (IsPrefix)
{
// (op) value.member
// ... is reduced into ...
// temp1 = value
// temp1.member = op(temp1.member)
return Block(
new TrueReadOnlyCollection<ParameterExpression>(temp1),
new TrueReadOnlyCollection<Expression>(
initTemp1,
Assign(member, FunctionalOp(member))
)
);
}
// value.member (op)
// ... is reduced into ...
// temp1 = value
// temp2 = temp1.member
// temp1.member = op(temp2)
// temp2
ParameterExpression temp2 = Parameter(member.Type, name: null);
return Block(
new TrueReadOnlyCollection<ParameterExpression>(temp1, temp2),
new TrueReadOnlyCollection<Expression>(
initTemp1,
Assign(temp2, member),
Assign(member, FunctionalOp(temp2)),
temp2
)
);
}
}
private Expression ReduceIndex()
{
// left[a0, a1, ... aN] (op)
//
// ... is reduced into ...
//
// tempObj = left
// tempArg0 = a0
// ...
// tempArgN = aN
// tempValue = tempObj[tempArg0, ... tempArgN]
// tempObj[tempArg0, ... tempArgN] = op(tempValue)
// tempValue
bool prefix = IsPrefix;
var index = (IndexExpression)Operand;
int count = index.ArgumentCount;
var block = new Expression[count + (prefix ? 2 : 4)];
var temps = new ParameterExpression[count + (prefix ? 1 : 2)];
var args = new ParameterExpression[count];
int i = 0;
temps[i] = Parameter(index.Object!.Type, name: null);
block[i] = Assign(temps[i], index.Object);
i++;
while (i <= count)
{
Expression arg = index.GetArgument(i - 1);
args[i - 1] = temps[i] = Parameter(arg.Type, name: null);
block[i] = Assign(temps[i], arg);
i++;
}
index = MakeIndex(temps[0], index.Indexer, new TrueReadOnlyCollection<Expression>(args));
if (!prefix)
{
ParameterExpression lastTemp = temps[i] = Parameter(index.Type, name: null);
block[i] = Assign(temps[i], index);
i++;
Debug.Assert(i == temps.Length);
block[i++] = Assign(index, FunctionalOp(lastTemp));
block[i++] = lastTemp;
}
else
{
Debug.Assert(i == temps.Length);
block[i++] = Assign(index, FunctionalOp(index));
}
Debug.Assert(i == block.Length);
return Block(new TrueReadOnlyCollection<ParameterExpression>(temps), new TrueReadOnlyCollection<Expression>(block));
}
/// <summary>
/// Creates a new expression that is like this one, but using the
/// supplied children. If all of the children are the same, it will
/// return this expression.
/// </summary>
/// <param name="operand">The <see cref="Operand"/> property of the result.</param>
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
public UnaryExpression Update(Expression operand)
{
if (operand == Operand)
{
return this;
}
return Expression.MakeUnary(NodeType, operand, Type, Method);
}
}
public partial class Expression
{
/// <summary>
/// Creates a <see cref="UnaryExpression"/>, given an operand, by calling the appropriate factory method.
/// </summary>
/// <param name="unaryType">The <see cref="ExpressionType"/> that specifies the type of unary operation.</param>
/// <param name="operand">An <see cref="Expression"/> that represents the operand.</param>
/// <param name="type">The <see cref="Type"/> that specifies the type to be converted to (pass null if not applicable).</param>
/// <returns>The <see cref="UnaryExpression"/> that results from calling the appropriate factory method.</returns>
/// <exception cref="ArgumentException">Thrown when <paramref name="unaryType"/> does not correspond to a unary expression.</exception>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="operand"/> is null.</exception>
public static UnaryExpression MakeUnary(ExpressionType unaryType, Expression operand, Type type)
{
return MakeUnary(unaryType, operand, type, method: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/>, given an operand and implementing method, by calling the appropriate factory method.
/// </summary>
/// <param name="unaryType">The <see cref="ExpressionType"/> that specifies the type of unary operation.</param>
/// <param name="operand">An <see cref="Expression"/> that represents the operand.</param>
/// <param name="type">The <see cref="Type"/> that specifies the type to be converted to (pass null if not applicable).</param>
/// <param name="method">The <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>The <see cref="UnaryExpression"/> that results from calling the appropriate factory method.</returns>
/// <exception cref="ArgumentException">Thrown when <paramref name="unaryType"/> does not correspond to a unary expression.</exception>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="operand"/> is null.</exception>
public static UnaryExpression MakeUnary(ExpressionType unaryType, Expression operand, Type type, MethodInfo? method) =>
unaryType switch
{
ExpressionType.Negate => Negate(operand, method),
ExpressionType.NegateChecked => NegateChecked(operand, method),
ExpressionType.Not => Not(operand, method),
ExpressionType.IsFalse => IsFalse(operand, method),
ExpressionType.IsTrue => IsTrue(operand, method),
ExpressionType.OnesComplement => OnesComplement(operand, method),
ExpressionType.ArrayLength => ArrayLength(operand),
ExpressionType.Convert => Convert(operand, type, method),
ExpressionType.ConvertChecked => ConvertChecked(operand, type, method),
ExpressionType.Throw => Throw(operand, type),
ExpressionType.TypeAs => TypeAs(operand, type),
ExpressionType.Quote => Quote(operand),
ExpressionType.UnaryPlus => UnaryPlus(operand, method),
ExpressionType.Unbox => Unbox(operand, type),
ExpressionType.Increment => Increment(operand, method),
ExpressionType.Decrement => Decrement(operand, method),
ExpressionType.PreIncrementAssign => PreIncrementAssign(operand, method),
ExpressionType.PostIncrementAssign => PostIncrementAssign(operand, method),
ExpressionType.PreDecrementAssign => PreDecrementAssign(operand, method),
ExpressionType.PostDecrementAssign => PostDecrementAssign(operand, method),
_ => throw Error.UnhandledUnary(unaryType, nameof(unaryType)),
};
private static UnaryExpression GetUserDefinedUnaryOperatorOrThrow(ExpressionType unaryType, string name, Expression operand)
{
UnaryExpression? u = GetUserDefinedUnaryOperator(unaryType, name, operand);
if (u != null)
{
ValidateParamswithOperandsOrThrow(u.Method!.GetParametersCached()[0].ParameterType, operand.Type, unaryType, name);
return u;
}
throw Error.UnaryOperatorNotDefined(unaryType, operand.Type);
}
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2072:UnrecognizedReflectionPattern",
Justification = "The trimmer doesn't remove operators when System.Linq.Expressions is used. See https://github.com/mono/linker/pull/2125.")]
private static UnaryExpression? GetUserDefinedUnaryOperator(ExpressionType unaryType, string name, Expression operand)
{
Type operandType = operand.Type;
Type[] types = new Type[] { operandType };
Type nnOperandType = operandType.GetNonNullableType();
MethodInfo? method = nnOperandType.GetAnyStaticMethodValidated(name, types);
if (method != null)
{
return new UnaryExpression(unaryType, operand, method.ReturnType, method);
}
// try lifted call
if (operandType.IsNullableType())
{
types[0] = nnOperandType;
method = nnOperandType.GetAnyStaticMethodValidated(name, types);
if (method != null && method.ReturnType.IsValueType && !method.ReturnType.IsNullableType())
{
return new UnaryExpression(unaryType, operand, method.ReturnType.GetNullableType(), method);
}
}
return null;
}
private static UnaryExpression GetMethodBasedUnaryOperator(ExpressionType unaryType, Expression operand, MethodInfo method)
{
Debug.Assert(method != null);
ValidateOperator(method);
ParameterInfo[] pms = method.GetParametersCached();
if (pms.Length != 1)
throw Error.IncorrectNumberOfMethodCallArguments(method, nameof(method));
if (ParameterIsAssignable(pms[0], operand.Type))
{
ValidateParamswithOperandsOrThrow(pms[0].ParameterType, operand.Type, unaryType, method.Name);
return new UnaryExpression(unaryType, operand, method.ReturnType, method);
}
// check for lifted call
if (operand.Type.IsNullableType() &&
ParameterIsAssignable(pms[0], operand.Type.GetNonNullableType()) &&
method.ReturnType.IsValueType && !method.ReturnType.IsNullableType())
{
return new UnaryExpression(unaryType, operand, method.ReturnType.GetNullableType(), method);
}
throw Error.OperandTypesDoNotMatchParameters(unaryType, method.Name);
}
private static UnaryExpression GetUserDefinedCoercionOrThrow(ExpressionType coercionType, Expression expression, Type convertToType)
{
UnaryExpression? u = GetUserDefinedCoercion(coercionType, expression, convertToType);
if (u != null)
{
return u;
}
throw Error.CoercionOperatorNotDefined(expression.Type, convertToType);
}
private static UnaryExpression? GetUserDefinedCoercion(ExpressionType coercionType, Expression expression, Type convertToType)
{
MethodInfo? method = TypeUtils.GetUserDefinedCoercionMethod(expression.Type, convertToType);
if (method != null)
{
return new UnaryExpression(coercionType, expression, convertToType, method);
}
else
{
return null;
}
}
private static UnaryExpression GetMethodBasedCoercionOperator(ExpressionType unaryType, Expression operand, Type convertToType, MethodInfo method)
{
Debug.Assert(method != null);
ValidateOperator(method);
ParameterInfo[] pms = method.GetParametersCached();
if (pms.Length != 1)
{
throw Error.IncorrectNumberOfMethodCallArguments(method, nameof(method));
}
if (ParameterIsAssignable(pms[0], operand.Type) && TypeUtils.AreEquivalent(method.ReturnType, convertToType))
{
return new UnaryExpression(unaryType, operand, method.ReturnType, method);
}
// check for lifted call
if ((operand.Type.IsNullableType() || convertToType.IsNullableType()) &&
ParameterIsAssignable(pms[0], operand.Type.GetNonNullableType()) &&
(TypeUtils.AreEquivalent(method.ReturnType, convertToType.GetNonNullableType()) ||
TypeUtils.AreEquivalent(method.ReturnType, convertToType)))
{
return new UnaryExpression(unaryType, operand, convertToType, method);
}
throw Error.OperandTypesDoNotMatchParameters(unaryType, method.Name);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents an arithmetic negation operation.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.Negate"/> and the <see cref="UnaryExpression.Operand"/> properties set to the specified value.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="expression"/> is null.</exception>
/// <exception cref="InvalidOperationException">Thrown when the unary minus operator is not defined for <paramref name="expression"/>.Type.</exception>
public static UnaryExpression Negate(Expression expression)
{
return Negate(expression, method: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents an arithmetic negation operation.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <param name="method">A <see cref="MethodInfo"/> to set the <see cref="UnaryExpression.Method"/> property equal to.</param>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.Negate"/> and the <see cref="UnaryExpression.Operand"/> and <see cref="UnaryExpression.Method"/> properties set to the specified value.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="expression"/> is null.</exception>
/// <exception cref="ArgumentException">Thrown when <paramref name="method"/> is not null and the method it represents returns void, is not static (Shared in Visual Basic), or does not take exactly one argument.</exception>
/// <exception cref="InvalidOperationException">Thrown when <paramref name="method"/> is null and the unary minus operator is not defined for <paramref name="expression"/>.Type (or its corresponding non-nullable type if it is a nullable value type) is not assignable to the argument type of the method represented by method.</exception>
public static UnaryExpression Negate(Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsArithmetic() && !expression.Type.IsUnsignedInt())
{
return new UnaryExpression(ExpressionType.Negate, expression, expression.Type, null);
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.Negate, "op_UnaryNegation", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.Negate, expression, method);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents a unary plus operation.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.UnaryPlus"/> and the <see cref="UnaryExpression.Operand"/> property set to the specified value.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="expression"/> is null.</exception>
/// <exception cref="InvalidOperationException">Thrown when the unary minus operator is not defined for <paramref name="expression"/>.Type.</exception>
public static UnaryExpression UnaryPlus(Expression expression)
{
return UnaryPlus(expression, method: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents a unary plus operation.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <param name="method">A <see cref="MethodInfo"/> to set the <see cref="UnaryExpression.Method"/> property equal to.</param>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.UnaryPlus"/> and the <see cref="UnaryExpression.Operand"/> and <see cref="UnaryExpression.Method"/>property set to the specified value.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="expression"/> is null.</exception>
/// <exception cref="ArgumentException">Thrown when <paramref name="method"/> is not null and the method it represents returns void, is not static (Shared in Visual Basic), or does not take exactly one argument.</exception>
/// <exception cref="InvalidOperationException">Thrown when <paramref name="method"/> is null and the unary minus operator is not defined for <paramref name="expression"/>.Type (or its corresponding non-nullable type if it is a nullable value type) is not assignable to the argument type of the method represented by method.</exception>
public static UnaryExpression UnaryPlus(Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsArithmetic())
{
return new UnaryExpression(ExpressionType.UnaryPlus, expression, expression.Type, null);
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.UnaryPlus, "op_UnaryPlus", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.UnaryPlus, expression, method);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents an arithmetic negation operation that has overflow checking.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.NegateChecked"/> and the <see cref="UnaryExpression.Operand"/> property set to the specified value.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="expression"/> is null.</exception>
/// <exception cref="InvalidOperationException">Thrown when the unary minus operator is not defined for <paramref name="expression"/>.Type.</exception>
public static UnaryExpression NegateChecked(Expression expression)
{
return NegateChecked(expression, method: null);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents an arithmetic negation operation that has overflow checking. The implementing method can be specified.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.NegateChecked"/> and the <see cref="UnaryExpression.Operand"/> and <see cref="UnaryExpression.Method"/> properties set to the specified values.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <param name="method">A <see cref="MethodInfo"/> to set the <see cref="UnaryExpression.Method"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> is null.</exception>
/// <exception cref="ArgumentException">
/// <paramref name="method"/> is not null and the method it represents returns void, is not static (Shared in Visual Basic), or does not take exactly one argument.</exception>
/// <exception cref="InvalidOperationException">
/// <paramref name="method"/> is null and the unary minus operator is not defined for <paramref name="expression"/>.Type.-or-<paramref name="expression"/>.Type (or its corresponding non-nullable type if it is a nullable value type) is not assignable to the argument type of the method represented by <paramref name="method"/>.</exception>
public static UnaryExpression NegateChecked(Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsArithmetic() && !expression.Type.IsUnsignedInt())
{
return new UnaryExpression(ExpressionType.NegateChecked, expression, expression.Type, null);
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.NegateChecked, "op_UnaryNegation", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.NegateChecked, expression, method);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents a bitwise complement operation.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.Not"/> and the <see cref="UnaryExpression.Operand"/> property set to the specified value.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> is null.</exception>
/// <exception cref="InvalidOperationException">The unary not operator is not defined for <paramref name="expression"/>.Type.</exception>
public static UnaryExpression Not(Expression expression)
{
return Not(expression, method: null);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents a bitwise complement operation. The implementing method can be specified.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.Not"/> and the <see cref="UnaryExpression.Operand"/> and <see cref="UnaryExpression.Method"/> properties set to the specified values.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <param name="method">A <see cref="MethodInfo"/> to set the <see cref="UnaryExpression.Method"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> is null.</exception>
/// <exception cref="ArgumentException">
/// <paramref name="method"/> is not null and the method it represents returns void, is not static (Shared in Visual Basic), or does not take exactly one argument.</exception>
/// <exception cref="InvalidOperationException">
/// <paramref name="method"/> is null and the unary not operator is not defined for <paramref name="expression"/>.Type.-or-<paramref name="expression"/>.Type (or its corresponding non-nullable type if it is a nullable value type) is not assignable to the argument type of the method represented by <paramref name="method"/>.</exception>
public static UnaryExpression Not(Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsIntegerOrBool())
{
return new UnaryExpression(ExpressionType.Not, expression, expression.Type, null);
}
UnaryExpression? u = GetUserDefinedUnaryOperator(ExpressionType.Not, "op_LogicalNot", expression);
if (u != null)
{
return u;
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.Not, "op_OnesComplement", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.Not, expression, method);
}
/// <summary>
/// Returns whether the expression evaluates to false.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to evaluate.</param>
/// <returns>An instance of <see cref="UnaryExpression"/>.</returns>
public static UnaryExpression IsFalse(Expression expression)
{
return IsFalse(expression, method: null);
}
/// <summary>
/// Returns whether the expression evaluates to false.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to evaluate.</param>
/// <param name="method">A <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>An instance of <see cref="UnaryExpression"/>.</returns>
public static UnaryExpression IsFalse(Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsBool())
{
return new UnaryExpression(ExpressionType.IsFalse, expression, expression.Type, null);
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.IsFalse, "op_False", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.IsFalse, expression, method);
}
/// <summary>
/// Returns whether the expression evaluates to true.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to evaluate.</param>
/// <returns>An instance of <see cref="UnaryExpression"/>.</returns>
public static UnaryExpression IsTrue(Expression expression)
{
return IsTrue(expression, method: null);
}
/// <summary>
/// Returns whether the expression evaluates to true.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to evaluate.</param>
/// <param name="method">A <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>An instance of <see cref="UnaryExpression"/>.</returns>
public static UnaryExpression IsTrue(Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsBool())
{
return new UnaryExpression(ExpressionType.IsTrue, expression, expression.Type, null);
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.IsTrue, "op_True", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.IsTrue, expression, method);
}
/// <summary>
/// Returns the expression representing the ones complement.
/// </summary>
/// <param name="expression">An <see cref="Expression"/>.</param>
/// <returns>An instance of <see cref="UnaryExpression"/>.</returns>
public static UnaryExpression OnesComplement(Expression expression)
{
return OnesComplement(expression, method: null);
}
/// <summary>
/// Returns the expression representing the ones complement.
/// </summary>
/// <param name="expression">An <see cref="Expression"/>.</param>
/// <param name="method">A <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>An instance of <see cref="UnaryExpression"/>.</returns>
public static UnaryExpression OnesComplement(Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsInteger())
{
return new UnaryExpression(ExpressionType.OnesComplement, expression, expression.Type, null);
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.OnesComplement, "op_OnesComplement", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.OnesComplement, expression, method);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents an explicit reference or boxing conversion where null is supplied if the conversion fails.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.TypeAs"/> and the <see cref="UnaryExpression.Operand"/> and <see cref="Expression.Type"/> properties set to the specified values.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="Type"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> or <paramref name="type"/> is null.</exception>
public static UnaryExpression TypeAs(Expression expression, Type type)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
ContractUtils.RequiresNotNull(type, nameof(type));
TypeUtils.ValidateType(type, nameof(type));
if (type.IsValueType && !type.IsNullableType())
{
throw Error.IncorrectTypeForTypeAs(type, nameof(type));
}
return new UnaryExpression(ExpressionType.TypeAs, expression, type, null);
}
/// <summary>
/// <summary>Creates a <see cref="UnaryExpression"/> that represents an explicit unboxing.</summary>
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to unbox.</param>
/// <param name="type">The new <see cref="System.Type"/> of the expression.</param>
/// <returns>An instance of <see cref="UnaryExpression"/>.</returns>
public static UnaryExpression Unbox(Expression expression, Type type)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
ContractUtils.RequiresNotNull(type, nameof(type));
if (!expression.Type.IsInterface && expression.Type != typeof(object))
{
throw Error.InvalidUnboxType(nameof(expression));
}
if (!type.IsValueType) throw Error.InvalidUnboxType(nameof(type));
TypeUtils.ValidateType(type, nameof(type));
return new UnaryExpression(ExpressionType.Unbox, expression, type, null);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents a conversion operation.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.Convert"/> and the <see cref="UnaryExpression.Operand"/> and <see cref="Expression.Type"/> properties set to the specified values.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="Type"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> or <paramref name="type"/> is null.</exception>
/// <exception cref="InvalidOperationException">No conversion operator is defined between <paramref name="expression"/>.Type and <paramref name="type"/>.</exception>
public static UnaryExpression Convert(Expression expression, Type type)
{
return Convert(expression, type, method: null);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents a conversion operation for which the implementing method is specified.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.Convert"/> and the <see cref="UnaryExpression.Operand"/>, <see cref="Expression.Type"/>, and <see cref="UnaryExpression.Method"/> properties set to the specified values.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="Type"/> property equal to.</param>
/// <param name="method">A <see cref="MethodInfo"/> to set the <see cref="UnaryExpression.Method"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> or <paramref name="type"/> is null.</exception>
/// <exception cref="ArgumentException">
/// <paramref name="method"/> is not null and the method it represents returns void, is not static (Shared in Visual Basic), or does not take exactly one argument.</exception>
/// <exception cref="AmbiguousMatchException">More than one method that matches the <paramref name="method"/> description was found.</exception>
/// <exception cref="InvalidOperationException">No conversion operator is defined between <paramref name="expression"/>.Type and <paramref name="type"/>.-or-<paramref name="expression"/>.Type is not assignable to the argument type of the method represented by <paramref name="method"/>.-or-The return type of the method represented by <paramref name="method"/> is not assignable to <paramref name="type"/>.-or-<paramref name="expression"/>.Type or <paramref name="type"/> is a nullable value type and the corresponding non-nullable value type does not equal the argument type or the return type, respectively, of the method represented by <paramref name="method"/>.</exception>
public static UnaryExpression Convert(Expression expression, Type type, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
ContractUtils.RequiresNotNull(type, nameof(type));
TypeUtils.ValidateType(type, nameof(type));
if (method == null)
{
if (expression.Type.HasIdentityPrimitiveOrNullableConversionTo(type) ||
expression.Type.HasReferenceConversionTo(type))
{
return new UnaryExpression(ExpressionType.Convert, expression, type, null);
}
return GetUserDefinedCoercionOrThrow(ExpressionType.Convert, expression, type);
}
return GetMethodBasedCoercionOperator(ExpressionType.Convert, expression, type, method);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents a conversion operation that throws an exception if the target type is overflowed.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.ConvertChecked"/> and the <see cref="UnaryExpression.Operand"/> and <see cref="Expression.Type"/> properties set to the specified values.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="Type"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> or <paramref name="type"/> is null.</exception>
/// <exception cref="InvalidOperationException">No conversion operator is defined between <paramref name="expression"/>.Type and <paramref name="type"/>.</exception>
public static UnaryExpression ConvertChecked(Expression expression, Type type)
{
return ConvertChecked(expression, type, method: null);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents a conversion operation that throws an exception if the target type is overflowed and for which the implementing method is specified.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.ConvertChecked"/> and the <see cref="UnaryExpression.Operand"/>, <see cref="Expression.Type"/>, and <see cref="UnaryExpression.Method"/> properties set to the specified values.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="Type"/> property equal to.</param>
/// <param name="method">A <see cref="MethodInfo"/> to set the <see cref="UnaryExpression.Method"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> or <paramref name="type"/> is null.</exception>
/// <exception cref="ArgumentException">
/// <paramref name="method"/> is not null and the method it represents returns void, is not static (Shared in Visual Basic), or does not take exactly one argument.</exception>
/// <exception cref="AmbiguousMatchException">More than one method that matches the <paramref name="method"/> description was found.</exception>
/// <exception cref="InvalidOperationException">No conversion operator is defined between <paramref name="expression"/>.Type and <paramref name="type"/>.-or-<paramref name="expression"/>.Type is not assignable to the argument type of the method represented by <paramref name="method"/>.-or-The return type of the method represented by <paramref name="method"/> is not assignable to <paramref name="type"/>.-or-<paramref name="expression"/>.Type or <paramref name="type"/> is a nullable value type and the corresponding non-nullable value type does not equal the argument type or the return type, respectively, of the method represented by <paramref name="method"/>.</exception>
public static UnaryExpression ConvertChecked(Expression expression, Type type, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
ContractUtils.RequiresNotNull(type, nameof(type));
TypeUtils.ValidateType(type, nameof(type));
if (method == null)
{
if (expression.Type.HasIdentityPrimitiveOrNullableConversionTo(type))
{
return new UnaryExpression(ExpressionType.ConvertChecked, expression, type, null);
}
if (expression.Type.HasReferenceConversionTo(type))
{
return new UnaryExpression(ExpressionType.Convert, expression, type, null);
}
return GetUserDefinedCoercionOrThrow(ExpressionType.ConvertChecked, expression, type);
}
return GetMethodBasedCoercionOperator(ExpressionType.ConvertChecked, expression, type, method);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents getting the length of a one-dimensional, zero-based array.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.ArrayLength"/> and the <see cref="UnaryExpression.Operand"/> property equal to <paramref name="array"/>.</returns>
/// <param name="array">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="array"/> is null.</exception>
/// <exception cref="ArgumentException">
/// <paramref name="array"/>.Type does not represent a single-dimensional, zero-based array type.</exception>
public static UnaryExpression ArrayLength(Expression array)
{
ExpressionUtils.RequiresCanRead(array, nameof(array));
if (!array.Type.IsSZArray)
{
if (!array.Type.IsArray || !typeof(Array).IsAssignableFrom(array.Type))
{
throw Error.ArgumentMustBeArray(nameof(array));
}
throw Error.ArgumentMustBeSingleDimensionalArrayType(nameof(array));
}
return new UnaryExpression(ExpressionType.ArrayLength, array, typeof(int), null);
}
/// <summary>Creates a <see cref="UnaryExpression"/> that represents an expression that has a constant value of type <see cref="Expression"/>.</summary>
/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.Quote"/> and the <see cref="UnaryExpression.Operand"/> property set to the specified value.</returns>
/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> is null.</exception>
public static UnaryExpression Quote(Expression expression)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
LambdaExpression? lambda = expression as LambdaExpression;
if (lambda == null)
{
throw Error.QuotedExpressionMustBeLambda(nameof(expression));
}
return new UnaryExpression(ExpressionType.Quote, lambda, lambda.PublicType, null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents a rethrowing of an exception.
/// </summary>
/// <returns>A <see cref="UnaryExpression"/> that represents a rethrowing of an exception.</returns>
public static UnaryExpression Rethrow()
{
return Throw(value: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents a rethrowing of an exception with a given type.
/// </summary>
/// <param name="type">The new <see cref="Type"/> of the expression.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents a rethrowing of an exception.</returns>
public static UnaryExpression Rethrow(Type type)
{
return Throw(null, type);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents a throwing of an exception.
/// </summary>
/// <param name="value">An <see cref="Expression"/>.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the exception.</returns>
public static UnaryExpression Throw(Expression? value)
{
return Throw(value, typeof(void));
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents a throwing of a value with a given type.
/// </summary>
/// <param name="value">An <see cref="Expression"/>.</param>
/// <param name="type">The new <see cref="Type"/> of the expression.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the exception.</returns>
public static UnaryExpression Throw(Expression? value, Type type)
{
ContractUtils.RequiresNotNull(type, nameof(type));
TypeUtils.ValidateType(type, nameof(type));
if (value != null)
{
ExpressionUtils.RequiresCanRead(value, nameof(value));
if (value.Type.IsValueType) throw Error.ArgumentMustNotHaveValueType(nameof(value));
}
return new UnaryExpression(ExpressionType.Throw, value!, type, null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents the incrementing of the expression by 1.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to increment.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the incremented expression.</returns>
public static UnaryExpression Increment(Expression expression)
{
return Increment(expression, method: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents the incrementing of the expression by 1.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to increment.</param>
/// <param name="method">A <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the incremented expression.</returns>
public static UnaryExpression Increment(Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsArithmetic())
{
return new UnaryExpression(ExpressionType.Increment, expression, expression.Type, null);
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.Increment, "op_Increment", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.Increment, expression, method);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents the decrementing of the expression by 1.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to decrement.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the decremented expression.</returns>
public static UnaryExpression Decrement(Expression expression)
{
return Decrement(expression, method: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents the decrementing of the expression by 1.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to decrement.</param>
/// <param name="method">A <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the decremented expression.</returns>
public static UnaryExpression Decrement(Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
if (method == null)
{
if (expression.Type.IsArithmetic())
{
return new UnaryExpression(ExpressionType.Decrement, expression, expression.Type, null);
}
return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.Decrement, "op_Decrement", expression);
}
return GetMethodBasedUnaryOperator(ExpressionType.Decrement, expression, method);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that increments the expression by 1
/// and assigns the result back to the expression.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the resultant expression.</returns>
public static UnaryExpression PreIncrementAssign(Expression expression)
{
return MakeOpAssignUnary(ExpressionType.PreIncrementAssign, expression, method: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that increments the expression by 1
/// and assigns the result back to the expression.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param>
/// <param name="method">A <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the resultant expression.</returns>
public static UnaryExpression PreIncrementAssign(Expression expression, MethodInfo? method)
{
return MakeOpAssignUnary(ExpressionType.PreIncrementAssign, expression, method);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that decrements the expression by 1
/// and assigns the result back to the expression.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the resultant expression.</returns>
public static UnaryExpression PreDecrementAssign(Expression expression)
{
return MakeOpAssignUnary(ExpressionType.PreDecrementAssign, expression, method: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that decrements the expression by 1
/// and assigns the result back to the expression.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param>
/// <param name="method">A <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the resultant expression.</returns>
public static UnaryExpression PreDecrementAssign(Expression expression, MethodInfo? method)
{
return MakeOpAssignUnary(ExpressionType.PreDecrementAssign, expression, method);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents the assignment of the expression
/// followed by a subsequent increment by 1 of the original expression.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the resultant expression.</returns>
public static UnaryExpression PostIncrementAssign(Expression expression)
{
return MakeOpAssignUnary(ExpressionType.PostIncrementAssign, expression, method: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents the assignment of the expression
/// followed by a subsequent increment by 1 of the original expression.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param>
/// <param name="method">A <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the resultant expression.</returns>
public static UnaryExpression PostIncrementAssign(Expression expression, MethodInfo? method)
{
return MakeOpAssignUnary(ExpressionType.PostIncrementAssign, expression, method);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents the assignment of the expression
/// followed by a subsequent decrement by 1 of the original expression.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the resultant expression.</returns>
public static UnaryExpression PostDecrementAssign(Expression expression)
{
return MakeOpAssignUnary(ExpressionType.PostDecrementAssign, expression, method: null);
}
/// <summary>
/// Creates a <see cref="UnaryExpression"/> that represents the assignment of the expression
/// followed by a subsequent decrement by 1 of the original expression.
/// </summary>
/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param>
/// <param name="method">A <see cref="MethodInfo"/> that represents the implementing method.</param>
/// <returns>A <see cref="UnaryExpression"/> that represents the resultant expression.</returns>
public static UnaryExpression PostDecrementAssign(Expression expression, MethodInfo? method)
{
return MakeOpAssignUnary(ExpressionType.PostDecrementAssign, expression, method);
}
private static UnaryExpression MakeOpAssignUnary(ExpressionType kind, Expression expression, MethodInfo? method)
{
ExpressionUtils.RequiresCanRead(expression, nameof(expression));
RequiresCanWrite(expression, nameof(expression));
UnaryExpression result;
if (method == null)
{
if (expression.Type.IsArithmetic())
{
return new UnaryExpression(kind, expression, expression.Type, null);
}
string name;
if (kind == ExpressionType.PreIncrementAssign || kind == ExpressionType.PostIncrementAssign)
{
name = "op_Increment";
}
else
{
Debug.Assert(kind == ExpressionType.PreDecrementAssign || kind == ExpressionType.PostDecrementAssign);
name = "op_Decrement";
}
result = GetUserDefinedUnaryOperatorOrThrow(kind, name, expression);
}
else
{
result = GetMethodBasedUnaryOperator(kind, expression, method);
}
// return type must be assignable back to the operand type
if (!TypeUtils.AreReferenceAssignable(expression.Type, result.Type))
{
throw Error.UserDefinedOpMustHaveValidReturnType(kind, method!.Name);
}
return result;
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_X64/X64Emitter.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.Diagnostics;
namespace ILCompiler.DependencyAnalysis.X64
{
public struct X64Emitter
{
public X64Emitter(NodeFactory factory, bool relocsOnly)
{
Builder = new ObjectDataBuilder(factory, relocsOnly);
TargetRegister = new TargetRegisterMap(factory.Target.OperatingSystem);
}
public ObjectDataBuilder Builder;
public TargetRegisterMap TargetRegister;
// Assembly stub creation api. TBD, actually make this general purpose
public void EmitMOV(Register regDst, ref AddrMode memory)
{
EmitIndirInstructionSize(0x8a, regDst, ref memory);
}
public void EmitMOV(Register regDst, Register regSrc)
{
AddrMode rexAddrMode = new AddrMode(regSrc, null, 0, 0, AddrModeSize.Int64);
EmitRexPrefix(regDst, ref rexAddrMode);
Builder.EmitByte(0x8B);
Builder.EmitByte((byte)(0xC0 | (((int)regDst & 0x07) << 3) | (((int)regSrc & 0x07))));
}
public void EmitMOV(Register regDst, int imm32)
{
AddrMode rexAddrMode = new AddrMode(regDst, null, 0, 0, AddrModeSize.Int32);
EmitRexPrefix(regDst, ref rexAddrMode);
Builder.EmitByte((byte)(0xB8 | ((int)regDst & 0x07)));
Builder.EmitInt(imm32);
}
public void EmitMOV(Register regDst, ISymbolNode node)
{
if (node.RepresentsIndirectionCell)
{
Builder.EmitByte(0x67);
Builder.EmitByte(0x48);
Builder.EmitByte(0x8B);
Builder.EmitByte((byte)(0x00 | ((byte)regDst << 3) | 0x05));
Builder.EmitReloc(node, RelocType.IMAGE_REL_BASED_REL32);
}
else
{
EmitLEAQ(regDst, node, delta: 0);
}
}
public void EmitLEAQ(Register reg, ISymbolNode symbol, int delta = 0)
{
AddrMode rexAddrMode = new AddrMode(Register.RAX, null, 0, 0, AddrModeSize.Int64);
EmitRexPrefix(reg, ref rexAddrMode);
Builder.EmitByte(0x8D);
Builder.EmitByte((byte)(0x05 | (((int)reg) & 0x07) << 3));
Builder.EmitReloc(symbol, RelocType.IMAGE_REL_BASED_REL32, delta);
}
public void EmitLEA(Register reg, ref AddrMode addrMode)
{
Debug.Assert(addrMode.Size != AddrModeSize.Int8 &&
addrMode.Size != AddrModeSize.Int16);
EmitIndirInstruction(0x8D, reg, ref addrMode);
}
public void EmitCMP(ref AddrMode addrMode, sbyte immediate)
{
if (addrMode.Size == AddrModeSize.Int16)
Builder.EmitByte(0x66);
EmitIndirInstruction((byte)((addrMode.Size != AddrModeSize.Int8) ? 0x83 : 0x80), 0x7, ref addrMode);
Builder.EmitByte((byte)immediate);
}
public void EmitADD(ref AddrMode addrMode, sbyte immediate)
{
if (addrMode.Size == AddrModeSize.Int16)
Builder.EmitByte(0x66);
EmitIndirInstruction((byte)((addrMode.Size != AddrModeSize.Int8) ? 0x83 : 0x80), (byte)0, ref addrMode);
Builder.EmitByte((byte)immediate);
}
public void EmitJMP(ISymbolNode symbol)
{
if (symbol.RepresentsIndirectionCell)
{
Builder.EmitByte(0xff);
Builder.EmitByte(0x25);
Builder.EmitReloc(symbol, RelocType.IMAGE_REL_BASED_REL32);
}
else
{
Builder.EmitByte(0xE9);
Builder.EmitReloc(symbol, RelocType.IMAGE_REL_BASED_REL32);
}
}
public void EmitJE(ISymbolNode symbol)
{
if (symbol.RepresentsIndirectionCell)
{
throw new NotImplementedException();
}
else
{
Builder.EmitByte(0x0f);
Builder.EmitByte(0x84);
Builder.EmitReloc(symbol, RelocType.IMAGE_REL_BASED_REL32);
}
}
public void EmitINT3()
{
Builder.EmitByte(0xCC);
}
public void EmitJmpToAddrMode(ref AddrMode addrMode)
{
EmitIndirInstruction(0xFF, 0x4, ref addrMode);
}
public void EmitPUSH(sbyte imm8)
{
Builder.EmitByte(0x6A);
Builder.EmitByte(unchecked((byte)imm8));
}
public void EmitPUSH(ISymbolNode node)
{
if (node.RepresentsIndirectionCell)
{
// push [rip + relative node offset]
Builder.EmitByte(0xFF);
Builder.EmitByte(0x35);
Builder.EmitReloc(node, RelocType.IMAGE_REL_BASED_REL32);
}
else
{
// push rax (arbitrary value)
Builder.EmitByte(0x50);
// lea rax, [rip + relative node offset]
Builder.EmitByte(0x48);
Builder.EmitByte(0x8D);
Builder.EmitByte(0x05);
Builder.EmitReloc(node, RelocType.IMAGE_REL_BASED_REL32);
// xchg [rsp], rax; this also restores the previous value of rax
Builder.EmitByte(0x48);
Builder.EmitByte(0x87);
Builder.EmitByte(0x04);
Builder.EmitByte(0x24);
}
}
public void EmitRET()
{
Builder.EmitByte(0xC3);
}
public void EmitRETIfEqual()
{
// jne @+1
Builder.EmitByte(0x75);
Builder.EmitByte(0x01);
// ret
Builder.EmitByte(0xC3);
}
public void EmitCompareToZero(Register reg)
{
AddrMode rexAddrMode = new AddrMode(Register.RegDirect | reg, null, 0, 0, AddrModeSize.Int64);
EmitIndirInstructionSize(0x84, reg, ref rexAddrMode);
}
public void EmitZeroReg(Register reg)
{
// High 32 bits get cleared automatically when using 32bit registers
AddrMode rexAddrMode = new AddrMode(reg, null, 0, 0, AddrModeSize.Int32);
EmitRexPrefix(reg, ref rexAddrMode);
Builder.EmitByte(0x33);
Builder.EmitByte((byte)(0xC0 | (((int)reg & 0x07) << 3) | ((int)reg & 0x07)));
}
private bool InSignedByteRange(int i)
{
return i == (int)(sbyte)i;
}
private void EmitImmediate(int immediate, int size)
{
switch (size)
{
case 0:
break;
case 1:
Builder.EmitByte((byte)immediate);
break;
case 2:
Builder.EmitShort((short)immediate);
break;
case 4:
Builder.EmitInt(immediate);
break;
default:
throw new NotImplementedException();
}
}
private void EmitModRM(byte subOpcode, ref AddrMode addrMode)
{
byte modRM = (byte)((subOpcode & 0x07) << 3);
if (addrMode.BaseReg > Register.None)
{
Debug.Assert(addrMode.BaseReg >= Register.RegDirect);
Register reg = (Register)(addrMode.BaseReg - Register.RegDirect);
Builder.EmitByte((byte)(0xC0 | modRM | ((int)reg & 0x07)));
}
else
{
byte lowOrderBitsOfBaseReg = (byte)((int)addrMode.BaseReg & 0x07);
modRM |= lowOrderBitsOfBaseReg;
int offsetSize = 0;
if (addrMode.Offset == 0 && (lowOrderBitsOfBaseReg != (byte)Register.RBP))
{
offsetSize = 0;
}
else if (InSignedByteRange(addrMode.Offset))
{
offsetSize = 1;
modRM |= 0x40;
}
else
{
offsetSize = 4;
modRM |= 0x80;
}
bool emitSibByte = false;
Register sibByteBaseRegister = addrMode.BaseReg;
if (addrMode.BaseReg == Register.None)
{
//# ifdef _TARGET_AMD64_
// x64 requires SIB to avoid RIP relative address
emitSibByte = true;
//#else
// emitSibByte = (addrMode.m_indexReg != MDIL_REG_NO_INDEX);
//#endif
modRM &= 0x38; // set Mod bits to 00 and clear out base reg
offsetSize = 4; // this forces 32-bit displacement
if (emitSibByte)
{
// EBP in SIB byte means no base
// ModRM base register forced to ESP in SIB code below
sibByteBaseRegister = Register.RBP;
}
else
{
// EBP in ModRM means no base
modRM |= (byte)(Register.RBP);
}
}
else if (lowOrderBitsOfBaseReg == (byte)Register.RSP || addrMode.IndexReg.HasValue)
{
emitSibByte = true;
}
if (!emitSibByte)
{
Builder.EmitByte(modRM);
}
else
{
// MDIL_REG_ESP as the base is the marker that there is a SIB byte
modRM = (byte)((modRM & 0xF8) | (int)Register.RSP);
Builder.EmitByte(modRM);
int indexRegAsInt = (int)(addrMode.IndexReg.HasValue ? addrMode.IndexReg.Value : Register.RSP);
Builder.EmitByte((byte)((addrMode.Scale << 6) + ((indexRegAsInt & 0x07) << 3) + ((int)sibByteBaseRegister & 0x07)));
}
EmitImmediate(addrMode.Offset, offsetSize);
}
}
private void EmitExtendedOpcode(int opcode)
{
if ((opcode >> 16) != 0)
{
if ((opcode >> 24) != 0)
{
Builder.EmitByte((byte)(opcode >> 24));
}
Builder.EmitByte((byte)(opcode >> 16));
}
Builder.EmitByte((byte)(opcode >> 8));
}
private void EmitRexPrefix(Register reg, ref AddrMode addrMode)
{
byte rexPrefix = 0;
// Check the situations where a REX prefix is needed
// Are we accessing a byte register that wasn't byte accessible in x86?
if (addrMode.Size == AddrModeSize.Int8 && reg >= Register.RSP)
{
rexPrefix |= 0x40; // REX - access to new 8-bit registers
}
// Is this a 64 bit instruction?
if (addrMode.Size == AddrModeSize.Int64)
{
rexPrefix |= 0x48; // REX.W - 64-bit data operand
}
// Is the destination register one of the new ones?
if (reg >= Register.R8)
{
rexPrefix |= 0x44; // REX.R - extension of the register field
}
// Is the index register one of the new ones?
if (addrMode.IndexReg.HasValue && addrMode.IndexReg.Value >= Register.R8 && addrMode.IndexReg.Value <= Register.R15)
{
rexPrefix |= 0x42; // REX.X - extension of the SIB index field
}
// Is the base register one of the new ones?
if (addrMode.BaseReg >= Register.R8 && addrMode.BaseReg <= Register.R15
|| addrMode.BaseReg >= (int)Register.R8 + Register.RegDirect && addrMode.BaseReg <= (int)Register.R15 + Register.RegDirect)
{
rexPrefix |= 0x41; // REX.WB (Wide, extended Base)
}
// If we have anything so far, emit it.
if (rexPrefix != 0)
{
Builder.EmitByte(rexPrefix);
}
}
private void EmitIndirInstruction(int opcode, byte subOpcode, ref AddrMode addrMode)
{
EmitRexPrefix(Register.RAX, ref addrMode);
if ((opcode >> 8) != 0)
{
EmitExtendedOpcode(opcode);
}
Builder.EmitByte((byte)opcode);
EmitModRM(subOpcode, ref addrMode);
}
private void EmitIndirInstruction(int opcode, Register dstReg, ref AddrMode addrMode)
{
EmitRexPrefix(dstReg, ref addrMode);
if ((opcode >> 8) != 0)
{
EmitExtendedOpcode(opcode);
}
Builder.EmitByte((byte)opcode);
EmitModRM((byte)((int)dstReg & 0x07), ref addrMode);
}
private void EmitIndirInstructionSize(int opcode, Register dstReg, ref AddrMode addrMode)
{
//# ifndef _TARGET_AMD64_
// assert that ESP, EBP, ESI, EDI are not accessed as bytes in 32-bit mode
// Debug.Assert(!(addrMode.Size == AddrModeSize.Int8 && dstReg > Register.RBX));
//#endif
Debug.Assert(addrMode.Size != 0);
if (addrMode.Size == AddrModeSize.Int16)
Builder.EmitByte(0x66);
EmitIndirInstruction(opcode + ((addrMode.Size != AddrModeSize.Int8) ? 1 : 0), dstReg, ref addrMode);
}
}
}
| // 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.Diagnostics;
namespace ILCompiler.DependencyAnalysis.X64
{
public struct X64Emitter
{
public X64Emitter(NodeFactory factory, bool relocsOnly)
{
Builder = new ObjectDataBuilder(factory, relocsOnly);
TargetRegister = new TargetRegisterMap(factory.Target.OperatingSystem);
}
public ObjectDataBuilder Builder;
public TargetRegisterMap TargetRegister;
// Assembly stub creation api. TBD, actually make this general purpose
public void EmitMOV(Register regDst, ref AddrMode memory)
{
EmitIndirInstructionSize(0x8a, regDst, ref memory);
}
public void EmitMOV(Register regDst, Register regSrc)
{
AddrMode rexAddrMode = new AddrMode(regSrc, null, 0, 0, AddrModeSize.Int64);
EmitRexPrefix(regDst, ref rexAddrMode);
Builder.EmitByte(0x8B);
Builder.EmitByte((byte)(0xC0 | (((int)regDst & 0x07) << 3) | (((int)regSrc & 0x07))));
}
public void EmitMOV(Register regDst, int imm32)
{
AddrMode rexAddrMode = new AddrMode(regDst, null, 0, 0, AddrModeSize.Int32);
EmitRexPrefix(regDst, ref rexAddrMode);
Builder.EmitByte((byte)(0xB8 | ((int)regDst & 0x07)));
Builder.EmitInt(imm32);
}
public void EmitMOV(Register regDst, ISymbolNode node)
{
if (node.RepresentsIndirectionCell)
{
Builder.EmitByte(0x67);
Builder.EmitByte(0x48);
Builder.EmitByte(0x8B);
Builder.EmitByte((byte)(0x00 | ((byte)regDst << 3) | 0x05));
Builder.EmitReloc(node, RelocType.IMAGE_REL_BASED_REL32);
}
else
{
EmitLEAQ(regDst, node, delta: 0);
}
}
public void EmitLEAQ(Register reg, ISymbolNode symbol, int delta = 0)
{
AddrMode rexAddrMode = new AddrMode(Register.RAX, null, 0, 0, AddrModeSize.Int64);
EmitRexPrefix(reg, ref rexAddrMode);
Builder.EmitByte(0x8D);
Builder.EmitByte((byte)(0x05 | (((int)reg) & 0x07) << 3));
Builder.EmitReloc(symbol, RelocType.IMAGE_REL_BASED_REL32, delta);
}
public void EmitLEA(Register reg, ref AddrMode addrMode)
{
Debug.Assert(addrMode.Size != AddrModeSize.Int8 &&
addrMode.Size != AddrModeSize.Int16);
EmitIndirInstruction(0x8D, reg, ref addrMode);
}
public void EmitCMP(ref AddrMode addrMode, sbyte immediate)
{
if (addrMode.Size == AddrModeSize.Int16)
Builder.EmitByte(0x66);
EmitIndirInstruction((byte)((addrMode.Size != AddrModeSize.Int8) ? 0x83 : 0x80), 0x7, ref addrMode);
Builder.EmitByte((byte)immediate);
}
public void EmitADD(ref AddrMode addrMode, sbyte immediate)
{
if (addrMode.Size == AddrModeSize.Int16)
Builder.EmitByte(0x66);
EmitIndirInstruction((byte)((addrMode.Size != AddrModeSize.Int8) ? 0x83 : 0x80), (byte)0, ref addrMode);
Builder.EmitByte((byte)immediate);
}
public void EmitJMP(ISymbolNode symbol)
{
if (symbol.RepresentsIndirectionCell)
{
Builder.EmitByte(0xff);
Builder.EmitByte(0x25);
Builder.EmitReloc(symbol, RelocType.IMAGE_REL_BASED_REL32);
}
else
{
Builder.EmitByte(0xE9);
Builder.EmitReloc(symbol, RelocType.IMAGE_REL_BASED_REL32);
}
}
public void EmitJE(ISymbolNode symbol)
{
if (symbol.RepresentsIndirectionCell)
{
throw new NotImplementedException();
}
else
{
Builder.EmitByte(0x0f);
Builder.EmitByte(0x84);
Builder.EmitReloc(symbol, RelocType.IMAGE_REL_BASED_REL32);
}
}
public void EmitINT3()
{
Builder.EmitByte(0xCC);
}
public void EmitJmpToAddrMode(ref AddrMode addrMode)
{
EmitIndirInstruction(0xFF, 0x4, ref addrMode);
}
public void EmitPUSH(sbyte imm8)
{
Builder.EmitByte(0x6A);
Builder.EmitByte(unchecked((byte)imm8));
}
public void EmitPUSH(ISymbolNode node)
{
if (node.RepresentsIndirectionCell)
{
// push [rip + relative node offset]
Builder.EmitByte(0xFF);
Builder.EmitByte(0x35);
Builder.EmitReloc(node, RelocType.IMAGE_REL_BASED_REL32);
}
else
{
// push rax (arbitrary value)
Builder.EmitByte(0x50);
// lea rax, [rip + relative node offset]
Builder.EmitByte(0x48);
Builder.EmitByte(0x8D);
Builder.EmitByte(0x05);
Builder.EmitReloc(node, RelocType.IMAGE_REL_BASED_REL32);
// xchg [rsp], rax; this also restores the previous value of rax
Builder.EmitByte(0x48);
Builder.EmitByte(0x87);
Builder.EmitByte(0x04);
Builder.EmitByte(0x24);
}
}
public void EmitRET()
{
Builder.EmitByte(0xC3);
}
public void EmitRETIfEqual()
{
// jne @+1
Builder.EmitByte(0x75);
Builder.EmitByte(0x01);
// ret
Builder.EmitByte(0xC3);
}
public void EmitCompareToZero(Register reg)
{
AddrMode rexAddrMode = new AddrMode(Register.RegDirect | reg, null, 0, 0, AddrModeSize.Int64);
EmitIndirInstructionSize(0x84, reg, ref rexAddrMode);
}
public void EmitZeroReg(Register reg)
{
// High 32 bits get cleared automatically when using 32bit registers
AddrMode rexAddrMode = new AddrMode(reg, null, 0, 0, AddrModeSize.Int32);
EmitRexPrefix(reg, ref rexAddrMode);
Builder.EmitByte(0x33);
Builder.EmitByte((byte)(0xC0 | (((int)reg & 0x07) << 3) | ((int)reg & 0x07)));
}
private bool InSignedByteRange(int i)
{
return i == (int)(sbyte)i;
}
private void EmitImmediate(int immediate, int size)
{
switch (size)
{
case 0:
break;
case 1:
Builder.EmitByte((byte)immediate);
break;
case 2:
Builder.EmitShort((short)immediate);
break;
case 4:
Builder.EmitInt(immediate);
break;
default:
throw new NotImplementedException();
}
}
private void EmitModRM(byte subOpcode, ref AddrMode addrMode)
{
byte modRM = (byte)((subOpcode & 0x07) << 3);
if (addrMode.BaseReg > Register.None)
{
Debug.Assert(addrMode.BaseReg >= Register.RegDirect);
Register reg = (Register)(addrMode.BaseReg - Register.RegDirect);
Builder.EmitByte((byte)(0xC0 | modRM | ((int)reg & 0x07)));
}
else
{
byte lowOrderBitsOfBaseReg = (byte)((int)addrMode.BaseReg & 0x07);
modRM |= lowOrderBitsOfBaseReg;
int offsetSize = 0;
if (addrMode.Offset == 0 && (lowOrderBitsOfBaseReg != (byte)Register.RBP))
{
offsetSize = 0;
}
else if (InSignedByteRange(addrMode.Offset))
{
offsetSize = 1;
modRM |= 0x40;
}
else
{
offsetSize = 4;
modRM |= 0x80;
}
bool emitSibByte = false;
Register sibByteBaseRegister = addrMode.BaseReg;
if (addrMode.BaseReg == Register.None)
{
//# ifdef _TARGET_AMD64_
// x64 requires SIB to avoid RIP relative address
emitSibByte = true;
//#else
// emitSibByte = (addrMode.m_indexReg != MDIL_REG_NO_INDEX);
//#endif
modRM &= 0x38; // set Mod bits to 00 and clear out base reg
offsetSize = 4; // this forces 32-bit displacement
if (emitSibByte)
{
// EBP in SIB byte means no base
// ModRM base register forced to ESP in SIB code below
sibByteBaseRegister = Register.RBP;
}
else
{
// EBP in ModRM means no base
modRM |= (byte)(Register.RBP);
}
}
else if (lowOrderBitsOfBaseReg == (byte)Register.RSP || addrMode.IndexReg.HasValue)
{
emitSibByte = true;
}
if (!emitSibByte)
{
Builder.EmitByte(modRM);
}
else
{
// MDIL_REG_ESP as the base is the marker that there is a SIB byte
modRM = (byte)((modRM & 0xF8) | (int)Register.RSP);
Builder.EmitByte(modRM);
int indexRegAsInt = (int)(addrMode.IndexReg.HasValue ? addrMode.IndexReg.Value : Register.RSP);
Builder.EmitByte((byte)((addrMode.Scale << 6) + ((indexRegAsInt & 0x07) << 3) + ((int)sibByteBaseRegister & 0x07)));
}
EmitImmediate(addrMode.Offset, offsetSize);
}
}
private void EmitExtendedOpcode(int opcode)
{
if ((opcode >> 16) != 0)
{
if ((opcode >> 24) != 0)
{
Builder.EmitByte((byte)(opcode >> 24));
}
Builder.EmitByte((byte)(opcode >> 16));
}
Builder.EmitByte((byte)(opcode >> 8));
}
private void EmitRexPrefix(Register reg, ref AddrMode addrMode)
{
byte rexPrefix = 0;
// Check the situations where a REX prefix is needed
// Are we accessing a byte register that wasn't byte accessible in x86?
if (addrMode.Size == AddrModeSize.Int8 && reg >= Register.RSP)
{
rexPrefix |= 0x40; // REX - access to new 8-bit registers
}
// Is this a 64 bit instruction?
if (addrMode.Size == AddrModeSize.Int64)
{
rexPrefix |= 0x48; // REX.W - 64-bit data operand
}
// Is the destination register one of the new ones?
if (reg >= Register.R8)
{
rexPrefix |= 0x44; // REX.R - extension of the register field
}
// Is the index register one of the new ones?
if (addrMode.IndexReg.HasValue && addrMode.IndexReg.Value >= Register.R8 && addrMode.IndexReg.Value <= Register.R15)
{
rexPrefix |= 0x42; // REX.X - extension of the SIB index field
}
// Is the base register one of the new ones?
if (addrMode.BaseReg >= Register.R8 && addrMode.BaseReg <= Register.R15
|| addrMode.BaseReg >= (int)Register.R8 + Register.RegDirect && addrMode.BaseReg <= (int)Register.R15 + Register.RegDirect)
{
rexPrefix |= 0x41; // REX.WB (Wide, extended Base)
}
// If we have anything so far, emit it.
if (rexPrefix != 0)
{
Builder.EmitByte(rexPrefix);
}
}
private void EmitIndirInstruction(int opcode, byte subOpcode, ref AddrMode addrMode)
{
EmitRexPrefix(Register.RAX, ref addrMode);
if ((opcode >> 8) != 0)
{
EmitExtendedOpcode(opcode);
}
Builder.EmitByte((byte)opcode);
EmitModRM(subOpcode, ref addrMode);
}
private void EmitIndirInstruction(int opcode, Register dstReg, ref AddrMode addrMode)
{
EmitRexPrefix(dstReg, ref addrMode);
if ((opcode >> 8) != 0)
{
EmitExtendedOpcode(opcode);
}
Builder.EmitByte((byte)opcode);
EmitModRM((byte)((int)dstReg & 0x07), ref addrMode);
}
private void EmitIndirInstructionSize(int opcode, Register dstReg, ref AddrMode addrMode)
{
//# ifndef _TARGET_AMD64_
// assert that ESP, EBP, ESI, EDI are not accessed as bytes in 32-bit mode
// Debug.Assert(!(addrMode.Size == AddrModeSize.Int8 && dstReg > Register.RBX));
//#endif
Debug.Assert(addrMode.Size != 0);
if (addrMode.Size == AddrModeSize.Int16)
Builder.EmitByte(0x66);
EmitIndirInstruction(opcode + ((addrMode.Size != AddrModeSize.Int8) ? 1 : 0), dstReg, ref addrMode);
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/mono/mono/tests/test-tls.cs | using System;
using System.Threading;
public class Program
{
public const int nr_threads = 4;
public const int reps = 10000;
public static int[] allocs = new int[nr_threads];
public Program (int index)
{
allocs [index] += 1;
}
public static void Work (object oindex)
{
int index = (int)oindex;
for (int i = 0; i < reps; i++) {
Thread thread = Thread.CurrentThread;
if (string.Compare (thread.Name, "t" + index) == 0)
new Program (index);
}
}
public static int Main (string[] args)
{
Thread[] threads = new Thread[nr_threads];
for (int i = 0; i < nr_threads; i++) {
threads [i] = new Thread (Work);
threads [i].Name = "t" + i;
threads [i].Start (i);
}
for (int i = 0; i < nr_threads; i++) {
threads [i].Join ();
if (allocs [i] != reps)
return 1;
}
return 0;
}
}
| using System;
using System.Threading;
public class Program
{
public const int nr_threads = 4;
public const int reps = 10000;
public static int[] allocs = new int[nr_threads];
public Program (int index)
{
allocs [index] += 1;
}
public static void Work (object oindex)
{
int index = (int)oindex;
for (int i = 0; i < reps; i++) {
Thread thread = Thread.CurrentThread;
if (string.Compare (thread.Name, "t" + index) == 0)
new Program (index);
}
}
public static int Main (string[] args)
{
Thread[] threads = new Thread[nr_threads];
for (int i = 0; i < nr_threads; i++) {
threads [i] = new Thread (Work);
threads [i].Name = "t" + i;
threads [i].Start (i);
}
for (int i = 0; i < nr_threads; i++) {
threads [i].Join ();
if (allocs [i] != reps)
return 1;
}
return 0;
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.ComponentModel.Composition/tests/System/ComponentModel/Composition/Hosting/ImportEngineTests.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.ComponentModel.Composition.Factories;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Primitives;
using Xunit;
namespace System.ComponentModel.Composition
{
public class ImportEngineTests
{
[Fact]
public void PreviewImports_Successful_NoAtomicComposition_ShouldBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value");
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 21);
engine.PreviewImports(importer, null);
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.AddExport("Value", 22));
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.RemoveExport("Value"));
GC.KeepAlive(importer);
}
[Fact]
public void PreviewImports_Unsuccessful_NoAtomicComposition_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value");
var importer = PartFactory.CreateImporter(import);
Assert.Throws<CompositionException>(() =>
engine.PreviewImports(importer, null));
exportProvider.AddExport("Value", 22);
exportProvider.AddExport("Value", 23);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
[Fact]
public void PreviewImports_Successful_AtomicComposition_Completeted_ShouldBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value");
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 21);
using (var atomicComposition = new AtomicComposition())
{
engine.PreviewImports(importer, atomicComposition);
atomicComposition.Complete();
}
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.AddExport("Value", 22));
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.RemoveExport("Value"));
GC.KeepAlive(importer);
}
[Fact]
public void PreviewImports_Successful_AtomicComposition_RolledBack_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value");
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 21);
using (var atomicComposition = new AtomicComposition())
{
engine.PreviewImports(importer, atomicComposition);
// Let atomicComposition get disposed thus rolledback
}
exportProvider.AddExport("Value", 22);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
[Fact]
public void PreviewImports_Unsuccessful_AtomicComposition_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value");
var importer = PartFactory.CreateImporter(import);
using (var atomicComposition = new AtomicComposition())
{
Assert.Throws<ChangeRejectedException>(() =>
engine.PreviewImports(importer, atomicComposition));
}
exportProvider.AddExport("Value", 22);
exportProvider.AddExport("Value", 23);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
[Fact]
public void PreviewImports_ReleaseImports_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value");
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 21);
engine.PreviewImports(importer, null);
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.AddExport("Value", 22));
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.RemoveExport("Value"));
engine.ReleaseImports(importer, null);
exportProvider.AddExport("Value", 22);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
[Fact]
public void PreviewImports_MissingOptionalImport_ShouldSucceed()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", ImportCardinality.ZeroOrOne);
var importer = PartFactory.CreateImporter(import);
engine.PreviewImports(importer, null);
GC.KeepAlive(importer);
}
[Fact]
public void PreviewImports_ZeroCollectionImport_ShouldSucceed()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", ImportCardinality.ZeroOrMore);
var importer = PartFactory.CreateImporter(import);
engine.PreviewImports(importer, null);
GC.KeepAlive(importer);
}
[Fact]
public void PreviewImports_MissingOptionalImport_NonRecomposable_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", ImportCardinality.ZeroOrOne, false, false);
var importer = PartFactory.CreateImporter(import);
engine.PreviewImports(importer, null);
exportProvider.AddExport("Value", 21);
exportProvider.AddExport("Value", 22);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
[Fact]
public void PreviewImports_ZeroCollectionImport_NonRecomposable_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", ImportCardinality.ZeroOrMore, false, false);
var importer = PartFactory.CreateImporter(import);
engine.PreviewImports(importer, null);
exportProvider.AddExport("Value", 21);
exportProvider.AddExport("Value", 22);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_NonRecomposable_ValueShouldNotChange()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
exportProvider.AddExport("Value", 21);
var import = ImportDefinitionFactory.Create("Value", false);
var importer = PartFactory.CreateImporter(import);
engine.SatisfyImports(importer);
Assert.Equal(21, importer.GetImport(import));
// After rejection batch failures throw ChangeRejectedException to indicate that
// the failure did not affect the container
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.ReplaceExportValue("Value", 42));
Assert.Equal(21, importer.GetImport(import));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_Recomposable_ValueShouldChange()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
exportProvider.AddExport("Value", 21);
var import = ImportDefinitionFactory.Create("Value", true);
var importer = PartFactory.CreateImporter(import);
engine.SatisfyImports(importer);
Assert.Equal(21, importer.GetImport(import));
exportProvider.ReplaceExportValue("Value", 42);
Assert.Equal(42, importer.GetImport(import));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_NonRecomposable_Prerequisite_ValueShouldNotChange()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", false, true);
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 21);
engine.SatisfyImports(importer);
Assert.Equal(21, importer.GetImport(import));
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.ReplaceExportValue("Value", 42));
Assert.Equal(21, importer.GetImport(import));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_Recomposable_Prerequisite_ValueShouldChange()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", true, true);
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 21);
engine.SatisfyImports(importer);
Assert.Equal(21, importer.GetImport(import));
exportProvider.ReplaceExportValue("Value", 42);
Assert.Equal(42, importer.GetImport(import));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_OneRecomposable_OneNotRecomposable()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import1 = ImportDefinitionFactory.Create("Value", true);
var import2 = ImportDefinitionFactory.Create("Value", false);
var importer = PartFactory.CreateImporter(import1, import2);
exportProvider.AddExport("Value", 21);
engine.SatisfyImports(importer);
// Initial compose values should be 21
Assert.Equal(21, importer.GetImport(import1));
Assert.Equal(21, importer.GetImport(import2));
// Reset value to ensure it doesn't get set to same value again
importer.ResetImport(import1);
importer.ResetImport(import2);
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.ReplaceExportValue("Value", 42));
Assert.Null(importer.GetImport(import1));
Assert.Null(importer.GetImport(import2));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_TwoRecomposables_SingleExportValueChanged()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import1 = ImportDefinitionFactory.Create("Value1", true);
var import2 = ImportDefinitionFactory.Create("Value2", true);
var importer = PartFactory.CreateImporter(import1, import2);
exportProvider.AddExport("Value1", 21);
exportProvider.AddExport("Value2", 23);
engine.SatisfyImports(importer);
Assert.Equal(21, importer.GetImport(import1));
Assert.Equal(23, importer.GetImport(import2));
importer.ResetImport(import1);
importer.ResetImport(import2);
// Only change Value1
exportProvider.ReplaceExportValue("Value1", 42);
Assert.Equal(42, importer.GetImport(import1));
Assert.Null(importer.GetImport(import2));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_Recomposable_Unregister_ValueShouldChangeOnce()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
exportProvider.AddExport("Value", 21);
var import = ImportDefinitionFactory.Create("Value", true);
var importer = PartFactory.CreateImporter(import);
engine.SatisfyImports(importer);
Assert.Equal(21, importer.GetImport(import));
exportProvider.ReplaceExportValue("Value", 42);
Assert.Equal(42, importer.GetImport(import));
engine.ReleaseImports(importer, null);
exportProvider.ReplaceExportValue("Value", 666);
Assert.Equal(42, importer.GetImport(import));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_MissingOptionalImport_NonRecomposable_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", ImportCardinality.ZeroOrOne, false, false);
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 20);
engine.SatisfyImports(importer);
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.AddExport("Value", 21));
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.RemoveExport("Value"));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_ZeroCollectionImport_NonRecomposable_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", ImportCardinality.ZeroOrMore, false, false);
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 20);
engine.SatisfyImports(importer);
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.AddExport("Value", 21));
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.RemoveExport("Value"));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_MissingOptionalImport_Recomposable_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", ImportCardinality.ZeroOrOne, true, false);
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 20);
engine.SatisfyImports(importer);
exportProvider.AddExport("Value", 21);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_ZeroCollectionImport_Recomposable_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", ImportCardinality.ZeroOrMore, true, false);
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 20);
engine.SatisfyImports(importer);
exportProvider.AddExport("Value", 21);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImportsOnce_Recomposable_ValueShouldNotChange_NoRecompositionRequested()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
exportProvider.AddExport("Value", 21);
var import = ImportDefinitionFactory.Create("Value", true);
var importer = PartFactory.CreateImporter(import);
engine.SatisfyImportsOnce(importer);
Assert.Equal(21, importer.GetImport(import));
exportProvider.ReplaceExportValue("Value", 42);
Assert.Equal(21, importer.GetImport(import));
GC.KeepAlive(importer);
}
[Fact]
public void SatisifyImportsOnce_Recomposable_ValueShouldNotChange_NoRecompositionRequested_ViaNonArgumentSignature()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
exportProvider.AddExport("Value", 21);
var import = ImportDefinitionFactory.Create("Value", true);
var importer = PartFactory.CreateImporter(import);
engine.SatisfyImportsOnce(importer);
Assert.Equal(21, importer.GetImport(import));
exportProvider.ReplaceExportValue("Value", 42);
Assert.Equal(21, importer.GetImport(import));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImportsOnce_Successful_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value");
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 21);
engine.SatisfyImportsOnce(importer);
exportProvider.AddExport("Value", 22);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImportsOnce_Unsuccessful_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value");
var importer = PartFactory.CreateImporter(import);
Assert.Throws<CompositionException>(() =>
engine.SatisfyImportsOnce(importer));
exportProvider.AddExport("Value", 22);
exportProvider.AddExport("Value", 23);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.ComponentModel.Composition.Factories;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Primitives;
using Xunit;
namespace System.ComponentModel.Composition
{
public class ImportEngineTests
{
[Fact]
public void PreviewImports_Successful_NoAtomicComposition_ShouldBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value");
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 21);
engine.PreviewImports(importer, null);
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.AddExport("Value", 22));
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.RemoveExport("Value"));
GC.KeepAlive(importer);
}
[Fact]
public void PreviewImports_Unsuccessful_NoAtomicComposition_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value");
var importer = PartFactory.CreateImporter(import);
Assert.Throws<CompositionException>(() =>
engine.PreviewImports(importer, null));
exportProvider.AddExport("Value", 22);
exportProvider.AddExport("Value", 23);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
[Fact]
public void PreviewImports_Successful_AtomicComposition_Completeted_ShouldBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value");
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 21);
using (var atomicComposition = new AtomicComposition())
{
engine.PreviewImports(importer, atomicComposition);
atomicComposition.Complete();
}
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.AddExport("Value", 22));
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.RemoveExport("Value"));
GC.KeepAlive(importer);
}
[Fact]
public void PreviewImports_Successful_AtomicComposition_RolledBack_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value");
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 21);
using (var atomicComposition = new AtomicComposition())
{
engine.PreviewImports(importer, atomicComposition);
// Let atomicComposition get disposed thus rolledback
}
exportProvider.AddExport("Value", 22);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
[Fact]
public void PreviewImports_Unsuccessful_AtomicComposition_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value");
var importer = PartFactory.CreateImporter(import);
using (var atomicComposition = new AtomicComposition())
{
Assert.Throws<ChangeRejectedException>(() =>
engine.PreviewImports(importer, atomicComposition));
}
exportProvider.AddExport("Value", 22);
exportProvider.AddExport("Value", 23);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
[Fact]
public void PreviewImports_ReleaseImports_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value");
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 21);
engine.PreviewImports(importer, null);
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.AddExport("Value", 22));
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.RemoveExport("Value"));
engine.ReleaseImports(importer, null);
exportProvider.AddExport("Value", 22);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
[Fact]
public void PreviewImports_MissingOptionalImport_ShouldSucceed()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", ImportCardinality.ZeroOrOne);
var importer = PartFactory.CreateImporter(import);
engine.PreviewImports(importer, null);
GC.KeepAlive(importer);
}
[Fact]
public void PreviewImports_ZeroCollectionImport_ShouldSucceed()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", ImportCardinality.ZeroOrMore);
var importer = PartFactory.CreateImporter(import);
engine.PreviewImports(importer, null);
GC.KeepAlive(importer);
}
[Fact]
public void PreviewImports_MissingOptionalImport_NonRecomposable_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", ImportCardinality.ZeroOrOne, false, false);
var importer = PartFactory.CreateImporter(import);
engine.PreviewImports(importer, null);
exportProvider.AddExport("Value", 21);
exportProvider.AddExport("Value", 22);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
[Fact]
public void PreviewImports_ZeroCollectionImport_NonRecomposable_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", ImportCardinality.ZeroOrMore, false, false);
var importer = PartFactory.CreateImporter(import);
engine.PreviewImports(importer, null);
exportProvider.AddExport("Value", 21);
exportProvider.AddExport("Value", 22);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_NonRecomposable_ValueShouldNotChange()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
exportProvider.AddExport("Value", 21);
var import = ImportDefinitionFactory.Create("Value", false);
var importer = PartFactory.CreateImporter(import);
engine.SatisfyImports(importer);
Assert.Equal(21, importer.GetImport(import));
// After rejection batch failures throw ChangeRejectedException to indicate that
// the failure did not affect the container
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.ReplaceExportValue("Value", 42));
Assert.Equal(21, importer.GetImport(import));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_Recomposable_ValueShouldChange()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
exportProvider.AddExport("Value", 21);
var import = ImportDefinitionFactory.Create("Value", true);
var importer = PartFactory.CreateImporter(import);
engine.SatisfyImports(importer);
Assert.Equal(21, importer.GetImport(import));
exportProvider.ReplaceExportValue("Value", 42);
Assert.Equal(42, importer.GetImport(import));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_NonRecomposable_Prerequisite_ValueShouldNotChange()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", false, true);
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 21);
engine.SatisfyImports(importer);
Assert.Equal(21, importer.GetImport(import));
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.ReplaceExportValue("Value", 42));
Assert.Equal(21, importer.GetImport(import));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_Recomposable_Prerequisite_ValueShouldChange()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", true, true);
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 21);
engine.SatisfyImports(importer);
Assert.Equal(21, importer.GetImport(import));
exportProvider.ReplaceExportValue("Value", 42);
Assert.Equal(42, importer.GetImport(import));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_OneRecomposable_OneNotRecomposable()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import1 = ImportDefinitionFactory.Create("Value", true);
var import2 = ImportDefinitionFactory.Create("Value", false);
var importer = PartFactory.CreateImporter(import1, import2);
exportProvider.AddExport("Value", 21);
engine.SatisfyImports(importer);
// Initial compose values should be 21
Assert.Equal(21, importer.GetImport(import1));
Assert.Equal(21, importer.GetImport(import2));
// Reset value to ensure it doesn't get set to same value again
importer.ResetImport(import1);
importer.ResetImport(import2);
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.ReplaceExportValue("Value", 42));
Assert.Null(importer.GetImport(import1));
Assert.Null(importer.GetImport(import2));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_TwoRecomposables_SingleExportValueChanged()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import1 = ImportDefinitionFactory.Create("Value1", true);
var import2 = ImportDefinitionFactory.Create("Value2", true);
var importer = PartFactory.CreateImporter(import1, import2);
exportProvider.AddExport("Value1", 21);
exportProvider.AddExport("Value2", 23);
engine.SatisfyImports(importer);
Assert.Equal(21, importer.GetImport(import1));
Assert.Equal(23, importer.GetImport(import2));
importer.ResetImport(import1);
importer.ResetImport(import2);
// Only change Value1
exportProvider.ReplaceExportValue("Value1", 42);
Assert.Equal(42, importer.GetImport(import1));
Assert.Null(importer.GetImport(import2));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_Recomposable_Unregister_ValueShouldChangeOnce()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
exportProvider.AddExport("Value", 21);
var import = ImportDefinitionFactory.Create("Value", true);
var importer = PartFactory.CreateImporter(import);
engine.SatisfyImports(importer);
Assert.Equal(21, importer.GetImport(import));
exportProvider.ReplaceExportValue("Value", 42);
Assert.Equal(42, importer.GetImport(import));
engine.ReleaseImports(importer, null);
exportProvider.ReplaceExportValue("Value", 666);
Assert.Equal(42, importer.GetImport(import));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_MissingOptionalImport_NonRecomposable_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", ImportCardinality.ZeroOrOne, false, false);
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 20);
engine.SatisfyImports(importer);
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.AddExport("Value", 21));
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.RemoveExport("Value"));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_ZeroCollectionImport_NonRecomposable_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", ImportCardinality.ZeroOrMore, false, false);
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 20);
engine.SatisfyImports(importer);
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.AddExport("Value", 21));
Assert.Throws<ChangeRejectedException>(() =>
exportProvider.RemoveExport("Value"));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_MissingOptionalImport_Recomposable_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", ImportCardinality.ZeroOrOne, true, false);
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 20);
engine.SatisfyImports(importer);
exportProvider.AddExport("Value", 21);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImports_ZeroCollectionImport_Recomposable_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value", ImportCardinality.ZeroOrMore, true, false);
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 20);
engine.SatisfyImports(importer);
exportProvider.AddExport("Value", 21);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImportsOnce_Recomposable_ValueShouldNotChange_NoRecompositionRequested()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
exportProvider.AddExport("Value", 21);
var import = ImportDefinitionFactory.Create("Value", true);
var importer = PartFactory.CreateImporter(import);
engine.SatisfyImportsOnce(importer);
Assert.Equal(21, importer.GetImport(import));
exportProvider.ReplaceExportValue("Value", 42);
Assert.Equal(21, importer.GetImport(import));
GC.KeepAlive(importer);
}
[Fact]
public void SatisifyImportsOnce_Recomposable_ValueShouldNotChange_NoRecompositionRequested_ViaNonArgumentSignature()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
exportProvider.AddExport("Value", 21);
var import = ImportDefinitionFactory.Create("Value", true);
var importer = PartFactory.CreateImporter(import);
engine.SatisfyImportsOnce(importer);
Assert.Equal(21, importer.GetImport(import));
exportProvider.ReplaceExportValue("Value", 42);
Assert.Equal(21, importer.GetImport(import));
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImportsOnce_Successful_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value");
var importer = PartFactory.CreateImporter(import);
exportProvider.AddExport("Value", 21);
engine.SatisfyImportsOnce(importer);
exportProvider.AddExport("Value", 22);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
[Fact]
public void SatisfyImportsOnce_Unsuccessful_ShouldNotBlockChanges()
{
var exportProvider = ExportProviderFactory.CreateRecomposable();
var engine = new ImportEngine(exportProvider);
var import = ImportDefinitionFactory.Create("Value");
var importer = PartFactory.CreateImporter(import);
Assert.Throws<CompositionException>(() =>
engine.SatisfyImportsOnce(importer));
exportProvider.AddExport("Value", 22);
exportProvider.AddExport("Value", 23);
exportProvider.RemoveExport("Value");
GC.KeepAlive(importer);
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/baseservices/threading/generics/WaitCallback/thread03.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.Threading;
class Gen
{
public void Target<U>(object p)
{
//dummy line to avoid warnings
Test_thread03.Eval(typeof(U)!=p.GetType());
ManualResetEvent evt = (ManualResetEvent) p;
Interlocked.Increment(ref Test_thread03.Xcounter);
evt.Set();
}
public static void ThreadPoolTest<U>()
{
ManualResetEvent[] evts = new ManualResetEvent[Test_thread03.nThreads];
WaitHandle[] hdls = new WaitHandle[Test_thread03.nThreads];
for (int i=0; i<Test_thread03.nThreads; i++)
{
evts[i] = new ManualResetEvent(false);
hdls[i] = (WaitHandle) evts[i];
}
Gen obj = new Gen();
for (int i = 0; i < Test_thread03.nThreads; i++)
{
WaitCallback cb = new WaitCallback(obj.Target<U>);
ThreadPool.QueueUserWorkItem(cb,evts[i]);
}
WaitHandle.WaitAll(hdls);
Test_thread03.Eval(Test_thread03.Xcounter==Test_thread03.nThreads);
Test_thread03.Xcounter = 0;
}
}
public class Test_thread03
{
public static int nThreads =50;
public static int counter = 0;
public static int Xcounter = 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()
{
Gen.ThreadPoolTest<object>();
Gen.ThreadPoolTest<string>();
Gen.ThreadPoolTest<Guid>();
Gen.ThreadPoolTest<int>();
Gen.ThreadPoolTest<double>();
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;
using System.Threading;
class Gen
{
public void Target<U>(object p)
{
//dummy line to avoid warnings
Test_thread03.Eval(typeof(U)!=p.GetType());
ManualResetEvent evt = (ManualResetEvent) p;
Interlocked.Increment(ref Test_thread03.Xcounter);
evt.Set();
}
public static void ThreadPoolTest<U>()
{
ManualResetEvent[] evts = new ManualResetEvent[Test_thread03.nThreads];
WaitHandle[] hdls = new WaitHandle[Test_thread03.nThreads];
for (int i=0; i<Test_thread03.nThreads; i++)
{
evts[i] = new ManualResetEvent(false);
hdls[i] = (WaitHandle) evts[i];
}
Gen obj = new Gen();
for (int i = 0; i < Test_thread03.nThreads; i++)
{
WaitCallback cb = new WaitCallback(obj.Target<U>);
ThreadPool.QueueUserWorkItem(cb,evts[i]);
}
WaitHandle.WaitAll(hdls);
Test_thread03.Eval(Test_thread03.Xcounter==Test_thread03.nThreads);
Test_thread03.Xcounter = 0;
}
}
public class Test_thread03
{
public static int nThreads =50;
public static int counter = 0;
public static int Xcounter = 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()
{
Gen.ThreadPoolTest<object>();
Gen.ThreadPoolTest<string>();
Gen.ThreadPoolTest<Guid>();
Gen.ThreadPoolTest<int>();
Gen.ThreadPoolTest<double>();
if (result)
{
Console.WriteLine("Test Passed");
return 100;
}
else
{
Console.WriteLine("Test Failed");
return 1;
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/HardwareIntrinsics/General/Vector256/CreateScalarUnsafe.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\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 CreateScalarUnsafeByte()
{
var test = new VectorCreate__CreateScalarUnsafeByte();
// 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 VectorCreate__CreateScalarUnsafeByte
{
private static readonly int LargestVectorSize = 32;
private static readonly int ElementCount = Unsafe.SizeOf<Vector256<Byte>>() / sizeof(Byte);
public bool Succeeded { get; set; } = true;
public void RunBasicScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario));
Byte value = TestLibrary.Generator.GetByte();
Vector256<Byte> result = Vector256.CreateScalarUnsafe(value);
ValidateResult(result, value);
}
public void RunReflectionScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario));
Byte value = TestLibrary.Generator.GetByte();
object result = typeof(Vector256)
.GetMethod(nameof(Vector256.CreateScalarUnsafe), new Type[] { typeof(Byte) })
.Invoke(null, new object[] { value });
ValidateResult((Vector256<Byte>)(result), value);
}
private void ValidateResult(Vector256<Byte> result, Byte expectedValue, [CallerMemberName] string method = "")
{
Byte[] resultElements = new Byte[ElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref resultElements[0]), result);
ValidateResult(resultElements, expectedValue, method);
}
private void ValidateResult(Byte[] resultElements, Byte expectedValue, [CallerMemberName] string method = "")
{
bool succeeded = true;
if (resultElements[0] != expectedValue)
{
succeeded = false;
}
else
{
for (var i = 1; i < ElementCount; i++)
{
if (false /* value is uninitialized */)
{
succeeded = false;
break;
}
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"Vector256.CreateScalarUnsafe(Byte): {method} failed:");
TestLibrary.TestFramework.LogInformation($" value: {expectedValue}");
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 CreateScalarUnsafeByte()
{
var test = new VectorCreate__CreateScalarUnsafeByte();
// 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 VectorCreate__CreateScalarUnsafeByte
{
private static readonly int LargestVectorSize = 32;
private static readonly int ElementCount = Unsafe.SizeOf<Vector256<Byte>>() / sizeof(Byte);
public bool Succeeded { get; set; } = true;
public void RunBasicScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario));
Byte value = TestLibrary.Generator.GetByte();
Vector256<Byte> result = Vector256.CreateScalarUnsafe(value);
ValidateResult(result, value);
}
public void RunReflectionScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario));
Byte value = TestLibrary.Generator.GetByte();
object result = typeof(Vector256)
.GetMethod(nameof(Vector256.CreateScalarUnsafe), new Type[] { typeof(Byte) })
.Invoke(null, new object[] { value });
ValidateResult((Vector256<Byte>)(result), value);
}
private void ValidateResult(Vector256<Byte> result, Byte expectedValue, [CallerMemberName] string method = "")
{
Byte[] resultElements = new Byte[ElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref resultElements[0]), result);
ValidateResult(resultElements, expectedValue, method);
}
private void ValidateResult(Byte[] resultElements, Byte expectedValue, [CallerMemberName] string method = "")
{
bool succeeded = true;
if (resultElements[0] != expectedValue)
{
succeeded = false;
}
else
{
for (var i = 1; i < ElementCount; i++)
{
if (false /* value is uninitialized */)
{
succeeded = false;
break;
}
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"Vector256.CreateScalarUnsafe(Byte): {method} failed:");
TestLibrary.TestFramework.LogInformation($" value: {expectedValue}");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", resultElements)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/SignExtendWideningLower.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 SignExtendWideningLower_Vector64_Int32()
{
var test = new SimpleUnaryOpTest__SignExtendWideningLower_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 SimpleUnaryOpTest__SignExtendWideningLower_Vector64_Int32
{
private struct DataTable
{
private byte[] inArray1;
private byte[] outArray;
private GCHandle inHandle1;
private GCHandle outHandle;
private ulong alignment;
public DataTable(Int32[] inArray1, Int64[] outArray, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int32>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int64>();
if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray1 = new byte[alignment * 2];
this.outArray = new byte[alignment * 2];
this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned);
this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int32, byte>(ref inArray1[0]), (uint)sizeOfinArray1);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle1.Free();
outHandle.Free();
}
private static unsafe void* Align(byte* buffer, ulong expectedAlignment)
{
return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1));
}
}
private struct TestStruct
{
public Vector64<Int32> _fld1;
public static TestStruct Create()
{
var testStruct = new TestStruct();
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref testStruct._fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>());
return testStruct;
}
public void RunStructFldScenario(SimpleUnaryOpTest__SignExtendWideningLower_Vector64_Int32 testClass)
{
var result = AdvSimd.SignExtendWideningLower(_fld1);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(SimpleUnaryOpTest__SignExtendWideningLower_Vector64_Int32 testClass)
{
fixed (Vector64<Int32>* pFld1 = &_fld1)
{
var result = AdvSimd.SignExtendWideningLower(
AdvSimd.LoadVector64((Int32*)(pFld1))
);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr);
}
}
}
private static readonly int LargestVectorSize = 16;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<Int32>>() / sizeof(Int32);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64);
private static Int32[] _data1 = new Int32[Op1ElementCount];
private static Vector64<Int32> _clsVar1;
private Vector64<Int32> _fld1;
private DataTable _dataTable;
static SimpleUnaryOpTest__SignExtendWideningLower_Vector64_Int32()
{
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>());
}
public SimpleUnaryOpTest__SignExtendWideningLower_Vector64_Int32()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>());
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
_dataTable = new DataTable(_data1, 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.SignExtendWideningLower(
Unsafe.Read<Vector64<Int32>>(_dataTable.inArray1Ptr)
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunBasicScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));
var result = AdvSimd.SignExtendWideningLower(
AdvSimd.LoadVector64((Int32*)(_dataTable.inArray1Ptr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.SignExtendWideningLower), new Type[] { typeof(Vector64<Int32>) })
.Invoke(null, new object[] {
Unsafe.Read<Vector64<Int32>>(_dataTable.inArray1Ptr)
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.SignExtendWideningLower), new Type[] { typeof(Vector64<Int32>) })
.Invoke(null, new object[] {
AdvSimd.LoadVector64((Int32*)(_dataTable.inArray1Ptr))
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = AdvSimd.SignExtendWideningLower(
_clsVar1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector64<Int32>* pClsVar1 = &_clsVar1)
{
var result = AdvSimd.SignExtendWideningLower(
AdvSimd.LoadVector64((Int32*)(pClsVar1))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _dataTable.outArrayPtr);
}
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var op1 = Unsafe.Read<Vector64<Int32>>(_dataTable.inArray1Ptr);
var result = AdvSimd.SignExtendWideningLower(op1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load));
var op1 = AdvSimd.LoadVector64((Int32*)(_dataTable.inArray1Ptr));
var result = AdvSimd.SignExtendWideningLower(op1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new SimpleUnaryOpTest__SignExtendWideningLower_Vector64_Int32();
var result = AdvSimd.SignExtendWideningLower(test._fld1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));
var test = new SimpleUnaryOpTest__SignExtendWideningLower_Vector64_Int32();
fixed (Vector64<Int32>* pFld1 = &test._fld1)
{
var result = AdvSimd.SignExtendWideningLower(
AdvSimd.LoadVector64((Int32*)(pFld1))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = AdvSimd.SignExtendWideningLower(_fld1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector64<Int32>* pFld1 = &_fld1)
{
var result = AdvSimd.SignExtendWideningLower(
AdvSimd.LoadVector64((Int32*)(pFld1))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _dataTable.outArrayPtr);
}
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = AdvSimd.SignExtendWideningLower(test._fld1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));
var test = TestStruct.Create();
var result = AdvSimd.SignExtendWideningLower(
AdvSimd.LoadVector64((Int32*)(&test._fld1))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
public void RunStructFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario));
var test = TestStruct.Create();
test.RunStructFldScenario(this);
}
public void RunStructFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load));
var test = TestStruct.Create();
test.RunStructFldScenario_Load(this);
}
public void RunUnsupportedScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario));
bool succeeded = false;
try
{
RunBasicScenario_UnsafeRead();
}
catch (PlatformNotSupportedException)
{
succeeded = true;
}
if (!succeeded)
{
Succeeded = false;
}
}
private void ValidateResult(Vector64<Int32> op1, void* result, [CallerMemberName] string method = "")
{
Int32[] inArray1 = new Int32[Op1ElementCount];
Int64[] outArray = new Int64[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), op1);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>());
ValidateResult(inArray1, outArray, method);
}
private void ValidateResult(void* op1, void* result, [CallerMemberName] string method = "")
{
Int32[] inArray1 = new Int32[Op1ElementCount];
Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (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, outArray, method);
}
private void ValidateResult(Int32[] firstOp, Int64[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (var i = 0; i < RetElementCount; i++)
{
if (Helpers.SignExtendWidening(firstOp[i]) != result[i])
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.SignExtendWideningLower)}<Int64>(Vector64<Int32>): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/******************************************************************************
* This file is auto-generated from a template file by the GenerateTests.csx *
* script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make *
* changes, please update the corresponding template and run according to the *
* directions listed in the file. *
******************************************************************************/
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
namespace JIT.HardwareIntrinsics.Arm
{
public static partial class Program
{
private static void SignExtendWideningLower_Vector64_Int32()
{
var test = new SimpleUnaryOpTest__SignExtendWideningLower_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 SimpleUnaryOpTest__SignExtendWideningLower_Vector64_Int32
{
private struct DataTable
{
private byte[] inArray1;
private byte[] outArray;
private GCHandle inHandle1;
private GCHandle outHandle;
private ulong alignment;
public DataTable(Int32[] inArray1, Int64[] outArray, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int32>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int64>();
if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray1 = new byte[alignment * 2];
this.outArray = new byte[alignment * 2];
this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned);
this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int32, byte>(ref inArray1[0]), (uint)sizeOfinArray1);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle1.Free();
outHandle.Free();
}
private static unsafe void* Align(byte* buffer, ulong expectedAlignment)
{
return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1));
}
}
private struct TestStruct
{
public Vector64<Int32> _fld1;
public static TestStruct Create()
{
var testStruct = new TestStruct();
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref testStruct._fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>());
return testStruct;
}
public void RunStructFldScenario(SimpleUnaryOpTest__SignExtendWideningLower_Vector64_Int32 testClass)
{
var result = AdvSimd.SignExtendWideningLower(_fld1);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(SimpleUnaryOpTest__SignExtendWideningLower_Vector64_Int32 testClass)
{
fixed (Vector64<Int32>* pFld1 = &_fld1)
{
var result = AdvSimd.SignExtendWideningLower(
AdvSimd.LoadVector64((Int32*)(pFld1))
);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr);
}
}
}
private static readonly int LargestVectorSize = 16;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<Int32>>() / sizeof(Int32);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64);
private static Int32[] _data1 = new Int32[Op1ElementCount];
private static Vector64<Int32> _clsVar1;
private Vector64<Int32> _fld1;
private DataTable _dataTable;
static SimpleUnaryOpTest__SignExtendWideningLower_Vector64_Int32()
{
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>());
}
public SimpleUnaryOpTest__SignExtendWideningLower_Vector64_Int32()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>());
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
_dataTable = new DataTable(_data1, 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.SignExtendWideningLower(
Unsafe.Read<Vector64<Int32>>(_dataTable.inArray1Ptr)
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunBasicScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));
var result = AdvSimd.SignExtendWideningLower(
AdvSimd.LoadVector64((Int32*)(_dataTable.inArray1Ptr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.SignExtendWideningLower), new Type[] { typeof(Vector64<Int32>) })
.Invoke(null, new object[] {
Unsafe.Read<Vector64<Int32>>(_dataTable.inArray1Ptr)
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.SignExtendWideningLower), new Type[] { typeof(Vector64<Int32>) })
.Invoke(null, new object[] {
AdvSimd.LoadVector64((Int32*)(_dataTable.inArray1Ptr))
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = AdvSimd.SignExtendWideningLower(
_clsVar1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector64<Int32>* pClsVar1 = &_clsVar1)
{
var result = AdvSimd.SignExtendWideningLower(
AdvSimd.LoadVector64((Int32*)(pClsVar1))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _dataTable.outArrayPtr);
}
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var op1 = Unsafe.Read<Vector64<Int32>>(_dataTable.inArray1Ptr);
var result = AdvSimd.SignExtendWideningLower(op1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load));
var op1 = AdvSimd.LoadVector64((Int32*)(_dataTable.inArray1Ptr));
var result = AdvSimd.SignExtendWideningLower(op1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new SimpleUnaryOpTest__SignExtendWideningLower_Vector64_Int32();
var result = AdvSimd.SignExtendWideningLower(test._fld1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));
var test = new SimpleUnaryOpTest__SignExtendWideningLower_Vector64_Int32();
fixed (Vector64<Int32>* pFld1 = &test._fld1)
{
var result = AdvSimd.SignExtendWideningLower(
AdvSimd.LoadVector64((Int32*)(pFld1))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = AdvSimd.SignExtendWideningLower(_fld1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector64<Int32>* pFld1 = &_fld1)
{
var result = AdvSimd.SignExtendWideningLower(
AdvSimd.LoadVector64((Int32*)(pFld1))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _dataTable.outArrayPtr);
}
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = AdvSimd.SignExtendWideningLower(test._fld1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));
var test = TestStruct.Create();
var result = AdvSimd.SignExtendWideningLower(
AdvSimd.LoadVector64((Int32*)(&test._fld1))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
public void RunStructFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario));
var test = TestStruct.Create();
test.RunStructFldScenario(this);
}
public void RunStructFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load));
var test = TestStruct.Create();
test.RunStructFldScenario_Load(this);
}
public void RunUnsupportedScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario));
bool succeeded = false;
try
{
RunBasicScenario_UnsafeRead();
}
catch (PlatformNotSupportedException)
{
succeeded = true;
}
if (!succeeded)
{
Succeeded = false;
}
}
private void ValidateResult(Vector64<Int32> op1, void* result, [CallerMemberName] string method = "")
{
Int32[] inArray1 = new Int32[Op1ElementCount];
Int64[] outArray = new Int64[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), op1);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>());
ValidateResult(inArray1, outArray, method);
}
private void ValidateResult(void* op1, void* result, [CallerMemberName] string method = "")
{
Int32[] inArray1 = new Int32[Op1ElementCount];
Int64[] outArray = new Int64[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (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, outArray, method);
}
private void ValidateResult(Int32[] firstOp, Int64[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (var i = 0; i < RetElementCount; i++)
{
if (Helpers.SignExtendWidening(firstOp[i]) != result[i])
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.SignExtendWideningLower)}<Int64>(Vector64<Int32>): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Private.Xml/src/System/Xml/Xsl/QIL/WhitespaceRule.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 System.IO;
using System.Xml.Xsl.Runtime;
namespace System.Xml.Xsl.Qil
{
/// <summary>
/// Data structure for storing whitespace rules generated by xsl:strip-space and xsl:preserve-space
/// </summary>
internal class WhitespaceRule
{
private string? _localName;
private string? _namespaceName;
private bool _preserveSpace;
/// <summary>
/// Allow derived classes to construct empty whitespace rule.
/// </summary>
protected WhitespaceRule()
{
}
/// <summary>
/// Construct new whitespace rule.
/// </summary>
public WhitespaceRule(string? localName, string? namespaceName, bool preserveSpace)
{
Init(localName, namespaceName, preserveSpace);
}
/// <summary>
/// Initialize whitespace rule after it's been constructed.
/// </summary>
protected void Init(string? localName, string? namespaceName, bool preserveSpace)
{
_localName = localName;
_namespaceName = namespaceName;
_preserveSpace = preserveSpace;
}
/// <summary>
/// Local name of the element.
/// </summary>
public string? LocalName
{
get { return _localName; }
set { _localName = value; }
}
/// <summary>
/// Namespace name (uri) of the element.
/// </summary>
public string? NamespaceName
{
get { return _namespaceName; }
set { _namespaceName = value; }
}
/// <summary>
/// True, if this element is whitespace-preserving.
/// False, if this element is whitespace-stripping.
/// </summary>
public bool PreserveSpace
{
get { return _preserveSpace; }
}
/// <summary>
/// Serialize the object to BinaryWriter.
/// </summary>
public void GetObjectData(XmlQueryDataWriter writer)
{
Debug.Assert(this.GetType() == typeof(WhitespaceRule), "Serialization of WhitespaceRule subclasses is not implemented");
// string localName;
writer.WriteStringQ(_localName);
// string namespaceName;
writer.WriteStringQ(_namespaceName);
// bool preserveSpace;
writer.Write(_preserveSpace);
}
/// <summary>
/// Deserialize the object from BinaryReader.
/// </summary>
public WhitespaceRule(XmlQueryDataReader reader)
{
// string localName;
_localName = reader.ReadStringQ();
// string namespaceName;
_namespaceName = reader.ReadStringQ();
// bool preserveSpace;
_preserveSpace = reader.ReadBoolean();
}
}
}
| // 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 System.IO;
using System.Xml.Xsl.Runtime;
namespace System.Xml.Xsl.Qil
{
/// <summary>
/// Data structure for storing whitespace rules generated by xsl:strip-space and xsl:preserve-space
/// </summary>
internal class WhitespaceRule
{
private string? _localName;
private string? _namespaceName;
private bool _preserveSpace;
/// <summary>
/// Allow derived classes to construct empty whitespace rule.
/// </summary>
protected WhitespaceRule()
{
}
/// <summary>
/// Construct new whitespace rule.
/// </summary>
public WhitespaceRule(string? localName, string? namespaceName, bool preserveSpace)
{
Init(localName, namespaceName, preserveSpace);
}
/// <summary>
/// Initialize whitespace rule after it's been constructed.
/// </summary>
protected void Init(string? localName, string? namespaceName, bool preserveSpace)
{
_localName = localName;
_namespaceName = namespaceName;
_preserveSpace = preserveSpace;
}
/// <summary>
/// Local name of the element.
/// </summary>
public string? LocalName
{
get { return _localName; }
set { _localName = value; }
}
/// <summary>
/// Namespace name (uri) of the element.
/// </summary>
public string? NamespaceName
{
get { return _namespaceName; }
set { _namespaceName = value; }
}
/// <summary>
/// True, if this element is whitespace-preserving.
/// False, if this element is whitespace-stripping.
/// </summary>
public bool PreserveSpace
{
get { return _preserveSpace; }
}
/// <summary>
/// Serialize the object to BinaryWriter.
/// </summary>
public void GetObjectData(XmlQueryDataWriter writer)
{
Debug.Assert(this.GetType() == typeof(WhitespaceRule), "Serialization of WhitespaceRule subclasses is not implemented");
// string localName;
writer.WriteStringQ(_localName);
// string namespaceName;
writer.WriteStringQ(_namespaceName);
// bool preserveSpace;
writer.Write(_preserveSpace);
}
/// <summary>
/// Deserialize the object from BinaryReader.
/// </summary>
public WhitespaceRule(XmlQueryDataReader reader)
{
// string localName;
_localName = reader.ReadStringQ();
// string namespaceName;
_namespaceName = reader.ReadStringQ();
// bool preserveSpace;
_preserveSpace = reader.ReadBoolean();
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegistryConstants.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
internal static partial class Interop
{
internal static partial class Advapi32
{
internal static class RegistryOptions
{
internal const int REG_OPTION_NON_VOLATILE = 0x0000; // (default) keys are persisted beyond reboot/unload
internal const int REG_OPTION_VOLATILE = 0x0001; // All keys created by the function are volatile
internal const int REG_OPTION_CREATE_LINK = 0x0002; // They key is a symbolic link
internal const int REG_OPTION_BACKUP_RESTORE = 0x0004; // Use SE_BACKUP_NAME process special privileges
}
internal static class RegistryView
{
internal const int KEY_WOW64_64KEY = 0x0100;
internal const int KEY_WOW64_32KEY = 0x0200;
}
internal static class RegistryOperations
{
internal const int KEY_QUERY_VALUE = 0x0001;
internal const int KEY_SET_VALUE = 0x0002;
internal const int KEY_CREATE_SUB_KEY = 0x0004;
internal const int KEY_ENUMERATE_SUB_KEYS = 0x0008;
internal const int KEY_NOTIFY = 0x0010;
internal const int KEY_CREATE_LINK = 0x0020;
internal const int KEY_READ = ((STANDARD_RIGHTS_READ |
KEY_QUERY_VALUE |
KEY_ENUMERATE_SUB_KEYS |
KEY_NOTIFY)
&
(~SYNCHRONIZE));
internal const int KEY_WRITE = ((STANDARD_RIGHTS_WRITE |
KEY_SET_VALUE |
KEY_CREATE_SUB_KEY)
&
(~SYNCHRONIZE));
internal const int SYNCHRONIZE = 0x00100000;
internal const int READ_CONTROL = 0x00020000;
internal const int STANDARD_RIGHTS_READ = READ_CONTROL;
internal const int STANDARD_RIGHTS_WRITE = READ_CONTROL;
}
internal static class RegistryValues
{
internal const int REG_NONE = 0; // No value type
internal const int REG_SZ = 1; // Unicode nul terminated string
internal const int REG_EXPAND_SZ = 2; // Unicode nul terminated string
// (with environment variable references)
internal const int REG_BINARY = 3; // Free form binary
internal const int REG_DWORD = 4; // 32-bit number
internal const int REG_DWORD_LITTLE_ENDIAN = 4; // 32-bit number (same as REG_DWORD)
internal const int REG_DWORD_BIG_ENDIAN = 5; // 32-bit number
internal const int REG_LINK = 6; // Symbolic Link (Unicode)
internal const int REG_MULTI_SZ = 7; // Multiple Unicode strings
internal const int REG_QWORD = 11; // 64-bit number
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
internal static partial class Interop
{
internal static partial class Advapi32
{
internal static class RegistryOptions
{
internal const int REG_OPTION_NON_VOLATILE = 0x0000; // (default) keys are persisted beyond reboot/unload
internal const int REG_OPTION_VOLATILE = 0x0001; // All keys created by the function are volatile
internal const int REG_OPTION_CREATE_LINK = 0x0002; // They key is a symbolic link
internal const int REG_OPTION_BACKUP_RESTORE = 0x0004; // Use SE_BACKUP_NAME process special privileges
}
internal static class RegistryView
{
internal const int KEY_WOW64_64KEY = 0x0100;
internal const int KEY_WOW64_32KEY = 0x0200;
}
internal static class RegistryOperations
{
internal const int KEY_QUERY_VALUE = 0x0001;
internal const int KEY_SET_VALUE = 0x0002;
internal const int KEY_CREATE_SUB_KEY = 0x0004;
internal const int KEY_ENUMERATE_SUB_KEYS = 0x0008;
internal const int KEY_NOTIFY = 0x0010;
internal const int KEY_CREATE_LINK = 0x0020;
internal const int KEY_READ = ((STANDARD_RIGHTS_READ |
KEY_QUERY_VALUE |
KEY_ENUMERATE_SUB_KEYS |
KEY_NOTIFY)
&
(~SYNCHRONIZE));
internal const int KEY_WRITE = ((STANDARD_RIGHTS_WRITE |
KEY_SET_VALUE |
KEY_CREATE_SUB_KEY)
&
(~SYNCHRONIZE));
internal const int SYNCHRONIZE = 0x00100000;
internal const int READ_CONTROL = 0x00020000;
internal const int STANDARD_RIGHTS_READ = READ_CONTROL;
internal const int STANDARD_RIGHTS_WRITE = READ_CONTROL;
}
internal static class RegistryValues
{
internal const int REG_NONE = 0; // No value type
internal const int REG_SZ = 1; // Unicode nul terminated string
internal const int REG_EXPAND_SZ = 2; // Unicode nul terminated string
// (with environment variable references)
internal const int REG_BINARY = 3; // Free form binary
internal const int REG_DWORD = 4; // 32-bit number
internal const int REG_DWORD_LITTLE_ENDIAN = 4; // 32-bit number (same as REG_DWORD)
internal const int REG_DWORD_BIG_ENDIAN = 5; // 32-bit number
internal const int REG_LINK = 6; // Symbolic Link (Unicode)
internal const int REG_MULTI_SZ = 7; // Multiple Unicode strings
internal const int REG_QWORD = 11; // 64-bit number
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/GuidConverter.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 GuidConverter : JsonConverter<Guid>
{
public override Guid Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return reader.GetGuid();
}
public override void Write(Utf8JsonWriter writer, Guid value, JsonSerializerOptions options)
{
writer.WriteStringValue(value);
}
internal override Guid ReadAsPropertyNameCore(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return reader.GetGuidNoValidation();
}
internal override void WriteAsPropertyNameCore(Utf8JsonWriter writer, Guid value, JsonSerializerOptions options, bool isWritingExtensionDataProperty)
{
writer.WritePropertyName(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 GuidConverter : JsonConverter<Guid>
{
public override Guid Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return reader.GetGuid();
}
public override void Write(Utf8JsonWriter writer, Guid value, JsonSerializerOptions options)
{
writer.WriteStringValue(value);
}
internal override Guid ReadAsPropertyNameCore(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return reader.GetGuidNoValidation();
}
internal override void WriteAsPropertyNameCore(Utf8JsonWriter writer, Guid value, JsonSerializerOptions options, bool isWritingExtensionDataProperty)
{
writer.WritePropertyName(value);
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/Common/src/System/Security/Cryptography/RSACng.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.Runtime.Versioning;
using Internal.Cryptography;
namespace System.Security.Cryptography
{
public sealed partial class RSACng : RSA
{
/// <summary>
/// Create an RSACng algorithm with a random 2048 bit key pair.
/// </summary>
[SupportedOSPlatform("windows")]
public RSACng()
: this(2048)
{
}
/// <summary>
/// Creates a new RSACng object that will use a randomly generated key of the specified size.
/// Valid key sizes range from 512 to 16384 bits, in increments of 64 bits. It is suggested that a
/// minimum size of 2048 bits be used for all keys.
/// </summary>
/// <param name="keySize">Size of the key to generate, in bits.</param>
/// <exception cref="CryptographicException">if <paramref name="keySize" /> is not valid</exception>
[SupportedOSPlatform("windows")]
public RSACng(int keySize)
{
// Set the property directly so that it gets validated against LegalKeySizes.
KeySize = keySize;
}
public override KeySizes[] LegalKeySizes
{
get
{
// See https://msdn.microsoft.com/en-us/library/windows/desktop/bb931354(v=vs.85).aspx
return new KeySizes[]
{
// All values are in bits.
new KeySizes(minSize: 512, maxSize: 16384, skipSize: 64),
};
}
}
protected override byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm) =>
CngCommon.HashData(data, offset, count, hashAlgorithm);
protected override bool TryHashData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten) =>
CngCommon.TryHashData(data, destination, hashAlgorithm, out bytesWritten);
protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm) =>
CngCommon.HashData(data, hashAlgorithm);
private void ForceSetKeySize(int newKeySize)
{
// Our LegalKeySizes value stores the values that we encoded as being the correct
// legal key size limitations for this algorithm, as documented on MSDN.
//
// But on a new OS version we might not question if our limit is accurate, or MSDN
// could have been inaccurate to start with.
//
// Since the key is already loaded, we know that Windows thought it to be valid;
// therefore we should set KeySizeValue directly to bypass the LegalKeySizes conformance
// check.
//
// For RSA there are known cases where this change matters. RSACryptoServiceProvider can
// create a 384-bit RSA key, which we consider too small to be legal. It can also create
// a 1032-bit RSA key, which we consider illegal because it doesn't match our 64-bit
// alignment requirement. (In both cases Windows loads it just fine)
KeySizeValue = newKeySize;
}
}
}
| // 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.Runtime.Versioning;
using Internal.Cryptography;
namespace System.Security.Cryptography
{
public sealed partial class RSACng : RSA
{
/// <summary>
/// Create an RSACng algorithm with a random 2048 bit key pair.
/// </summary>
[SupportedOSPlatform("windows")]
public RSACng()
: this(2048)
{
}
/// <summary>
/// Creates a new RSACng object that will use a randomly generated key of the specified size.
/// Valid key sizes range from 512 to 16384 bits, in increments of 64 bits. It is suggested that a
/// minimum size of 2048 bits be used for all keys.
/// </summary>
/// <param name="keySize">Size of the key to generate, in bits.</param>
/// <exception cref="CryptographicException">if <paramref name="keySize" /> is not valid</exception>
[SupportedOSPlatform("windows")]
public RSACng(int keySize)
{
// Set the property directly so that it gets validated against LegalKeySizes.
KeySize = keySize;
}
public override KeySizes[] LegalKeySizes
{
get
{
// See https://msdn.microsoft.com/en-us/library/windows/desktop/bb931354(v=vs.85).aspx
return new KeySizes[]
{
// All values are in bits.
new KeySizes(minSize: 512, maxSize: 16384, skipSize: 64),
};
}
}
protected override byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm) =>
CngCommon.HashData(data, offset, count, hashAlgorithm);
protected override bool TryHashData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten) =>
CngCommon.TryHashData(data, destination, hashAlgorithm, out bytesWritten);
protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm) =>
CngCommon.HashData(data, hashAlgorithm);
private void ForceSetKeySize(int newKeySize)
{
// Our LegalKeySizes value stores the values that we encoded as being the correct
// legal key size limitations for this algorithm, as documented on MSDN.
//
// But on a new OS version we might not question if our limit is accurate, or MSDN
// could have been inaccurate to start with.
//
// Since the key is already loaded, we know that Windows thought it to be valid;
// therefore we should set KeySizeValue directly to bypass the LegalKeySizes conformance
// check.
//
// For RSA there are known cases where this change matters. RSACryptoServiceProvider can
// create a 384-bit RSA key, which we consider too small to be legal. It can also create
// a 1032-bit RSA key, which we consider illegal because it doesn't match our 64-bit
// alignment requirement. (In both cases Windows loads it just fine)
KeySizeValue = newKeySize;
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Runtime.Extensions/tests/System/Convert.ToDouble.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.Tests
{
public class ConvertToDoubleTests : ConvertTestBase<double>
{
[Fact]
public void FromBoolean()
{
bool[] testValues = { true, false };
double[] expectedValues = { 1.0, 0.0 };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromByte()
{
byte[] testValues = { byte.MaxValue, byte.MinValue };
double[] expectedValues = { byte.MaxValue, byte.MinValue };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromDecimal()
{
decimal[] testValues = { decimal.MaxValue, decimal.MinValue, 0.0m };
double[] expectedValues = { (double)decimal.MaxValue, (double)decimal.MinValue, 0.0 };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromDouble()
{
double[] testValues = { double.MaxValue, double.MinValue, double.NegativeInfinity, double.PositiveInfinity, double.Epsilon };
double[] expectedValues = { double.MaxValue, double.MinValue, double.NegativeInfinity, double.PositiveInfinity, double.Epsilon };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromInt16()
{
short[] testValues = { short.MaxValue, short.MinValue, 0 };
double[] expectedValues = { short.MaxValue, short.MinValue, 0 };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromInt32()
{
int[] testValues = { int.MaxValue, int.MinValue, 0 };
double[] expectedValues = { int.MaxValue, int.MinValue, 0 };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromInt64()
{
long[] testValues = { long.MaxValue, long.MinValue, 0 };
double[] expectedValues = { (double)long.MaxValue, (double)long.MinValue, 0 };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromObject()
{
object[] testValues = { null };
double[] expectedValues = { 0.0 };
VerifyFromObject(Convert.ToDouble, Convert.ToDouble, testValues, expectedValues);
object[] invalidValues = { new object(), DateTime.Now };
VerifyFromObjectThrows<InvalidCastException>(Convert.ToDouble, Convert.ToDouble, invalidValues);
}
[Fact]
public void FromSByte()
{
sbyte[] testValues = { sbyte.MaxValue, sbyte.MinValue };
double[] expectedValues = { sbyte.MaxValue, sbyte.MinValue };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromSingle()
{
float[] testValues = { float.MaxValue, float.MinValue, 0.0f };
double[] expectedValues = { float.MaxValue, float.MinValue, 0.0 };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromString()
{
string[] testValues = { Double.MinValue.ToString("R"), Double.MaxValue.ToString("R"), (0.0).ToString(), (10.0).ToString(), (-10.0).ToString(), null };
double[] expectedValues = { double.MinValue, double.MaxValue, 0.0, 10.0, -10.0, 0.0 };
VerifyFromString(Convert.ToDouble, Convert.ToDouble, testValues, expectedValues);
string[] formatExceptionValues = { "123xyz" };
VerifyFromStringThrows<FormatException>(Convert.ToDouble, Convert.ToDouble, formatExceptionValues);
}
[Fact]
public void FromString_NotNetFramework()
{
string[] overflowValues = { Double.MaxValue.ToString(), Double.MinValue.ToString() };
VerifyFromString(Convert.ToDouble, Convert.ToDouble, overflowValues, new double[] { 1.7976931348623157E+308, -1.7976931348623157E+308 });
}
[Fact]
public void FromUInt16()
{
ushort[] testValues = { ushort.MaxValue, ushort.MinValue };
double[] expectedValues = { ushort.MaxValue, ushort.MinValue };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromUInt32()
{
uint[] testValues = { uint.MaxValue, uint.MinValue };
double[] expectedValues = { uint.MaxValue, uint.MinValue };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromUInt64()
{
ulong[] testValues = { ulong.MaxValue, ulong.MinValue };
double[] expectedValues = { (double)ulong.MaxValue, (double)ulong.MinValue };
Verify(Convert.ToDouble, testValues, expectedValues);
}
}
}
| // 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.Tests
{
public class ConvertToDoubleTests : ConvertTestBase<double>
{
[Fact]
public void FromBoolean()
{
bool[] testValues = { true, false };
double[] expectedValues = { 1.0, 0.0 };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromByte()
{
byte[] testValues = { byte.MaxValue, byte.MinValue };
double[] expectedValues = { byte.MaxValue, byte.MinValue };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromDecimal()
{
decimal[] testValues = { decimal.MaxValue, decimal.MinValue, 0.0m };
double[] expectedValues = { (double)decimal.MaxValue, (double)decimal.MinValue, 0.0 };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromDouble()
{
double[] testValues = { double.MaxValue, double.MinValue, double.NegativeInfinity, double.PositiveInfinity, double.Epsilon };
double[] expectedValues = { double.MaxValue, double.MinValue, double.NegativeInfinity, double.PositiveInfinity, double.Epsilon };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromInt16()
{
short[] testValues = { short.MaxValue, short.MinValue, 0 };
double[] expectedValues = { short.MaxValue, short.MinValue, 0 };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromInt32()
{
int[] testValues = { int.MaxValue, int.MinValue, 0 };
double[] expectedValues = { int.MaxValue, int.MinValue, 0 };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromInt64()
{
long[] testValues = { long.MaxValue, long.MinValue, 0 };
double[] expectedValues = { (double)long.MaxValue, (double)long.MinValue, 0 };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromObject()
{
object[] testValues = { null };
double[] expectedValues = { 0.0 };
VerifyFromObject(Convert.ToDouble, Convert.ToDouble, testValues, expectedValues);
object[] invalidValues = { new object(), DateTime.Now };
VerifyFromObjectThrows<InvalidCastException>(Convert.ToDouble, Convert.ToDouble, invalidValues);
}
[Fact]
public void FromSByte()
{
sbyte[] testValues = { sbyte.MaxValue, sbyte.MinValue };
double[] expectedValues = { sbyte.MaxValue, sbyte.MinValue };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromSingle()
{
float[] testValues = { float.MaxValue, float.MinValue, 0.0f };
double[] expectedValues = { float.MaxValue, float.MinValue, 0.0 };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromString()
{
string[] testValues = { Double.MinValue.ToString("R"), Double.MaxValue.ToString("R"), (0.0).ToString(), (10.0).ToString(), (-10.0).ToString(), null };
double[] expectedValues = { double.MinValue, double.MaxValue, 0.0, 10.0, -10.0, 0.0 };
VerifyFromString(Convert.ToDouble, Convert.ToDouble, testValues, expectedValues);
string[] formatExceptionValues = { "123xyz" };
VerifyFromStringThrows<FormatException>(Convert.ToDouble, Convert.ToDouble, formatExceptionValues);
}
[Fact]
public void FromString_NotNetFramework()
{
string[] overflowValues = { Double.MaxValue.ToString(), Double.MinValue.ToString() };
VerifyFromString(Convert.ToDouble, Convert.ToDouble, overflowValues, new double[] { 1.7976931348623157E+308, -1.7976931348623157E+308 });
}
[Fact]
public void FromUInt16()
{
ushort[] testValues = { ushort.MaxValue, ushort.MinValue };
double[] expectedValues = { ushort.MaxValue, ushort.MinValue };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromUInt32()
{
uint[] testValues = { uint.MaxValue, uint.MinValue };
double[] expectedValues = { uint.MaxValue, uint.MinValue };
Verify(Convert.ToDouble, testValues, expectedValues);
}
[Fact]
public void FromUInt64()
{
ulong[] testValues = { ulong.MaxValue, ulong.MinValue };
double[] expectedValues = { (double)ulong.MaxValue, (double)ulong.MinValue };
Verify(Convert.ToDouble, testValues, expectedValues);
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/ShiftRightLogicalRoundedNarrowingSaturateLower.Vector64.Int32.1.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.Arm;
namespace JIT.HardwareIntrinsics.Arm
{
public static partial class Program
{
private static void ShiftRightLogicalRoundedNarrowingSaturateLower_Vector64_Int32_1()
{
var test = new ImmUnaryOpTest__ShiftRightLogicalRoundedNarrowingSaturateLower_Vector64_Int32_1();
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 ImmUnaryOpTest__ShiftRightLogicalRoundedNarrowingSaturateLower_Vector64_Int32_1
{
private struct DataTable
{
private byte[] inArray;
private byte[] outArray;
private GCHandle inHandle;
private GCHandle outHandle;
private ulong alignment;
public DataTable(Int64[] inArray, Int32[] outArray, int alignment)
{
int sizeOfinArray = inArray.Length * Unsafe.SizeOf<Int64>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int32>();
if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray = new byte[alignment * 2];
this.outArray = new byte[alignment * 2];
this.inHandle = GCHandle.Alloc(this.inArray, GCHandleType.Pinned);
this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArrayPtr), ref Unsafe.As<Int64, byte>(ref inArray[0]), (uint)sizeOfinArray);
}
public void* inArrayPtr => Align((byte*)(inHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle.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> _fld;
public static TestStruct Create()
{
var testStruct = new TestStruct();
for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt64(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref testStruct._fld), ref Unsafe.As<Int64, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>());
return testStruct;
}
public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalRoundedNarrowingSaturateLower_Vector64_Int32_1 testClass)
{
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(_fld, 1);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(ImmUnaryOpTest__ShiftRightLogicalRoundedNarrowingSaturateLower_Vector64_Int32_1 testClass)
{
fixed (Vector128<Int64>* pFld = &_fld)
{
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(
AdvSimd.LoadVector128((Int64*)(pFld)),
1
);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr);
}
}
}
private static readonly int LargestVectorSize = 16;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<Int32>>() / sizeof(Int32);
private static readonly byte Imm = 1;
private static Int64[] _data = new Int64[Op1ElementCount];
private static Vector128<Int64> _clsVar;
private Vector128<Int64> _fld;
private DataTable _dataTable;
static ImmUnaryOpTest__ShiftRightLogicalRoundedNarrowingSaturateLower_Vector64_Int32_1()
{
for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt64(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar), ref Unsafe.As<Int64, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>());
}
public ImmUnaryOpTest__ShiftRightLogicalRoundedNarrowingSaturateLower_Vector64_Int32_1()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt64(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld), ref Unsafe.As<Int64, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>());
for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt64(); }
_dataTable = new DataTable(_data, 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.ShiftRightLogicalRoundedNarrowingSaturateLower(
Unsafe.Read<Vector128<Int64>>(_dataTable.inArrayPtr),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunBasicScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(
AdvSimd.LoadVector128((Int64*)(_dataTable.inArrayPtr)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower), new Type[] { typeof(Vector128<Int64>), typeof(byte) })
.Invoke(null, new object[] {
Unsafe.Read<Vector128<Int64>>(_dataTable.inArrayPtr),
(byte)1
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int32>)(result));
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower), new Type[] { typeof(Vector128<Int64>), typeof(byte) })
.Invoke(null, new object[] {
AdvSimd.LoadVector128((Int64*)(_dataTable.inArrayPtr)),
(byte)1
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int32>)(result));
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(
_clsVar,
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector128<Int64>* pClsVar = &_clsVar)
{
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(
AdvSimd.LoadVector128((Int64*)(pClsVar)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar, _dataTable.outArrayPtr);
}
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var firstOp = Unsafe.Read<Vector128<Int64>>(_dataTable.inArrayPtr);
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(firstOp, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(firstOp, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load));
var firstOp = AdvSimd.LoadVector128((Int64*)(_dataTable.inArrayPtr));
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(firstOp, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(firstOp, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new ImmUnaryOpTest__ShiftRightLogicalRoundedNarrowingSaturateLower_Vector64_Int32_1();
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(test._fld, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));
var test = new ImmUnaryOpTest__ShiftRightLogicalRoundedNarrowingSaturateLower_Vector64_Int32_1();
fixed (Vector128<Int64>* pFld = &test._fld)
{
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(
AdvSimd.LoadVector128((Int64*)(pFld)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(_fld, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector128<Int64>* pFld = &_fld)
{
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(
AdvSimd.LoadVector128((Int64*)(pFld)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld, _dataTable.outArrayPtr);
}
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(test._fld, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));
var test = TestStruct.Create();
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(
AdvSimd.LoadVector128((Int64*)(&test._fld)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld, _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> firstOp, void* result, [CallerMemberName] string method = "")
{
Int64[] inArray = new Int64[Op1ElementCount];
Int32[] outArray = new Int32[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray[0]), firstOp);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int32>>());
ValidateResult(inArray, outArray, method);
}
private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
{
Int64[] inArray = new Int64[Op1ElementCount];
Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (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(inArray, outArray, method);
}
private void ValidateResult(Int64[] firstOp, Int32[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (var i = 0; i < RetElementCount; i++)
{
if (Helpers.ShiftRightLogicalRoundedNarrowingSaturate(firstOp[i], Imm) != result[i])
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower)}<Int32>(Vector128<Int64>, 1): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/******************************************************************************
* This file is auto-generated from a template file by the GenerateTests.csx *
* script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make *
* changes, please update the corresponding template and run according to the *
* directions listed in the file. *
******************************************************************************/
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
namespace JIT.HardwareIntrinsics.Arm
{
public static partial class Program
{
private static void ShiftRightLogicalRoundedNarrowingSaturateLower_Vector64_Int32_1()
{
var test = new ImmUnaryOpTest__ShiftRightLogicalRoundedNarrowingSaturateLower_Vector64_Int32_1();
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 ImmUnaryOpTest__ShiftRightLogicalRoundedNarrowingSaturateLower_Vector64_Int32_1
{
private struct DataTable
{
private byte[] inArray;
private byte[] outArray;
private GCHandle inHandle;
private GCHandle outHandle;
private ulong alignment;
public DataTable(Int64[] inArray, Int32[] outArray, int alignment)
{
int sizeOfinArray = inArray.Length * Unsafe.SizeOf<Int64>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int32>();
if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray = new byte[alignment * 2];
this.outArray = new byte[alignment * 2];
this.inHandle = GCHandle.Alloc(this.inArray, GCHandleType.Pinned);
this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArrayPtr), ref Unsafe.As<Int64, byte>(ref inArray[0]), (uint)sizeOfinArray);
}
public void* inArrayPtr => Align((byte*)(inHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle.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> _fld;
public static TestStruct Create()
{
var testStruct = new TestStruct();
for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt64(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref testStruct._fld), ref Unsafe.As<Int64, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>());
return testStruct;
}
public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalRoundedNarrowingSaturateLower_Vector64_Int32_1 testClass)
{
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(_fld, 1);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(ImmUnaryOpTest__ShiftRightLogicalRoundedNarrowingSaturateLower_Vector64_Int32_1 testClass)
{
fixed (Vector128<Int64>* pFld = &_fld)
{
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(
AdvSimd.LoadVector128((Int64*)(pFld)),
1
);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr);
}
}
}
private static readonly int LargestVectorSize = 16;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<Int32>>() / sizeof(Int32);
private static readonly byte Imm = 1;
private static Int64[] _data = new Int64[Op1ElementCount];
private static Vector128<Int64> _clsVar;
private Vector128<Int64> _fld;
private DataTable _dataTable;
static ImmUnaryOpTest__ShiftRightLogicalRoundedNarrowingSaturateLower_Vector64_Int32_1()
{
for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt64(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar), ref Unsafe.As<Int64, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>());
}
public ImmUnaryOpTest__ShiftRightLogicalRoundedNarrowingSaturateLower_Vector64_Int32_1()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt64(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld), ref Unsafe.As<Int64, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>());
for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt64(); }
_dataTable = new DataTable(_data, 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.ShiftRightLogicalRoundedNarrowingSaturateLower(
Unsafe.Read<Vector128<Int64>>(_dataTable.inArrayPtr),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunBasicScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(
AdvSimd.LoadVector128((Int64*)(_dataTable.inArrayPtr)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower), new Type[] { typeof(Vector128<Int64>), typeof(byte) })
.Invoke(null, new object[] {
Unsafe.Read<Vector128<Int64>>(_dataTable.inArrayPtr),
(byte)1
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int32>)(result));
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower), new Type[] { typeof(Vector128<Int64>), typeof(byte) })
.Invoke(null, new object[] {
AdvSimd.LoadVector128((Int64*)(_dataTable.inArrayPtr)),
(byte)1
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int32>)(result));
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(
_clsVar,
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector128<Int64>* pClsVar = &_clsVar)
{
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(
AdvSimd.LoadVector128((Int64*)(pClsVar)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar, _dataTable.outArrayPtr);
}
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var firstOp = Unsafe.Read<Vector128<Int64>>(_dataTable.inArrayPtr);
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(firstOp, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(firstOp, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load));
var firstOp = AdvSimd.LoadVector128((Int64*)(_dataTable.inArrayPtr));
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(firstOp, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(firstOp, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new ImmUnaryOpTest__ShiftRightLogicalRoundedNarrowingSaturateLower_Vector64_Int32_1();
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(test._fld, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));
var test = new ImmUnaryOpTest__ShiftRightLogicalRoundedNarrowingSaturateLower_Vector64_Int32_1();
fixed (Vector128<Int64>* pFld = &test._fld)
{
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(
AdvSimd.LoadVector128((Int64*)(pFld)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(_fld, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector128<Int64>* pFld = &_fld)
{
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(
AdvSimd.LoadVector128((Int64*)(pFld)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld, _dataTable.outArrayPtr);
}
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(test._fld, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));
var test = TestStruct.Create();
var result = AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower(
AdvSimd.LoadVector128((Int64*)(&test._fld)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld, _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> firstOp, void* result, [CallerMemberName] string method = "")
{
Int64[] inArray = new Int64[Op1ElementCount];
Int32[] outArray = new Int32[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray[0]), firstOp);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int32>>());
ValidateResult(inArray, outArray, method);
}
private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
{
Int64[] inArray = new Int64[Op1ElementCount];
Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (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(inArray, outArray, method);
}
private void ValidateResult(Int64[] firstOp, Int32[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (var i = 0; i < RetElementCount; i++)
{
if (Helpers.ShiftRightLogicalRoundedNarrowingSaturate(firstOp[i], Imm) != result[i])
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.ShiftRightLogicalRoundedNarrowingSaturateLower)}<Int32>(Vector128<Int64>, 1): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/Validator.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.Linq;
namespace System.ComponentModel.DataAnnotations
{
/// <summary>
/// Helper class to validate objects, properties and other values using their associated
/// <see cref="ValidationAttribute" />
/// custom attributes.
/// </summary>
public static class Validator
{
private static readonly ValidationAttributeStore _store = ValidationAttributeStore.Instance;
/// <summary>
/// Tests whether the given property value is valid.
/// </summary>
/// <remarks>
/// This method will test each <see cref="ValidationAttribute" /> associated with the property
/// identified by <paramref name="validationContext" />. If <paramref name="validationResults" /> is non-null,
/// this method will add a <see cref="ValidationResult" /> to it for each validation failure.
/// <para>
/// If there is a <see cref="RequiredAttribute" /> found on the property, it will be evaluated before all other
/// validation attributes. If the required validator fails then validation will abort, adding that single
/// failure into the <paramref name="validationResults" /> when applicable, returning a value of <c>false</c>.
/// </para>
/// <para>
/// If <paramref name="validationResults" /> is null and there isn't a <see cref="RequiredAttribute" /> failure,
/// then all validators will be evaluated.
/// </para>
/// </remarks>
/// <param name="value">The value to test.</param>
/// <param name="validationContext">
/// Describes the property member to validate and provides services and context for the
/// validators.
/// </param>
/// <param name="validationResults">Optional collection to receive <see cref="ValidationResult" />s for the failures.</param>
/// <returns><c>true</c> if the value is valid, <c>false</c> if any validation errors are encountered.</returns>
/// <exception cref="ArgumentException">
/// When the <see cref="ValidationContext.MemberName" /> of <paramref name="validationContext" /> is not a valid
/// property.
/// </exception>
[RequiresUnreferencedCode("The Type of validationContext.ObjectType cannot be statically discovered.")]
public static bool TryValidateProperty(object? value, ValidationContext validationContext,
ICollection<ValidationResult>? validationResults)
{
// Throw if value cannot be assigned to this property. That is not a validation exception.
var propertyType = _store.GetPropertyType(validationContext);
var propertyName = validationContext.MemberName!;
EnsureValidPropertyType(propertyName, propertyType, value);
var result = true;
var breakOnFirstError = (validationResults == null);
var attributes = _store.GetPropertyValidationAttributes(validationContext);
foreach (var err in GetValidationErrors(value, validationContext, attributes, breakOnFirstError))
{
result = false;
validationResults?.Add(err.ValidationResult);
}
return result;
}
/// <summary>
/// Tests whether the given object instance is valid.
/// </summary>
/// <remarks>
/// This method evaluates all <see cref="ValidationAttribute" />s attached to the object instance's type. It also
/// checks to ensure all properties marked with <see cref="RequiredAttribute" /> are set. It does not validate the
/// property values of the object.
/// <para>
/// If <paramref name="validationResults" /> is null, then execution will abort upon the first validation
/// failure. If <paramref name="validationResults" /> is non-null, then all validation attributes will be
/// evaluated.
/// </para>
/// </remarks>
/// <param name="instance">The object instance to test. It cannot be <c>null</c>.</param>
/// <param name="validationContext">Describes the object to validate and provides services and context for the validators.</param>
/// <param name="validationResults">Optional collection to receive <see cref="ValidationResult" />s for the failures.</param>
/// <returns><c>true</c> if the object is valid, <c>false</c> if any validation errors are encountered.</returns>
/// <exception cref="ArgumentNullException">When <paramref name="instance" /> is null.</exception>
/// <exception cref="ArgumentException">
/// When <paramref name="instance" /> doesn't match the
/// <see cref="ValidationContext.ObjectInstance" />on <paramref name="validationContext" />.
/// </exception>
[RequiresUnreferencedCode(ValidationContext.InstanceTypeNotStaticallyDiscovered)]
public static bool TryValidateObject(
object instance, ValidationContext validationContext, ICollection<ValidationResult>? validationResults) =>
TryValidateObject(instance, validationContext, validationResults, false /*validateAllProperties*/);
/// <summary>
/// Tests whether the given object instance is valid.
/// </summary>
/// <remarks>
/// This method evaluates all <see cref="ValidationAttribute" />s attached to the object instance's type. It also
/// checks to ensure all properties marked with <see cref="RequiredAttribute" /> are set. If
/// <paramref name="validateAllProperties" />
/// is <c>true</c>, this method will also evaluate the <see cref="ValidationAttribute" />s for all the immediate
/// properties
/// of this object. This process is not recursive.
/// <para>
/// If <paramref name="validationResults" /> is null, then execution will abort upon the first validation
/// failure. If <paramref name="validationResults" /> is non-null, then all validation attributes will be
/// evaluated.
/// </para>
/// <para>
/// For any given property, if it has a <see cref="RequiredAttribute" /> that fails validation, no other validators
/// will be evaluated for that property.
/// </para>
/// </remarks>
/// <param name="instance">The object instance to test. It cannot be null.</param>
/// <param name="validationContext">Describes the object to validate and provides services and context for the validators.</param>
/// <param name="validationResults">Optional collection to receive <see cref="ValidationResult" />s for the failures.</param>
/// <param name="validateAllProperties">
/// If <c>true</c>, also evaluates all properties of the object (this process is not
/// recursive over properties of the properties).
/// </param>
/// <returns><c>true</c> if the object is valid, <c>false</c> if any validation errors are encountered.</returns>
/// <exception cref="ArgumentNullException">When <paramref name="instance" /> is null.</exception>
/// <exception cref="ArgumentException">
/// When <paramref name="instance" /> doesn't match the
/// <see cref="ValidationContext.ObjectInstance" />on <paramref name="validationContext" />.
/// </exception>
[RequiresUnreferencedCode(ValidationContext.InstanceTypeNotStaticallyDiscovered)]
public static bool TryValidateObject(object instance!!, ValidationContext validationContext,
ICollection<ValidationResult>? validationResults, bool validateAllProperties)
{
if (validationContext != null && instance != validationContext.ObjectInstance)
{
throw new ArgumentException(SR.Validator_InstanceMustMatchValidationContextInstance, nameof(instance));
}
var result = true;
var breakOnFirstError = (validationResults == null);
foreach (ValidationError err in GetObjectValidationErrors(instance, validationContext!, validateAllProperties, breakOnFirstError))
{
result = false;
validationResults?.Add(err.ValidationResult);
}
return result;
}
/// <summary>
/// Tests whether the given value is valid against a specified list of <see cref="ValidationAttribute" />s.
/// </summary>
/// <remarks>
/// This method will test each <see cref="ValidationAttribute" />s specified. If
/// <paramref name="validationResults" /> is non-null, this method will add a <see cref="ValidationResult" />
/// to it for each validation failure.
/// <para>
/// If there is a <see cref="RequiredAttribute" /> within the <paramref name="validationAttributes" />, it will
/// be evaluated before all other validation attributes. If the required validator fails then validation will
/// abort, adding that single failure into the <paramref name="validationResults" /> when applicable, returning a
/// value of <c>false</c>.
/// </para>
/// <para>
/// If <paramref name="validationResults" /> is null and there isn't a <see cref="RequiredAttribute" /> failure,
/// then all validators will be evaluated.
/// </para>
/// </remarks>
/// <param name="value">The value to test. It cannot be null.</param>
/// <param name="validationContext">
/// Describes the object being validated and provides services and context for the
/// validators.
/// </param>
/// <param name="validationResults">Optional collection to receive <see cref="ValidationResult" />s for the failures.</param>
/// <param name="validationAttributes">
/// The list of <see cref="ValidationAttribute" />s to validate this
/// <paramref name="value" /> against.
/// </param>
/// <returns><c>true</c> if the object is valid, <c>false</c> if any validation errors are encountered.</returns>
public static bool TryValidateValue(object value, ValidationContext validationContext,
ICollection<ValidationResult>? validationResults, IEnumerable<ValidationAttribute> validationAttributes!!)
{
var result = true;
var breakOnFirstError = validationResults == null;
foreach (
var err in
GetValidationErrors(value, validationContext, validationAttributes, breakOnFirstError))
{
result = false;
validationResults?.Add(err.ValidationResult);
}
return result;
}
/// <summary>
/// Throws a <see cref="ValidationException" /> if the given property <paramref name="value" /> is not valid.
/// </summary>
/// <param name="value">The value to test.</param>
/// <param name="validationContext">
/// Describes the object being validated and provides services and context for the
/// validators. It cannot be <c>null</c>.
/// </param>
/// <exception cref="ArgumentNullException">When <paramref name="validationContext" /> is null.</exception>
/// <exception cref="ValidationException">When <paramref name="value" /> is invalid for this property.</exception>
[RequiresUnreferencedCode("The Type of validationContext.ObjectType cannot be statically discovered.")]
public static void ValidateProperty(object? value, ValidationContext validationContext)
{
// Throw if value cannot be assigned to this property. That is not a validation exception.
var propertyType = _store.GetPropertyType(validationContext);
EnsureValidPropertyType(validationContext.MemberName!, propertyType, value);
var attributes = _store.GetPropertyValidationAttributes(validationContext);
List<ValidationError> errors = GetValidationErrors(value, validationContext, attributes, false);
if (errors.Count > 0)
{
errors[0].ThrowValidationException();
}
}
/// <summary>
/// Throws a <see cref="ValidationException" /> if the given <paramref name="instance" /> is not valid.
/// </summary>
/// <remarks>
/// This method evaluates all <see cref="ValidationAttribute" />s attached to the object's type.
/// </remarks>
/// <param name="instance">The object instance to test. It cannot be null.</param>
/// <param name="validationContext">
/// Describes the object being validated and provides services and context for the
/// validators. It cannot be <c>null</c>.
/// </param>
/// <exception cref="ArgumentNullException">When <paramref name="instance" /> is null.</exception>
/// <exception cref="ArgumentNullException">When <paramref name="validationContext" /> is null.</exception>
/// <exception cref="ArgumentException">
/// When <paramref name="instance" /> doesn't match the
/// <see cref="ValidationContext.ObjectInstance" /> on <paramref name="validationContext" />.
/// </exception>
/// <exception cref="ValidationException">When <paramref name="instance" /> is found to be invalid.</exception>
[RequiresUnreferencedCode(ValidationContext.InstanceTypeNotStaticallyDiscovered)]
public static void ValidateObject(object instance, ValidationContext validationContext)
{
ValidateObject(instance, validationContext, false /*validateAllProperties*/);
}
/// <summary>
/// Throws a <see cref="ValidationException" /> if the given object instance is not valid.
/// </summary>
/// <remarks>
/// This method evaluates all <see cref="ValidationAttribute" />s attached to the object's type.
/// If <paramref name="validateAllProperties" /> is <c>true</c> it also validates all the object's properties.
/// </remarks>
/// <param name="instance">The object instance to test. It cannot be null.</param>
/// <param name="validationContext">
/// Describes the object being validated and provides services and context for the
/// validators. It cannot be <c>null</c>.
/// </param>
/// <param name="validateAllProperties">If <c>true</c>, also validates all the <paramref name="instance" />'s properties.</param>
/// <exception cref="ArgumentNullException">When <paramref name="instance" /> is null.</exception>
/// <exception cref="ArgumentNullException">When <paramref name="validationContext" /> is null.</exception>
/// <exception cref="ArgumentException">
/// When <paramref name="instance" /> doesn't match the
/// <see cref="ValidationContext.ObjectInstance" /> on <paramref name="validationContext" />.
/// </exception>
/// <exception cref="ValidationException">When <paramref name="instance" /> is found to be invalid.</exception>
[RequiresUnreferencedCode(ValidationContext.InstanceTypeNotStaticallyDiscovered)]
public static void ValidateObject(object instance!!, ValidationContext validationContext!!,
bool validateAllProperties)
{
if (instance != validationContext.ObjectInstance)
{
throw new ArgumentException(SR.Validator_InstanceMustMatchValidationContextInstance, nameof(instance));
}
List<ValidationError> errors = GetObjectValidationErrors(instance, validationContext, validateAllProperties, false);
if (errors.Count > 0)
{
errors[0].ThrowValidationException();
}
}
/// <summary>
/// Throw a <see cref="ValidationException" /> if the given value is not valid for the
/// <see cref="ValidationAttribute" />s.
/// </summary>
/// <remarks>
/// This method evaluates the <see cref="ValidationAttribute" />s supplied until a validation error occurs,
/// at which time a <see cref="ValidationException" /> is thrown.
/// <para>
/// A <see cref="RequiredAttribute" /> within the <paramref name="validationAttributes" /> will always be evaluated
/// first.
/// </para>
/// </remarks>
/// <param name="value">The value to test. It cannot be null.</param>
/// <param name="validationContext">Describes the object being tested.</param>
/// <param name="validationAttributes">The list of <see cref="ValidationAttribute" />s to validate against this instance.</param>
/// <exception cref="ArgumentNullException">When <paramref name="validationContext" /> is null.</exception>
/// <exception cref="ValidationException">When <paramref name="value" /> is found to be invalid.</exception>
public static void ValidateValue(object value, ValidationContext validationContext!!,
IEnumerable<ValidationAttribute> validationAttributes!!)
{
List<ValidationError> errors = GetValidationErrors(value, validationContext, validationAttributes, false);
if (errors.Count > 0)
{
errors[0].ThrowValidationException();
}
}
/// <summary>
/// Creates a new <see cref="ValidationContext" /> to use to validate the type or a member of
/// the given object instance.
/// </summary>
/// <param name="instance">The object instance to use for the context.</param>
/// <param name="validationContext">
/// An parent validation context that supplies an <see cref="IServiceProvider" />
/// and <see cref="ValidationContext.Items" />.
/// </param>
/// <returns>A new <see cref="ValidationContext" /> for the <paramref name="instance" /> provided.</returns>
/// <exception cref="ArgumentNullException">When <paramref name="validationContext" /> is null.</exception>
[RequiresUnreferencedCode(ValidationContext.InstanceTypeNotStaticallyDiscovered)]
private static ValidationContext CreateValidationContext(object instance, ValidationContext validationContext)
{
Debug.Assert(validationContext != null);
// Create a new context using the existing ValidationContext that acts as an IServiceProvider and contains our existing items.
var context = new ValidationContext(instance, validationContext, validationContext.Items);
return context;
}
/// <summary>
/// Determine whether the given value can legally be assigned into the specified type.
/// </summary>
/// <param name="destinationType">The destination <see cref="Type" /> for the value.</param>
/// <param name="value">
/// The value to test to see if it can be assigned as the Type indicated by
/// <paramref name="destinationType" />.
/// </param>
/// <returns><c>true</c> if the assignment is legal.</returns>
/// <exception cref="ArgumentNullException">When <paramref name="destinationType" /> is null.</exception>
private static bool CanBeAssigned(Type destinationType, object? value)
{
if (value == null)
{
// Null can be assigned only to reference types or Nullable or Nullable<>
return !destinationType.IsValueType ||
(destinationType.IsGenericType &&
destinationType.GetGenericTypeDefinition() == typeof(Nullable<>));
}
// Not null -- be sure it can be cast to the right type
return destinationType.IsInstanceOfType(value);
}
/// <summary>
/// Determines whether the given value can legally be assigned to the given property.
/// </summary>
/// <param name="propertyName">The name of the property.</param>
/// <param name="propertyType">The type of the property.</param>
/// <param name="value">The value. Null is permitted only if the property will accept it.</param>
/// <exception cref="ArgumentException"> is thrown if <paramref name="value" /> is the wrong type for this property.</exception>
private static void EnsureValidPropertyType(string propertyName, Type propertyType, object? value)
{
if (!CanBeAssigned(propertyType, value))
{
throw new ArgumentException(SR.Format(SR.Validator_Property_Value_Wrong_Type, propertyName, propertyType),
nameof(value));
}
}
/// <summary>
/// Internal iterator to enumerate all validation errors for the given object instance.
/// </summary>
/// <param name="instance">Object instance to test.</param>
/// <param name="validationContext">Describes the object type.</param>
/// <param name="validateAllProperties">if <c>true</c> also validates all properties.</param>
/// <param name="breakOnFirstError">Whether to break on the first error or validate everything.</param>
/// <returns>
/// A collection of validation errors that result from validating the <paramref name="instance" /> with
/// the given <paramref name="validationContext" />.
/// </returns>
/// <exception cref="ArgumentNullException">When <paramref name="instance" /> is null.</exception>
/// <exception cref="ArgumentNullException">When <paramref name="validationContext" /> is null.</exception>
/// <exception cref="ArgumentException">
/// When <paramref name="instance" /> doesn't match the
/// <see cref="ValidationContext.ObjectInstance" /> on <paramref name="validationContext" />.
/// </exception>
[RequiresUnreferencedCode(ValidationContext.InstanceTypeNotStaticallyDiscovered)]
private static List<ValidationError> GetObjectValidationErrors(object instance,
ValidationContext validationContext!!, bool validateAllProperties, bool breakOnFirstError)
{
Debug.Assert(instance != null);
// Step 1: Validate the object properties' validation attributes
var errors = new List<ValidationError>();
errors.AddRange(GetObjectPropertyValidationErrors(instance, validationContext, validateAllProperties,
breakOnFirstError));
// We only proceed to Step 2 if there are no errors
if (errors.Count > 0)
{
return errors;
}
// Step 2: Validate the object's validation attributes
var attributes = _store.GetTypeValidationAttributes(validationContext);
errors.AddRange(GetValidationErrors(instance, validationContext, attributes, breakOnFirstError));
// We only proceed to Step 3 if there are no errors
if (errors.Count > 0)
{
return errors;
}
// Step 3: Test for IValidatableObject implementation
if (instance is IValidatableObject validatable)
{
var results = validatable.Validate(validationContext);
if (results != null)
{
foreach (ValidationResult result in results)
{
if (result != ValidationResult.Success)
{
errors.Add(new ValidationError(null, instance, result));
}
}
}
}
return errors;
}
/// <summary>
/// Internal iterator to enumerate all the validation errors for all properties of the given object instance.
/// </summary>
/// <param name="instance">Object instance to test.</param>
/// <param name="validationContext">Describes the object type.</param>
/// <param name="validateAllProperties">
/// If <c>true</c>, evaluates all the properties, otherwise just checks that
/// ones marked with <see cref="RequiredAttribute" /> are not null.
/// </param>
/// <param name="breakOnFirstError">Whether to break on the first error or validate everything.</param>
/// <returns>A list of <see cref="ValidationError" /> instances.</returns>
[RequiresUnreferencedCode(ValidationContext.InstanceTypeNotStaticallyDiscovered)]
private static IEnumerable<ValidationError> GetObjectPropertyValidationErrors(object instance,
ValidationContext validationContext, bool validateAllProperties, bool breakOnFirstError)
{
var properties = GetPropertyValues(instance, validationContext);
var errors = new List<ValidationError>();
foreach (var property in properties)
{
// get list of all validation attributes for this property
var attributes = _store.GetPropertyValidationAttributes(property.Key);
if (validateAllProperties)
{
// validate all validation attributes on this property
errors.AddRange(GetValidationErrors(property.Value, property.Key, attributes, breakOnFirstError));
}
else
{
// only validate the first Required attribute
foreach (ValidationAttribute attribute in attributes)
{
if (attribute is RequiredAttribute reqAttr)
{
// Note: we let the [Required] attribute do its own null testing,
// since the user may have subclassed it and have a deeper meaning to what 'required' means
var validationResult = reqAttr.GetValidationResult(property.Value, property.Key);
if (validationResult != ValidationResult.Success)
{
errors.Add(new ValidationError(reqAttr, property.Value, validationResult!));
}
break;
}
}
}
if (breakOnFirstError && errors.Count > 0)
{
break;
}
}
return errors;
}
/// <summary>
/// Retrieves the property values for the given instance.
/// </summary>
/// <param name="instance">Instance from which to fetch the properties.</param>
/// <param name="validationContext">Describes the entity being validated.</param>
/// <returns>
/// A set of key value pairs, where the key is a validation context for the property and the value is its current
/// value.
/// </returns>
/// <remarks>Ignores indexed properties.</remarks>
[RequiresUnreferencedCode(ValidationContext.InstanceTypeNotStaticallyDiscovered)]
private static ICollection<KeyValuePair<ValidationContext, object?>> GetPropertyValues(object instance,
ValidationContext validationContext)
{
var properties = TypeDescriptor.GetProperties(instance);
var items = new List<KeyValuePair<ValidationContext, object?>>(properties.Count);
foreach (PropertyDescriptor property in properties)
{
var context = CreateValidationContext(instance, validationContext);
context.MemberName = property.Name;
if (_store.GetPropertyValidationAttributes(context).Any())
{
items.Add(new KeyValuePair<ValidationContext, object?>(context, property.GetValue(instance)));
}
}
return items;
}
/// <summary>
/// Internal iterator to enumerate all validation errors for an value.
/// </summary>
/// <remarks>
/// If a <see cref="RequiredAttribute" /> is found, it will be evaluated first, and if that fails,
/// validation will abort, regardless of the <paramref name="breakOnFirstError" /> parameter value.
/// </remarks>
/// <param name="value">The value to pass to the validation attributes.</param>
/// <param name="validationContext">Describes the type/member being evaluated.</param>
/// <param name="attributes">The validation attributes to evaluate.</param>
/// <param name="breakOnFirstError">
/// Whether or not to break on the first validation failure. A
/// <see cref="RequiredAttribute" /> failure will always abort with that sole failure.
/// </param>
/// <returns>The collection of validation errors.</returns>
/// <exception cref="ArgumentNullException">When <paramref name="validationContext" /> is null.</exception>
private static List<ValidationError> GetValidationErrors(object? value,
ValidationContext validationContext!!, IEnumerable<ValidationAttribute> attributes, bool breakOnFirstError)
{
var errors = new List<ValidationError>();
ValidationError? validationError;
// Get the required validator if there is one and test it first, aborting on failure
RequiredAttribute? required = null;
foreach (ValidationAttribute attribute in attributes)
{
required = attribute as RequiredAttribute;
if (required is not null)
{
if (!TryValidate(value, validationContext, required, out validationError))
{
errors.Add(validationError);
return errors;
}
break;
}
}
// Iterate through the rest of the validators, skipping the required validator
foreach (ValidationAttribute attr in attributes)
{
if (attr != required)
{
if (!TryValidate(value, validationContext, attr, out validationError))
{
errors.Add(validationError);
if (breakOnFirstError)
{
break;
}
}
}
}
return errors;
}
/// <summary>
/// Tests whether a value is valid against a single <see cref="ValidationAttribute" /> using the
/// <see cref="ValidationContext" />.
/// </summary>
/// <param name="value">The value to be tested for validity.</param>
/// <param name="validationContext">Describes the property member to validate.</param>
/// <param name="attribute">The validation attribute to test.</param>
/// <param name="validationError">
/// The validation error that occurs during validation. Will be <c>null</c> when the return
/// value is <c>true</c>.
/// </param>
/// <returns><c>true</c> if the value is valid.</returns>
/// <exception cref="ArgumentNullException">When <paramref name="validationContext" /> is null.</exception>
private static bool TryValidate(object? value, ValidationContext validationContext, ValidationAttribute attribute,
[NotNullWhen(false)] out ValidationError? validationError)
{
Debug.Assert(validationContext != null);
var validationResult = attribute.GetValidationResult(value, validationContext);
if (validationResult != ValidationResult.Success)
{
validationError = new ValidationError(attribute, value, validationResult!);
return false;
}
validationError = null;
return true;
}
/// <summary>
/// Private helper class to encapsulate a ValidationAttribute with the failed value and the user-visible
/// target name against which it was validated.
/// </summary>
private sealed class ValidationError
{
private readonly object? _value;
private readonly ValidationAttribute? _validationAttribute;
internal ValidationError(ValidationAttribute? validationAttribute, object? value,
ValidationResult validationResult)
{
_validationAttribute = validationAttribute;
ValidationResult = validationResult;
_value = value;
}
internal ValidationResult ValidationResult { get; }
internal void ThrowValidationException() => throw new ValidationException(ValidationResult, _validationAttribute, _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.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
namespace System.ComponentModel.DataAnnotations
{
/// <summary>
/// Helper class to validate objects, properties and other values using their associated
/// <see cref="ValidationAttribute" />
/// custom attributes.
/// </summary>
public static class Validator
{
private static readonly ValidationAttributeStore _store = ValidationAttributeStore.Instance;
/// <summary>
/// Tests whether the given property value is valid.
/// </summary>
/// <remarks>
/// This method will test each <see cref="ValidationAttribute" /> associated with the property
/// identified by <paramref name="validationContext" />. If <paramref name="validationResults" /> is non-null,
/// this method will add a <see cref="ValidationResult" /> to it for each validation failure.
/// <para>
/// If there is a <see cref="RequiredAttribute" /> found on the property, it will be evaluated before all other
/// validation attributes. If the required validator fails then validation will abort, adding that single
/// failure into the <paramref name="validationResults" /> when applicable, returning a value of <c>false</c>.
/// </para>
/// <para>
/// If <paramref name="validationResults" /> is null and there isn't a <see cref="RequiredAttribute" /> failure,
/// then all validators will be evaluated.
/// </para>
/// </remarks>
/// <param name="value">The value to test.</param>
/// <param name="validationContext">
/// Describes the property member to validate and provides services and context for the
/// validators.
/// </param>
/// <param name="validationResults">Optional collection to receive <see cref="ValidationResult" />s for the failures.</param>
/// <returns><c>true</c> if the value is valid, <c>false</c> if any validation errors are encountered.</returns>
/// <exception cref="ArgumentException">
/// When the <see cref="ValidationContext.MemberName" /> of <paramref name="validationContext" /> is not a valid
/// property.
/// </exception>
[RequiresUnreferencedCode("The Type of validationContext.ObjectType cannot be statically discovered.")]
public static bool TryValidateProperty(object? value, ValidationContext validationContext,
ICollection<ValidationResult>? validationResults)
{
// Throw if value cannot be assigned to this property. That is not a validation exception.
var propertyType = _store.GetPropertyType(validationContext);
var propertyName = validationContext.MemberName!;
EnsureValidPropertyType(propertyName, propertyType, value);
var result = true;
var breakOnFirstError = (validationResults == null);
var attributes = _store.GetPropertyValidationAttributes(validationContext);
foreach (var err in GetValidationErrors(value, validationContext, attributes, breakOnFirstError))
{
result = false;
validationResults?.Add(err.ValidationResult);
}
return result;
}
/// <summary>
/// Tests whether the given object instance is valid.
/// </summary>
/// <remarks>
/// This method evaluates all <see cref="ValidationAttribute" />s attached to the object instance's type. It also
/// checks to ensure all properties marked with <see cref="RequiredAttribute" /> are set. It does not validate the
/// property values of the object.
/// <para>
/// If <paramref name="validationResults" /> is null, then execution will abort upon the first validation
/// failure. If <paramref name="validationResults" /> is non-null, then all validation attributes will be
/// evaluated.
/// </para>
/// </remarks>
/// <param name="instance">The object instance to test. It cannot be <c>null</c>.</param>
/// <param name="validationContext">Describes the object to validate and provides services and context for the validators.</param>
/// <param name="validationResults">Optional collection to receive <see cref="ValidationResult" />s for the failures.</param>
/// <returns><c>true</c> if the object is valid, <c>false</c> if any validation errors are encountered.</returns>
/// <exception cref="ArgumentNullException">When <paramref name="instance" /> is null.</exception>
/// <exception cref="ArgumentException">
/// When <paramref name="instance" /> doesn't match the
/// <see cref="ValidationContext.ObjectInstance" />on <paramref name="validationContext" />.
/// </exception>
[RequiresUnreferencedCode(ValidationContext.InstanceTypeNotStaticallyDiscovered)]
public static bool TryValidateObject(
object instance, ValidationContext validationContext, ICollection<ValidationResult>? validationResults) =>
TryValidateObject(instance, validationContext, validationResults, false /*validateAllProperties*/);
/// <summary>
/// Tests whether the given object instance is valid.
/// </summary>
/// <remarks>
/// This method evaluates all <see cref="ValidationAttribute" />s attached to the object instance's type. It also
/// checks to ensure all properties marked with <see cref="RequiredAttribute" /> are set. If
/// <paramref name="validateAllProperties" />
/// is <c>true</c>, this method will also evaluate the <see cref="ValidationAttribute" />s for all the immediate
/// properties
/// of this object. This process is not recursive.
/// <para>
/// If <paramref name="validationResults" /> is null, then execution will abort upon the first validation
/// failure. If <paramref name="validationResults" /> is non-null, then all validation attributes will be
/// evaluated.
/// </para>
/// <para>
/// For any given property, if it has a <see cref="RequiredAttribute" /> that fails validation, no other validators
/// will be evaluated for that property.
/// </para>
/// </remarks>
/// <param name="instance">The object instance to test. It cannot be null.</param>
/// <param name="validationContext">Describes the object to validate and provides services and context for the validators.</param>
/// <param name="validationResults">Optional collection to receive <see cref="ValidationResult" />s for the failures.</param>
/// <param name="validateAllProperties">
/// If <c>true</c>, also evaluates all properties of the object (this process is not
/// recursive over properties of the properties).
/// </param>
/// <returns><c>true</c> if the object is valid, <c>false</c> if any validation errors are encountered.</returns>
/// <exception cref="ArgumentNullException">When <paramref name="instance" /> is null.</exception>
/// <exception cref="ArgumentException">
/// When <paramref name="instance" /> doesn't match the
/// <see cref="ValidationContext.ObjectInstance" />on <paramref name="validationContext" />.
/// </exception>
[RequiresUnreferencedCode(ValidationContext.InstanceTypeNotStaticallyDiscovered)]
public static bool TryValidateObject(object instance!!, ValidationContext validationContext,
ICollection<ValidationResult>? validationResults, bool validateAllProperties)
{
if (validationContext != null && instance != validationContext.ObjectInstance)
{
throw new ArgumentException(SR.Validator_InstanceMustMatchValidationContextInstance, nameof(instance));
}
var result = true;
var breakOnFirstError = (validationResults == null);
foreach (ValidationError err in GetObjectValidationErrors(instance, validationContext!, validateAllProperties, breakOnFirstError))
{
result = false;
validationResults?.Add(err.ValidationResult);
}
return result;
}
/// <summary>
/// Tests whether the given value is valid against a specified list of <see cref="ValidationAttribute" />s.
/// </summary>
/// <remarks>
/// This method will test each <see cref="ValidationAttribute" />s specified. If
/// <paramref name="validationResults" /> is non-null, this method will add a <see cref="ValidationResult" />
/// to it for each validation failure.
/// <para>
/// If there is a <see cref="RequiredAttribute" /> within the <paramref name="validationAttributes" />, it will
/// be evaluated before all other validation attributes. If the required validator fails then validation will
/// abort, adding that single failure into the <paramref name="validationResults" /> when applicable, returning a
/// value of <c>false</c>.
/// </para>
/// <para>
/// If <paramref name="validationResults" /> is null and there isn't a <see cref="RequiredAttribute" /> failure,
/// then all validators will be evaluated.
/// </para>
/// </remarks>
/// <param name="value">The value to test. It cannot be null.</param>
/// <param name="validationContext">
/// Describes the object being validated and provides services and context for the
/// validators.
/// </param>
/// <param name="validationResults">Optional collection to receive <see cref="ValidationResult" />s for the failures.</param>
/// <param name="validationAttributes">
/// The list of <see cref="ValidationAttribute" />s to validate this
/// <paramref name="value" /> against.
/// </param>
/// <returns><c>true</c> if the object is valid, <c>false</c> if any validation errors are encountered.</returns>
public static bool TryValidateValue(object value, ValidationContext validationContext,
ICollection<ValidationResult>? validationResults, IEnumerable<ValidationAttribute> validationAttributes!!)
{
var result = true;
var breakOnFirstError = validationResults == null;
foreach (
var err in
GetValidationErrors(value, validationContext, validationAttributes, breakOnFirstError))
{
result = false;
validationResults?.Add(err.ValidationResult);
}
return result;
}
/// <summary>
/// Throws a <see cref="ValidationException" /> if the given property <paramref name="value" /> is not valid.
/// </summary>
/// <param name="value">The value to test.</param>
/// <param name="validationContext">
/// Describes the object being validated and provides services and context for the
/// validators. It cannot be <c>null</c>.
/// </param>
/// <exception cref="ArgumentNullException">When <paramref name="validationContext" /> is null.</exception>
/// <exception cref="ValidationException">When <paramref name="value" /> is invalid for this property.</exception>
[RequiresUnreferencedCode("The Type of validationContext.ObjectType cannot be statically discovered.")]
public static void ValidateProperty(object? value, ValidationContext validationContext)
{
// Throw if value cannot be assigned to this property. That is not a validation exception.
var propertyType = _store.GetPropertyType(validationContext);
EnsureValidPropertyType(validationContext.MemberName!, propertyType, value);
var attributes = _store.GetPropertyValidationAttributes(validationContext);
List<ValidationError> errors = GetValidationErrors(value, validationContext, attributes, false);
if (errors.Count > 0)
{
errors[0].ThrowValidationException();
}
}
/// <summary>
/// Throws a <see cref="ValidationException" /> if the given <paramref name="instance" /> is not valid.
/// </summary>
/// <remarks>
/// This method evaluates all <see cref="ValidationAttribute" />s attached to the object's type.
/// </remarks>
/// <param name="instance">The object instance to test. It cannot be null.</param>
/// <param name="validationContext">
/// Describes the object being validated and provides services and context for the
/// validators. It cannot be <c>null</c>.
/// </param>
/// <exception cref="ArgumentNullException">When <paramref name="instance" /> is null.</exception>
/// <exception cref="ArgumentNullException">When <paramref name="validationContext" /> is null.</exception>
/// <exception cref="ArgumentException">
/// When <paramref name="instance" /> doesn't match the
/// <see cref="ValidationContext.ObjectInstance" /> on <paramref name="validationContext" />.
/// </exception>
/// <exception cref="ValidationException">When <paramref name="instance" /> is found to be invalid.</exception>
[RequiresUnreferencedCode(ValidationContext.InstanceTypeNotStaticallyDiscovered)]
public static void ValidateObject(object instance, ValidationContext validationContext)
{
ValidateObject(instance, validationContext, false /*validateAllProperties*/);
}
/// <summary>
/// Throws a <see cref="ValidationException" /> if the given object instance is not valid.
/// </summary>
/// <remarks>
/// This method evaluates all <see cref="ValidationAttribute" />s attached to the object's type.
/// If <paramref name="validateAllProperties" /> is <c>true</c> it also validates all the object's properties.
/// </remarks>
/// <param name="instance">The object instance to test. It cannot be null.</param>
/// <param name="validationContext">
/// Describes the object being validated and provides services and context for the
/// validators. It cannot be <c>null</c>.
/// </param>
/// <param name="validateAllProperties">If <c>true</c>, also validates all the <paramref name="instance" />'s properties.</param>
/// <exception cref="ArgumentNullException">When <paramref name="instance" /> is null.</exception>
/// <exception cref="ArgumentNullException">When <paramref name="validationContext" /> is null.</exception>
/// <exception cref="ArgumentException">
/// When <paramref name="instance" /> doesn't match the
/// <see cref="ValidationContext.ObjectInstance" /> on <paramref name="validationContext" />.
/// </exception>
/// <exception cref="ValidationException">When <paramref name="instance" /> is found to be invalid.</exception>
[RequiresUnreferencedCode(ValidationContext.InstanceTypeNotStaticallyDiscovered)]
public static void ValidateObject(object instance!!, ValidationContext validationContext!!,
bool validateAllProperties)
{
if (instance != validationContext.ObjectInstance)
{
throw new ArgumentException(SR.Validator_InstanceMustMatchValidationContextInstance, nameof(instance));
}
List<ValidationError> errors = GetObjectValidationErrors(instance, validationContext, validateAllProperties, false);
if (errors.Count > 0)
{
errors[0].ThrowValidationException();
}
}
/// <summary>
/// Throw a <see cref="ValidationException" /> if the given value is not valid for the
/// <see cref="ValidationAttribute" />s.
/// </summary>
/// <remarks>
/// This method evaluates the <see cref="ValidationAttribute" />s supplied until a validation error occurs,
/// at which time a <see cref="ValidationException" /> is thrown.
/// <para>
/// A <see cref="RequiredAttribute" /> within the <paramref name="validationAttributes" /> will always be evaluated
/// first.
/// </para>
/// </remarks>
/// <param name="value">The value to test. It cannot be null.</param>
/// <param name="validationContext">Describes the object being tested.</param>
/// <param name="validationAttributes">The list of <see cref="ValidationAttribute" />s to validate against this instance.</param>
/// <exception cref="ArgumentNullException">When <paramref name="validationContext" /> is null.</exception>
/// <exception cref="ValidationException">When <paramref name="value" /> is found to be invalid.</exception>
public static void ValidateValue(object value, ValidationContext validationContext!!,
IEnumerable<ValidationAttribute> validationAttributes!!)
{
List<ValidationError> errors = GetValidationErrors(value, validationContext, validationAttributes, false);
if (errors.Count > 0)
{
errors[0].ThrowValidationException();
}
}
/// <summary>
/// Creates a new <see cref="ValidationContext" /> to use to validate the type or a member of
/// the given object instance.
/// </summary>
/// <param name="instance">The object instance to use for the context.</param>
/// <param name="validationContext">
/// An parent validation context that supplies an <see cref="IServiceProvider" />
/// and <see cref="ValidationContext.Items" />.
/// </param>
/// <returns>A new <see cref="ValidationContext" /> for the <paramref name="instance" /> provided.</returns>
/// <exception cref="ArgumentNullException">When <paramref name="validationContext" /> is null.</exception>
[RequiresUnreferencedCode(ValidationContext.InstanceTypeNotStaticallyDiscovered)]
private static ValidationContext CreateValidationContext(object instance, ValidationContext validationContext)
{
Debug.Assert(validationContext != null);
// Create a new context using the existing ValidationContext that acts as an IServiceProvider and contains our existing items.
var context = new ValidationContext(instance, validationContext, validationContext.Items);
return context;
}
/// <summary>
/// Determine whether the given value can legally be assigned into the specified type.
/// </summary>
/// <param name="destinationType">The destination <see cref="Type" /> for the value.</param>
/// <param name="value">
/// The value to test to see if it can be assigned as the Type indicated by
/// <paramref name="destinationType" />.
/// </param>
/// <returns><c>true</c> if the assignment is legal.</returns>
/// <exception cref="ArgumentNullException">When <paramref name="destinationType" /> is null.</exception>
private static bool CanBeAssigned(Type destinationType, object? value)
{
if (value == null)
{
// Null can be assigned only to reference types or Nullable or Nullable<>
return !destinationType.IsValueType ||
(destinationType.IsGenericType &&
destinationType.GetGenericTypeDefinition() == typeof(Nullable<>));
}
// Not null -- be sure it can be cast to the right type
return destinationType.IsInstanceOfType(value);
}
/// <summary>
/// Determines whether the given value can legally be assigned to the given property.
/// </summary>
/// <param name="propertyName">The name of the property.</param>
/// <param name="propertyType">The type of the property.</param>
/// <param name="value">The value. Null is permitted only if the property will accept it.</param>
/// <exception cref="ArgumentException"> is thrown if <paramref name="value" /> is the wrong type for this property.</exception>
private static void EnsureValidPropertyType(string propertyName, Type propertyType, object? value)
{
if (!CanBeAssigned(propertyType, value))
{
throw new ArgumentException(SR.Format(SR.Validator_Property_Value_Wrong_Type, propertyName, propertyType),
nameof(value));
}
}
/// <summary>
/// Internal iterator to enumerate all validation errors for the given object instance.
/// </summary>
/// <param name="instance">Object instance to test.</param>
/// <param name="validationContext">Describes the object type.</param>
/// <param name="validateAllProperties">if <c>true</c> also validates all properties.</param>
/// <param name="breakOnFirstError">Whether to break on the first error or validate everything.</param>
/// <returns>
/// A collection of validation errors that result from validating the <paramref name="instance" /> with
/// the given <paramref name="validationContext" />.
/// </returns>
/// <exception cref="ArgumentNullException">When <paramref name="instance" /> is null.</exception>
/// <exception cref="ArgumentNullException">When <paramref name="validationContext" /> is null.</exception>
/// <exception cref="ArgumentException">
/// When <paramref name="instance" /> doesn't match the
/// <see cref="ValidationContext.ObjectInstance" /> on <paramref name="validationContext" />.
/// </exception>
[RequiresUnreferencedCode(ValidationContext.InstanceTypeNotStaticallyDiscovered)]
private static List<ValidationError> GetObjectValidationErrors(object instance,
ValidationContext validationContext!!, bool validateAllProperties, bool breakOnFirstError)
{
Debug.Assert(instance != null);
// Step 1: Validate the object properties' validation attributes
var errors = new List<ValidationError>();
errors.AddRange(GetObjectPropertyValidationErrors(instance, validationContext, validateAllProperties,
breakOnFirstError));
// We only proceed to Step 2 if there are no errors
if (errors.Count > 0)
{
return errors;
}
// Step 2: Validate the object's validation attributes
var attributes = _store.GetTypeValidationAttributes(validationContext);
errors.AddRange(GetValidationErrors(instance, validationContext, attributes, breakOnFirstError));
// We only proceed to Step 3 if there are no errors
if (errors.Count > 0)
{
return errors;
}
// Step 3: Test for IValidatableObject implementation
if (instance is IValidatableObject validatable)
{
var results = validatable.Validate(validationContext);
if (results != null)
{
foreach (ValidationResult result in results)
{
if (result != ValidationResult.Success)
{
errors.Add(new ValidationError(null, instance, result));
}
}
}
}
return errors;
}
/// <summary>
/// Internal iterator to enumerate all the validation errors for all properties of the given object instance.
/// </summary>
/// <param name="instance">Object instance to test.</param>
/// <param name="validationContext">Describes the object type.</param>
/// <param name="validateAllProperties">
/// If <c>true</c>, evaluates all the properties, otherwise just checks that
/// ones marked with <see cref="RequiredAttribute" /> are not null.
/// </param>
/// <param name="breakOnFirstError">Whether to break on the first error or validate everything.</param>
/// <returns>A list of <see cref="ValidationError" /> instances.</returns>
[RequiresUnreferencedCode(ValidationContext.InstanceTypeNotStaticallyDiscovered)]
private static IEnumerable<ValidationError> GetObjectPropertyValidationErrors(object instance,
ValidationContext validationContext, bool validateAllProperties, bool breakOnFirstError)
{
var properties = GetPropertyValues(instance, validationContext);
var errors = new List<ValidationError>();
foreach (var property in properties)
{
// get list of all validation attributes for this property
var attributes = _store.GetPropertyValidationAttributes(property.Key);
if (validateAllProperties)
{
// validate all validation attributes on this property
errors.AddRange(GetValidationErrors(property.Value, property.Key, attributes, breakOnFirstError));
}
else
{
// only validate the first Required attribute
foreach (ValidationAttribute attribute in attributes)
{
if (attribute is RequiredAttribute reqAttr)
{
// Note: we let the [Required] attribute do its own null testing,
// since the user may have subclassed it and have a deeper meaning to what 'required' means
var validationResult = reqAttr.GetValidationResult(property.Value, property.Key);
if (validationResult != ValidationResult.Success)
{
errors.Add(new ValidationError(reqAttr, property.Value, validationResult!));
}
break;
}
}
}
if (breakOnFirstError && errors.Count > 0)
{
break;
}
}
return errors;
}
/// <summary>
/// Retrieves the property values for the given instance.
/// </summary>
/// <param name="instance">Instance from which to fetch the properties.</param>
/// <param name="validationContext">Describes the entity being validated.</param>
/// <returns>
/// A set of key value pairs, where the key is a validation context for the property and the value is its current
/// value.
/// </returns>
/// <remarks>Ignores indexed properties.</remarks>
[RequiresUnreferencedCode(ValidationContext.InstanceTypeNotStaticallyDiscovered)]
private static ICollection<KeyValuePair<ValidationContext, object?>> GetPropertyValues(object instance,
ValidationContext validationContext)
{
var properties = TypeDescriptor.GetProperties(instance);
var items = new List<KeyValuePair<ValidationContext, object?>>(properties.Count);
foreach (PropertyDescriptor property in properties)
{
var context = CreateValidationContext(instance, validationContext);
context.MemberName = property.Name;
if (_store.GetPropertyValidationAttributes(context).Any())
{
items.Add(new KeyValuePair<ValidationContext, object?>(context, property.GetValue(instance)));
}
}
return items;
}
/// <summary>
/// Internal iterator to enumerate all validation errors for an value.
/// </summary>
/// <remarks>
/// If a <see cref="RequiredAttribute" /> is found, it will be evaluated first, and if that fails,
/// validation will abort, regardless of the <paramref name="breakOnFirstError" /> parameter value.
/// </remarks>
/// <param name="value">The value to pass to the validation attributes.</param>
/// <param name="validationContext">Describes the type/member being evaluated.</param>
/// <param name="attributes">The validation attributes to evaluate.</param>
/// <param name="breakOnFirstError">
/// Whether or not to break on the first validation failure. A
/// <see cref="RequiredAttribute" /> failure will always abort with that sole failure.
/// </param>
/// <returns>The collection of validation errors.</returns>
/// <exception cref="ArgumentNullException">When <paramref name="validationContext" /> is null.</exception>
private static List<ValidationError> GetValidationErrors(object? value,
ValidationContext validationContext!!, IEnumerable<ValidationAttribute> attributes, bool breakOnFirstError)
{
var errors = new List<ValidationError>();
ValidationError? validationError;
// Get the required validator if there is one and test it first, aborting on failure
RequiredAttribute? required = null;
foreach (ValidationAttribute attribute in attributes)
{
required = attribute as RequiredAttribute;
if (required is not null)
{
if (!TryValidate(value, validationContext, required, out validationError))
{
errors.Add(validationError);
return errors;
}
break;
}
}
// Iterate through the rest of the validators, skipping the required validator
foreach (ValidationAttribute attr in attributes)
{
if (attr != required)
{
if (!TryValidate(value, validationContext, attr, out validationError))
{
errors.Add(validationError);
if (breakOnFirstError)
{
break;
}
}
}
}
return errors;
}
/// <summary>
/// Tests whether a value is valid against a single <see cref="ValidationAttribute" /> using the
/// <see cref="ValidationContext" />.
/// </summary>
/// <param name="value">The value to be tested for validity.</param>
/// <param name="validationContext">Describes the property member to validate.</param>
/// <param name="attribute">The validation attribute to test.</param>
/// <param name="validationError">
/// The validation error that occurs during validation. Will be <c>null</c> when the return
/// value is <c>true</c>.
/// </param>
/// <returns><c>true</c> if the value is valid.</returns>
/// <exception cref="ArgumentNullException">When <paramref name="validationContext" /> is null.</exception>
private static bool TryValidate(object? value, ValidationContext validationContext, ValidationAttribute attribute,
[NotNullWhen(false)] out ValidationError? validationError)
{
Debug.Assert(validationContext != null);
var validationResult = attribute.GetValidationResult(value, validationContext);
if (validationResult != ValidationResult.Success)
{
validationError = new ValidationError(attribute, value, validationResult!);
return false;
}
validationError = null;
return true;
}
/// <summary>
/// Private helper class to encapsulate a ValidationAttribute with the failed value and the user-visible
/// target name against which it was validated.
/// </summary>
private sealed class ValidationError
{
private readonly object? _value;
private readonly ValidationAttribute? _validationAttribute;
internal ValidationError(ValidationAttribute? validationAttribute, object? value,
ValidationResult validationResult)
{
_validationAttribute = validationAttribute;
ValidationResult = validationResult;
_value = value;
}
internal ValidationResult ValidationResult { get; }
internal void ThrowValidationException() => throw new ValidationException(ValidationResult, _validationAttribute, _value);
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Linq.Queryable/tests/AggregateTests.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Linq.Expressions;
using Xunit;
namespace System.Linq.Tests
{
public class AggregateTests : EnumerableBasedTests
{
[Fact]
public void MultipleElements()
{
int[] source = { 5, 6, 0, -4 };
int expected = 7;
Assert.Equal(expected, source.AsQueryable().Aggregate((x, y) => x + y));
}
[Fact]
public void MultipleElementsAndSeed()
{
int[] source = { 5, 6, 2, -4 };
long seed = 2;
long expected = -480;
Assert.Equal(expected, source.AsQueryable().Aggregate(seed, (x, y) => x * y));
}
[Fact]
public void MultipleElementsSeedResultSelector()
{
int[] source = { 5, 6, 2, -4 };
long seed = 2;
long expected = -475;
Assert.Equal(expected, source.AsQueryable().Aggregate(seed, (x, y) => x * y, x => x + 5.0));
}
[Fact]
public void NullSource()
{
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IQueryable<int>)null).Aggregate((x, y) => x + y));
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IQueryable<int>)null).Aggregate(0, (x, y) => x + y));
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IQueryable<int>)null).Aggregate(0, (x, y) => x + y, i => i));
}
[Fact]
public void NullFunc()
{
Expression<Func<int, int, int>> func = null;
AssertExtensions.Throws<ArgumentNullException>("func", () => Enumerable.Range(0, 3).AsQueryable().Aggregate(func));
AssertExtensions.Throws<ArgumentNullException>("func", () => Enumerable.Range(0, 3).AsQueryable().Aggregate(0, func));
AssertExtensions.Throws<ArgumentNullException>("func", () => Enumerable.Range(0, 3).AsQueryable().Aggregate(0, func, i => i));
}
[Fact]
public void NullResultSelector()
{
Expression<Func<int, int>> resultSelector = null;
AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Range(0, 3).AsQueryable().Aggregate(0, (x, y) => x + y, resultSelector));
}
[Fact]
public void Aggregate1()
{
var val = (new int[] { 0, 2, 1 }).AsQueryable().Aggregate((n1, n2) => n1 + n2);
Assert.Equal((int)3, val);
}
[Fact]
public void Aggregate2()
{
var val = (new int[] { 0, 2, 1 }).AsQueryable().Aggregate("", (n1, n2) => n1 + n2.ToString());
Assert.Equal("021", val);
}
[Fact]
public void Aggregate3()
{
var val = (new int[] { 0, 2, 1 }).AsQueryable().Aggregate(0L, (n1, n2) => n1 + n2, n => n.ToString());
Assert.Equal("3", val);
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Linq.Expressions;
using Xunit;
namespace System.Linq.Tests
{
public class AggregateTests : EnumerableBasedTests
{
[Fact]
public void MultipleElements()
{
int[] source = { 5, 6, 0, -4 };
int expected = 7;
Assert.Equal(expected, source.AsQueryable().Aggregate((x, y) => x + y));
}
[Fact]
public void MultipleElementsAndSeed()
{
int[] source = { 5, 6, 2, -4 };
long seed = 2;
long expected = -480;
Assert.Equal(expected, source.AsQueryable().Aggregate(seed, (x, y) => x * y));
}
[Fact]
public void MultipleElementsSeedResultSelector()
{
int[] source = { 5, 6, 2, -4 };
long seed = 2;
long expected = -475;
Assert.Equal(expected, source.AsQueryable().Aggregate(seed, (x, y) => x * y, x => x + 5.0));
}
[Fact]
public void NullSource()
{
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IQueryable<int>)null).Aggregate((x, y) => x + y));
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IQueryable<int>)null).Aggregate(0, (x, y) => x + y));
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IQueryable<int>)null).Aggregate(0, (x, y) => x + y, i => i));
}
[Fact]
public void NullFunc()
{
Expression<Func<int, int, int>> func = null;
AssertExtensions.Throws<ArgumentNullException>("func", () => Enumerable.Range(0, 3).AsQueryable().Aggregate(func));
AssertExtensions.Throws<ArgumentNullException>("func", () => Enumerable.Range(0, 3).AsQueryable().Aggregate(0, func));
AssertExtensions.Throws<ArgumentNullException>("func", () => Enumerable.Range(0, 3).AsQueryable().Aggregate(0, func, i => i));
}
[Fact]
public void NullResultSelector()
{
Expression<Func<int, int>> resultSelector = null;
AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Range(0, 3).AsQueryable().Aggregate(0, (x, y) => x + y, resultSelector));
}
[Fact]
public void Aggregate1()
{
var val = (new int[] { 0, 2, 1 }).AsQueryable().Aggregate((n1, n2) => n1 + n2);
Assert.Equal((int)3, val);
}
[Fact]
public void Aggregate2()
{
var val = (new int[] { 0, 2, 1 }).AsQueryable().Aggregate("", (n1, n2) => n1 + n2.ToString());
Assert.Equal("021", val);
}
[Fact]
public void Aggregate3()
{
var val = (new int[] { 0, 2, 1 }).AsQueryable().Aggregate(0L, (n1, n2) => n1 + n2, n => n.ToString());
Assert.Equal("3", val);
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationItemFormatter.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.Xml;
using System.Runtime.Serialization;
namespace System.ServiceModel.Syndication
{
[DataContract]
public abstract class SyndicationItemFormatter
{
private SyndicationItem _item;
protected SyndicationItemFormatter()
{
_item = null;
}
protected SyndicationItemFormatter(SyndicationItem itemToWrite!!)
{
_item = itemToWrite;
}
public SyndicationItem Item => _item;
public abstract string Version { get; }
public abstract bool CanRead(XmlReader reader);
public abstract void ReadFrom(XmlReader reader);
public override string ToString() => $"{GetType()}, SyndicationVersion={Version}";
public abstract void WriteTo(XmlWriter writer);
protected internal virtual void SetItem(SyndicationItem item!!)
{
_item = item;
}
internal static SyndicationItem CreateItemInstance(Type itemType)
{
if (itemType.Equals(typeof(SyndicationItem)))
{
return new SyndicationItem();
}
else
{
return (SyndicationItem)Activator.CreateInstance(itemType);
}
}
protected static SyndicationCategory CreateCategory(SyndicationItem item) => SyndicationFeedFormatter.CreateCategory(item);
protected static SyndicationLink CreateLink(SyndicationItem item) => SyndicationFeedFormatter.CreateLink(item);
protected static SyndicationPerson CreatePerson(SyndicationItem item) => SyndicationFeedFormatter.CreatePerson(item);
protected static void LoadElementExtensions(XmlReader reader, SyndicationItem item, int maxExtensionSize)
{
SyndicationFeedFormatter.LoadElementExtensions(reader, item, maxExtensionSize);
}
protected static void LoadElementExtensions(XmlReader reader, SyndicationCategory category, int maxExtensionSize)
{
SyndicationFeedFormatter.LoadElementExtensions(reader, category, maxExtensionSize);
}
protected static void LoadElementExtensions(XmlReader reader, SyndicationLink link, int maxExtensionSize)
{
SyndicationFeedFormatter.LoadElementExtensions(reader, link, maxExtensionSize);
}
protected static void LoadElementExtensions(XmlReader reader, SyndicationPerson person, int maxExtensionSize)
{
SyndicationFeedFormatter.LoadElementExtensions(reader, person, maxExtensionSize);
}
protected static bool TryParseAttribute(string name, string ns, string value, SyndicationItem item, string version)
{
return SyndicationFeedFormatter.TryParseAttribute(name, ns, value, item, version);
}
protected static bool TryParseAttribute(string name, string ns, string value, SyndicationCategory category, string version)
{
return SyndicationFeedFormatter.TryParseAttribute(name, ns, value, category, version);
}
protected static bool TryParseAttribute(string name, string ns, string value, SyndicationLink link, string version)
{
return SyndicationFeedFormatter.TryParseAttribute(name, ns, value, link, version);
}
protected static bool TryParseAttribute(string name, string ns, string value, SyndicationPerson person, string version)
{
return SyndicationFeedFormatter.TryParseAttribute(name, ns, value, person, version);
}
protected static bool TryParseContent(XmlReader reader, SyndicationItem item, string contentType, string version, out SyndicationContent content)
{
return SyndicationFeedFormatter.TryParseContent(reader, item, contentType, version, out content);
}
protected static bool TryParseElement(XmlReader reader, SyndicationItem item, string version)
{
return SyndicationFeedFormatter.TryParseElement(reader, item, version);
}
protected static bool TryParseElement(XmlReader reader, SyndicationCategory category, string version)
{
return SyndicationFeedFormatter.TryParseElement(reader, category, version);
}
protected static bool TryParseElement(XmlReader reader, SyndicationLink link, string version)
{
return SyndicationFeedFormatter.TryParseElement(reader, link, version);
}
protected static bool TryParseElement(XmlReader reader, SyndicationPerson person, string version)
{
return SyndicationFeedFormatter.TryParseElement(reader, person, version);
}
protected static void WriteAttributeExtensions(XmlWriter writer, SyndicationItem item, string version)
{
SyndicationFeedFormatter.WriteAttributeExtensions(writer, item, version);
}
protected static void WriteAttributeExtensions(XmlWriter writer, SyndicationCategory category, string version)
{
SyndicationFeedFormatter.WriteAttributeExtensions(writer, category, version);
}
protected static void WriteAttributeExtensions(XmlWriter writer, SyndicationLink link, string version)
{
SyndicationFeedFormatter.WriteAttributeExtensions(writer, link, version);
}
protected static void WriteAttributeExtensions(XmlWriter writer, SyndicationPerson person, string version)
{
SyndicationFeedFormatter.WriteAttributeExtensions(writer, person, version);
}
protected static void WriteElementExtensions(XmlWriter writer, SyndicationItem item, string version)
{
SyndicationFeedFormatter.WriteElementExtensions(writer, item, version);
}
protected abstract SyndicationItem CreateItemInstance();
protected void WriteElementExtensions(XmlWriter writer, SyndicationCategory category, string version)
{
SyndicationFeedFormatter.WriteElementExtensions(writer, category, version);
}
protected void WriteElementExtensions(XmlWriter writer, SyndicationLink link, string version)
{
SyndicationFeedFormatter.WriteElementExtensions(writer, link, version);
}
protected void WriteElementExtensions(XmlWriter writer, SyndicationPerson person, string version)
{
SyndicationFeedFormatter.WriteElementExtensions(writer, person, version);
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Xml;
using System.Runtime.Serialization;
namespace System.ServiceModel.Syndication
{
[DataContract]
public abstract class SyndicationItemFormatter
{
private SyndicationItem _item;
protected SyndicationItemFormatter()
{
_item = null;
}
protected SyndicationItemFormatter(SyndicationItem itemToWrite!!)
{
_item = itemToWrite;
}
public SyndicationItem Item => _item;
public abstract string Version { get; }
public abstract bool CanRead(XmlReader reader);
public abstract void ReadFrom(XmlReader reader);
public override string ToString() => $"{GetType()}, SyndicationVersion={Version}";
public abstract void WriteTo(XmlWriter writer);
protected internal virtual void SetItem(SyndicationItem item!!)
{
_item = item;
}
internal static SyndicationItem CreateItemInstance(Type itemType)
{
if (itemType.Equals(typeof(SyndicationItem)))
{
return new SyndicationItem();
}
else
{
return (SyndicationItem)Activator.CreateInstance(itemType);
}
}
protected static SyndicationCategory CreateCategory(SyndicationItem item) => SyndicationFeedFormatter.CreateCategory(item);
protected static SyndicationLink CreateLink(SyndicationItem item) => SyndicationFeedFormatter.CreateLink(item);
protected static SyndicationPerson CreatePerson(SyndicationItem item) => SyndicationFeedFormatter.CreatePerson(item);
protected static void LoadElementExtensions(XmlReader reader, SyndicationItem item, int maxExtensionSize)
{
SyndicationFeedFormatter.LoadElementExtensions(reader, item, maxExtensionSize);
}
protected static void LoadElementExtensions(XmlReader reader, SyndicationCategory category, int maxExtensionSize)
{
SyndicationFeedFormatter.LoadElementExtensions(reader, category, maxExtensionSize);
}
protected static void LoadElementExtensions(XmlReader reader, SyndicationLink link, int maxExtensionSize)
{
SyndicationFeedFormatter.LoadElementExtensions(reader, link, maxExtensionSize);
}
protected static void LoadElementExtensions(XmlReader reader, SyndicationPerson person, int maxExtensionSize)
{
SyndicationFeedFormatter.LoadElementExtensions(reader, person, maxExtensionSize);
}
protected static bool TryParseAttribute(string name, string ns, string value, SyndicationItem item, string version)
{
return SyndicationFeedFormatter.TryParseAttribute(name, ns, value, item, version);
}
protected static bool TryParseAttribute(string name, string ns, string value, SyndicationCategory category, string version)
{
return SyndicationFeedFormatter.TryParseAttribute(name, ns, value, category, version);
}
protected static bool TryParseAttribute(string name, string ns, string value, SyndicationLink link, string version)
{
return SyndicationFeedFormatter.TryParseAttribute(name, ns, value, link, version);
}
protected static bool TryParseAttribute(string name, string ns, string value, SyndicationPerson person, string version)
{
return SyndicationFeedFormatter.TryParseAttribute(name, ns, value, person, version);
}
protected static bool TryParseContent(XmlReader reader, SyndicationItem item, string contentType, string version, out SyndicationContent content)
{
return SyndicationFeedFormatter.TryParseContent(reader, item, contentType, version, out content);
}
protected static bool TryParseElement(XmlReader reader, SyndicationItem item, string version)
{
return SyndicationFeedFormatter.TryParseElement(reader, item, version);
}
protected static bool TryParseElement(XmlReader reader, SyndicationCategory category, string version)
{
return SyndicationFeedFormatter.TryParseElement(reader, category, version);
}
protected static bool TryParseElement(XmlReader reader, SyndicationLink link, string version)
{
return SyndicationFeedFormatter.TryParseElement(reader, link, version);
}
protected static bool TryParseElement(XmlReader reader, SyndicationPerson person, string version)
{
return SyndicationFeedFormatter.TryParseElement(reader, person, version);
}
protected static void WriteAttributeExtensions(XmlWriter writer, SyndicationItem item, string version)
{
SyndicationFeedFormatter.WriteAttributeExtensions(writer, item, version);
}
protected static void WriteAttributeExtensions(XmlWriter writer, SyndicationCategory category, string version)
{
SyndicationFeedFormatter.WriteAttributeExtensions(writer, category, version);
}
protected static void WriteAttributeExtensions(XmlWriter writer, SyndicationLink link, string version)
{
SyndicationFeedFormatter.WriteAttributeExtensions(writer, link, version);
}
protected static void WriteAttributeExtensions(XmlWriter writer, SyndicationPerson person, string version)
{
SyndicationFeedFormatter.WriteAttributeExtensions(writer, person, version);
}
protected static void WriteElementExtensions(XmlWriter writer, SyndicationItem item, string version)
{
SyndicationFeedFormatter.WriteElementExtensions(writer, item, version);
}
protected abstract SyndicationItem CreateItemInstance();
protected void WriteElementExtensions(XmlWriter writer, SyndicationCategory category, string version)
{
SyndicationFeedFormatter.WriteElementExtensions(writer, category, version);
}
protected void WriteElementExtensions(XmlWriter writer, SyndicationLink link, string version)
{
SyndicationFeedFormatter.WriteElementExtensions(writer, link, version);
}
protected void WriteElementExtensions(XmlWriter writer, SyndicationPerson person, string version)
{
SyndicationFeedFormatter.WriteElementExtensions(writer, person, version);
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Reflection.Emit/tests/EventBuilder/EventBuilderSetCustomAttribute.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Linq;
using Xunit;
namespace System.Reflection.Emit.Tests
{
public class EventBuilderSetCustomAttribute
{
public delegate void TestEventHandler(object sender, object arg);
[Fact]
public void SetCustomAttribute_ConstructorInfo_ByteArray()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract);
EventBuilder eventBuilder = type.DefineEvent("TestEvent", EventAttributes.None, typeof(TestEventHandler));
ConstructorInfo atrtributeConstructor = typeof(EmptyAttribute).GetConstructor(new Type[0]);
byte[] bytes = Enumerable.Range(0, 256).Select(i => (byte)i).ToArray();
eventBuilder.SetCustomAttribute(atrtributeConstructor, bytes);
}
[Fact]
public void SetCustomAttribute_ConstructorInfo_ByteArray_NullConstructorInfo_ThrowsArgumentNullException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract);
EventBuilder ev = type.DefineEvent("TestEvent", EventAttributes.None, typeof(TestEventHandler));
AssertExtensions.Throws<ArgumentNullException>("con", () => ev.SetCustomAttribute(null, new byte[256]));
}
[Fact]
public void SetCustomAttribute_ConstructorInfo_ByteArray_NullByteArray_ThrowsArgumentNullException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract);
EventBuilder eventBuilder = type.DefineEvent("TestEvent", EventAttributes.None, typeof(TestEventHandler));
ConstructorInfo attributeConstructor = typeof(EmptyAttribute).GetConstructor(new Type[0]);
AssertExtensions.Throws<ArgumentNullException>("binaryAttribute", () => eventBuilder.SetCustomAttribute(attributeConstructor, null));
}
[Fact]
public void SetCustomAttribute_ConstructorInfo_ByteArray_TypeCreated_ThrowsInvalidOperationException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract);
EventBuilder eventBuilder = type.DefineEvent("TestEvent", EventAttributes.None, typeof(TestEventHandler));
ConstructorInfo attributeConstructor = typeof(EmptyAttribute).GetConstructor(new Type[0]);
byte[] bytes = Enumerable.Range(0, 256).Select(i => (byte)i).ToArray();
type.CreateTypeInfo().AsType();
Assert.Throws<InvalidOperationException>(() => eventBuilder.SetCustomAttribute(attributeConstructor, bytes));
}
[Fact]
public void SetCustomAttribute_CustomAttributeBuilder()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract);
EventBuilder eventBuilder = type.DefineEvent("TestEvent", EventAttributes.None, typeof(TestEventHandler));
ConstructorInfo attributeConstructor = typeof(EmptyAttribute).GetConstructor(new Type[0]);
CustomAttributeBuilder attribute = new CustomAttributeBuilder(attributeConstructor, new object[0]);
eventBuilder.SetCustomAttribute(attribute);
}
[Fact]
public void SetCustomAttribute_CustomAttributeBuilder_NullBuilder_ThrowsArgumentNullException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract);
EventBuilder eventBuilder = type.DefineEvent("TestEvent", EventAttributes.None, typeof(TestEventHandler));
AssertExtensions.Throws<ArgumentNullException>("customBuilder", () => eventBuilder.SetCustomAttribute(null));
}
[Fact]
public void SetCustomAttribute_CustomAttributeBuilder_TypeCreated_ThrowsInvalidOperationException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract);
EventBuilder eventBuilder = type.DefineEvent("TestEvent", EventAttributes.None, typeof(TestEventHandler));
ConstructorInfo attributeConstructor = typeof(EmptyAttribute).GetConstructor(new Type[0]);
CustomAttributeBuilder attribute = new CustomAttributeBuilder(attributeConstructor, new object[0]);
type.CreateTypeInfo().AsType();
Assert.Throws<InvalidOperationException>(() => eventBuilder.SetCustomAttribute(attribute));
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Linq;
using Xunit;
namespace System.Reflection.Emit.Tests
{
public class EventBuilderSetCustomAttribute
{
public delegate void TestEventHandler(object sender, object arg);
[Fact]
public void SetCustomAttribute_ConstructorInfo_ByteArray()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract);
EventBuilder eventBuilder = type.DefineEvent("TestEvent", EventAttributes.None, typeof(TestEventHandler));
ConstructorInfo atrtributeConstructor = typeof(EmptyAttribute).GetConstructor(new Type[0]);
byte[] bytes = Enumerable.Range(0, 256).Select(i => (byte)i).ToArray();
eventBuilder.SetCustomAttribute(atrtributeConstructor, bytes);
}
[Fact]
public void SetCustomAttribute_ConstructorInfo_ByteArray_NullConstructorInfo_ThrowsArgumentNullException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract);
EventBuilder ev = type.DefineEvent("TestEvent", EventAttributes.None, typeof(TestEventHandler));
AssertExtensions.Throws<ArgumentNullException>("con", () => ev.SetCustomAttribute(null, new byte[256]));
}
[Fact]
public void SetCustomAttribute_ConstructorInfo_ByteArray_NullByteArray_ThrowsArgumentNullException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract);
EventBuilder eventBuilder = type.DefineEvent("TestEvent", EventAttributes.None, typeof(TestEventHandler));
ConstructorInfo attributeConstructor = typeof(EmptyAttribute).GetConstructor(new Type[0]);
AssertExtensions.Throws<ArgumentNullException>("binaryAttribute", () => eventBuilder.SetCustomAttribute(attributeConstructor, null));
}
[Fact]
public void SetCustomAttribute_ConstructorInfo_ByteArray_TypeCreated_ThrowsInvalidOperationException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract);
EventBuilder eventBuilder = type.DefineEvent("TestEvent", EventAttributes.None, typeof(TestEventHandler));
ConstructorInfo attributeConstructor = typeof(EmptyAttribute).GetConstructor(new Type[0]);
byte[] bytes = Enumerable.Range(0, 256).Select(i => (byte)i).ToArray();
type.CreateTypeInfo().AsType();
Assert.Throws<InvalidOperationException>(() => eventBuilder.SetCustomAttribute(attributeConstructor, bytes));
}
[Fact]
public void SetCustomAttribute_CustomAttributeBuilder()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract);
EventBuilder eventBuilder = type.DefineEvent("TestEvent", EventAttributes.None, typeof(TestEventHandler));
ConstructorInfo attributeConstructor = typeof(EmptyAttribute).GetConstructor(new Type[0]);
CustomAttributeBuilder attribute = new CustomAttributeBuilder(attributeConstructor, new object[0]);
eventBuilder.SetCustomAttribute(attribute);
}
[Fact]
public void SetCustomAttribute_CustomAttributeBuilder_NullBuilder_ThrowsArgumentNullException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract);
EventBuilder eventBuilder = type.DefineEvent("TestEvent", EventAttributes.None, typeof(TestEventHandler));
AssertExtensions.Throws<ArgumentNullException>("customBuilder", () => eventBuilder.SetCustomAttribute(null));
}
[Fact]
public void SetCustomAttribute_CustomAttributeBuilder_TypeCreated_ThrowsInvalidOperationException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract);
EventBuilder eventBuilder = type.DefineEvent("TestEvent", EventAttributes.None, typeof(TestEventHandler));
ConstructorInfo attributeConstructor = typeof(EmptyAttribute).GetConstructor(new Type[0]);
CustomAttributeBuilder attribute = new CustomAttributeBuilder(attributeConstructor, new object[0]);
type.CreateTypeInfo().AsType();
Assert.Throws<InvalidOperationException>(() => eventBuilder.SetCustomAttribute(attribute));
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Security.Cryptography/src/Microsoft/Win32/SafeHandles/SafePasswordHandle.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 System.Security;
#pragma warning disable CA1419 // TODO https://github.com/dotnet/roslyn-analyzers/issues/5232: not intended for use with P/Invoke
namespace Microsoft.Win32.SafeHandles
{
/// <summary>
/// Wrap a string- or SecureString-based object. A null value indicates IntPtr.Zero should be used.
/// </summary>
internal sealed partial class SafePasswordHandle : SafeHandleZeroOrMinusOneIsInvalid
{
internal int Length { get; private set; }
public SafePasswordHandle(string? password)
: base(ownsHandle: true)
{
if (password != null)
{
handle = Marshal.StringToHGlobalUni(password);
Length = password.Length;
}
}
public SafePasswordHandle(ReadOnlySpan<char> password)
: base(ownsHandle: true)
{
// "".AsSpan() is not default, so this is compat for "null tries NULL first".
if (password != default)
{
int spanLen;
checked
{
spanLen = password.Length + 1;
handle = Marshal.AllocHGlobal(spanLen * sizeof(char));
}
unsafe
{
Span<char> dest = new Span<char>((void*)handle, spanLen);
password.CopyTo(dest);
dest[password.Length] = '\0';
}
Length = password.Length;
}
}
public SafePasswordHandle(SecureString? password)
: base(ownsHandle: true)
{
if (password != null)
{
handle = Marshal.SecureStringToGlobalAllocUnicode(password);
Length = password.Length;
}
}
protected override bool ReleaseHandle()
{
Marshal.ZeroFreeGlobalAllocUnicode(handle);
SetHandle((IntPtr)(-1));
Length = 0;
return true;
}
protected override void Dispose(bool disposing)
{
if (disposing && SafeHandleCache<SafePasswordHandle>.IsCachedInvalidHandle(this))
{
return;
}
base.Dispose(disposing);
}
internal ReadOnlySpan<char> DangerousGetSpan()
{
if (IsInvalid)
{
return default;
}
unsafe
{
return new ReadOnlySpan<char>((char*)handle, Length);
}
}
public static SafePasswordHandle InvalidHandle =>
SafeHandleCache<SafePasswordHandle>.GetInvalidHandle(
() =>
{
var handle = new SafePasswordHandle((string?)null);
handle.handle = (IntPtr)(-1);
return handle;
});
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
using System.Security;
#pragma warning disable CA1419 // TODO https://github.com/dotnet/roslyn-analyzers/issues/5232: not intended for use with P/Invoke
namespace Microsoft.Win32.SafeHandles
{
/// <summary>
/// Wrap a string- or SecureString-based object. A null value indicates IntPtr.Zero should be used.
/// </summary>
internal sealed partial class SafePasswordHandle : SafeHandleZeroOrMinusOneIsInvalid
{
internal int Length { get; private set; }
public SafePasswordHandle(string? password)
: base(ownsHandle: true)
{
if (password != null)
{
handle = Marshal.StringToHGlobalUni(password);
Length = password.Length;
}
}
public SafePasswordHandle(ReadOnlySpan<char> password)
: base(ownsHandle: true)
{
// "".AsSpan() is not default, so this is compat for "null tries NULL first".
if (password != default)
{
int spanLen;
checked
{
spanLen = password.Length + 1;
handle = Marshal.AllocHGlobal(spanLen * sizeof(char));
}
unsafe
{
Span<char> dest = new Span<char>((void*)handle, spanLen);
password.CopyTo(dest);
dest[password.Length] = '\0';
}
Length = password.Length;
}
}
public SafePasswordHandle(SecureString? password)
: base(ownsHandle: true)
{
if (password != null)
{
handle = Marshal.SecureStringToGlobalAllocUnicode(password);
Length = password.Length;
}
}
protected override bool ReleaseHandle()
{
Marshal.ZeroFreeGlobalAllocUnicode(handle);
SetHandle((IntPtr)(-1));
Length = 0;
return true;
}
protected override void Dispose(bool disposing)
{
if (disposing && SafeHandleCache<SafePasswordHandle>.IsCachedInvalidHandle(this))
{
return;
}
base.Dispose(disposing);
}
internal ReadOnlySpan<char> DangerousGetSpan()
{
if (IsInvalid)
{
return default;
}
unsafe
{
return new ReadOnlySpan<char>((char*)handle, Length);
}
}
public static SafePasswordHandle InvalidHandle =>
SafeHandleCache<SafePasswordHandle>.GetInvalidHandle(
() =>
{
var handle = new SafePasswordHandle((string?)null);
handle.handle = (IntPtr)(-1);
return handle;
});
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b80764/b80764.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;
namespace JitTest
{
internal class Test
{
private static unsafe void initbuf(byte* buf, int num)
{
for (int i = 0; i < 100; i++)
buf[i] = (byte)i;
Console.WriteLine("buffer " + num.ToString() + " allocated");
}
private static unsafe void ckbuf(byte* buf, int num)
{
if (buf != null)
{
for (int i = 0; i < 100; i++)
{
if (buf[i] != (byte)i)
{
Console.WriteLine("buffer " + num.ToString() + " is garbage !!");
return;
}
}
}
Console.WriteLine("buffer " + num.ToString() + " is OK");
}
private static unsafe int Main()
{
byte* buf1 = stackalloc byte[100], buf2 = null, buf3 = null;
initbuf(buf1, 1);
ckbuf(buf1, 1);
try
{
Console.WriteLine("--- entered outer try ---");
byte* TEMP1 = stackalloc byte[100];
buf2 = TEMP1;
initbuf(buf2, 2);
ckbuf(buf1, 1);
ckbuf(buf2, 2);
try
{
Console.WriteLine("--- entered inner try ---");
byte* TEMP2 = stackalloc byte[100];
buf3 = TEMP2;
initbuf(buf3, 3);
ckbuf(buf1, 1);
ckbuf(buf2, 2);
ckbuf(buf3, 3);
Console.WriteLine("--- throwing exception ---");
throw new Exception();
}
finally
{
Console.WriteLine("--- finally ---");
ckbuf(buf1, 1);
ckbuf(buf2, 2);
ckbuf(buf3, 3);
}
}
catch (Exception)
{
Console.WriteLine("--- catch ---");
ckbuf(buf1, 1);
ckbuf(buf2, 2);
ckbuf(buf3, 3);
}
Console.WriteLine("--- after try-catch ---");
ckbuf(buf1, 1);
ckbuf(buf2, 2);
ckbuf(buf3, 3);
Console.WriteLine("=== TEST ENDED ===");
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.Runtime.InteropServices;
namespace JitTest
{
internal class Test
{
private static unsafe void initbuf(byte* buf, int num)
{
for (int i = 0; i < 100; i++)
buf[i] = (byte)i;
Console.WriteLine("buffer " + num.ToString() + " allocated");
}
private static unsafe void ckbuf(byte* buf, int num)
{
if (buf != null)
{
for (int i = 0; i < 100; i++)
{
if (buf[i] != (byte)i)
{
Console.WriteLine("buffer " + num.ToString() + " is garbage !!");
return;
}
}
}
Console.WriteLine("buffer " + num.ToString() + " is OK");
}
private static unsafe int Main()
{
byte* buf1 = stackalloc byte[100], buf2 = null, buf3 = null;
initbuf(buf1, 1);
ckbuf(buf1, 1);
try
{
Console.WriteLine("--- entered outer try ---");
byte* TEMP1 = stackalloc byte[100];
buf2 = TEMP1;
initbuf(buf2, 2);
ckbuf(buf1, 1);
ckbuf(buf2, 2);
try
{
Console.WriteLine("--- entered inner try ---");
byte* TEMP2 = stackalloc byte[100];
buf3 = TEMP2;
initbuf(buf3, 3);
ckbuf(buf1, 1);
ckbuf(buf2, 2);
ckbuf(buf3, 3);
Console.WriteLine("--- throwing exception ---");
throw new Exception();
}
finally
{
Console.WriteLine("--- finally ---");
ckbuf(buf1, 1);
ckbuf(buf2, 2);
ckbuf(buf3, 3);
}
}
catch (Exception)
{
Console.WriteLine("--- catch ---");
ckbuf(buf1, 1);
ckbuf(buf2, 2);
ckbuf(buf3, 3);
}
Console.WriteLine("--- after try-catch ---");
ckbuf(buf1, 1);
ckbuf(buf2, 2);
ckbuf(buf3, 3);
Console.WriteLine("=== TEST ENDED ===");
return 100;
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetEUid.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 Sys
{
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetEUid")]
internal static partial int SetEUid(uint euid);
}
}
| // 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 Sys
{
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetEUid")]
internal static partial int SetEUid(uint euid);
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/RateLimiter.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.Tasks;
namespace System.Threading.RateLimiting
{
/// <summary>
/// Represents a limiter type that users interact with to determine if an operation can proceed.
/// </summary>
public abstract class RateLimiter : IAsyncDisposable, IDisposable
{
/// <summary>
/// An estimated count of available permits.
/// </summary>
/// <returns></returns>
public abstract int GetAvailablePermits();
/// <summary>
/// Fast synchronous attempt to acquire permits.
/// </summary>
/// <remarks>
/// Set <paramref name="permitCount"/> to 0 to get whether permits are exhausted.
/// </remarks>
/// <param name="permitCount">Number of permits to try and acquire.</param>
/// <returns>A successful or failed lease.</returns>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public RateLimitLease Acquire(int permitCount = 1)
{
if (permitCount < 0)
{
throw new ArgumentOutOfRangeException(nameof(permitCount));
}
return AcquireCore(permitCount);
}
/// <summary>
/// Method that <see cref="RateLimiter"/> implementations implement for <see cref="Acquire"/>.
/// </summary>
/// <param name="permitCount">Number of permits to try and acquire.</param>
/// <returns></returns>
protected abstract RateLimitLease AcquireCore(int permitCount);
/// <summary>
/// Wait until the requested permits are available or permits can no longer be acquired.
/// </summary>
/// <remarks>
/// Set <paramref name="permitCount"/> to 0 to wait until permits are replenished.
/// </remarks>
/// <param name="permitCount">Number of permits to try and acquire.</param>
/// <param name="cancellationToken">Optional token to allow canceling a queued request for permits.</param>
/// <returns>A task that completes when the requested permits are acquired or when the requested permits are denied.</returns>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public ValueTask<RateLimitLease> WaitAsync(int permitCount = 1, CancellationToken cancellationToken = default)
{
if (permitCount < 0)
{
throw new ArgumentOutOfRangeException(nameof(permitCount));
}
if (cancellationToken.IsCancellationRequested)
{
return new ValueTask<RateLimitLease>(Task.FromCanceled<RateLimitLease>(cancellationToken));
}
return WaitAsyncCore(permitCount, cancellationToken);
}
/// <summary>
/// Method that <see cref="RateLimiter"/> implementations implement for <see cref="WaitAsync"/>.
/// </summary>
/// <param name="permitCount">Number of permits to try and acquire.</param>
/// <param name="cancellationToken">Optional token to allow canceling a queued request for permits.</param>
/// <returns>A task that completes when the requested permits are acquired or when the requested permits are denied.</returns>
protected abstract ValueTask<RateLimitLease> WaitAsyncCore(int permitCount, CancellationToken cancellationToken);
/// <summary>
/// Dispose method for implementations to write.
/// </summary>
/// <param name="disposing"></param>
protected virtual void Dispose(bool disposing) { }
/// <summary>
/// Disposes the RateLimiter. This completes any queued acquires with a failed lease.
/// </summary>
public void Dispose()
{
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
/// <summary>
/// DisposeAsync method for implementations to write.
/// </summary>
protected virtual ValueTask DisposeAsyncCore()
{
return default;
}
/// <summary>
/// Disposes the RateLimiter asynchronously.
/// </summary>
/// <returns>ValueTask representin the completion of the disposal.</returns>
public async ValueTask DisposeAsync()
{
// Perform async cleanup.
await DisposeAsyncCore().ConfigureAwait(false);
// Dispose of unmanaged resources.
Dispose(false);
// Suppress finalization.
GC.SuppressFinalize(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.Threading.Tasks;
namespace System.Threading.RateLimiting
{
/// <summary>
/// Represents a limiter type that users interact with to determine if an operation can proceed.
/// </summary>
public abstract class RateLimiter : IAsyncDisposable, IDisposable
{
/// <summary>
/// An estimated count of available permits.
/// </summary>
/// <returns></returns>
public abstract int GetAvailablePermits();
/// <summary>
/// Fast synchronous attempt to acquire permits.
/// </summary>
/// <remarks>
/// Set <paramref name="permitCount"/> to 0 to get whether permits are exhausted.
/// </remarks>
/// <param name="permitCount">Number of permits to try and acquire.</param>
/// <returns>A successful or failed lease.</returns>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public RateLimitLease Acquire(int permitCount = 1)
{
if (permitCount < 0)
{
throw new ArgumentOutOfRangeException(nameof(permitCount));
}
return AcquireCore(permitCount);
}
/// <summary>
/// Method that <see cref="RateLimiter"/> implementations implement for <see cref="Acquire"/>.
/// </summary>
/// <param name="permitCount">Number of permits to try and acquire.</param>
/// <returns></returns>
protected abstract RateLimitLease AcquireCore(int permitCount);
/// <summary>
/// Wait until the requested permits are available or permits can no longer be acquired.
/// </summary>
/// <remarks>
/// Set <paramref name="permitCount"/> to 0 to wait until permits are replenished.
/// </remarks>
/// <param name="permitCount">Number of permits to try and acquire.</param>
/// <param name="cancellationToken">Optional token to allow canceling a queued request for permits.</param>
/// <returns>A task that completes when the requested permits are acquired or when the requested permits are denied.</returns>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public ValueTask<RateLimitLease> WaitAsync(int permitCount = 1, CancellationToken cancellationToken = default)
{
if (permitCount < 0)
{
throw new ArgumentOutOfRangeException(nameof(permitCount));
}
if (cancellationToken.IsCancellationRequested)
{
return new ValueTask<RateLimitLease>(Task.FromCanceled<RateLimitLease>(cancellationToken));
}
return WaitAsyncCore(permitCount, cancellationToken);
}
/// <summary>
/// Method that <see cref="RateLimiter"/> implementations implement for <see cref="WaitAsync"/>.
/// </summary>
/// <param name="permitCount">Number of permits to try and acquire.</param>
/// <param name="cancellationToken">Optional token to allow canceling a queued request for permits.</param>
/// <returns>A task that completes when the requested permits are acquired or when the requested permits are denied.</returns>
protected abstract ValueTask<RateLimitLease> WaitAsyncCore(int permitCount, CancellationToken cancellationToken);
/// <summary>
/// Dispose method for implementations to write.
/// </summary>
/// <param name="disposing"></param>
protected virtual void Dispose(bool disposing) { }
/// <summary>
/// Disposes the RateLimiter. This completes any queued acquires with a failed lease.
/// </summary>
public void Dispose()
{
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
/// <summary>
/// DisposeAsync method for implementations to write.
/// </summary>
protected virtual ValueTask DisposeAsyncCore()
{
return default;
}
/// <summary>
/// Disposes the RateLimiter asynchronously.
/// </summary>
/// <returns>ValueTask representin the completion of the disposal.</returns>
public async ValueTask DisposeAsync()
{
// Perform async cleanup.
await DisposeAsyncCore().ConfigureAwait(false);
// Dispose of unmanaged resources.
Dispose(false);
// Suppress finalization.
GC.SuppressFinalize(this);
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/coreclr/nativeaot/System.Private.Reflection.Core/src/System/Reflection/Runtime/General/Dispensers.NativeFormat.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.Collections.Generic;
using System.Reflection.Runtime.General;
using System.Reflection.Runtime.TypeInfos;
using System.Reflection.Runtime.TypeInfos.NativeFormat;
using System.Reflection.Runtime.Assemblies;
using System.Reflection.Runtime.Assemblies.NativeFormat;
using System.Reflection.Runtime.Dispensers;
using System.Reflection.Runtime.PropertyInfos;
using Internal.Reflection.Core;
using Internal.Reflection.Core.Execution;
using Internal.Metadata.NativeFormat;
//=================================================================================================================
// This file collects the various chokepoints that create the various Runtime*Info objects. This allows
// easy reviewing of the overall caching and unification policy.
//
// The dispenser functions are defined as static members of the associated Info class. This permits us
// to keep the constructors private to ensure that these really are the only ways to obtain these objects.
//=================================================================================================================
namespace System.Reflection.Runtime.Assemblies
{
//-----------------------------------------------------------------------------------------------------------
// Assemblies (maps 1-1 with a MetadataReader/ScopeDefinitionHandle.
//-----------------------------------------------------------------------------------------------------------
internal partial class RuntimeAssemblyInfo
{
static partial void GetNativeFormatRuntimeAssembly(AssemblyBindResult bindResult, ref RuntimeAssembly runtimeAssembly)
{
if (bindResult.Reader != null)
runtimeAssembly = NativeFormatRuntimeAssembly.GetRuntimeAssembly(bindResult.Reader, bindResult.ScopeDefinitionHandle, bindResult.OverflowScopes);
}
}
}
namespace System.Reflection.Runtime.Assemblies.NativeFormat
{
internal sealed partial class NativeFormatRuntimeAssembly
{
internal static RuntimeAssembly GetRuntimeAssembly(MetadataReader reader, ScopeDefinitionHandle scope, IEnumerable<QScopeDefinition> overflowScopes)
{
return s_scopeToAssemblyDispenser.GetOrAdd(new RuntimeAssemblyKey(reader, scope, overflowScopes));
}
private static readonly Dispenser<RuntimeAssemblyKey, RuntimeAssembly> s_scopeToAssemblyDispenser =
DispenserFactory.CreateDispenserV<RuntimeAssemblyKey, RuntimeAssembly>(
DispenserScenario.Scope_Assembly,
delegate (RuntimeAssemblyKey qScopeDefinition)
{
return (RuntimeAssembly)new NativeFormat.NativeFormatRuntimeAssembly(qScopeDefinition.Reader, qScopeDefinition.Handle, qScopeDefinition.Overflows);
}
);
//-----------------------------------------------------------------------------------------------------------
// Captures a qualified scope (a reader plus a handle) representing the canonical definition of an assembly,
// plus a set of "overflow" scopes representing additional pieces of the assembly.
//-----------------------------------------------------------------------------------------------------------
private struct RuntimeAssemblyKey : IEquatable<RuntimeAssemblyKey>
{
public RuntimeAssemblyKey(MetadataReader reader, ScopeDefinitionHandle handle, IEnumerable<QScopeDefinition> overflows)
{
_reader = reader;
_handle = handle;
_overflows = overflows;
}
public MetadataReader Reader { get { return _reader; } }
public ScopeDefinitionHandle Handle { get { return _handle; } }
public IEnumerable<QScopeDefinition> Overflows { get { return _overflows; } }
public ScopeDefinition ScopeDefinition
{
get
{
return _handle.GetScopeDefinition(_reader);
}
}
public override bool Equals(object obj)
{
if (!(obj is RuntimeAssemblyKey other))
return false;
return Equals(other);
}
public bool Equals(RuntimeAssemblyKey other)
{
// Equality depends only on the canonical definition of an assembly, not
// the overflows.
if (!(_reader == other._reader))
return false;
if (!(_handle.Equals(other._handle)))
return false;
return true;
}
public override int GetHashCode()
{
return _handle.GetHashCode();
}
private readonly MetadataReader _reader;
private readonly ScopeDefinitionHandle _handle;
private readonly IEnumerable<QScopeDefinition> _overflows;
}
}
}
namespace System.Reflection.Runtime.FieldInfos.NativeFormat
{
//-----------------------------------------------------------------------------------------------------------
// FieldInfos
//-----------------------------------------------------------------------------------------------------------
internal sealed partial class NativeFormatRuntimeFieldInfo
{
internal static RuntimeFieldInfo GetRuntimeFieldInfo(FieldHandle fieldHandle, NativeFormatRuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType)
{
return new NativeFormatRuntimeFieldInfo(fieldHandle, definingTypeInfo, contextTypeInfo, reflectedType).WithDebugName();
}
}
}
namespace System.Reflection.Runtime.PropertyInfos.NativeFormat
{
//-----------------------------------------------------------------------------------------------------------
// PropertyInfos
//-----------------------------------------------------------------------------------------------------------
internal sealed partial class NativeFormatRuntimePropertyInfo
{
internal static RuntimePropertyInfo GetRuntimePropertyInfo(PropertyHandle propertyHandle, NativeFormatRuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType)
{
return new NativeFormatRuntimePropertyInfo(propertyHandle, definingTypeInfo, contextTypeInfo, reflectedType).WithDebugName();
}
}
}
namespace System.Reflection.Runtime.EventInfos.NativeFormat
{
//-----------------------------------------------------------------------------------------------------------
// EventInfos
//-----------------------------------------------------------------------------------------------------------
internal sealed partial class NativeFormatRuntimeEventInfo
{
internal static RuntimeEventInfo GetRuntimeEventInfo(EventHandle eventHandle, NativeFormatRuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType)
{
return new NativeFormatRuntimeEventInfo(eventHandle, definingTypeInfo, contextTypeInfo, reflectedType).WithDebugName();
}
}
}
namespace System.Reflection.Runtime.Modules.NativeFormat
{
//-----------------------------------------------------------------------------------------------------------
// Modules (these exist only because Modules still exist in the Win8P surface area. There is a 1-1
// mapping between Assemblies and Modules.)
//-----------------------------------------------------------------------------------------------------------
internal sealed partial class NativeFormatRuntimeModule
{
internal static RuntimeModule GetRuntimeModule(NativeFormatRuntimeAssembly assembly)
{
return new NativeFormatRuntimeModule(assembly);
}
}
}
namespace System.Reflection.Runtime.ParameterInfos.NativeFormat
{
//-----------------------------------------------------------------------------------------------------------
// ParameterInfos for MethodBase objects with Parameter metadata.
//-----------------------------------------------------------------------------------------------------------
internal sealed partial class NativeFormatMethodParameterInfo
{
internal static NativeFormatMethodParameterInfo GetNativeFormatMethodParameterInfo(MethodBase member, MethodHandle methodHandle, int position, ParameterHandle parameterHandle, QSignatureTypeHandle qualifiedParameterType, TypeContext typeContext)
{
return new NativeFormatMethodParameterInfo(member, methodHandle, position, parameterHandle, qualifiedParameterType, typeContext);
}
}
}
namespace System.Reflection.Runtime.CustomAttributes
{
using NativeFormat;
//-----------------------------------------------------------------------------------------------------------
// CustomAttributeData objects returned by various CustomAttributes properties.
//-----------------------------------------------------------------------------------------------------------
internal abstract partial class RuntimeCustomAttributeData
{
internal static IEnumerable<CustomAttributeData> GetCustomAttributes(MetadataReader reader, CustomAttributeHandleCollection customAttributeHandles)
{
foreach (CustomAttributeHandle customAttributeHandle in customAttributeHandles)
yield return GetCustomAttributeData(reader, customAttributeHandle);
}
private static CustomAttributeData GetCustomAttributeData(MetadataReader reader, CustomAttributeHandle customAttributeHandle)
{
return new NativeFormatCustomAttributeData(reader, customAttributeHandle);
}
}
}
| // 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.Collections.Generic;
using System.Reflection.Runtime.General;
using System.Reflection.Runtime.TypeInfos;
using System.Reflection.Runtime.TypeInfos.NativeFormat;
using System.Reflection.Runtime.Assemblies;
using System.Reflection.Runtime.Assemblies.NativeFormat;
using System.Reflection.Runtime.Dispensers;
using System.Reflection.Runtime.PropertyInfos;
using Internal.Reflection.Core;
using Internal.Reflection.Core.Execution;
using Internal.Metadata.NativeFormat;
//=================================================================================================================
// This file collects the various chokepoints that create the various Runtime*Info objects. This allows
// easy reviewing of the overall caching and unification policy.
//
// The dispenser functions are defined as static members of the associated Info class. This permits us
// to keep the constructors private to ensure that these really are the only ways to obtain these objects.
//=================================================================================================================
namespace System.Reflection.Runtime.Assemblies
{
//-----------------------------------------------------------------------------------------------------------
// Assemblies (maps 1-1 with a MetadataReader/ScopeDefinitionHandle.
//-----------------------------------------------------------------------------------------------------------
internal partial class RuntimeAssemblyInfo
{
static partial void GetNativeFormatRuntimeAssembly(AssemblyBindResult bindResult, ref RuntimeAssembly runtimeAssembly)
{
if (bindResult.Reader != null)
runtimeAssembly = NativeFormatRuntimeAssembly.GetRuntimeAssembly(bindResult.Reader, bindResult.ScopeDefinitionHandle, bindResult.OverflowScopes);
}
}
}
namespace System.Reflection.Runtime.Assemblies.NativeFormat
{
internal sealed partial class NativeFormatRuntimeAssembly
{
internal static RuntimeAssembly GetRuntimeAssembly(MetadataReader reader, ScopeDefinitionHandle scope, IEnumerable<QScopeDefinition> overflowScopes)
{
return s_scopeToAssemblyDispenser.GetOrAdd(new RuntimeAssemblyKey(reader, scope, overflowScopes));
}
private static readonly Dispenser<RuntimeAssemblyKey, RuntimeAssembly> s_scopeToAssemblyDispenser =
DispenserFactory.CreateDispenserV<RuntimeAssemblyKey, RuntimeAssembly>(
DispenserScenario.Scope_Assembly,
delegate (RuntimeAssemblyKey qScopeDefinition)
{
return (RuntimeAssembly)new NativeFormat.NativeFormatRuntimeAssembly(qScopeDefinition.Reader, qScopeDefinition.Handle, qScopeDefinition.Overflows);
}
);
//-----------------------------------------------------------------------------------------------------------
// Captures a qualified scope (a reader plus a handle) representing the canonical definition of an assembly,
// plus a set of "overflow" scopes representing additional pieces of the assembly.
//-----------------------------------------------------------------------------------------------------------
private struct RuntimeAssemblyKey : IEquatable<RuntimeAssemblyKey>
{
public RuntimeAssemblyKey(MetadataReader reader, ScopeDefinitionHandle handle, IEnumerable<QScopeDefinition> overflows)
{
_reader = reader;
_handle = handle;
_overflows = overflows;
}
public MetadataReader Reader { get { return _reader; } }
public ScopeDefinitionHandle Handle { get { return _handle; } }
public IEnumerable<QScopeDefinition> Overflows { get { return _overflows; } }
public ScopeDefinition ScopeDefinition
{
get
{
return _handle.GetScopeDefinition(_reader);
}
}
public override bool Equals(object obj)
{
if (!(obj is RuntimeAssemblyKey other))
return false;
return Equals(other);
}
public bool Equals(RuntimeAssemblyKey other)
{
// Equality depends only on the canonical definition of an assembly, not
// the overflows.
if (!(_reader == other._reader))
return false;
if (!(_handle.Equals(other._handle)))
return false;
return true;
}
public override int GetHashCode()
{
return _handle.GetHashCode();
}
private readonly MetadataReader _reader;
private readonly ScopeDefinitionHandle _handle;
private readonly IEnumerable<QScopeDefinition> _overflows;
}
}
}
namespace System.Reflection.Runtime.FieldInfos.NativeFormat
{
//-----------------------------------------------------------------------------------------------------------
// FieldInfos
//-----------------------------------------------------------------------------------------------------------
internal sealed partial class NativeFormatRuntimeFieldInfo
{
internal static RuntimeFieldInfo GetRuntimeFieldInfo(FieldHandle fieldHandle, NativeFormatRuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType)
{
return new NativeFormatRuntimeFieldInfo(fieldHandle, definingTypeInfo, contextTypeInfo, reflectedType).WithDebugName();
}
}
}
namespace System.Reflection.Runtime.PropertyInfos.NativeFormat
{
//-----------------------------------------------------------------------------------------------------------
// PropertyInfos
//-----------------------------------------------------------------------------------------------------------
internal sealed partial class NativeFormatRuntimePropertyInfo
{
internal static RuntimePropertyInfo GetRuntimePropertyInfo(PropertyHandle propertyHandle, NativeFormatRuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType)
{
return new NativeFormatRuntimePropertyInfo(propertyHandle, definingTypeInfo, contextTypeInfo, reflectedType).WithDebugName();
}
}
}
namespace System.Reflection.Runtime.EventInfos.NativeFormat
{
//-----------------------------------------------------------------------------------------------------------
// EventInfos
//-----------------------------------------------------------------------------------------------------------
internal sealed partial class NativeFormatRuntimeEventInfo
{
internal static RuntimeEventInfo GetRuntimeEventInfo(EventHandle eventHandle, NativeFormatRuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType)
{
return new NativeFormatRuntimeEventInfo(eventHandle, definingTypeInfo, contextTypeInfo, reflectedType).WithDebugName();
}
}
}
namespace System.Reflection.Runtime.Modules.NativeFormat
{
//-----------------------------------------------------------------------------------------------------------
// Modules (these exist only because Modules still exist in the Win8P surface area. There is a 1-1
// mapping between Assemblies and Modules.)
//-----------------------------------------------------------------------------------------------------------
internal sealed partial class NativeFormatRuntimeModule
{
internal static RuntimeModule GetRuntimeModule(NativeFormatRuntimeAssembly assembly)
{
return new NativeFormatRuntimeModule(assembly);
}
}
}
namespace System.Reflection.Runtime.ParameterInfos.NativeFormat
{
//-----------------------------------------------------------------------------------------------------------
// ParameterInfos for MethodBase objects with Parameter metadata.
//-----------------------------------------------------------------------------------------------------------
internal sealed partial class NativeFormatMethodParameterInfo
{
internal static NativeFormatMethodParameterInfo GetNativeFormatMethodParameterInfo(MethodBase member, MethodHandle methodHandle, int position, ParameterHandle parameterHandle, QSignatureTypeHandle qualifiedParameterType, TypeContext typeContext)
{
return new NativeFormatMethodParameterInfo(member, methodHandle, position, parameterHandle, qualifiedParameterType, typeContext);
}
}
}
namespace System.Reflection.Runtime.CustomAttributes
{
using NativeFormat;
//-----------------------------------------------------------------------------------------------------------
// CustomAttributeData objects returned by various CustomAttributes properties.
//-----------------------------------------------------------------------------------------------------------
internal abstract partial class RuntimeCustomAttributeData
{
internal static IEnumerable<CustomAttributeData> GetCustomAttributes(MetadataReader reader, CustomAttributeHandleCollection customAttributeHandles)
{
foreach (CustomAttributeHandle customAttributeHandle in customAttributeHandles)
yield return GetCustomAttributeData(reader, customAttributeHandle);
}
private static CustomAttributeData GetCustomAttributeData(MetadataReader reader, CustomAttributeHandle customAttributeHandle)
{
return new NativeFormatCustomAttributeData(reader, customAttributeHandle);
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonReaderDelegator.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.Xml;
using System.Runtime.Serialization;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
namespace System.Runtime.Serialization.Json
{
internal sealed class JsonReaderDelegator : XmlReaderDelegator
{
private readonly DateTimeFormat? _dateTimeFormat;
private DateTimeArrayJsonHelperWithString? _dateTimeArrayHelper;
public JsonReaderDelegator(XmlReader reader)
: base(reader)
{
}
public JsonReaderDelegator(XmlReader reader, DateTimeFormat? dateTimeFormat)
: this(reader)
{
_dateTimeFormat = dateTimeFormat;
}
internal XmlDictionaryReaderQuotas? ReaderQuotas
{
get
{
if (this.dictionaryReader == null)
{
return null;
}
else
{
return dictionaryReader.Quotas;
}
}
}
private DateTimeArrayJsonHelperWithString DateTimeArrayHelper
{
get
{
if (_dateTimeArrayHelper == null)
{
_dateTimeArrayHelper = new DateTimeArrayJsonHelperWithString(_dateTimeFormat);
}
return _dateTimeArrayHelper;
}
}
internal static XmlQualifiedName ParseQualifiedName(string qname)
{
string name, ns;
if (string.IsNullOrEmpty(qname))
{
name = ns = string.Empty;
}
else
{
qname = qname.Trim();
int colon = qname.IndexOf(':');
if (colon >= 0)
{
name = qname.Substring(0, colon);
ns = qname.Substring(colon + 1);
}
else
{
name = qname;
ns = string.Empty;
}
}
return new XmlQualifiedName(name, ns);
}
internal override char ReadContentAsChar()
{
return XmlConvert.ToChar(ReadContentAsString());
}
internal override XmlQualifiedName ReadContentAsQName()
{
return ParseQualifiedName(ReadContentAsString());
}
internal override char ReadElementContentAsChar()
{
return XmlConvert.ToChar(ReadElementContentAsString());
}
public override byte[] ReadContentAsBase64()
{
if (isEndOfEmptyElement)
return Array.Empty<byte>();
byte[] buffer;
if (dictionaryReader == null)
{
XmlDictionaryReader tempDictionaryReader = XmlDictionaryReader.CreateDictionaryReader(reader);
buffer = ByteArrayHelperWithString.Instance.ReadArray(tempDictionaryReader, JsonGlobals.itemString, string.Empty, tempDictionaryReader.Quotas.MaxArrayLength);
}
else
{
buffer = ByteArrayHelperWithString.Instance.ReadArray(dictionaryReader, JsonGlobals.itemString, string.Empty, dictionaryReader.Quotas.MaxArrayLength);
}
return buffer;
}
internal override byte[] ReadElementContentAsBase64()
{
if (isEndOfEmptyElement)
{
throw new XmlException(SR.Format(SR.XmlStartElementExpected, "EndElement"));
}
bool isEmptyElement = reader.IsStartElement() && reader.IsEmptyElement;
byte[] buffer;
if (isEmptyElement)
{
reader.Read();
buffer = Array.Empty<byte>();
}
else
{
reader.ReadStartElement();
buffer = ReadContentAsBase64();
reader.ReadEndElement();
}
return buffer;
}
internal override DateTime ReadContentAsDateTime()
{
return ParseJsonDate(ReadContentAsString(), _dateTimeFormat);
}
internal static DateTime ParseJsonDate(string originalDateTimeValue, DateTimeFormat? dateTimeFormat)
{
if (dateTimeFormat == null)
{
return ParseJsonDateInDefaultFormat(originalDateTimeValue);
}
else
{
return DateTime.ParseExact(originalDateTimeValue, dateTimeFormat.FormatString, dateTimeFormat.FormatProvider, dateTimeFormat.DateTimeStyles);
}
}
internal static DateTime ParseJsonDateInDefaultFormat(string originalDateTimeValue)
{
// Dates are represented in JSON as "\/Date(number of ticks)\/".
// The number of ticks is the number of milliseconds since January 1, 1970.
string dateTimeValue;
if (!string.IsNullOrEmpty(originalDateTimeValue))
{
dateTimeValue = originalDateTimeValue.Trim();
}
else
{
dateTimeValue = originalDateTimeValue;
}
if (string.IsNullOrEmpty(dateTimeValue) ||
!dateTimeValue.StartsWith(JsonGlobals.DateTimeStartGuardReader, StringComparison.Ordinal) ||
!dateTimeValue.EndsWith(JsonGlobals.DateTimeEndGuardReader, StringComparison.Ordinal))
{
throw new FormatException(SR.Format(SR.JsonInvalidDateTimeString, originalDateTimeValue, JsonGlobals.DateTimeStartGuardWriter, JsonGlobals.DateTimeEndGuardWriter));
}
string ticksvalue = dateTimeValue.Substring(6, dateTimeValue.Length - 8);
long millisecondsSinceUnixEpoch;
DateTimeKind dateTimeKind = DateTimeKind.Utc;
int indexOfTimeZoneOffset = ticksvalue.IndexOf('+', 1);
if (indexOfTimeZoneOffset == -1)
{
indexOfTimeZoneOffset = ticksvalue.IndexOf('-', 1);
}
if (indexOfTimeZoneOffset != -1)
{
dateTimeKind = DateTimeKind.Local;
ticksvalue = ticksvalue.Substring(0, indexOfTimeZoneOffset);
}
try
{
millisecondsSinceUnixEpoch = long.Parse(ticksvalue, CultureInfo.InvariantCulture);
}
catch (ArgumentException exception)
{
throw XmlExceptionHelper.CreateConversionException(ticksvalue, "Int64", exception);
}
catch (FormatException exception)
{
throw XmlExceptionHelper.CreateConversionException(ticksvalue, "Int64", exception);
}
catch (OverflowException exception)
{
throw XmlExceptionHelper.CreateConversionException(ticksvalue, "Int64", exception);
}
// Convert from # milliseconds since epoch to # of 100-nanosecond units, which is what DateTime understands
long ticks = millisecondsSinceUnixEpoch * 10000 + JsonGlobals.unixEpochTicks;
try
{
DateTime dateTime = new DateTime(ticks, DateTimeKind.Utc);
switch (dateTimeKind)
{
case DateTimeKind.Local:
return dateTime.ToLocalTime();
case DateTimeKind.Unspecified:
return DateTime.SpecifyKind(dateTime.ToLocalTime(), DateTimeKind.Unspecified);
case DateTimeKind.Utc:
default:
return dateTime;
}
}
catch (ArgumentException exception)
{
throw XmlExceptionHelper.CreateConversionException(ticksvalue, "DateTime", exception);
}
}
internal override DateTime ReadElementContentAsDateTime()
{
return ParseJsonDate(ReadElementContentAsString(), _dateTimeFormat);
}
internal override bool TryReadDateTimeArray(XmlObjectSerializerReadContext context,
XmlDictionaryString itemName, XmlDictionaryString itemNamespace,
int arrayLength, [NotNullWhen(true)] out DateTime[]? array)
{
return TryReadJsonDateTimeArray(context, itemName, itemNamespace, arrayLength, out array);
}
internal bool TryReadJsonDateTimeArray(XmlObjectSerializerReadContext context,
XmlDictionaryString itemName, XmlDictionaryString itemNamespace,
int arrayLength, [NotNullWhen(true)] out DateTime[]? array)
{
if ((dictionaryReader == null) || (arrayLength != -1))
{
array = null;
return false;
}
array = this.DateTimeArrayHelper.ReadArray(dictionaryReader, XmlDictionaryString.GetString(itemName), XmlDictionaryString.GetString(itemNamespace), GetArrayLengthQuota(context));
context.IncrementItemCount(array.Length);
return true;
}
private sealed class DateTimeArrayJsonHelperWithString : ArrayHelper<string, DateTime>
{
private readonly DateTimeFormat? _dateTimeFormat;
public DateTimeArrayJsonHelperWithString(DateTimeFormat? dateTimeFormat)
{
_dateTimeFormat = dateTimeFormat;
}
protected override int ReadArray(XmlDictionaryReader reader, string localName, string namespaceUri, DateTime[] array, int offset, int count)
{
XmlJsonReader.CheckArray(array, offset, count);
int actual = 0;
while (actual < count && reader.IsStartElement(JsonGlobals.itemString, string.Empty))
{
array[offset + actual] = JsonReaderDelegator.ParseJsonDate(reader.ReadElementContentAsString(), _dateTimeFormat);
actual++;
}
return actual;
}
protected override void WriteArray(XmlDictionaryWriter writer, string prefix, string localName, string namespaceUri, DateTime[] array, int offset, int count)
{
throw NotImplemented.ByDesign;
}
}
// Overridden because base reader relies on XmlConvert.ToUInt64 for conversion to ulong
internal override ulong ReadContentAsUnsignedLong()
{
string value = reader.ReadContentAsString();
if (value == null || value.Length == 0)
{
throw new XmlException(XmlObjectSerializer.TryAddLineInfo(this, SR.Format(SR.XmlInvalidConversion, value, "UInt64")));
}
try
{
return ulong.Parse(value, NumberStyles.Float, NumberFormatInfo.InvariantInfo);
}
catch (ArgumentException exception)
{
throw XmlExceptionHelper.CreateConversionException(value, "UInt64", exception);
}
catch (FormatException exception)
{
throw XmlExceptionHelper.CreateConversionException(value, "UInt64", exception);
}
catch (OverflowException exception)
{
throw XmlExceptionHelper.CreateConversionException(value, "UInt64", exception);
}
}
// Overridden because base reader relies on XmlConvert.ToUInt64 for conversion to ulong
internal override ulong ReadElementContentAsUnsignedLong()
{
if (isEndOfEmptyElement)
{
throw new XmlException(SR.Format(SR.XmlStartElementExpected, "EndElement"));
}
string value = reader.ReadElementContentAsString();
if (value == null || value.Length == 0)
{
throw new XmlException(XmlObjectSerializer.TryAddLineInfo(this, SR.Format(SR.XmlInvalidConversion, value, "UInt64")));
}
try
{
return ulong.Parse(value, NumberStyles.Float, NumberFormatInfo.InvariantInfo);
}
catch (ArgumentException exception)
{
throw XmlExceptionHelper.CreateConversionException(value, "UInt64", exception);
}
catch (FormatException exception)
{
throw XmlExceptionHelper.CreateConversionException(value, "UInt64", exception);
}
catch (OverflowException exception)
{
throw XmlExceptionHelper.CreateConversionException(value, "UInt64", exception);
}
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Xml;
using System.Runtime.Serialization;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
namespace System.Runtime.Serialization.Json
{
internal sealed class JsonReaderDelegator : XmlReaderDelegator
{
private readonly DateTimeFormat? _dateTimeFormat;
private DateTimeArrayJsonHelperWithString? _dateTimeArrayHelper;
public JsonReaderDelegator(XmlReader reader)
: base(reader)
{
}
public JsonReaderDelegator(XmlReader reader, DateTimeFormat? dateTimeFormat)
: this(reader)
{
_dateTimeFormat = dateTimeFormat;
}
internal XmlDictionaryReaderQuotas? ReaderQuotas
{
get
{
if (this.dictionaryReader == null)
{
return null;
}
else
{
return dictionaryReader.Quotas;
}
}
}
private DateTimeArrayJsonHelperWithString DateTimeArrayHelper
{
get
{
if (_dateTimeArrayHelper == null)
{
_dateTimeArrayHelper = new DateTimeArrayJsonHelperWithString(_dateTimeFormat);
}
return _dateTimeArrayHelper;
}
}
internal static XmlQualifiedName ParseQualifiedName(string qname)
{
string name, ns;
if (string.IsNullOrEmpty(qname))
{
name = ns = string.Empty;
}
else
{
qname = qname.Trim();
int colon = qname.IndexOf(':');
if (colon >= 0)
{
name = qname.Substring(0, colon);
ns = qname.Substring(colon + 1);
}
else
{
name = qname;
ns = string.Empty;
}
}
return new XmlQualifiedName(name, ns);
}
internal override char ReadContentAsChar()
{
return XmlConvert.ToChar(ReadContentAsString());
}
internal override XmlQualifiedName ReadContentAsQName()
{
return ParseQualifiedName(ReadContentAsString());
}
internal override char ReadElementContentAsChar()
{
return XmlConvert.ToChar(ReadElementContentAsString());
}
public override byte[] ReadContentAsBase64()
{
if (isEndOfEmptyElement)
return Array.Empty<byte>();
byte[] buffer;
if (dictionaryReader == null)
{
XmlDictionaryReader tempDictionaryReader = XmlDictionaryReader.CreateDictionaryReader(reader);
buffer = ByteArrayHelperWithString.Instance.ReadArray(tempDictionaryReader, JsonGlobals.itemString, string.Empty, tempDictionaryReader.Quotas.MaxArrayLength);
}
else
{
buffer = ByteArrayHelperWithString.Instance.ReadArray(dictionaryReader, JsonGlobals.itemString, string.Empty, dictionaryReader.Quotas.MaxArrayLength);
}
return buffer;
}
internal override byte[] ReadElementContentAsBase64()
{
if (isEndOfEmptyElement)
{
throw new XmlException(SR.Format(SR.XmlStartElementExpected, "EndElement"));
}
bool isEmptyElement = reader.IsStartElement() && reader.IsEmptyElement;
byte[] buffer;
if (isEmptyElement)
{
reader.Read();
buffer = Array.Empty<byte>();
}
else
{
reader.ReadStartElement();
buffer = ReadContentAsBase64();
reader.ReadEndElement();
}
return buffer;
}
internal override DateTime ReadContentAsDateTime()
{
return ParseJsonDate(ReadContentAsString(), _dateTimeFormat);
}
internal static DateTime ParseJsonDate(string originalDateTimeValue, DateTimeFormat? dateTimeFormat)
{
if (dateTimeFormat == null)
{
return ParseJsonDateInDefaultFormat(originalDateTimeValue);
}
else
{
return DateTime.ParseExact(originalDateTimeValue, dateTimeFormat.FormatString, dateTimeFormat.FormatProvider, dateTimeFormat.DateTimeStyles);
}
}
internal static DateTime ParseJsonDateInDefaultFormat(string originalDateTimeValue)
{
// Dates are represented in JSON as "\/Date(number of ticks)\/".
// The number of ticks is the number of milliseconds since January 1, 1970.
string dateTimeValue;
if (!string.IsNullOrEmpty(originalDateTimeValue))
{
dateTimeValue = originalDateTimeValue.Trim();
}
else
{
dateTimeValue = originalDateTimeValue;
}
if (string.IsNullOrEmpty(dateTimeValue) ||
!dateTimeValue.StartsWith(JsonGlobals.DateTimeStartGuardReader, StringComparison.Ordinal) ||
!dateTimeValue.EndsWith(JsonGlobals.DateTimeEndGuardReader, StringComparison.Ordinal))
{
throw new FormatException(SR.Format(SR.JsonInvalidDateTimeString, originalDateTimeValue, JsonGlobals.DateTimeStartGuardWriter, JsonGlobals.DateTimeEndGuardWriter));
}
string ticksvalue = dateTimeValue.Substring(6, dateTimeValue.Length - 8);
long millisecondsSinceUnixEpoch;
DateTimeKind dateTimeKind = DateTimeKind.Utc;
int indexOfTimeZoneOffset = ticksvalue.IndexOf('+', 1);
if (indexOfTimeZoneOffset == -1)
{
indexOfTimeZoneOffset = ticksvalue.IndexOf('-', 1);
}
if (indexOfTimeZoneOffset != -1)
{
dateTimeKind = DateTimeKind.Local;
ticksvalue = ticksvalue.Substring(0, indexOfTimeZoneOffset);
}
try
{
millisecondsSinceUnixEpoch = long.Parse(ticksvalue, CultureInfo.InvariantCulture);
}
catch (ArgumentException exception)
{
throw XmlExceptionHelper.CreateConversionException(ticksvalue, "Int64", exception);
}
catch (FormatException exception)
{
throw XmlExceptionHelper.CreateConversionException(ticksvalue, "Int64", exception);
}
catch (OverflowException exception)
{
throw XmlExceptionHelper.CreateConversionException(ticksvalue, "Int64", exception);
}
// Convert from # milliseconds since epoch to # of 100-nanosecond units, which is what DateTime understands
long ticks = millisecondsSinceUnixEpoch * 10000 + JsonGlobals.unixEpochTicks;
try
{
DateTime dateTime = new DateTime(ticks, DateTimeKind.Utc);
switch (dateTimeKind)
{
case DateTimeKind.Local:
return dateTime.ToLocalTime();
case DateTimeKind.Unspecified:
return DateTime.SpecifyKind(dateTime.ToLocalTime(), DateTimeKind.Unspecified);
case DateTimeKind.Utc:
default:
return dateTime;
}
}
catch (ArgumentException exception)
{
throw XmlExceptionHelper.CreateConversionException(ticksvalue, "DateTime", exception);
}
}
internal override DateTime ReadElementContentAsDateTime()
{
return ParseJsonDate(ReadElementContentAsString(), _dateTimeFormat);
}
internal override bool TryReadDateTimeArray(XmlObjectSerializerReadContext context,
XmlDictionaryString itemName, XmlDictionaryString itemNamespace,
int arrayLength, [NotNullWhen(true)] out DateTime[]? array)
{
return TryReadJsonDateTimeArray(context, itemName, itemNamespace, arrayLength, out array);
}
internal bool TryReadJsonDateTimeArray(XmlObjectSerializerReadContext context,
XmlDictionaryString itemName, XmlDictionaryString itemNamespace,
int arrayLength, [NotNullWhen(true)] out DateTime[]? array)
{
if ((dictionaryReader == null) || (arrayLength != -1))
{
array = null;
return false;
}
array = this.DateTimeArrayHelper.ReadArray(dictionaryReader, XmlDictionaryString.GetString(itemName), XmlDictionaryString.GetString(itemNamespace), GetArrayLengthQuota(context));
context.IncrementItemCount(array.Length);
return true;
}
private sealed class DateTimeArrayJsonHelperWithString : ArrayHelper<string, DateTime>
{
private readonly DateTimeFormat? _dateTimeFormat;
public DateTimeArrayJsonHelperWithString(DateTimeFormat? dateTimeFormat)
{
_dateTimeFormat = dateTimeFormat;
}
protected override int ReadArray(XmlDictionaryReader reader, string localName, string namespaceUri, DateTime[] array, int offset, int count)
{
XmlJsonReader.CheckArray(array, offset, count);
int actual = 0;
while (actual < count && reader.IsStartElement(JsonGlobals.itemString, string.Empty))
{
array[offset + actual] = JsonReaderDelegator.ParseJsonDate(reader.ReadElementContentAsString(), _dateTimeFormat);
actual++;
}
return actual;
}
protected override void WriteArray(XmlDictionaryWriter writer, string prefix, string localName, string namespaceUri, DateTime[] array, int offset, int count)
{
throw NotImplemented.ByDesign;
}
}
// Overridden because base reader relies on XmlConvert.ToUInt64 for conversion to ulong
internal override ulong ReadContentAsUnsignedLong()
{
string value = reader.ReadContentAsString();
if (value == null || value.Length == 0)
{
throw new XmlException(XmlObjectSerializer.TryAddLineInfo(this, SR.Format(SR.XmlInvalidConversion, value, "UInt64")));
}
try
{
return ulong.Parse(value, NumberStyles.Float, NumberFormatInfo.InvariantInfo);
}
catch (ArgumentException exception)
{
throw XmlExceptionHelper.CreateConversionException(value, "UInt64", exception);
}
catch (FormatException exception)
{
throw XmlExceptionHelper.CreateConversionException(value, "UInt64", exception);
}
catch (OverflowException exception)
{
throw XmlExceptionHelper.CreateConversionException(value, "UInt64", exception);
}
}
// Overridden because base reader relies on XmlConvert.ToUInt64 for conversion to ulong
internal override ulong ReadElementContentAsUnsignedLong()
{
if (isEndOfEmptyElement)
{
throw new XmlException(SR.Format(SR.XmlStartElementExpected, "EndElement"));
}
string value = reader.ReadElementContentAsString();
if (value == null || value.Length == 0)
{
throw new XmlException(XmlObjectSerializer.TryAddLineInfo(this, SR.Format(SR.XmlInvalidConversion, value, "UInt64")));
}
try
{
return ulong.Parse(value, NumberStyles.Float, NumberFormatInfo.InvariantInfo);
}
catch (ArgumentException exception)
{
throw XmlExceptionHelper.CreateConversionException(value, "UInt64", exception);
}
catch (FormatException exception)
{
throw XmlExceptionHelper.CreateConversionException(value, "UInt64", exception);
}
catch (OverflowException exception)
{
throw XmlExceptionHelper.CreateConversionException(value, "UInt64", exception);
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Private.Xml/tests/XmlReader/ReadContentAs/ReadAsUriTests.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.Xml.Tests
{
public class UriTests
{
[Fact]
public static void ReadContentAsTypeOfUri1()
{
var reader = Utils.CreateFragmentReader("<a b=' http://wddata '> http://wddata </a>");
reader.PositionOnElement("a");
reader.Read();
Assert.Equal(new Uri("http://wddata/"), reader.ReadContentAs(typeof(Uri), null));
}
[Fact]
public static void ReadContentAsTypeOfUri2()
{
var reader = Utils.CreateFragmentReader("<a b=' '> </a>");
reader.PositionOnElement("a");
reader.Read();
Assert.Throws<XmlException>(() => reader.ReadContentAs(typeof(Uri), null));
}
}
}
| // 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.Xml.Tests
{
public class UriTests
{
[Fact]
public static void ReadContentAsTypeOfUri1()
{
var reader = Utils.CreateFragmentReader("<a b=' http://wddata '> http://wddata </a>");
reader.PositionOnElement("a");
reader.Read();
Assert.Equal(new Uri("http://wddata/"), reader.ReadContentAs(typeof(Uri), null));
}
[Fact]
public static void ReadContentAsTypeOfUri2()
{
var reader = Utils.CreateFragmentReader("<a b=' '> </a>");
reader.PositionOnElement("a");
reader.Read();
Assert.Throws<XmlException>(() => reader.ReadContentAs(typeof(Uri), null));
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/ShiftLeftLogicalSaturateUnsigned.Vector128.SByte.1.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.Arm;
namespace JIT.HardwareIntrinsics.Arm
{
public static partial class Program
{
private static void ShiftLeftLogicalSaturateUnsigned_Vector128_SByte_1()
{
var test = new ImmUnaryOpTest__ShiftLeftLogicalSaturateUnsigned_Vector128_SByte_1();
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 ImmUnaryOpTest__ShiftLeftLogicalSaturateUnsigned_Vector128_SByte_1
{
private struct DataTable
{
private byte[] inArray;
private byte[] outArray;
private GCHandle inHandle;
private GCHandle outHandle;
private ulong alignment;
public DataTable(SByte[] inArray, Byte[] outArray, int alignment)
{
int sizeOfinArray = inArray.Length * Unsafe.SizeOf<SByte>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Byte>();
if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray = new byte[alignment * 2];
this.outArray = new byte[alignment * 2];
this.inHandle = GCHandle.Alloc(this.inArray, GCHandleType.Pinned);
this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArrayPtr), ref Unsafe.As<SByte, byte>(ref inArray[0]), (uint)sizeOfinArray);
}
public void* inArrayPtr => Align((byte*)(inHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle.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> _fld;
public static TestStruct Create()
{
var testStruct = new TestStruct();
for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSByte(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref testStruct._fld), ref Unsafe.As<SByte, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>());
return testStruct;
}
public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalSaturateUnsigned_Vector128_SByte_1 testClass)
{
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(_fld, 1);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(ImmUnaryOpTest__ShiftLeftLogicalSaturateUnsigned_Vector128_SByte_1 testClass)
{
fixed (Vector128<SByte>* pFld = &_fld)
{
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(
AdvSimd.LoadVector128((SByte*)(pFld)),
1
);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr);
}
}
}
private static readonly int LargestVectorSize = 16;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<SByte>>() / sizeof(SByte);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte);
private static readonly byte Imm = 1;
private static SByte[] _data = new SByte[Op1ElementCount];
private static Vector128<SByte> _clsVar;
private Vector128<SByte> _fld;
private DataTable _dataTable;
static ImmUnaryOpTest__ShiftLeftLogicalSaturateUnsigned_Vector128_SByte_1()
{
for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSByte(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar), ref Unsafe.As<SByte, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>());
}
public ImmUnaryOpTest__ShiftLeftLogicalSaturateUnsigned_Vector128_SByte_1()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSByte(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld), ref Unsafe.As<SByte, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>());
for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSByte(); }
_dataTable = new DataTable(_data, new Byte[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.ShiftLeftLogicalSaturateUnsigned(
Unsafe.Read<Vector128<SByte>>(_dataTable.inArrayPtr),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunBasicScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(
AdvSimd.LoadVector128((SByte*)(_dataTable.inArrayPtr)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.ShiftLeftLogicalSaturateUnsigned), new Type[] { typeof(Vector128<SByte>), typeof(byte) })
.Invoke(null, new object[] {
Unsafe.Read<Vector128<SByte>>(_dataTable.inArrayPtr),
(byte)1
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Byte>)(result));
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.ShiftLeftLogicalSaturateUnsigned), new Type[] { typeof(Vector128<SByte>), typeof(byte) })
.Invoke(null, new object[] {
AdvSimd.LoadVector128((SByte*)(_dataTable.inArrayPtr)),
(byte)1
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Byte>)(result));
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(
_clsVar,
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector128<SByte>* pClsVar = &_clsVar)
{
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(
AdvSimd.LoadVector128((SByte*)(pClsVar)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar, _dataTable.outArrayPtr);
}
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var firstOp = Unsafe.Read<Vector128<SByte>>(_dataTable.inArrayPtr);
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(firstOp, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(firstOp, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load));
var firstOp = AdvSimd.LoadVector128((SByte*)(_dataTable.inArrayPtr));
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(firstOp, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(firstOp, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new ImmUnaryOpTest__ShiftLeftLogicalSaturateUnsigned_Vector128_SByte_1();
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(test._fld, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));
var test = new ImmUnaryOpTest__ShiftLeftLogicalSaturateUnsigned_Vector128_SByte_1();
fixed (Vector128<SByte>* pFld = &test._fld)
{
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(
AdvSimd.LoadVector128((SByte*)(pFld)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(_fld, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector128<SByte>* pFld = &_fld)
{
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(
AdvSimd.LoadVector128((SByte*)(pFld)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld, _dataTable.outArrayPtr);
}
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(test._fld, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));
var test = TestStruct.Create();
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(
AdvSimd.LoadVector128((SByte*)(&test._fld)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld, _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> firstOp, void* result, [CallerMemberName] string method = "")
{
SByte[] inArray = new SByte[Op1ElementCount];
Byte[] outArray = new Byte[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray[0]), firstOp);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Byte>>());
ValidateResult(inArray, outArray, method);
}
private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
{
SByte[] inArray = new SByte[Op1ElementCount];
Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector128<SByte>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Byte>>());
ValidateResult(inArray, outArray, method);
}
private void ValidateResult(SByte[] firstOp, Byte[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (var i = 0; i < RetElementCount; i++)
{
if (Helpers.ShiftLeftLogicalSaturateUnsigned(firstOp[i], Imm) != result[i])
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.ShiftLeftLogicalSaturateUnsigned)}<Byte>(Vector128<SByte>, 1): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/******************************************************************************
* This file is auto-generated from a template file by the GenerateTests.csx *
* script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make *
* changes, please update the corresponding template and run according to the *
* directions listed in the file. *
******************************************************************************/
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
namespace JIT.HardwareIntrinsics.Arm
{
public static partial class Program
{
private static void ShiftLeftLogicalSaturateUnsigned_Vector128_SByte_1()
{
var test = new ImmUnaryOpTest__ShiftLeftLogicalSaturateUnsigned_Vector128_SByte_1();
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 ImmUnaryOpTest__ShiftLeftLogicalSaturateUnsigned_Vector128_SByte_1
{
private struct DataTable
{
private byte[] inArray;
private byte[] outArray;
private GCHandle inHandle;
private GCHandle outHandle;
private ulong alignment;
public DataTable(SByte[] inArray, Byte[] outArray, int alignment)
{
int sizeOfinArray = inArray.Length * Unsafe.SizeOf<SByte>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Byte>();
if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray = new byte[alignment * 2];
this.outArray = new byte[alignment * 2];
this.inHandle = GCHandle.Alloc(this.inArray, GCHandleType.Pinned);
this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArrayPtr), ref Unsafe.As<SByte, byte>(ref inArray[0]), (uint)sizeOfinArray);
}
public void* inArrayPtr => Align((byte*)(inHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle.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> _fld;
public static TestStruct Create()
{
var testStruct = new TestStruct();
for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSByte(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref testStruct._fld), ref Unsafe.As<SByte, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>());
return testStruct;
}
public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalSaturateUnsigned_Vector128_SByte_1 testClass)
{
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(_fld, 1);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(ImmUnaryOpTest__ShiftLeftLogicalSaturateUnsigned_Vector128_SByte_1 testClass)
{
fixed (Vector128<SByte>* pFld = &_fld)
{
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(
AdvSimd.LoadVector128((SByte*)(pFld)),
1
);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr);
}
}
}
private static readonly int LargestVectorSize = 16;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<SByte>>() / sizeof(SByte);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte);
private static readonly byte Imm = 1;
private static SByte[] _data = new SByte[Op1ElementCount];
private static Vector128<SByte> _clsVar;
private Vector128<SByte> _fld;
private DataTable _dataTable;
static ImmUnaryOpTest__ShiftLeftLogicalSaturateUnsigned_Vector128_SByte_1()
{
for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSByte(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar), ref Unsafe.As<SByte, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>());
}
public ImmUnaryOpTest__ShiftLeftLogicalSaturateUnsigned_Vector128_SByte_1()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSByte(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld), ref Unsafe.As<SByte, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>());
for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSByte(); }
_dataTable = new DataTable(_data, new Byte[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.ShiftLeftLogicalSaturateUnsigned(
Unsafe.Read<Vector128<SByte>>(_dataTable.inArrayPtr),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunBasicScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(
AdvSimd.LoadVector128((SByte*)(_dataTable.inArrayPtr)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.ShiftLeftLogicalSaturateUnsigned), new Type[] { typeof(Vector128<SByte>), typeof(byte) })
.Invoke(null, new object[] {
Unsafe.Read<Vector128<SByte>>(_dataTable.inArrayPtr),
(byte)1
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Byte>)(result));
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.ShiftLeftLogicalSaturateUnsigned), new Type[] { typeof(Vector128<SByte>), typeof(byte) })
.Invoke(null, new object[] {
AdvSimd.LoadVector128((SByte*)(_dataTable.inArrayPtr)),
(byte)1
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Byte>)(result));
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(
_clsVar,
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector128<SByte>* pClsVar = &_clsVar)
{
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(
AdvSimd.LoadVector128((SByte*)(pClsVar)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar, _dataTable.outArrayPtr);
}
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var firstOp = Unsafe.Read<Vector128<SByte>>(_dataTable.inArrayPtr);
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(firstOp, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(firstOp, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load));
var firstOp = AdvSimd.LoadVector128((SByte*)(_dataTable.inArrayPtr));
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(firstOp, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(firstOp, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new ImmUnaryOpTest__ShiftLeftLogicalSaturateUnsigned_Vector128_SByte_1();
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(test._fld, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));
var test = new ImmUnaryOpTest__ShiftLeftLogicalSaturateUnsigned_Vector128_SByte_1();
fixed (Vector128<SByte>* pFld = &test._fld)
{
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(
AdvSimd.LoadVector128((SByte*)(pFld)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(_fld, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector128<SByte>* pFld = &_fld)
{
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(
AdvSimd.LoadVector128((SByte*)(pFld)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld, _dataTable.outArrayPtr);
}
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(test._fld, 1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));
var test = TestStruct.Create();
var result = AdvSimd.ShiftLeftLogicalSaturateUnsigned(
AdvSimd.LoadVector128((SByte*)(&test._fld)),
1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld, _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> firstOp, void* result, [CallerMemberName] string method = "")
{
SByte[] inArray = new SByte[Op1ElementCount];
Byte[] outArray = new Byte[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray[0]), firstOp);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Byte>>());
ValidateResult(inArray, outArray, method);
}
private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
{
SByte[] inArray = new SByte[Op1ElementCount];
Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector128<SByte>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Byte>>());
ValidateResult(inArray, outArray, method);
}
private void ValidateResult(SByte[] firstOp, Byte[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (var i = 0; i < RetElementCount; i++)
{
if (Helpers.ShiftLeftLogicalSaturateUnsigned(firstOp[i], Imm) != result[i])
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.ShiftLeftLogicalSaturateUnsigned)}<Byte>(Vector128<SByte>, 1): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/coreclr/nativeaot/System.Private.CoreLib/src/Interop/Windows/Interop.Libraries.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
internal static partial class Interop
{
internal static partial class Libraries
{
internal const string ThreadPool = "api-ms-win-core-threadpool-l1-2-0.dll";
internal const string ProcessEnvironment = "api-ms-win-core-processenvironment-l1-1-0.dll";
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
internal static partial class Interop
{
internal static partial class Libraries
{
internal const string ThreadPool = "api-ms-win-core-threadpool-l1-2-0.dll";
internal const string ProcessEnvironment = "api-ms-win-core-processenvironment-l1-1-0.dll";
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaBuilder.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Xml.Schema
{
internal abstract class SchemaBuilder
{
internal abstract bool ProcessElement(string prefix, string name, string ns);
internal abstract void ProcessAttribute(string prefix, string name, string ns, string value);
internal abstract bool IsContentParsed();
internal abstract void ProcessMarkup(XmlNode?[] markup);
internal abstract void ProcessCData(string value);
internal abstract void StartChildren();
internal abstract void EndChildren();
};
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Xml.Schema
{
internal abstract class SchemaBuilder
{
internal abstract bool ProcessElement(string prefix, string name, string ns);
internal abstract void ProcessAttribute(string prefix, string name, string ns, string value);
internal abstract bool IsContentParsed();
internal abstract void ProcessMarkup(XmlNode?[] markup);
internal abstract void ProcessCData(string value);
internal abstract void StartChildren();
internal abstract void EndChildren();
};
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/Microsoft.Extensions.DependencyModel/src/ResourceAssembly.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.DependencyModel
{
public class ResourceAssembly
{
public ResourceAssembly(string path, string locale)
{
if (string.IsNullOrEmpty(path))
{
throw new ArgumentException(null, nameof(path));
}
if (string.IsNullOrEmpty(locale))
{
throw new ArgumentException(null, nameof(locale));
}
Locale = locale;
Path = path;
}
public string Locale { get; set; }
public string Path { get; set; }
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
namespace Microsoft.Extensions.DependencyModel
{
public class ResourceAssembly
{
public ResourceAssembly(string path, string locale)
{
if (string.IsNullOrEmpty(path))
{
throw new ArgumentException(null, nameof(path));
}
if (string.IsNullOrEmpty(locale))
{
throw new ArgumentException(null, nameof(locale));
}
Locale = locale;
Path = path;
}
public string Locale { get; set; }
public string Path { get; set; }
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Parameters/RoFatMethodParameter.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.Runtime.InteropServices;
namespace System.Reflection.TypeLoading
{
/// <summary>
/// Base class for all RoParameter's returned by MethodBase.GetParameters() that have an entry in the Param table.
/// </summary>
internal abstract class RoFatMethodParameter : RoMethodParameter
{
protected RoFatMethodParameter(IRoMethodBase roMethodBase, int position, Type parameterType)
: base(roMethodBase, position, parameterType)
{
Debug.Assert(roMethodBase != null);
Debug.Assert(parameterType != null);
}
public sealed override string? Name => _lazyName ?? (_lazyName = ComputeName());
protected abstract string? ComputeName();
private volatile string? _lazyName;
public sealed override ParameterAttributes Attributes => (_lazyParameterAttributes == ParameterAttributesSentinel) ? (_lazyParameterAttributes = ComputeAttributes()) : _lazyParameterAttributes;
protected abstract ParameterAttributes ComputeAttributes();
private const ParameterAttributes ParameterAttributesSentinel = (ParameterAttributes)(-1);
private volatile ParameterAttributes _lazyParameterAttributes = ParameterAttributesSentinel;
public sealed override IEnumerable<CustomAttributeData> CustomAttributes
{
get
{
foreach (CustomAttributeData cad in GetTrueCustomAttributes())
yield return cad;
ParameterAttributes attributes = Attributes;
if (0 != (attributes & ParameterAttributes.In))
{
ConstructorInfo? ci = Loader.TryGetInCtor();
if (ci != null)
yield return new RoPseudoCustomAttributeData(ci);
}
if (0 != (attributes & ParameterAttributes.Out))
{
ConstructorInfo? ci = Loader.TryGetOutCtor();
if (ci != null)
yield return new RoPseudoCustomAttributeData(ci);
}
if (0 != (attributes & ParameterAttributes.Optional))
{
ConstructorInfo? ci = Loader.TryGetOptionalCtor();
if (ci != null)
yield return new RoPseudoCustomAttributeData(ci);
}
if (0 != (attributes & ParameterAttributes.HasFieldMarshal))
{
CustomAttributeData? cad = CustomAttributeHelpers.TryComputeMarshalAsCustomAttributeData(ComputeMarshalAsAttribute, Loader);
if (cad != null)
yield return cad;
}
}
}
protected abstract MarshalAsAttribute ComputeMarshalAsAttribute();
public abstract override bool HasDefaultValue { get; }
public abstract override object? RawDefaultValue { get; }
protected abstract IEnumerable<CustomAttributeData> GetTrueCustomAttributes();
private MetadataLoadContext Loader => GetRoMethodBase().Loader;
}
}
| // 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.Runtime.InteropServices;
namespace System.Reflection.TypeLoading
{
/// <summary>
/// Base class for all RoParameter's returned by MethodBase.GetParameters() that have an entry in the Param table.
/// </summary>
internal abstract class RoFatMethodParameter : RoMethodParameter
{
protected RoFatMethodParameter(IRoMethodBase roMethodBase, int position, Type parameterType)
: base(roMethodBase, position, parameterType)
{
Debug.Assert(roMethodBase != null);
Debug.Assert(parameterType != null);
}
public sealed override string? Name => _lazyName ?? (_lazyName = ComputeName());
protected abstract string? ComputeName();
private volatile string? _lazyName;
public sealed override ParameterAttributes Attributes => (_lazyParameterAttributes == ParameterAttributesSentinel) ? (_lazyParameterAttributes = ComputeAttributes()) : _lazyParameterAttributes;
protected abstract ParameterAttributes ComputeAttributes();
private const ParameterAttributes ParameterAttributesSentinel = (ParameterAttributes)(-1);
private volatile ParameterAttributes _lazyParameterAttributes = ParameterAttributesSentinel;
public sealed override IEnumerable<CustomAttributeData> CustomAttributes
{
get
{
foreach (CustomAttributeData cad in GetTrueCustomAttributes())
yield return cad;
ParameterAttributes attributes = Attributes;
if (0 != (attributes & ParameterAttributes.In))
{
ConstructorInfo? ci = Loader.TryGetInCtor();
if (ci != null)
yield return new RoPseudoCustomAttributeData(ci);
}
if (0 != (attributes & ParameterAttributes.Out))
{
ConstructorInfo? ci = Loader.TryGetOutCtor();
if (ci != null)
yield return new RoPseudoCustomAttributeData(ci);
}
if (0 != (attributes & ParameterAttributes.Optional))
{
ConstructorInfo? ci = Loader.TryGetOptionalCtor();
if (ci != null)
yield return new RoPseudoCustomAttributeData(ci);
}
if (0 != (attributes & ParameterAttributes.HasFieldMarshal))
{
CustomAttributeData? cad = CustomAttributeHelpers.TryComputeMarshalAsCustomAttributeData(ComputeMarshalAsAttribute, Loader);
if (cad != null)
yield return cad;
}
}
}
protected abstract MarshalAsAttribute ComputeMarshalAsAttribute();
public abstract override bool HasDefaultValue { get; }
public abstract override object? RawDefaultValue { get; }
protected abstract IEnumerable<CustomAttributeData> GetTrueCustomAttributes();
private MetadataLoadContext Loader => GetRoMethodBase().Loader;
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/Regression/JitBlue/GitHub_19149/GitHub_19149.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Bug report thanks to @mgravell
//
// JIT bug affecting how fixed buffers are handled
//
// Affects: netcoreapp2.1, debug and release
// Does not seem to affect: netcoreapp2.0, net47
//
// the idea behind CommandBytes is that it is a fixed-sized string-like thing
// used for matching commands; it is *implemented* as a fixed buffer
// of **longs**, but: the first byte of the first element is coerced into
// a byte and used to store the length; the actual text payload (ASCII)
// starts at the second byte of the first element
//
// as far as I can tell, it is all validly implemented, and it works fine
// in isolation, however: when used in a dictionary, it goes bad;
// - items not being found despite having GetHashCode and Equals match
// - items over 1 chunk size becoming corrupted (see: ToInnerString)
//
// however, if I replace the fixed buffer with the same number of
// regular fields (_c0,_c1,_c2) and use *all the same code*, it
// all works correctly!
//
// The "Main" method populates a dictionary in the expected way,
// then attempts to find things - either via TryGetValue or manually;
// it then compares the contents
//
// Yes, this code is evil; it is for a very specific optimized scenario.
using System;
using System.Collections.Generic;
using System.Text;
unsafe struct CommandBytes : IEquatable<CommandBytes>
{
private const int ChunkLength = 3;
public const int MaxLength = (ChunkLength * 8) - 1;
fixed long _chunks[ChunkLength];
public override int GetHashCode()
{
fixed (long* lPtr = _chunks)
{
var hashCode = -1923861349;
long* x = lPtr;
for (int i = 0; i < ChunkLength; i++)
{
hashCode = hashCode * -1521134295 + (*x++).GetHashCode();
}
return hashCode;
}
}
public override string ToString()
{
fixed (long* lPtr = _chunks)
{
var bPtr = (byte*)lPtr;
return Encoding.ASCII.GetString(bPtr + 1, bPtr[0]);
}
}
public int Length
{
get
{
fixed (long* lPtr = _chunks)
{
var bPtr = (byte*)lPtr;
return bPtr[0];
}
}
}
public byte this[int index]
{
get
{
fixed (long* lPtr = _chunks)
{
byte* bPtr = (byte*)lPtr;
int len = bPtr[0];
if (index < 0 || index >= len) throw new IndexOutOfRangeException();
return bPtr[index + 1];
}
}
}
public CommandBytes(string value)
{
value = value.ToLowerInvariant();
var len = Encoding.ASCII.GetByteCount(value);
if (len > MaxLength) throw new ArgumentOutOfRangeException("Maximum command length exceeed");
fixed (long* lPtr = _chunks)
{
Clear(lPtr);
byte* bPtr = (byte*)lPtr;
bPtr[0] = (byte)len;
fixed (char* cPtr = value)
{
Encoding.ASCII.GetBytes(cPtr, value.Length, bPtr + 1, len);
}
}
}
public override bool Equals(object obj) => obj is CommandBytes cb && Equals(cb);
public string ToInnerString()
{
fixed (long* lPtr = _chunks)
{
long* x = lPtr;
var sb = new StringBuilder();
for (int i = 0; i < ChunkLength; i++)
{
if (sb.Length != 0) sb.Append(',');
sb.Append(*x++);
}
return sb.ToString();
}
}
public bool Equals(CommandBytes value)
{
fixed (long* lPtr = _chunks)
{
long* x = lPtr;
long* y = value._chunks;
for (int i = 0; i < ChunkLength; i++)
{
if (*x++ != *y++) return false;
}
return true;
}
}
private static void Clear(long* ptr)
{
for (int i = 0; i < ChunkLength; i++)
{
*ptr++ = 0L;
}
}
}
static class Program
{
static int Main()
{
var lookup = new Dictionary<CommandBytes, string>();
void Add(string val)
{
var cb = new CommandBytes(val);
// prove we didn't screw up
if (cb.ToString() != val)
throw new InvalidOperationException("oops!");
lookup.Add(cb, val);
}
Add("client");
Add("cluster");
Add("command");
Add("config");
Add("dbsize");
Add("decr");
Add("del");
Add("echo");
Add("exists");
Add("flushall");
Add("flushdb");
Add("get");
Add("incr");
Add("incrby");
Add("info");
Add("keys");
Add("llen");
Add("lpop");
Add("lpush");
Add("lrange");
Add("memory");
Add("mget");
Add("mset");
Add("ping");
Add("quit");
Add("role");
Add("rpop");
Add("rpush");
Add("sadd");
Add("scard");
Add("select");
Add("set");
Add("shutdown");
Add("sismember");
Add("spop");
Add("srem");
Add("strlen");
Add("subscribe");
Add("time");
Add("unlink");
Add("unsubscribe");
bool HuntFor(string lookFor)
{
Console.WriteLine($"Looking for: '{lookFor}'");
var hunt = new CommandBytes(lookFor);
bool result = lookup.TryGetValue(hunt, out var found);
if (result)
{
Console.WriteLine($"Found via TryGetValue: '{found}'");
}
else
{
Console.WriteLine("**NOT FOUND** via TryGetValue");
}
Console.WriteLine("looking manually");
foreach (var pair in lookup)
{
if (pair.Value == lookFor)
{
Console.WriteLine($"Found manually: '{pair.Value}'");
var key = pair.Key;
void Compare<T>(string caption, Func<CommandBytes, T> func)
{
T x = func(hunt), y = func(key);
Console.WriteLine($"{caption}: {EqualityComparer<T>.Default.Equals(x, y)}, '{x}' vs '{y}'");
}
Compare("GetHashCode", _ => _.GetHashCode());
Compare("ToString", _ => _.ToString());
Compare("Length", _ => _.Length);
Compare("ToInnerString", _ => _.ToInnerString());
Console.WriteLine($"Equals: {key.Equals(hunt)}, {hunt.Equals(key)}");
var eq = EqualityComparer<CommandBytes>.Default;
Console.WriteLine($"EqualityComparer: {eq.Equals(key, hunt)}, {eq.Equals(hunt, key)}");
Compare("eq GetHashCode", _ => eq.GetHashCode(_));
}
}
Console.WriteLine();
return result;
}
bool result1 = HuntFor("ping");
bool result2 = HuntFor("subscribe");
return (result1 && result2) ? 100 : -1;
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Bug report thanks to @mgravell
//
// JIT bug affecting how fixed buffers are handled
//
// Affects: netcoreapp2.1, debug and release
// Does not seem to affect: netcoreapp2.0, net47
//
// the idea behind CommandBytes is that it is a fixed-sized string-like thing
// used for matching commands; it is *implemented* as a fixed buffer
// of **longs**, but: the first byte of the first element is coerced into
// a byte and used to store the length; the actual text payload (ASCII)
// starts at the second byte of the first element
//
// as far as I can tell, it is all validly implemented, and it works fine
// in isolation, however: when used in a dictionary, it goes bad;
// - items not being found despite having GetHashCode and Equals match
// - items over 1 chunk size becoming corrupted (see: ToInnerString)
//
// however, if I replace the fixed buffer with the same number of
// regular fields (_c0,_c1,_c2) and use *all the same code*, it
// all works correctly!
//
// The "Main" method populates a dictionary in the expected way,
// then attempts to find things - either via TryGetValue or manually;
// it then compares the contents
//
// Yes, this code is evil; it is for a very specific optimized scenario.
using System;
using System.Collections.Generic;
using System.Text;
unsafe struct CommandBytes : IEquatable<CommandBytes>
{
private const int ChunkLength = 3;
public const int MaxLength = (ChunkLength * 8) - 1;
fixed long _chunks[ChunkLength];
public override int GetHashCode()
{
fixed (long* lPtr = _chunks)
{
var hashCode = -1923861349;
long* x = lPtr;
for (int i = 0; i < ChunkLength; i++)
{
hashCode = hashCode * -1521134295 + (*x++).GetHashCode();
}
return hashCode;
}
}
public override string ToString()
{
fixed (long* lPtr = _chunks)
{
var bPtr = (byte*)lPtr;
return Encoding.ASCII.GetString(bPtr + 1, bPtr[0]);
}
}
public int Length
{
get
{
fixed (long* lPtr = _chunks)
{
var bPtr = (byte*)lPtr;
return bPtr[0];
}
}
}
public byte this[int index]
{
get
{
fixed (long* lPtr = _chunks)
{
byte* bPtr = (byte*)lPtr;
int len = bPtr[0];
if (index < 0 || index >= len) throw new IndexOutOfRangeException();
return bPtr[index + 1];
}
}
}
public CommandBytes(string value)
{
value = value.ToLowerInvariant();
var len = Encoding.ASCII.GetByteCount(value);
if (len > MaxLength) throw new ArgumentOutOfRangeException("Maximum command length exceeed");
fixed (long* lPtr = _chunks)
{
Clear(lPtr);
byte* bPtr = (byte*)lPtr;
bPtr[0] = (byte)len;
fixed (char* cPtr = value)
{
Encoding.ASCII.GetBytes(cPtr, value.Length, bPtr + 1, len);
}
}
}
public override bool Equals(object obj) => obj is CommandBytes cb && Equals(cb);
public string ToInnerString()
{
fixed (long* lPtr = _chunks)
{
long* x = lPtr;
var sb = new StringBuilder();
for (int i = 0; i < ChunkLength; i++)
{
if (sb.Length != 0) sb.Append(',');
sb.Append(*x++);
}
return sb.ToString();
}
}
public bool Equals(CommandBytes value)
{
fixed (long* lPtr = _chunks)
{
long* x = lPtr;
long* y = value._chunks;
for (int i = 0; i < ChunkLength; i++)
{
if (*x++ != *y++) return false;
}
return true;
}
}
private static void Clear(long* ptr)
{
for (int i = 0; i < ChunkLength; i++)
{
*ptr++ = 0L;
}
}
}
static class Program
{
static int Main()
{
var lookup = new Dictionary<CommandBytes, string>();
void Add(string val)
{
var cb = new CommandBytes(val);
// prove we didn't screw up
if (cb.ToString() != val)
throw new InvalidOperationException("oops!");
lookup.Add(cb, val);
}
Add("client");
Add("cluster");
Add("command");
Add("config");
Add("dbsize");
Add("decr");
Add("del");
Add("echo");
Add("exists");
Add("flushall");
Add("flushdb");
Add("get");
Add("incr");
Add("incrby");
Add("info");
Add("keys");
Add("llen");
Add("lpop");
Add("lpush");
Add("lrange");
Add("memory");
Add("mget");
Add("mset");
Add("ping");
Add("quit");
Add("role");
Add("rpop");
Add("rpush");
Add("sadd");
Add("scard");
Add("select");
Add("set");
Add("shutdown");
Add("sismember");
Add("spop");
Add("srem");
Add("strlen");
Add("subscribe");
Add("time");
Add("unlink");
Add("unsubscribe");
bool HuntFor(string lookFor)
{
Console.WriteLine($"Looking for: '{lookFor}'");
var hunt = new CommandBytes(lookFor);
bool result = lookup.TryGetValue(hunt, out var found);
if (result)
{
Console.WriteLine($"Found via TryGetValue: '{found}'");
}
else
{
Console.WriteLine("**NOT FOUND** via TryGetValue");
}
Console.WriteLine("looking manually");
foreach (var pair in lookup)
{
if (pair.Value == lookFor)
{
Console.WriteLine($"Found manually: '{pair.Value}'");
var key = pair.Key;
void Compare<T>(string caption, Func<CommandBytes, T> func)
{
T x = func(hunt), y = func(key);
Console.WriteLine($"{caption}: {EqualityComparer<T>.Default.Equals(x, y)}, '{x}' vs '{y}'");
}
Compare("GetHashCode", _ => _.GetHashCode());
Compare("ToString", _ => _.ToString());
Compare("Length", _ => _.Length);
Compare("ToInnerString", _ => _.ToInnerString());
Console.WriteLine($"Equals: {key.Equals(hunt)}, {hunt.Equals(key)}");
var eq = EqualityComparer<CommandBytes>.Default;
Console.WriteLine($"EqualityComparer: {eq.Equals(key, hunt)}, {eq.Equals(hunt, key)}");
Compare("eq GetHashCode", _ => eq.GetHashCode(_));
}
}
Console.WriteLine();
return result;
}
bool result1 = HuntFor("ping");
bool result2 = HuntFor("subscribe");
return (result1 && result2) ? 100 : -1;
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/coreclr/nativeaot/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.CoreGetDeclared.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.Collections.Generic;
using System.Reflection.Runtime.General;
using System.Reflection.Runtime.MethodInfos;
using System.Reflection.Runtime.FieldInfos;
using System.Reflection.Runtime.PropertyInfos;
using System.Reflection.Runtime.EventInfos;
using NameFilter = System.Reflection.Runtime.BindingFlagSupport.NameFilter;
using Internal.Reflection.Core.Execution;
//
// The CoreGet() methods on RuntimeTypeInfo provide the raw source material for the Type.Get*() family of apis.
//
// These retrieve directly introduced (not inherited) members whose names match the passed in NameFilter (if NameFilter is null,
// return all members.) To avoid allocating objects, prefer to pass the metadata constant string value handle to NameFilter rather
// than strings.
//
// The ReflectedType is the type that the Type.Get*() api was invoked on. Use it to establish the returned MemberInfo object's
// ReflectedType.
//
namespace System.Reflection.Runtime.TypeInfos
{
internal abstract partial class RuntimeTypeInfo
{
internal IEnumerable<ConstructorInfo> CoreGetDeclaredConstructors(NameFilter optionalNameFilter)
{
//
// - It may sound odd to get a non-null name filter for a constructor search, but Type.GetMember() is an api that does this.
//
// - All GetConstructor() apis act as if BindingFlags.DeclaredOnly were specified. So the ReflectedType will always be the declaring type and so is not passed to this method.
//
RuntimeNamedTypeInfo definingType = AnchoringTypeDefinitionForDeclaredMembers;
if (definingType != null)
{
// If there is a definingType, we do not support Synthetic constructors
Debug.Assert(object.ReferenceEquals(SyntheticConstructors, Empty<RuntimeConstructorInfo>.Enumerable));
return definingType.CoreGetDeclaredConstructors(optionalNameFilter, this);
}
return CoreGetDeclaredSyntheticConstructors(optionalNameFilter);
}
private IEnumerable<ConstructorInfo> CoreGetDeclaredSyntheticConstructors(NameFilter optionalNameFilter)
{
foreach (RuntimeConstructorInfo syntheticConstructor in SyntheticConstructors)
{
if (optionalNameFilter == null || optionalNameFilter.Matches(syntheticConstructor.IsStatic ? ConstructorInfo.TypeConstructorName : ConstructorInfo.ConstructorName))
yield return syntheticConstructor;
}
}
internal IEnumerable<MethodInfo> CoreGetDeclaredMethods(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType)
{
RuntimeNamedTypeInfo definingType = AnchoringTypeDefinitionForDeclaredMembers;
if (definingType != null)
{
// If there is a definingType, we do not support Synthetic constructors
Debug.Assert(object.ReferenceEquals(SyntheticMethods, Empty<RuntimeMethodInfo>.Enumerable));
return definingType.CoreGetDeclaredMethods(optionalNameFilter, reflectedType, this);
}
return CoreGetDeclaredSyntheticMethods(optionalNameFilter);
}
private IEnumerable<MethodInfo> CoreGetDeclaredSyntheticMethods(NameFilter optionalNameFilter)
{
foreach (RuntimeMethodInfo syntheticMethod in SyntheticMethods)
{
if (optionalNameFilter == null || optionalNameFilter.Matches(syntheticMethod.Name))
yield return syntheticMethod;
}
}
internal IEnumerable<EventInfo> CoreGetDeclaredEvents(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType)
{
RuntimeNamedTypeInfo definingType = AnchoringTypeDefinitionForDeclaredMembers;
if (definingType != null)
{
return definingType.CoreGetDeclaredEvents(optionalNameFilter, reflectedType, this);
}
return Empty<EventInfo>.Enumerable;
}
internal IEnumerable<FieldInfo> CoreGetDeclaredFields(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType)
{
RuntimeNamedTypeInfo definingType = AnchoringTypeDefinitionForDeclaredMembers;
if (definingType != null)
{
return definingType.CoreGetDeclaredFields(optionalNameFilter, reflectedType, this);
}
return Empty<FieldInfo>.Enumerable;
}
internal IEnumerable<PropertyInfo> CoreGetDeclaredProperties(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType)
{
RuntimeNamedTypeInfo definingType = AnchoringTypeDefinitionForDeclaredMembers;
if (definingType != null)
{
return definingType.CoreGetDeclaredProperties(optionalNameFilter, reflectedType, this);
}
return Empty<PropertyInfo>.Enumerable;
}
//
// - All GetNestedType() apis act as if BindingFlags.DeclaredOnly were specified. So the ReflectedType will always be the declaring type and so is not passed to this method.
//
// This method is left unsealed as RuntimeNamedTypeInfo and others need to override with specific implementations.
//
internal virtual IEnumerable<Type> CoreGetDeclaredNestedTypes(NameFilter optionalNameFilter)
{
return Array.Empty<Type>();
}
}
internal abstract partial class RuntimeNamedTypeInfo
{
// Metadata providing implementations of RuntimeNamedTypeInfo implement the following methods
// to provide filtered access to the various reflection objects by reading metadata directly.
// The loop of examining methods is done in a metadata specific manner for greater efficiency.
internal abstract IEnumerable<ConstructorInfo> CoreGetDeclaredConstructors(NameFilter optionalNameFilter, RuntimeTypeInfo contextTypeInfo);
internal abstract IEnumerable<MethodInfo> CoreGetDeclaredMethods(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType, RuntimeTypeInfo contextTypeInfo);
internal abstract IEnumerable<EventInfo> CoreGetDeclaredEvents(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType, RuntimeTypeInfo contextTypeInfo);
internal abstract IEnumerable<FieldInfo> CoreGetDeclaredFields(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType, RuntimeTypeInfo contextTypeInfo);
internal abstract IEnumerable<PropertyInfo> CoreGetDeclaredProperties(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType, RuntimeTypeInfo contextTypeInfo);
}
internal sealed partial class RuntimeConstructedGenericTypeInfo
{
internal sealed override IEnumerable<Type> CoreGetDeclaredNestedTypes(NameFilter optionalNameFilter)
{
return GenericTypeDefinitionTypeInfo.CoreGetDeclaredNestedTypes(optionalNameFilter);
}
}
internal sealed partial class RuntimeBlockedTypeInfo
{
internal sealed override IEnumerable<Type> CoreGetDeclaredNestedTypes(NameFilter optionalNameFilter)
{
return Array.Empty<Type>();
}
}
internal sealed partial class RuntimeNoMetadataNamedTypeInfo
{
internal sealed override IEnumerable<Type> CoreGetDeclaredNestedTypes(NameFilter optionalNameFilter)
{
throw ReflectionCoreExecution.ExecutionDomain.CreateMissingMetadataException(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.Diagnostics;
using System.Collections.Generic;
using System.Reflection.Runtime.General;
using System.Reflection.Runtime.MethodInfos;
using System.Reflection.Runtime.FieldInfos;
using System.Reflection.Runtime.PropertyInfos;
using System.Reflection.Runtime.EventInfos;
using NameFilter = System.Reflection.Runtime.BindingFlagSupport.NameFilter;
using Internal.Reflection.Core.Execution;
//
// The CoreGet() methods on RuntimeTypeInfo provide the raw source material for the Type.Get*() family of apis.
//
// These retrieve directly introduced (not inherited) members whose names match the passed in NameFilter (if NameFilter is null,
// return all members.) To avoid allocating objects, prefer to pass the metadata constant string value handle to NameFilter rather
// than strings.
//
// The ReflectedType is the type that the Type.Get*() api was invoked on. Use it to establish the returned MemberInfo object's
// ReflectedType.
//
namespace System.Reflection.Runtime.TypeInfos
{
internal abstract partial class RuntimeTypeInfo
{
internal IEnumerable<ConstructorInfo> CoreGetDeclaredConstructors(NameFilter optionalNameFilter)
{
//
// - It may sound odd to get a non-null name filter for a constructor search, but Type.GetMember() is an api that does this.
//
// - All GetConstructor() apis act as if BindingFlags.DeclaredOnly were specified. So the ReflectedType will always be the declaring type and so is not passed to this method.
//
RuntimeNamedTypeInfo definingType = AnchoringTypeDefinitionForDeclaredMembers;
if (definingType != null)
{
// If there is a definingType, we do not support Synthetic constructors
Debug.Assert(object.ReferenceEquals(SyntheticConstructors, Empty<RuntimeConstructorInfo>.Enumerable));
return definingType.CoreGetDeclaredConstructors(optionalNameFilter, this);
}
return CoreGetDeclaredSyntheticConstructors(optionalNameFilter);
}
private IEnumerable<ConstructorInfo> CoreGetDeclaredSyntheticConstructors(NameFilter optionalNameFilter)
{
foreach (RuntimeConstructorInfo syntheticConstructor in SyntheticConstructors)
{
if (optionalNameFilter == null || optionalNameFilter.Matches(syntheticConstructor.IsStatic ? ConstructorInfo.TypeConstructorName : ConstructorInfo.ConstructorName))
yield return syntheticConstructor;
}
}
internal IEnumerable<MethodInfo> CoreGetDeclaredMethods(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType)
{
RuntimeNamedTypeInfo definingType = AnchoringTypeDefinitionForDeclaredMembers;
if (definingType != null)
{
// If there is a definingType, we do not support Synthetic constructors
Debug.Assert(object.ReferenceEquals(SyntheticMethods, Empty<RuntimeMethodInfo>.Enumerable));
return definingType.CoreGetDeclaredMethods(optionalNameFilter, reflectedType, this);
}
return CoreGetDeclaredSyntheticMethods(optionalNameFilter);
}
private IEnumerable<MethodInfo> CoreGetDeclaredSyntheticMethods(NameFilter optionalNameFilter)
{
foreach (RuntimeMethodInfo syntheticMethod in SyntheticMethods)
{
if (optionalNameFilter == null || optionalNameFilter.Matches(syntheticMethod.Name))
yield return syntheticMethod;
}
}
internal IEnumerable<EventInfo> CoreGetDeclaredEvents(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType)
{
RuntimeNamedTypeInfo definingType = AnchoringTypeDefinitionForDeclaredMembers;
if (definingType != null)
{
return definingType.CoreGetDeclaredEvents(optionalNameFilter, reflectedType, this);
}
return Empty<EventInfo>.Enumerable;
}
internal IEnumerable<FieldInfo> CoreGetDeclaredFields(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType)
{
RuntimeNamedTypeInfo definingType = AnchoringTypeDefinitionForDeclaredMembers;
if (definingType != null)
{
return definingType.CoreGetDeclaredFields(optionalNameFilter, reflectedType, this);
}
return Empty<FieldInfo>.Enumerable;
}
internal IEnumerable<PropertyInfo> CoreGetDeclaredProperties(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType)
{
RuntimeNamedTypeInfo definingType = AnchoringTypeDefinitionForDeclaredMembers;
if (definingType != null)
{
return definingType.CoreGetDeclaredProperties(optionalNameFilter, reflectedType, this);
}
return Empty<PropertyInfo>.Enumerable;
}
//
// - All GetNestedType() apis act as if BindingFlags.DeclaredOnly were specified. So the ReflectedType will always be the declaring type and so is not passed to this method.
//
// This method is left unsealed as RuntimeNamedTypeInfo and others need to override with specific implementations.
//
internal virtual IEnumerable<Type> CoreGetDeclaredNestedTypes(NameFilter optionalNameFilter)
{
return Array.Empty<Type>();
}
}
internal abstract partial class RuntimeNamedTypeInfo
{
// Metadata providing implementations of RuntimeNamedTypeInfo implement the following methods
// to provide filtered access to the various reflection objects by reading metadata directly.
// The loop of examining methods is done in a metadata specific manner for greater efficiency.
internal abstract IEnumerable<ConstructorInfo> CoreGetDeclaredConstructors(NameFilter optionalNameFilter, RuntimeTypeInfo contextTypeInfo);
internal abstract IEnumerable<MethodInfo> CoreGetDeclaredMethods(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType, RuntimeTypeInfo contextTypeInfo);
internal abstract IEnumerable<EventInfo> CoreGetDeclaredEvents(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType, RuntimeTypeInfo contextTypeInfo);
internal abstract IEnumerable<FieldInfo> CoreGetDeclaredFields(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType, RuntimeTypeInfo contextTypeInfo);
internal abstract IEnumerable<PropertyInfo> CoreGetDeclaredProperties(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType, RuntimeTypeInfo contextTypeInfo);
}
internal sealed partial class RuntimeConstructedGenericTypeInfo
{
internal sealed override IEnumerable<Type> CoreGetDeclaredNestedTypes(NameFilter optionalNameFilter)
{
return GenericTypeDefinitionTypeInfo.CoreGetDeclaredNestedTypes(optionalNameFilter);
}
}
internal sealed partial class RuntimeBlockedTypeInfo
{
internal sealed override IEnumerable<Type> CoreGetDeclaredNestedTypes(NameFilter optionalNameFilter)
{
return Array.Empty<Type>();
}
}
internal sealed partial class RuntimeNoMetadataNamedTypeInfo
{
internal sealed override IEnumerable<Type> CoreGetDeclaredNestedTypes(NameFilter optionalNameFilter)
{
throw ReflectionCoreExecution.ExecutionDomain.CreateMissingMetadataException(this);
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd.Arm64/LoadPairVector128.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\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.Reflection;
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 LoadPairVector128_Single()
{
var test = new LoadPairVector128_Single();
if (test.IsSupported)
{
// Validates basic functionality works
test.RunBasicScenario();
// Validates calling via reflection works
test.RunReflectionScenario();
// Validates loading to a static member works
test.RunClsVarScenario();
// Validates loading to the field of a local class works
test.RunClassLclFldScenario();
// Validates loading to the field of a local struct works
test.RunStructLclFldScenario();
// Validates loading to 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 LoadPairVector128_Single
{
private struct DataTable
{
private byte[] inArray;
private byte[] outArray;
private GCHandle inHandle;
private GCHandle outHandle;
private ulong alignment;
public DataTable(Single[] inArray, Single[] outArray, int alignment)
{
int sizeOfinArray = inArray.Length * Unsafe.SizeOf<Single>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Single>();
if ((alignment != 16 && alignment != 32) || (alignment * 2) < sizeOfinArray || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray = new byte[alignment * 2];
this.outArray = new byte[alignment * 2];
this.inHandle = GCHandle.Alloc(this.inArray, GCHandleType.Pinned);
this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArrayPtr), ref Unsafe.As<Single, byte>(ref inArray[0]), (uint)sizeOfinArray);
}
public void* inArrayPtr => Align((byte*)(inHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle.Free();
outHandle.Free();
}
private static unsafe void* Align(byte* buffer, ulong expectedAlignment)
{
return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1));
}
}
private struct TestStruct
{
public (Vector128<Single>,Vector128<Single>) _fld;
public static TestStruct Create()
{
return new TestStruct();
}
public void RunStructFldScenario(LoadPairVector128_Single testClass)
{
_fld = AdvSimd.Arm64.LoadPairVector128((Single*)(testClass._dataTable.inArrayPtr));
Unsafe.Write(testClass._dataTable.outArrayPtr, _fld);
testClass.ValidateResult(testClass._dataTable.inArrayPtr, testClass._dataTable.outArrayPtr);
}
}
private static readonly int LargestVectorSize = 32;
private static readonly int RetElementCount = Unsafe.SizeOf<(Vector128<Single>,Vector128<Single>)>() / sizeof(Single);
private static readonly int Op1ElementCount = RetElementCount;
private static Single[] _data = new Single[Op1ElementCount];
private static (Vector128<Single>,Vector128<Single>) _clsVar;
private (Vector128<Single>,Vector128<Single>) _fld;
private DataTable _dataTable;
public LoadPairVector128_Single()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); }
_dataTable = new DataTable(_data, new Single[RetElementCount], LargestVectorSize);
}
public bool IsSupported => AdvSimd.Arm64.IsSupported;
public bool Succeeded { get; set; }
public void RunBasicScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario));
var result = AdvSimd.Arm64.LoadPairVector128((Single*)(_dataTable.inArrayPtr));
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario));
var result = typeof(AdvSimd.Arm64).GetMethod(nameof(AdvSimd.Arm64.LoadPairVector128), new Type[] { typeof(Single*) })
.Invoke(null, new object[] {
Pointer.Box(_dataTable.inArrayPtr, typeof(Single*))
});
Unsafe.Write(_dataTable.outArrayPtr, ((Vector128<Single>,Vector128<Single>))result);
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
_clsVar = AdvSimd.Arm64.LoadPairVector128((Single*)(_dataTable.inArrayPtr));
Unsafe.Write(_dataTable.outArrayPtr, _clsVar);
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new LoadPairVector128_Single();
test._fld = AdvSimd.Arm64.LoadPairVector128((Single*)(_dataTable.inArrayPtr));
Unsafe.Write(_dataTable.outArrayPtr, test._fld);
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
test._fld = AdvSimd.Arm64.LoadPairVector128((Single*)(_dataTable.inArrayPtr));
Unsafe.Write(_dataTable.outArrayPtr, test._fld);
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunStructFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario));
var test = TestStruct.Create();
test.RunStructFldScenario(this);
}
public void RunUnsupportedScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario));
Succeeded = false;
try
{
RunBasicScenario();
}
catch (PlatformNotSupportedException)
{
Succeeded = true;
}
}
private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
{
Single[] inArray = new Single[Op1ElementCount];
Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)(Unsafe.SizeOf<Single>() * Op1ElementCount));
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)(Unsafe.SizeOf<Single>() * RetElementCount));
ValidateResult(inArray, outArray, method);
}
private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (int i = 0; i < Op1ElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd.Arm64)}.{nameof(AdvSimd.Arm64.LoadPairVector128)}<Single>(Vector128<Single>): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/******************************************************************************
* This file is auto-generated from a template file by the GenerateTests.csx *
* script in tests\src\JIT\HardwareIntrinsics\Arm\Shared. In order to make *
* changes, please update the corresponding template and run according to the *
* directions listed in the file. *
******************************************************************************/
using System;
using System.Reflection;
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 LoadPairVector128_Single()
{
var test = new LoadPairVector128_Single();
if (test.IsSupported)
{
// Validates basic functionality works
test.RunBasicScenario();
// Validates calling via reflection works
test.RunReflectionScenario();
// Validates loading to a static member works
test.RunClsVarScenario();
// Validates loading to the field of a local class works
test.RunClassLclFldScenario();
// Validates loading to the field of a local struct works
test.RunStructLclFldScenario();
// Validates loading to 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 LoadPairVector128_Single
{
private struct DataTable
{
private byte[] inArray;
private byte[] outArray;
private GCHandle inHandle;
private GCHandle outHandle;
private ulong alignment;
public DataTable(Single[] inArray, Single[] outArray, int alignment)
{
int sizeOfinArray = inArray.Length * Unsafe.SizeOf<Single>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Single>();
if ((alignment != 16 && alignment != 32) || (alignment * 2) < sizeOfinArray || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray = new byte[alignment * 2];
this.outArray = new byte[alignment * 2];
this.inHandle = GCHandle.Alloc(this.inArray, GCHandleType.Pinned);
this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArrayPtr), ref Unsafe.As<Single, byte>(ref inArray[0]), (uint)sizeOfinArray);
}
public void* inArrayPtr => Align((byte*)(inHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle.Free();
outHandle.Free();
}
private static unsafe void* Align(byte* buffer, ulong expectedAlignment)
{
return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1));
}
}
private struct TestStruct
{
public (Vector128<Single>,Vector128<Single>) _fld;
public static TestStruct Create()
{
return new TestStruct();
}
public void RunStructFldScenario(LoadPairVector128_Single testClass)
{
_fld = AdvSimd.Arm64.LoadPairVector128((Single*)(testClass._dataTable.inArrayPtr));
Unsafe.Write(testClass._dataTable.outArrayPtr, _fld);
testClass.ValidateResult(testClass._dataTable.inArrayPtr, testClass._dataTable.outArrayPtr);
}
}
private static readonly int LargestVectorSize = 32;
private static readonly int RetElementCount = Unsafe.SizeOf<(Vector128<Single>,Vector128<Single>)>() / sizeof(Single);
private static readonly int Op1ElementCount = RetElementCount;
private static Single[] _data = new Single[Op1ElementCount];
private static (Vector128<Single>,Vector128<Single>) _clsVar;
private (Vector128<Single>,Vector128<Single>) _fld;
private DataTable _dataTable;
public LoadPairVector128_Single()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); }
_dataTable = new DataTable(_data, new Single[RetElementCount], LargestVectorSize);
}
public bool IsSupported => AdvSimd.Arm64.IsSupported;
public bool Succeeded { get; set; }
public void RunBasicScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario));
var result = AdvSimd.Arm64.LoadPairVector128((Single*)(_dataTable.inArrayPtr));
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario));
var result = typeof(AdvSimd.Arm64).GetMethod(nameof(AdvSimd.Arm64.LoadPairVector128), new Type[] { typeof(Single*) })
.Invoke(null, new object[] {
Pointer.Box(_dataTable.inArrayPtr, typeof(Single*))
});
Unsafe.Write(_dataTable.outArrayPtr, ((Vector128<Single>,Vector128<Single>))result);
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
_clsVar = AdvSimd.Arm64.LoadPairVector128((Single*)(_dataTable.inArrayPtr));
Unsafe.Write(_dataTable.outArrayPtr, _clsVar);
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new LoadPairVector128_Single();
test._fld = AdvSimd.Arm64.LoadPairVector128((Single*)(_dataTable.inArrayPtr));
Unsafe.Write(_dataTable.outArrayPtr, test._fld);
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
test._fld = AdvSimd.Arm64.LoadPairVector128((Single*)(_dataTable.inArrayPtr));
Unsafe.Write(_dataTable.outArrayPtr, test._fld);
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}
public void RunStructFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario));
var test = TestStruct.Create();
test.RunStructFldScenario(this);
}
public void RunUnsupportedScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario));
Succeeded = false;
try
{
RunBasicScenario();
}
catch (PlatformNotSupportedException)
{
Succeeded = true;
}
}
private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
{
Single[] inArray = new Single[Op1ElementCount];
Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)(Unsafe.SizeOf<Single>() * Op1ElementCount));
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)(Unsafe.SizeOf<Single>() * RetElementCount));
ValidateResult(inArray, outArray, method);
}
private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (int i = 0; i < Op1ElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd.Arm64)}.{nameof(AdvSimd.Arm64.LoadPairVector128)}<Single>(Vector128<Single>): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/Regression/JitBlue/Runtime_64808/Runtime_64808.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;
// Generated by Fuzzlyn v1.5 on 2022-02-03 20:05:52
// Run on X64 Linux
// Seed: 17645686525285880576
// Reduced from 66.2 KiB to 1.0 KiB in 00:04:27
// Hits JIT assert in Release:
// Assertion failed 'compiler->opts.IsOSR() || ((genInitStkLclCnt > 0) == hasUntrLcl)' in 'Program:M8():S0' during 'Generate code' (IL size 110)
//
// File: /__w/1/s/src/coreclr/jit/codegencommon.cpp Line: 7256
//
public class C0
{
public int F0;
public ulong F1;
public sbyte F2;
}
public struct S0
{
public int F0;
public S0(int f0): this()
{
}
}
public class Runtime_64808
{
private static IRT s_rt;
public static long[] s_16;
public static bool s_23;
public static int s_result;
public static int Main()
{
s_16 = new long[1];
s_rt = new C();
s_result = -1;
M8();
return s_result;
}
public static S0 M8()
{
try
{
var vr0 = new ushort[]{0};
C0[] vr3 = default(C0[]);
return M15(vr0, ref s_23, vr3);
}
finally
{
var vr2 = new S0[]{new S0(0), new S0(0), new S0(0), new S0(0), new S0(0), new S0(0)};
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static S0 M15(ushort[] arg0, ref bool arg1, C0[] arg2)
{
s_result = 100;
S0 vr5 = default(S0);
return vr5;
}
}
public interface IRT
{
void WriteLine<T>(string a, T value);
}
public class C : IRT
{
public void WriteLine<T>(string a, T value)
{
System.Console.WriteLine(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;
using System.Runtime.CompilerServices;
// Generated by Fuzzlyn v1.5 on 2022-02-03 20:05:52
// Run on X64 Linux
// Seed: 17645686525285880576
// Reduced from 66.2 KiB to 1.0 KiB in 00:04:27
// Hits JIT assert in Release:
// Assertion failed 'compiler->opts.IsOSR() || ((genInitStkLclCnt > 0) == hasUntrLcl)' in 'Program:M8():S0' during 'Generate code' (IL size 110)
//
// File: /__w/1/s/src/coreclr/jit/codegencommon.cpp Line: 7256
//
public class C0
{
public int F0;
public ulong F1;
public sbyte F2;
}
public struct S0
{
public int F0;
public S0(int f0): this()
{
}
}
public class Runtime_64808
{
private static IRT s_rt;
public static long[] s_16;
public static bool s_23;
public static int s_result;
public static int Main()
{
s_16 = new long[1];
s_rt = new C();
s_result = -1;
M8();
return s_result;
}
public static S0 M8()
{
try
{
var vr0 = new ushort[]{0};
C0[] vr3 = default(C0[]);
return M15(vr0, ref s_23, vr3);
}
finally
{
var vr2 = new S0[]{new S0(0), new S0(0), new S0(0), new S0(0), new S0(0), new S0(0)};
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static S0 M15(ushort[] arg0, ref bool arg1, C0[] arg2)
{
s_result = 100;
S0 vr5 = default(S0);
return vr5;
}
}
public interface IRT
{
void WriteLine<T>(string a, T value);
}
public class C : IRT
{
public void WriteLine<T>(string a, T value)
{
System.Console.WriteLine(value);
}
} | -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Memory/tests/Memory/Trim.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;
#pragma warning disable xUnit1025 // analyzer is flagging unique InlineDatas as duplicates
namespace System.MemoryTests
{
public static partial class MemoryTests
{
[Theory]
[InlineData(new int[0], 1, new int[0])]
[InlineData(new int[] { 1 }, 1, new int[0])]
[InlineData(new int[] { 2 }, 1, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1 }, 1, new int[] { 2, 1 })]
[InlineData(new int[] { 1, 1, 2, 1 }, 1, new int[] { 2, 1 })]
[InlineData(new int[] { 1, 1, 2, 1 }, 2, new int[] { 1, 1, 2, 1 })]
[InlineData(new int[] { 1, 1, 2, 1 }, 3, new int[] { 1, 1, 2, 1 })]
[InlineData(new int[] { 1, 1, 1, 2 }, 1, new int[] { 2 })]
[InlineData(new int[] { 1, 1, 1, 1 }, 1, new int[0])]
public static void MemoryExtensions_TrimStart_Single(int[] values, int trim, int[] expected)
{
Memory<int> memory = new Memory<int>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<int> rom = new ReadOnlyMemory<int>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<int> span = new Span<int>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<int> ros = new ReadOnlySpan<int>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Theory]
[InlineData(new int[0], 1, new int[0])]
[InlineData(new int[] { 1 }, 1, new int[0])]
[InlineData(new int[] { 2 }, 1, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1 }, 1, new int[] { 1, 2 })]
[InlineData(new int[] { 1, 2, 1, 1 }, 1, new int[] { 1, 2 })]
[InlineData(new int[] { 1, 2, 1, 1 }, 2, new int[] { 1, 2, 1, 1 })]
[InlineData(new int[] { 1, 2, 1, 1 }, 3, new int[] { 1, 2, 1, 1 })]
[InlineData(new int[] { 2, 1, 1, 1 }, 1, new int[] { 2 })]
[InlineData(new int[] { 1, 1, 1, 1 }, 1, new int[0])]
public static void MemoryExtensions_TrimEnd_Single(int[] values, int trim, int[] expected)
{
Memory<int> memory = new Memory<int>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<int> rom = new ReadOnlyMemory<int>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<int> span = new Span<int>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<int> ros = new ReadOnlySpan<int>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Theory]
[InlineData(new int[0], 1, new int[0])]
[InlineData(new int[] { 1 }, 1, new int[0])]
[InlineData(new int[] { 2 }, 1, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1 }, 1, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1, 1 }, 1, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1, 1 }, 2, new int[] { 1, 2, 1, 1 })]
[InlineData(new int[] { 1, 2, 1, 1 }, 3, new int[] { 1, 2, 1, 1 })]
[InlineData(new int[] { 2, 1, 1, 1 }, 1, new int[] { 2 })]
[InlineData(new int[] { 1, 1, 1, 2 }, 1, new int[] { 2 })]
[InlineData(new int[] { 1, 1, 1, 1 }, 1, new int[0])]
public static void MemoryExtensions_Trim_Single(int[] values, int trim, int[] expected)
{
Memory<int> memory = new Memory<int>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<int> rom = new ReadOnlyMemory<int>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<int> span = new Span<int>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<int> ros = new ReadOnlySpan<int>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Theory]
[InlineData(new int[0], new int[0], new int[0])]
[InlineData(new int[0], new int[] { 1 }, new int[0])]
[InlineData(new int[] { 1 }, new int[0], new int[] { 1 })]
[InlineData(new int[] { 1 }, new int[] { 1 }, new int[0])]
[InlineData(new int[] { 2 }, new int[] { 1 }, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1 }, new int[] { 1 }, new int[] { 2, 1 })]
[InlineData(new int[] { 1, 1, 2, 1 }, new int[] { 1 }, new int[] { 2, 1 })]
[InlineData(new int[] { 1, 1, 2, 1 }, new int[] { 2 }, new int[] { 1, 1, 2, 1 })]
[InlineData(new int[] { 1, 1, 2, 1 }, new int[] { 3 }, new int[] { 1, 1, 2, 1 })]
[InlineData(new int[] { 1, 1, 2, 1 }, new int[] { 1, 2 }, new int[0])]
[InlineData(new int[] { 1, 1, 2, 3 }, new int[] { 1, 2 }, new int[] { 3 })]
[InlineData(new int[] { 1, 1, 2, 3 }, new int[] { 1, 2, 4 }, new int[] { 3 })]
[InlineData(new int[] { 1, 1, 1, 2 }, new int[] { 1 }, new int[] { 2 })]
[InlineData(new int[] { 1, 1, 1, 1 }, new int[] { 1 }, new int[0])]
public static void MemoryExtensions_TrimStart_Multi(int[] values, int[] trims, int[] expected)
{
Memory<int> memory = new Memory<int>(values).TrimStart(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<int> rom = new ReadOnlyMemory<int>(values).TrimStart(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<int> span = new Span<int>(values).TrimStart(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<int> ros = new ReadOnlySpan<int>(values).TrimStart(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Theory]
[InlineData(new int[0], new int[0], new int[0])]
[InlineData(new int[0], new int[] { 1 }, new int[0])]
[InlineData(new int[] { 1 }, new int[0], new int[] { 1 })]
[InlineData(new int[] { 1 }, new int[] { 1 }, new int[0])]
[InlineData(new int[] { 2 }, new int[] { 1 }, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1 }, new int[] { 1 }, new int[] { 1, 2 })]
[InlineData(new int[] { 1, 2, 1, 1 }, new int[] { 1 }, new int[] { 1, 2 })]
[InlineData(new int[] { 1, 2, 1, 1 }, new int[] { 2 }, new int[] { 1, 2, 1, 1 })]
[InlineData(new int[] { 1, 2, 1, 1 }, new int[] { 3 }, new int[] { 1, 2, 1, 1 })]
[InlineData(new int[] { 1, 2, 1, 1 }, new int[] { 1, 2 }, new int[0])]
[InlineData(new int[] { 3, 2, 1, 1 }, new int[] { 1, 2 }, new int[] { 3 })]
[InlineData(new int[] { 3, 2, 1, 1 }, new int[] { 1, 2, 4 }, new int[] { 3 })]
[InlineData(new int[] { 2, 1, 1, 1 }, new int[] { 1 }, new int[] { 2 })]
[InlineData(new int[] { 1, 1, 1, 1 }, new int[] { 1 }, new int[0])]
public static void MemoryExtensions_TrimEnd_Multi(int[] values, int[] trims, int[] expected)
{
Memory<int> memory = new Memory<int>(values).TrimEnd(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<int> rom = new ReadOnlyMemory<int>(values).TrimEnd(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<int> span = new Span<int>(values).TrimEnd(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<int> ros = new ReadOnlySpan<int>(values).TrimEnd(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Theory]
[InlineData(new int[0], new int[0], new int[0])]
[InlineData(new int[0], new int[] { 1 }, new int[0])]
[InlineData(new int[] { 1 }, new int[0], new int[] { 1 })]
[InlineData(new int[] { 1 }, new int[] { 1 }, new int[0])]
[InlineData(new int[] { 2 }, new int[] { 1 }, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1 }, new int[] { 1 }, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1, 1 }, new int[] { 1 }, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1, 1 }, new int[] { 2 }, new int[] { 1, 2, 1, 1 })]
[InlineData(new int[] { 1, 2, 1, 1 }, new int[] { 3 }, new int[] { 1, 2, 1, 1 })]
[InlineData(new int[] { 1, 2, 1, 1 }, new int[] { 1, 2 }, new int[0])]
[InlineData(new int[] { 2, 1, 3, 2, 1, 1 }, new int[] { 1, 2 }, new int[] { 3 })]
[InlineData(new int[] { 2, 1, 3, 2, 1, 1 }, new int[] { 1, 2, 4 }, new int[] { 3 })]
[InlineData(new int[] { 1, 2, 1, 1, 1 }, new int[] { 1 }, new int[] { 2 })]
[InlineData(new int[] { 1, 1, 1, 1 }, new int[] { 1 }, new int[0])]
public static void MemoryExtensions_Trim_Multi(int[] values, int[] trims, int[] expected)
{
Memory<int> memory = new Memory<int>(values).Trim(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<int> rom = new ReadOnlyMemory<int>(values).Trim(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<int> span = new Span<int>(values).Trim(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<int> ros = new ReadOnlySpan<int>(values).Trim(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
public sealed class Foo : IEquatable<Foo>
{
public int Value { get; set; }
public bool Equals(Foo other)
{
if (this == null && other == null)
return true;
if (other == null)
return false;
return Value == other.Value;
}
public static implicit operator Foo(int value) => new Foo { Value = value };
public static implicit operator int? (Foo foo) => foo?.Value;
}
public static IEnumerable<object[]> IdempotentValues => new object[][]
{
new object[1] { new Foo[] { } },
new object[1] { new Foo[] { null, 1, 2, 3, null, 2, 1, null } }
};
[Theory]
[MemberData(nameof(IdempotentValues))]
public static void MemoryExtensions_TrimStart_Idempotent(Foo[] values)
{
Foo[] expected = values;
Foo[] trim = null;
Memory<Foo> memory = new Memory<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<Foo> rom = new ReadOnlyMemory<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<Foo> span = new Span<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<Foo> ros = new ReadOnlySpan<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
trim = new Foo[] { };
memory = new Memory<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
rom = new ReadOnlyMemory<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
span = new Span<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ros = new ReadOnlySpan<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Theory]
[MemberData(nameof(IdempotentValues))]
public static void MemoryExtensions_TrimEnd_Idempotent(Foo[] values)
{
Foo[] expected = values;
Foo[] trim = null;
Memory<Foo> memory = new Memory<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<Foo> rom = new ReadOnlyMemory<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<Foo> span = new Span<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<Foo> ros = new ReadOnlySpan<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
trim = new Foo[] { };
memory = new Memory<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
rom = new ReadOnlyMemory<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
span = new Span<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ros = new ReadOnlySpan<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Theory]
[MemberData(nameof(IdempotentValues))]
public static void MemoryExtensions_Trim_Idempotent(Foo[] values)
{
Foo[] expected = values;
Foo[] trim = null;
Memory<Foo> memory = new Memory<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<Foo> rom = new ReadOnlyMemory<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<Foo> span = new Span<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<Foo> ros = new ReadOnlySpan<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
trim = new Foo[] { };
memory = new Memory<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
rom = new ReadOnlyMemory<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
span = new Span<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ros = new ReadOnlySpan<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Fact]
public static void MemoryExtensions_TrimStart_Single_Null()
{
var values = new Foo[] { null, null, 1, 2, null, null };
Foo trim = null;
var expected = new Foo[] { 1, 2, null, null };
Memory<Foo> memory = new Memory<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<Foo> rom = new ReadOnlyMemory<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<Foo> span = new Span<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<Foo> ros = new ReadOnlySpan<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Fact]
public static void MemoryExtensions_TrimStart_Multi_Null()
{
var values = new Foo[] { null, 1, 2, 3, null, 2, 1, null };
var trim = new Foo[] { null, 1, 2 };
var expected = new Foo[] { 3, null, 2, 1, null };
Memory<Foo> memory = new Memory<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<Foo> rom = new ReadOnlyMemory<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<Foo> span = new Span<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<Foo> ros = new ReadOnlySpan<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Fact]
public static void MemoryExtensions_TrimEnd_Single_Null()
{
var values = new Foo[] { null, null, 1, 2, null, null };
Foo trim = null;
var expected = new Foo[] { null, null, 1, 2 };
Memory<Foo> memory = new Memory<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<Foo> rom = new ReadOnlyMemory<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<Foo> span = new Span<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<Foo> ros = new ReadOnlySpan<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Fact]
public static void MemoryExtensions_TrimEnd_Multi_Null()
{
var values = new Foo[] { null, 1, 2, 3, null, 2, 1, null };
var trim = new Foo[] { null, 1, 2 };
var expected = new Foo[] { null, 1, 2, 3 };
Memory<Foo> memory = new Memory<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<Foo> rom = new ReadOnlyMemory<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<Foo> span = new Span<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<Foo> ros = new ReadOnlySpan<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Fact]
public static void MemoryExtensions_Trim_Single_Null()
{
var values = new Foo[] { null, null, 1, 2, null, null };
Foo trim = null;
var expected = new Foo[] { 1, 2 };
Memory<Foo> memory = new Memory<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<Foo> rom = new ReadOnlyMemory<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<Foo> span = new Span<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<Foo> ros = new ReadOnlySpan<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Fact]
public static void MemoryExtensions_Trim_Multi_Null()
{
var values = new Foo[] { null, 1, 2, 3, null, 2, 1, null };
var trim = new Foo[] { null, 1, 2 };
var expected = new Foo[] { 3 };
Memory<Foo> memory = new Memory<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<Foo> rom = new ReadOnlyMemory<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<Foo> span = new Span<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<Foo> ros = new ReadOnlySpan<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using Xunit;
#pragma warning disable xUnit1025 // analyzer is flagging unique InlineDatas as duplicates
namespace System.MemoryTests
{
public static partial class MemoryTests
{
[Theory]
[InlineData(new int[0], 1, new int[0])]
[InlineData(new int[] { 1 }, 1, new int[0])]
[InlineData(new int[] { 2 }, 1, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1 }, 1, new int[] { 2, 1 })]
[InlineData(new int[] { 1, 1, 2, 1 }, 1, new int[] { 2, 1 })]
[InlineData(new int[] { 1, 1, 2, 1 }, 2, new int[] { 1, 1, 2, 1 })]
[InlineData(new int[] { 1, 1, 2, 1 }, 3, new int[] { 1, 1, 2, 1 })]
[InlineData(new int[] { 1, 1, 1, 2 }, 1, new int[] { 2 })]
[InlineData(new int[] { 1, 1, 1, 1 }, 1, new int[0])]
public static void MemoryExtensions_TrimStart_Single(int[] values, int trim, int[] expected)
{
Memory<int> memory = new Memory<int>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<int> rom = new ReadOnlyMemory<int>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<int> span = new Span<int>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<int> ros = new ReadOnlySpan<int>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Theory]
[InlineData(new int[0], 1, new int[0])]
[InlineData(new int[] { 1 }, 1, new int[0])]
[InlineData(new int[] { 2 }, 1, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1 }, 1, new int[] { 1, 2 })]
[InlineData(new int[] { 1, 2, 1, 1 }, 1, new int[] { 1, 2 })]
[InlineData(new int[] { 1, 2, 1, 1 }, 2, new int[] { 1, 2, 1, 1 })]
[InlineData(new int[] { 1, 2, 1, 1 }, 3, new int[] { 1, 2, 1, 1 })]
[InlineData(new int[] { 2, 1, 1, 1 }, 1, new int[] { 2 })]
[InlineData(new int[] { 1, 1, 1, 1 }, 1, new int[0])]
public static void MemoryExtensions_TrimEnd_Single(int[] values, int trim, int[] expected)
{
Memory<int> memory = new Memory<int>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<int> rom = new ReadOnlyMemory<int>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<int> span = new Span<int>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<int> ros = new ReadOnlySpan<int>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Theory]
[InlineData(new int[0], 1, new int[0])]
[InlineData(new int[] { 1 }, 1, new int[0])]
[InlineData(new int[] { 2 }, 1, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1 }, 1, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1, 1 }, 1, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1, 1 }, 2, new int[] { 1, 2, 1, 1 })]
[InlineData(new int[] { 1, 2, 1, 1 }, 3, new int[] { 1, 2, 1, 1 })]
[InlineData(new int[] { 2, 1, 1, 1 }, 1, new int[] { 2 })]
[InlineData(new int[] { 1, 1, 1, 2 }, 1, new int[] { 2 })]
[InlineData(new int[] { 1, 1, 1, 1 }, 1, new int[0])]
public static void MemoryExtensions_Trim_Single(int[] values, int trim, int[] expected)
{
Memory<int> memory = new Memory<int>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<int> rom = new ReadOnlyMemory<int>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<int> span = new Span<int>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<int> ros = new ReadOnlySpan<int>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Theory]
[InlineData(new int[0], new int[0], new int[0])]
[InlineData(new int[0], new int[] { 1 }, new int[0])]
[InlineData(new int[] { 1 }, new int[0], new int[] { 1 })]
[InlineData(new int[] { 1 }, new int[] { 1 }, new int[0])]
[InlineData(new int[] { 2 }, new int[] { 1 }, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1 }, new int[] { 1 }, new int[] { 2, 1 })]
[InlineData(new int[] { 1, 1, 2, 1 }, new int[] { 1 }, new int[] { 2, 1 })]
[InlineData(new int[] { 1, 1, 2, 1 }, new int[] { 2 }, new int[] { 1, 1, 2, 1 })]
[InlineData(new int[] { 1, 1, 2, 1 }, new int[] { 3 }, new int[] { 1, 1, 2, 1 })]
[InlineData(new int[] { 1, 1, 2, 1 }, new int[] { 1, 2 }, new int[0])]
[InlineData(new int[] { 1, 1, 2, 3 }, new int[] { 1, 2 }, new int[] { 3 })]
[InlineData(new int[] { 1, 1, 2, 3 }, new int[] { 1, 2, 4 }, new int[] { 3 })]
[InlineData(new int[] { 1, 1, 1, 2 }, new int[] { 1 }, new int[] { 2 })]
[InlineData(new int[] { 1, 1, 1, 1 }, new int[] { 1 }, new int[0])]
public static void MemoryExtensions_TrimStart_Multi(int[] values, int[] trims, int[] expected)
{
Memory<int> memory = new Memory<int>(values).TrimStart(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<int> rom = new ReadOnlyMemory<int>(values).TrimStart(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<int> span = new Span<int>(values).TrimStart(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<int> ros = new ReadOnlySpan<int>(values).TrimStart(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Theory]
[InlineData(new int[0], new int[0], new int[0])]
[InlineData(new int[0], new int[] { 1 }, new int[0])]
[InlineData(new int[] { 1 }, new int[0], new int[] { 1 })]
[InlineData(new int[] { 1 }, new int[] { 1 }, new int[0])]
[InlineData(new int[] { 2 }, new int[] { 1 }, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1 }, new int[] { 1 }, new int[] { 1, 2 })]
[InlineData(new int[] { 1, 2, 1, 1 }, new int[] { 1 }, new int[] { 1, 2 })]
[InlineData(new int[] { 1, 2, 1, 1 }, new int[] { 2 }, new int[] { 1, 2, 1, 1 })]
[InlineData(new int[] { 1, 2, 1, 1 }, new int[] { 3 }, new int[] { 1, 2, 1, 1 })]
[InlineData(new int[] { 1, 2, 1, 1 }, new int[] { 1, 2 }, new int[0])]
[InlineData(new int[] { 3, 2, 1, 1 }, new int[] { 1, 2 }, new int[] { 3 })]
[InlineData(new int[] { 3, 2, 1, 1 }, new int[] { 1, 2, 4 }, new int[] { 3 })]
[InlineData(new int[] { 2, 1, 1, 1 }, new int[] { 1 }, new int[] { 2 })]
[InlineData(new int[] { 1, 1, 1, 1 }, new int[] { 1 }, new int[0])]
public static void MemoryExtensions_TrimEnd_Multi(int[] values, int[] trims, int[] expected)
{
Memory<int> memory = new Memory<int>(values).TrimEnd(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<int> rom = new ReadOnlyMemory<int>(values).TrimEnd(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<int> span = new Span<int>(values).TrimEnd(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<int> ros = new ReadOnlySpan<int>(values).TrimEnd(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Theory]
[InlineData(new int[0], new int[0], new int[0])]
[InlineData(new int[0], new int[] { 1 }, new int[0])]
[InlineData(new int[] { 1 }, new int[0], new int[] { 1 })]
[InlineData(new int[] { 1 }, new int[] { 1 }, new int[0])]
[InlineData(new int[] { 2 }, new int[] { 1 }, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1 }, new int[] { 1 }, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1, 1 }, new int[] { 1 }, new int[] { 2 })]
[InlineData(new int[] { 1, 2, 1, 1 }, new int[] { 2 }, new int[] { 1, 2, 1, 1 })]
[InlineData(new int[] { 1, 2, 1, 1 }, new int[] { 3 }, new int[] { 1, 2, 1, 1 })]
[InlineData(new int[] { 1, 2, 1, 1 }, new int[] { 1, 2 }, new int[0])]
[InlineData(new int[] { 2, 1, 3, 2, 1, 1 }, new int[] { 1, 2 }, new int[] { 3 })]
[InlineData(new int[] { 2, 1, 3, 2, 1, 1 }, new int[] { 1, 2, 4 }, new int[] { 3 })]
[InlineData(new int[] { 1, 2, 1, 1, 1 }, new int[] { 1 }, new int[] { 2 })]
[InlineData(new int[] { 1, 1, 1, 1 }, new int[] { 1 }, new int[0])]
public static void MemoryExtensions_Trim_Multi(int[] values, int[] trims, int[] expected)
{
Memory<int> memory = new Memory<int>(values).Trim(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<int> rom = new ReadOnlyMemory<int>(values).Trim(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<int> span = new Span<int>(values).Trim(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<int> ros = new ReadOnlySpan<int>(values).Trim(trims);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
public sealed class Foo : IEquatable<Foo>
{
public int Value { get; set; }
public bool Equals(Foo other)
{
if (this == null && other == null)
return true;
if (other == null)
return false;
return Value == other.Value;
}
public static implicit operator Foo(int value) => new Foo { Value = value };
public static implicit operator int? (Foo foo) => foo?.Value;
}
public static IEnumerable<object[]> IdempotentValues => new object[][]
{
new object[1] { new Foo[] { } },
new object[1] { new Foo[] { null, 1, 2, 3, null, 2, 1, null } }
};
[Theory]
[MemberData(nameof(IdempotentValues))]
public static void MemoryExtensions_TrimStart_Idempotent(Foo[] values)
{
Foo[] expected = values;
Foo[] trim = null;
Memory<Foo> memory = new Memory<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<Foo> rom = new ReadOnlyMemory<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<Foo> span = new Span<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<Foo> ros = new ReadOnlySpan<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
trim = new Foo[] { };
memory = new Memory<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
rom = new ReadOnlyMemory<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
span = new Span<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ros = new ReadOnlySpan<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Theory]
[MemberData(nameof(IdempotentValues))]
public static void MemoryExtensions_TrimEnd_Idempotent(Foo[] values)
{
Foo[] expected = values;
Foo[] trim = null;
Memory<Foo> memory = new Memory<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<Foo> rom = new ReadOnlyMemory<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<Foo> span = new Span<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<Foo> ros = new ReadOnlySpan<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
trim = new Foo[] { };
memory = new Memory<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
rom = new ReadOnlyMemory<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
span = new Span<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ros = new ReadOnlySpan<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Theory]
[MemberData(nameof(IdempotentValues))]
public static void MemoryExtensions_Trim_Idempotent(Foo[] values)
{
Foo[] expected = values;
Foo[] trim = null;
Memory<Foo> memory = new Memory<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<Foo> rom = new ReadOnlyMemory<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<Foo> span = new Span<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<Foo> ros = new ReadOnlySpan<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
trim = new Foo[] { };
memory = new Memory<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
rom = new ReadOnlyMemory<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
span = new Span<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ros = new ReadOnlySpan<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Fact]
public static void MemoryExtensions_TrimStart_Single_Null()
{
var values = new Foo[] { null, null, 1, 2, null, null };
Foo trim = null;
var expected = new Foo[] { 1, 2, null, null };
Memory<Foo> memory = new Memory<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<Foo> rom = new ReadOnlyMemory<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<Foo> span = new Span<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<Foo> ros = new ReadOnlySpan<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Fact]
public static void MemoryExtensions_TrimStart_Multi_Null()
{
var values = new Foo[] { null, 1, 2, 3, null, 2, 1, null };
var trim = new Foo[] { null, 1, 2 };
var expected = new Foo[] { 3, null, 2, 1, null };
Memory<Foo> memory = new Memory<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<Foo> rom = new ReadOnlyMemory<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<Foo> span = new Span<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<Foo> ros = new ReadOnlySpan<Foo>(values).TrimStart(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Fact]
public static void MemoryExtensions_TrimEnd_Single_Null()
{
var values = new Foo[] { null, null, 1, 2, null, null };
Foo trim = null;
var expected = new Foo[] { null, null, 1, 2 };
Memory<Foo> memory = new Memory<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<Foo> rom = new ReadOnlyMemory<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<Foo> span = new Span<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<Foo> ros = new ReadOnlySpan<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Fact]
public static void MemoryExtensions_TrimEnd_Multi_Null()
{
var values = new Foo[] { null, 1, 2, 3, null, 2, 1, null };
var trim = new Foo[] { null, 1, 2 };
var expected = new Foo[] { null, 1, 2, 3 };
Memory<Foo> memory = new Memory<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<Foo> rom = new ReadOnlyMemory<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<Foo> span = new Span<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<Foo> ros = new ReadOnlySpan<Foo>(values).TrimEnd(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Fact]
public static void MemoryExtensions_Trim_Single_Null()
{
var values = new Foo[] { null, null, 1, 2, null, null };
Foo trim = null;
var expected = new Foo[] { 1, 2 };
Memory<Foo> memory = new Memory<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<Foo> rom = new ReadOnlyMemory<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<Foo> span = new Span<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<Foo> ros = new ReadOnlySpan<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
[Fact]
public static void MemoryExtensions_Trim_Multi_Null()
{
var values = new Foo[] { null, 1, 2, 3, null, 2, 1, null };
var trim = new Foo[] { null, 1, 2 };
var expected = new Foo[] { 3 };
Memory<Foo> memory = new Memory<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, memory.ToArray()));
ReadOnlyMemory<Foo> rom = new ReadOnlyMemory<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, rom.ToArray()));
Span<Foo> span = new Span<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, span.ToArray()));
ReadOnlySpan<Foo> ros = new ReadOnlySpan<Foo>(values).Trim(trim);
Assert.True(System.Linq.Enumerable.SequenceEqual(expected, ros.ToArray()));
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Private.Xml.Linq/tests/SDMSample/SDMPI.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;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using Xunit;
namespace XDocumentTests.SDMSample
{
public class SDM__PI
{
/// <summary>
/// Tests the ProcessingInstruction constructor that takes a value.
/// </summary>
[Fact]
public void CreateProcessingInstructionSimple()
{
Assert.Throws<ArgumentNullException>(() => new XProcessingInstruction(null, "abcd"));
Assert.Throws<ArgumentNullException>(() => new XProcessingInstruction("abcd", null));
XProcessingInstruction c = new XProcessingInstruction("foo", "bar");
Assert.Equal("foo", c.Target);
Assert.Equal("bar", c.Data);
Assert.Null(c.Parent);
}
/// <summary>
/// Tests the ProcessingInstruction constructor that operated from an XmlReader.
/// </summary>
[Fact]
public void CreateProcessingInstructionFromReader()
{
TextReader textReader = new StringReader("<x><?target data?></x>");
XmlReader xmlReader = XmlReader.Create(textReader);
// Advance to the processing instruction and construct.
xmlReader.Read();
xmlReader.Read();
XProcessingInstruction c = (XProcessingInstruction)XNode.ReadFrom(xmlReader);
Assert.Equal("target", c.Target);
Assert.Equal("data", c.Data);
}
/// <summary>
/// Validates the behavior of the Equals overload on XProcessingInstruction.
/// </summary>
[Fact]
public void ProcessingInstructionEquals()
{
XProcessingInstruction c1 = new XProcessingInstruction("targetx", "datax");
XProcessingInstruction c2 = new XProcessingInstruction("targetx", "datay");
XProcessingInstruction c3 = new XProcessingInstruction("targety", "datax");
XProcessingInstruction c4 = new XProcessingInstruction("targety", "datay");
XProcessingInstruction c5 = new XProcessingInstruction("targetx", "datax");
Assert.False(XNode.DeepEquals(c1, (XProcessingInstruction)null));
Assert.True(XNode.DeepEquals(c1, c1));
Assert.False(XNode.DeepEquals(c1, c2));
Assert.False(XNode.DeepEquals(c1, c3));
Assert.False(XNode.DeepEquals(c1, c4));
Assert.True(XNode.DeepEquals(c1, c5));
Assert.Equal(XNode.EqualityComparer.GetHashCode(c1), XNode.EqualityComparer.GetHashCode(c5));
}
/// <summary>
/// Validates the behavior of the Target and Data properties on XProcessingInstruction.
/// </summary>
[Fact]
public void ProcessingInstructionValues()
{
XProcessingInstruction c = new XProcessingInstruction("xxx", "yyy");
Assert.Equal("xxx", c.Target);
Assert.Equal("yyy", c.Data);
// Null values not allowed.
Assert.Throws<ArgumentNullException>(() => c.Target = null);
Assert.Throws<ArgumentNullException>(() => c.Data = null);
// Try setting values.
c.Target = "abcd";
Assert.Equal("abcd", c.Target);
c.Data = "efgh";
Assert.Equal("efgh", c.Data);
Assert.Equal("abcd", c.Target);
}
/// <summary>
/// Tests the WriteTo method on XComment.
/// </summary>
[Fact]
public void ProcessingInstructionWriteTo()
{
XProcessingInstruction c = new XProcessingInstruction("target", "data");
// Null writer not allowed.
Assert.Throws<ArgumentNullException>(() => c.WriteTo(null));
// Test.
StringBuilder stringBuilder = new StringBuilder();
XmlWriter xmlWriter = XmlWriter.Create(stringBuilder);
xmlWriter.WriteStartElement("x");
c.WriteTo(xmlWriter);
xmlWriter.WriteEndElement();
xmlWriter.Flush();
Assert.Equal(
"<?xml version=\"1.0\" encoding=\"utf-16\"?><x><?target data?></x>",
stringBuilder.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.IO;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using Xunit;
namespace XDocumentTests.SDMSample
{
public class SDM__PI
{
/// <summary>
/// Tests the ProcessingInstruction constructor that takes a value.
/// </summary>
[Fact]
public void CreateProcessingInstructionSimple()
{
Assert.Throws<ArgumentNullException>(() => new XProcessingInstruction(null, "abcd"));
Assert.Throws<ArgumentNullException>(() => new XProcessingInstruction("abcd", null));
XProcessingInstruction c = new XProcessingInstruction("foo", "bar");
Assert.Equal("foo", c.Target);
Assert.Equal("bar", c.Data);
Assert.Null(c.Parent);
}
/// <summary>
/// Tests the ProcessingInstruction constructor that operated from an XmlReader.
/// </summary>
[Fact]
public void CreateProcessingInstructionFromReader()
{
TextReader textReader = new StringReader("<x><?target data?></x>");
XmlReader xmlReader = XmlReader.Create(textReader);
// Advance to the processing instruction and construct.
xmlReader.Read();
xmlReader.Read();
XProcessingInstruction c = (XProcessingInstruction)XNode.ReadFrom(xmlReader);
Assert.Equal("target", c.Target);
Assert.Equal("data", c.Data);
}
/// <summary>
/// Validates the behavior of the Equals overload on XProcessingInstruction.
/// </summary>
[Fact]
public void ProcessingInstructionEquals()
{
XProcessingInstruction c1 = new XProcessingInstruction("targetx", "datax");
XProcessingInstruction c2 = new XProcessingInstruction("targetx", "datay");
XProcessingInstruction c3 = new XProcessingInstruction("targety", "datax");
XProcessingInstruction c4 = new XProcessingInstruction("targety", "datay");
XProcessingInstruction c5 = new XProcessingInstruction("targetx", "datax");
Assert.False(XNode.DeepEquals(c1, (XProcessingInstruction)null));
Assert.True(XNode.DeepEquals(c1, c1));
Assert.False(XNode.DeepEquals(c1, c2));
Assert.False(XNode.DeepEquals(c1, c3));
Assert.False(XNode.DeepEquals(c1, c4));
Assert.True(XNode.DeepEquals(c1, c5));
Assert.Equal(XNode.EqualityComparer.GetHashCode(c1), XNode.EqualityComparer.GetHashCode(c5));
}
/// <summary>
/// Validates the behavior of the Target and Data properties on XProcessingInstruction.
/// </summary>
[Fact]
public void ProcessingInstructionValues()
{
XProcessingInstruction c = new XProcessingInstruction("xxx", "yyy");
Assert.Equal("xxx", c.Target);
Assert.Equal("yyy", c.Data);
// Null values not allowed.
Assert.Throws<ArgumentNullException>(() => c.Target = null);
Assert.Throws<ArgumentNullException>(() => c.Data = null);
// Try setting values.
c.Target = "abcd";
Assert.Equal("abcd", c.Target);
c.Data = "efgh";
Assert.Equal("efgh", c.Data);
Assert.Equal("abcd", c.Target);
}
/// <summary>
/// Tests the WriteTo method on XComment.
/// </summary>
[Fact]
public void ProcessingInstructionWriteTo()
{
XProcessingInstruction c = new XProcessingInstruction("target", "data");
// Null writer not allowed.
Assert.Throws<ArgumentNullException>(() => c.WriteTo(null));
// Test.
StringBuilder stringBuilder = new StringBuilder();
XmlWriter xmlWriter = XmlWriter.Create(stringBuilder);
xmlWriter.WriteStartElement("x");
c.WriteTo(xmlWriter);
xmlWriter.WriteEndElement();
xmlWriter.Flush();
Assert.Equal(
"<?xml version=\"1.0\" encoding=\"utf-16\"?><x><?target data?></x>",
stringBuilder.ToString());
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/mono/mono/tests/obj.cs | using System;
public class TestObj {
static public int sbah = 5;
public int bah = 1;
public int boh;
public TestObj () {
boh = 2;
}
public int amethod () {
return boh;
}
public static int Main () {
TestObj obj = new TestObj ();
TestObj clone;
if (sbah + obj.bah + obj.amethod () != 8)
return 1;
clone = (TestObj)obj.MemberwiseClone ();
if (clone.boh != 2)
return 1;
return 0;
}
}
| using System;
public class TestObj {
static public int sbah = 5;
public int bah = 1;
public int boh;
public TestObj () {
boh = 2;
}
public int amethod () {
return boh;
}
public static int Main () {
TestObj obj = new TestObj ();
TestObj clone;
if (sbah + obj.bah + obj.amethod () != 8)
return 1;
clone = (TestObj)obj.MemberwiseClone ();
if (clone.boh != 2)
return 1;
return 0;
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Linq.Expressions/tests/BinaryOperators/Arithmetic/BinaryNullableMultiplyTests.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.Linq.Expressions.Tests
{
public static class BinaryNullableMultiplyTests
{
#region Test methods
[Fact]
public static void CheckNullableByteMultiplyTest()
{
byte?[] array = { 0, 1, byte.MaxValue, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableByteMultiply(array[i], array[j]);
}
}
}
[Fact]
public static void CheckNullableSByteMultiplyTest()
{
sbyte?[] array = { 0, 1, -1, sbyte.MinValue, sbyte.MaxValue, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableSByteMultiply(array[i], array[j]);
}
}
}
[Theory, ClassData(typeof(CompilationTypes))]
public static void CheckNullableUShortMultiplyTest(bool useInterpreter)
{
ushort?[] array = { 0, 1, ushort.MaxValue, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableUShortMultiply(array[i], array[j], useInterpreter);
VerifyNullableUShortMultiplyOvf(array[i], array[j], useInterpreter);
}
}
}
[Theory, ClassData(typeof(CompilationTypes))]
public static void CheckNullableShortMultiplyTest(bool useInterpreter)
{
short?[] array = { 0, 1, -1, short.MinValue, short.MaxValue, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableShortMultiply(array[i], array[j], useInterpreter);
VerifyNullableShortMultiplyOvf(array[i], array[j], useInterpreter);
}
}
}
[Theory, ClassData(typeof(CompilationTypes))]
public static void CheckNullableUIntMultiplyTest(bool useInterpreter)
{
uint?[] array = { 0, 1, uint.MaxValue, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableUIntMultiply(array[i], array[j], useInterpreter);
VerifyNullableUIntMultiplyOvf(array[i], array[j], useInterpreter);
}
}
}
[Theory, ClassData(typeof(CompilationTypes))]
public static void CheckNullableIntMultiplyTest(bool useInterpreter)
{
int?[] array = { 0, 1, -1, int.MinValue, int.MaxValue, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableIntMultiply(array[i], array[j], useInterpreter);
VerifyNullableIntMultiplyOvf(array[i], array[j], useInterpreter);
}
}
}
[Theory, ClassData(typeof(CompilationTypes))]
public static void CheckNullableULongMultiplyTest(bool useInterpreter)
{
ulong?[] array = { 0, 1, ulong.MaxValue, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableULongMultiply(array[i], array[j], useInterpreter);
VerifyNullableULongMultiplyOvf(array[i], array[j], useInterpreter);
}
}
}
[Theory, ClassData(typeof(CompilationTypes))]
public static void CheckNullableLongMultiplyTest(bool useInterpreter)
{
long?[] array = { 0, 1, -1, long.MinValue, long.MaxValue, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableLongMultiply(array[i], array[j], useInterpreter);
VerifyNullableLongMultiplyOvf(array[i], array[j], useInterpreter);
}
}
}
[Theory, ClassData(typeof(CompilationTypes))]
public static void CheckNullableFloatMultiplyTest(bool useInterpreter)
{
float?[] array = { 0, 1, -1, float.MinValue, float.MaxValue, float.Epsilon, float.NegativeInfinity, float.PositiveInfinity, float.NaN, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableFloatMultiply(array[i], array[j], useInterpreter);
VerifyNullableFloatMultiplyOvf(array[i], array[j], useInterpreter);
}
}
}
[Theory, ClassData(typeof(CompilationTypes))]
public static void CheckNullableDoubleMultiplyTest(bool useInterpreter)
{
double?[] array = { 0, 1, -1, double.MinValue, double.MaxValue, double.Epsilon, double.NegativeInfinity, double.PositiveInfinity, double.NaN, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableDoubleMultiply(array[i], array[j], useInterpreter);
VerifyNullableDoubleMultiplyOvf(array[i], array[j], useInterpreter);
}
}
}
[Theory, ClassData(typeof(CompilationTypes))]
public static void CheckNullableDecimalMultiplyTest(bool useInterpreter)
{
decimal?[] array = { decimal.Zero, decimal.One, decimal.MinusOne, decimal.MinValue, decimal.MaxValue, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableDecimalMultiply(array[i], array[j], useInterpreter);
VerifyNullableDecimalMultiplyOvf(array[i], array[j], useInterpreter);
}
}
}
[Fact]
public static void CheckNullableCharMultiplyTest()
{
char?[] array = { '\0', '\b', 'A', '\uffff', null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableCharMultiply(array[i], array[j]);
}
}
}
#endregion
#region Test verifiers
private static void VerifyNullableByteMultiply(byte? a, byte? b)
{
Expression aExp = Expression.Constant(a, typeof(byte?));
Expression bExp = Expression.Constant(b, typeof(byte?));
Assert.Throws<InvalidOperationException>(() => Expression.Multiply(aExp, bExp));
Assert.Throws<InvalidOperationException>(() => Expression.MultiplyChecked(aExp, bExp));
}
private static void VerifyNullableSByteMultiply(sbyte? a, sbyte? b)
{
Expression aExp = Expression.Constant(a, typeof(sbyte?));
Expression bExp = Expression.Constant(b, typeof(sbyte?));
Assert.Throws<InvalidOperationException>(() => Expression.Multiply(aExp, bExp));
Assert.Throws<InvalidOperationException>(() => Expression.MultiplyChecked(aExp, bExp));
}
private static void VerifyNullableUShortMultiply(ushort? a, ushort? b, bool useInterpreter)
{
Expression<Func<ushort?>> e =
Expression.Lambda<Func<ushort?>>(
Expression.Multiply(
Expression.Constant(a, typeof(ushort?)),
Expression.Constant(b, typeof(ushort?))),
Enumerable.Empty<ParameterExpression>());
Func<ushort?> f = e.Compile(useInterpreter);
Assert.Equal(unchecked((ushort?)(a * b)), f());
}
private static void VerifyNullableUShortMultiplyOvf(ushort? a, ushort? b, bool useInterpreter)
{
Expression<Func<ushort?>> e =
Expression.Lambda<Func<ushort?>>(
Expression.MultiplyChecked(
Expression.Constant(a, typeof(ushort?)),
Expression.Constant(b, typeof(ushort?))),
Enumerable.Empty<ParameterExpression>());
Func<ushort?> f = e.Compile(useInterpreter);
ushort? expected;
try
{
expected = checked((ushort?)(a * b));
}
catch (OverflowException)
{
Assert.Throws<OverflowException>(() => f());
return;
}
Assert.Equal(expected, f());
}
private static void VerifyNullableShortMultiply(short? a, short? b, bool useInterpreter)
{
Expression<Func<short?>> e =
Expression.Lambda<Func<short?>>(
Expression.Multiply(
Expression.Constant(a, typeof(short?)),
Expression.Constant(b, typeof(short?))),
Enumerable.Empty<ParameterExpression>());
Func<short?> f = e.Compile(useInterpreter);
Assert.Equal(unchecked((short?)(a * b)), f());
}
private static void VerifyNullableShortMultiplyOvf(short? a, short? b, bool useInterpreter)
{
Expression<Func<short?>> e =
Expression.Lambda<Func<short?>>(
Expression.MultiplyChecked(
Expression.Constant(a, typeof(short?)),
Expression.Constant(b, typeof(short?))),
Enumerable.Empty<ParameterExpression>());
Func<short?> f = e.Compile(useInterpreter);
short? expected;
try
{
expected = checked((short?)(a * b));
}
catch (OverflowException)
{
Assert.Throws<OverflowException>(() => f());
return;
}
Assert.Equal(expected, f());
}
private static void VerifyNullableUIntMultiply(uint? a, uint? b, bool useInterpreter)
{
Expression<Func<uint?>> e =
Expression.Lambda<Func<uint?>>(
Expression.Multiply(
Expression.Constant(a, typeof(uint?)),
Expression.Constant(b, typeof(uint?))),
Enumerable.Empty<ParameterExpression>());
Func<uint?> f = e.Compile(useInterpreter);
Assert.Equal(unchecked(a * b), f());
}
private static void VerifyNullableUIntMultiplyOvf(uint? a, uint? b, bool useInterpreter)
{
Expression<Func<uint?>> e =
Expression.Lambda<Func<uint?>>(
Expression.MultiplyChecked(
Expression.Constant(a, typeof(uint?)),
Expression.Constant(b, typeof(uint?))),
Enumerable.Empty<ParameterExpression>());
Func<uint?> f = e.Compile(useInterpreter);
uint? expected;
try
{
expected = checked(a * b);
}
catch (OverflowException)
{
Assert.Throws<OverflowException>(() => f());
return;
}
Assert.Equal(expected, f());
}
private static void VerifyNullableIntMultiply(int? a, int? b, bool useInterpreter)
{
Expression<Func<int?>> e =
Expression.Lambda<Func<int?>>(
Expression.Multiply(
Expression.Constant(a, typeof(int?)),
Expression.Constant(b, typeof(int?))),
Enumerable.Empty<ParameterExpression>());
Func<int?> f = e.Compile(useInterpreter);
Assert.Equal(unchecked(a * b), f());
}
private static void VerifyNullableIntMultiplyOvf(int? a, int? b, bool useInterpreter)
{
Expression<Func<int?>> e =
Expression.Lambda<Func<int?>>(
Expression.MultiplyChecked(
Expression.Constant(a, typeof(int?)),
Expression.Constant(b, typeof(int?))),
Enumerable.Empty<ParameterExpression>());
Func<int?> f = e.Compile(useInterpreter);
int? expected;
try
{
expected = checked(a * b);
}
catch (OverflowException)
{
Assert.Throws<OverflowException>(() => f());
return;
}
Assert.Equal(expected, f());
}
private static void VerifyNullableULongMultiply(ulong? a, ulong? b, bool useInterpreter)
{
Expression<Func<ulong?>> e =
Expression.Lambda<Func<ulong?>>(
Expression.Multiply(
Expression.Constant(a, typeof(ulong?)),
Expression.Constant(b, typeof(ulong?))),
Enumerable.Empty<ParameterExpression>());
Func<ulong?> f = e.Compile(useInterpreter);
Assert.Equal(unchecked(a * b), f());
}
private static void VerifyNullableULongMultiplyOvf(ulong? a, ulong? b, bool useInterpreter)
{
Expression<Func<ulong?>> e =
Expression.Lambda<Func<ulong?>>(
Expression.MultiplyChecked(
Expression.Constant(a, typeof(ulong?)),
Expression.Constant(b, typeof(ulong?))),
Enumerable.Empty<ParameterExpression>());
Func<ulong?> f = e.Compile(useInterpreter);
ulong? expected;
try
{
expected = checked(a * b);
}
catch (OverflowException)
{
Assert.Throws<OverflowException>(() => f());
return;
}
Assert.Equal(expected, f());
}
private static void VerifyNullableLongMultiply(long? a, long? b, bool useInterpreter)
{
Expression<Func<long?>> e =
Expression.Lambda<Func<long?>>(
Expression.Multiply(
Expression.Constant(a, typeof(long?)),
Expression.Constant(b, typeof(long?))),
Enumerable.Empty<ParameterExpression>());
Func<long?> f = e.Compile(useInterpreter);
Assert.Equal(unchecked(a * b), f());
}
private static void VerifyNullableLongMultiplyOvf(long? a, long? b, bool useInterpreter)
{
Expression<Func<long?>> e =
Expression.Lambda<Func<long?>>(
Expression.MultiplyChecked(
Expression.Constant(a, typeof(long?)),
Expression.Constant(b, typeof(long?))),
Enumerable.Empty<ParameterExpression>());
Func<long?> f = e.Compile(useInterpreter);
long? expected;
try
{
expected = checked(a * b);
}
catch (OverflowException)
{
Assert.Throws<OverflowException>(() => f());
return;
}
Assert.Equal(expected, f());
}
private static void VerifyNullableFloatMultiply(float? a, float? b, bool useInterpreter)
{
Expression<Func<float?>> e =
Expression.Lambda<Func<float?>>(
Expression.Multiply(
Expression.Constant(a, typeof(float?)),
Expression.Constant(b, typeof(float?))),
Enumerable.Empty<ParameterExpression>());
Func<float?> f = e.Compile(useInterpreter);
Assert.Equal(a * b, f());
}
private static void VerifyNullableFloatMultiplyOvf(float? a, float? b, bool useInterpreter)
{
Expression<Func<float?>> e =
Expression.Lambda<Func<float?>>(
Expression.MultiplyChecked(
Expression.Constant(a, typeof(float?)),
Expression.Constant(b, typeof(float?))),
Enumerable.Empty<ParameterExpression>());
Func<float?> f = e.Compile(useInterpreter);
Assert.Equal(a * b, f());
}
private static void VerifyNullableDoubleMultiply(double? a, double? b, bool useInterpreter)
{
Expression<Func<double?>> e =
Expression.Lambda<Func<double?>>(
Expression.Multiply(
Expression.Constant(a, typeof(double?)),
Expression.Constant(b, typeof(double?))),
Enumerable.Empty<ParameterExpression>());
Func<double?> f = e.Compile(useInterpreter);
Assert.Equal(a * b, f());
}
private static void VerifyNullableDoubleMultiplyOvf(double? a, double? b, bool useInterpreter)
{
Expression<Func<double?>> e =
Expression.Lambda<Func<double?>>(
Expression.MultiplyChecked(
Expression.Constant(a, typeof(double?)),
Expression.Constant(b, typeof(double?))),
Enumerable.Empty<ParameterExpression>());
Func<double?> f = e.Compile(useInterpreter);
Assert.Equal(a * b, f());
}
private static void VerifyNullableDecimalMultiply(decimal? a, decimal? b, bool useInterpreter)
{
Expression<Func<decimal?>> e =
Expression.Lambda<Func<decimal?>>(
Expression.Multiply(
Expression.Constant(a, typeof(decimal?)),
Expression.Constant(b, typeof(decimal?))),
Enumerable.Empty<ParameterExpression>());
Func<decimal?> f = e.Compile(useInterpreter);
decimal? expected;
try
{
expected = a * b;
}
catch (OverflowException)
{
Assert.Throws<OverflowException>(() => f());
return;
}
Assert.Equal(expected, f());
}
private static void VerifyNullableDecimalMultiplyOvf(decimal? a, decimal? b, bool useInterpreter)
{
Expression<Func<decimal?>> e =
Expression.Lambda<Func<decimal?>>(
Expression.MultiplyChecked(
Expression.Constant(a, typeof(decimal?)),
Expression.Constant(b, typeof(decimal?))),
Enumerable.Empty<ParameterExpression>());
Func<decimal?> f = e.Compile(useInterpreter);
decimal? expected;
try
{
expected = a * b;
}
catch (OverflowException)
{
Assert.Throws<OverflowException>(() => f());
return;
}
Assert.Equal(expected, f());
}
private static void VerifyNullableCharMultiply(char? a, char? b)
{
Expression aExp = Expression.Constant(a, typeof(char?));
Expression bExp = Expression.Constant(b, typeof(char?));
Assert.Throws<InvalidOperationException>(() => Expression.Multiply(aExp, bExp));
Assert.Throws<InvalidOperationException>(() => Expression.MultiplyChecked(aExp, bExp));
}
#endregion
}
}
| // 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.Linq.Expressions.Tests
{
public static class BinaryNullableMultiplyTests
{
#region Test methods
[Fact]
public static void CheckNullableByteMultiplyTest()
{
byte?[] array = { 0, 1, byte.MaxValue, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableByteMultiply(array[i], array[j]);
}
}
}
[Fact]
public static void CheckNullableSByteMultiplyTest()
{
sbyte?[] array = { 0, 1, -1, sbyte.MinValue, sbyte.MaxValue, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableSByteMultiply(array[i], array[j]);
}
}
}
[Theory, ClassData(typeof(CompilationTypes))]
public static void CheckNullableUShortMultiplyTest(bool useInterpreter)
{
ushort?[] array = { 0, 1, ushort.MaxValue, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableUShortMultiply(array[i], array[j], useInterpreter);
VerifyNullableUShortMultiplyOvf(array[i], array[j], useInterpreter);
}
}
}
[Theory, ClassData(typeof(CompilationTypes))]
public static void CheckNullableShortMultiplyTest(bool useInterpreter)
{
short?[] array = { 0, 1, -1, short.MinValue, short.MaxValue, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableShortMultiply(array[i], array[j], useInterpreter);
VerifyNullableShortMultiplyOvf(array[i], array[j], useInterpreter);
}
}
}
[Theory, ClassData(typeof(CompilationTypes))]
public static void CheckNullableUIntMultiplyTest(bool useInterpreter)
{
uint?[] array = { 0, 1, uint.MaxValue, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableUIntMultiply(array[i], array[j], useInterpreter);
VerifyNullableUIntMultiplyOvf(array[i], array[j], useInterpreter);
}
}
}
[Theory, ClassData(typeof(CompilationTypes))]
public static void CheckNullableIntMultiplyTest(bool useInterpreter)
{
int?[] array = { 0, 1, -1, int.MinValue, int.MaxValue, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableIntMultiply(array[i], array[j], useInterpreter);
VerifyNullableIntMultiplyOvf(array[i], array[j], useInterpreter);
}
}
}
[Theory, ClassData(typeof(CompilationTypes))]
public static void CheckNullableULongMultiplyTest(bool useInterpreter)
{
ulong?[] array = { 0, 1, ulong.MaxValue, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableULongMultiply(array[i], array[j], useInterpreter);
VerifyNullableULongMultiplyOvf(array[i], array[j], useInterpreter);
}
}
}
[Theory, ClassData(typeof(CompilationTypes))]
public static void CheckNullableLongMultiplyTest(bool useInterpreter)
{
long?[] array = { 0, 1, -1, long.MinValue, long.MaxValue, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableLongMultiply(array[i], array[j], useInterpreter);
VerifyNullableLongMultiplyOvf(array[i], array[j], useInterpreter);
}
}
}
[Theory, ClassData(typeof(CompilationTypes))]
public static void CheckNullableFloatMultiplyTest(bool useInterpreter)
{
float?[] array = { 0, 1, -1, float.MinValue, float.MaxValue, float.Epsilon, float.NegativeInfinity, float.PositiveInfinity, float.NaN, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableFloatMultiply(array[i], array[j], useInterpreter);
VerifyNullableFloatMultiplyOvf(array[i], array[j], useInterpreter);
}
}
}
[Theory, ClassData(typeof(CompilationTypes))]
public static void CheckNullableDoubleMultiplyTest(bool useInterpreter)
{
double?[] array = { 0, 1, -1, double.MinValue, double.MaxValue, double.Epsilon, double.NegativeInfinity, double.PositiveInfinity, double.NaN, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableDoubleMultiply(array[i], array[j], useInterpreter);
VerifyNullableDoubleMultiplyOvf(array[i], array[j], useInterpreter);
}
}
}
[Theory, ClassData(typeof(CompilationTypes))]
public static void CheckNullableDecimalMultiplyTest(bool useInterpreter)
{
decimal?[] array = { decimal.Zero, decimal.One, decimal.MinusOne, decimal.MinValue, decimal.MaxValue, null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableDecimalMultiply(array[i], array[j], useInterpreter);
VerifyNullableDecimalMultiplyOvf(array[i], array[j], useInterpreter);
}
}
}
[Fact]
public static void CheckNullableCharMultiplyTest()
{
char?[] array = { '\0', '\b', 'A', '\uffff', null };
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length; j++)
{
VerifyNullableCharMultiply(array[i], array[j]);
}
}
}
#endregion
#region Test verifiers
private static void VerifyNullableByteMultiply(byte? a, byte? b)
{
Expression aExp = Expression.Constant(a, typeof(byte?));
Expression bExp = Expression.Constant(b, typeof(byte?));
Assert.Throws<InvalidOperationException>(() => Expression.Multiply(aExp, bExp));
Assert.Throws<InvalidOperationException>(() => Expression.MultiplyChecked(aExp, bExp));
}
private static void VerifyNullableSByteMultiply(sbyte? a, sbyte? b)
{
Expression aExp = Expression.Constant(a, typeof(sbyte?));
Expression bExp = Expression.Constant(b, typeof(sbyte?));
Assert.Throws<InvalidOperationException>(() => Expression.Multiply(aExp, bExp));
Assert.Throws<InvalidOperationException>(() => Expression.MultiplyChecked(aExp, bExp));
}
private static void VerifyNullableUShortMultiply(ushort? a, ushort? b, bool useInterpreter)
{
Expression<Func<ushort?>> e =
Expression.Lambda<Func<ushort?>>(
Expression.Multiply(
Expression.Constant(a, typeof(ushort?)),
Expression.Constant(b, typeof(ushort?))),
Enumerable.Empty<ParameterExpression>());
Func<ushort?> f = e.Compile(useInterpreter);
Assert.Equal(unchecked((ushort?)(a * b)), f());
}
private static void VerifyNullableUShortMultiplyOvf(ushort? a, ushort? b, bool useInterpreter)
{
Expression<Func<ushort?>> e =
Expression.Lambda<Func<ushort?>>(
Expression.MultiplyChecked(
Expression.Constant(a, typeof(ushort?)),
Expression.Constant(b, typeof(ushort?))),
Enumerable.Empty<ParameterExpression>());
Func<ushort?> f = e.Compile(useInterpreter);
ushort? expected;
try
{
expected = checked((ushort?)(a * b));
}
catch (OverflowException)
{
Assert.Throws<OverflowException>(() => f());
return;
}
Assert.Equal(expected, f());
}
private static void VerifyNullableShortMultiply(short? a, short? b, bool useInterpreter)
{
Expression<Func<short?>> e =
Expression.Lambda<Func<short?>>(
Expression.Multiply(
Expression.Constant(a, typeof(short?)),
Expression.Constant(b, typeof(short?))),
Enumerable.Empty<ParameterExpression>());
Func<short?> f = e.Compile(useInterpreter);
Assert.Equal(unchecked((short?)(a * b)), f());
}
private static void VerifyNullableShortMultiplyOvf(short? a, short? b, bool useInterpreter)
{
Expression<Func<short?>> e =
Expression.Lambda<Func<short?>>(
Expression.MultiplyChecked(
Expression.Constant(a, typeof(short?)),
Expression.Constant(b, typeof(short?))),
Enumerable.Empty<ParameterExpression>());
Func<short?> f = e.Compile(useInterpreter);
short? expected;
try
{
expected = checked((short?)(a * b));
}
catch (OverflowException)
{
Assert.Throws<OverflowException>(() => f());
return;
}
Assert.Equal(expected, f());
}
private static void VerifyNullableUIntMultiply(uint? a, uint? b, bool useInterpreter)
{
Expression<Func<uint?>> e =
Expression.Lambda<Func<uint?>>(
Expression.Multiply(
Expression.Constant(a, typeof(uint?)),
Expression.Constant(b, typeof(uint?))),
Enumerable.Empty<ParameterExpression>());
Func<uint?> f = e.Compile(useInterpreter);
Assert.Equal(unchecked(a * b), f());
}
private static void VerifyNullableUIntMultiplyOvf(uint? a, uint? b, bool useInterpreter)
{
Expression<Func<uint?>> e =
Expression.Lambda<Func<uint?>>(
Expression.MultiplyChecked(
Expression.Constant(a, typeof(uint?)),
Expression.Constant(b, typeof(uint?))),
Enumerable.Empty<ParameterExpression>());
Func<uint?> f = e.Compile(useInterpreter);
uint? expected;
try
{
expected = checked(a * b);
}
catch (OverflowException)
{
Assert.Throws<OverflowException>(() => f());
return;
}
Assert.Equal(expected, f());
}
private static void VerifyNullableIntMultiply(int? a, int? b, bool useInterpreter)
{
Expression<Func<int?>> e =
Expression.Lambda<Func<int?>>(
Expression.Multiply(
Expression.Constant(a, typeof(int?)),
Expression.Constant(b, typeof(int?))),
Enumerable.Empty<ParameterExpression>());
Func<int?> f = e.Compile(useInterpreter);
Assert.Equal(unchecked(a * b), f());
}
private static void VerifyNullableIntMultiplyOvf(int? a, int? b, bool useInterpreter)
{
Expression<Func<int?>> e =
Expression.Lambda<Func<int?>>(
Expression.MultiplyChecked(
Expression.Constant(a, typeof(int?)),
Expression.Constant(b, typeof(int?))),
Enumerable.Empty<ParameterExpression>());
Func<int?> f = e.Compile(useInterpreter);
int? expected;
try
{
expected = checked(a * b);
}
catch (OverflowException)
{
Assert.Throws<OverflowException>(() => f());
return;
}
Assert.Equal(expected, f());
}
private static void VerifyNullableULongMultiply(ulong? a, ulong? b, bool useInterpreter)
{
Expression<Func<ulong?>> e =
Expression.Lambda<Func<ulong?>>(
Expression.Multiply(
Expression.Constant(a, typeof(ulong?)),
Expression.Constant(b, typeof(ulong?))),
Enumerable.Empty<ParameterExpression>());
Func<ulong?> f = e.Compile(useInterpreter);
Assert.Equal(unchecked(a * b), f());
}
private static void VerifyNullableULongMultiplyOvf(ulong? a, ulong? b, bool useInterpreter)
{
Expression<Func<ulong?>> e =
Expression.Lambda<Func<ulong?>>(
Expression.MultiplyChecked(
Expression.Constant(a, typeof(ulong?)),
Expression.Constant(b, typeof(ulong?))),
Enumerable.Empty<ParameterExpression>());
Func<ulong?> f = e.Compile(useInterpreter);
ulong? expected;
try
{
expected = checked(a * b);
}
catch (OverflowException)
{
Assert.Throws<OverflowException>(() => f());
return;
}
Assert.Equal(expected, f());
}
private static void VerifyNullableLongMultiply(long? a, long? b, bool useInterpreter)
{
Expression<Func<long?>> e =
Expression.Lambda<Func<long?>>(
Expression.Multiply(
Expression.Constant(a, typeof(long?)),
Expression.Constant(b, typeof(long?))),
Enumerable.Empty<ParameterExpression>());
Func<long?> f = e.Compile(useInterpreter);
Assert.Equal(unchecked(a * b), f());
}
private static void VerifyNullableLongMultiplyOvf(long? a, long? b, bool useInterpreter)
{
Expression<Func<long?>> e =
Expression.Lambda<Func<long?>>(
Expression.MultiplyChecked(
Expression.Constant(a, typeof(long?)),
Expression.Constant(b, typeof(long?))),
Enumerable.Empty<ParameterExpression>());
Func<long?> f = e.Compile(useInterpreter);
long? expected;
try
{
expected = checked(a * b);
}
catch (OverflowException)
{
Assert.Throws<OverflowException>(() => f());
return;
}
Assert.Equal(expected, f());
}
private static void VerifyNullableFloatMultiply(float? a, float? b, bool useInterpreter)
{
Expression<Func<float?>> e =
Expression.Lambda<Func<float?>>(
Expression.Multiply(
Expression.Constant(a, typeof(float?)),
Expression.Constant(b, typeof(float?))),
Enumerable.Empty<ParameterExpression>());
Func<float?> f = e.Compile(useInterpreter);
Assert.Equal(a * b, f());
}
private static void VerifyNullableFloatMultiplyOvf(float? a, float? b, bool useInterpreter)
{
Expression<Func<float?>> e =
Expression.Lambda<Func<float?>>(
Expression.MultiplyChecked(
Expression.Constant(a, typeof(float?)),
Expression.Constant(b, typeof(float?))),
Enumerable.Empty<ParameterExpression>());
Func<float?> f = e.Compile(useInterpreter);
Assert.Equal(a * b, f());
}
private static void VerifyNullableDoubleMultiply(double? a, double? b, bool useInterpreter)
{
Expression<Func<double?>> e =
Expression.Lambda<Func<double?>>(
Expression.Multiply(
Expression.Constant(a, typeof(double?)),
Expression.Constant(b, typeof(double?))),
Enumerable.Empty<ParameterExpression>());
Func<double?> f = e.Compile(useInterpreter);
Assert.Equal(a * b, f());
}
private static void VerifyNullableDoubleMultiplyOvf(double? a, double? b, bool useInterpreter)
{
Expression<Func<double?>> e =
Expression.Lambda<Func<double?>>(
Expression.MultiplyChecked(
Expression.Constant(a, typeof(double?)),
Expression.Constant(b, typeof(double?))),
Enumerable.Empty<ParameterExpression>());
Func<double?> f = e.Compile(useInterpreter);
Assert.Equal(a * b, f());
}
private static void VerifyNullableDecimalMultiply(decimal? a, decimal? b, bool useInterpreter)
{
Expression<Func<decimal?>> e =
Expression.Lambda<Func<decimal?>>(
Expression.Multiply(
Expression.Constant(a, typeof(decimal?)),
Expression.Constant(b, typeof(decimal?))),
Enumerable.Empty<ParameterExpression>());
Func<decimal?> f = e.Compile(useInterpreter);
decimal? expected;
try
{
expected = a * b;
}
catch (OverflowException)
{
Assert.Throws<OverflowException>(() => f());
return;
}
Assert.Equal(expected, f());
}
private static void VerifyNullableDecimalMultiplyOvf(decimal? a, decimal? b, bool useInterpreter)
{
Expression<Func<decimal?>> e =
Expression.Lambda<Func<decimal?>>(
Expression.MultiplyChecked(
Expression.Constant(a, typeof(decimal?)),
Expression.Constant(b, typeof(decimal?))),
Enumerable.Empty<ParameterExpression>());
Func<decimal?> f = e.Compile(useInterpreter);
decimal? expected;
try
{
expected = a * b;
}
catch (OverflowException)
{
Assert.Throws<OverflowException>(() => f());
return;
}
Assert.Equal(expected, f());
}
private static void VerifyNullableCharMultiply(char? a, char? b)
{
Expression aExp = Expression.Constant(a, typeof(char?));
Expression bExp = Expression.Constant(b, typeof(char?));
Assert.Throws<InvalidOperationException>(() => Expression.Multiply(aExp, bExp));
Assert.Throws<InvalidOperationException>(() => Expression.MultiplyChecked(aExp, bExp));
}
#endregion
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Private.CoreLib/src/System/Reflection/ParameterAttributes.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// ParameterAttributes is an enum defining the attributes that may be
// associated with a Parameter. These are defined in CorHdr.h.
namespace System.Reflection
{
// This Enum matchs the CorParamAttr defined in CorHdr.h
[Flags]
public enum ParameterAttributes
{
None = 0x0000, // no flag is specified
In = 0x0001, // Param is [In]
Out = 0x0002, // Param is [Out]
Lcid = 0x0004, // Param is [lcid]
Retval = 0x0008, // Param is [Retval]
Optional = 0x0010, // Param is optional
HasDefault = 0x1000, // Param has default value.
HasFieldMarshal = 0x2000, // Param has FieldMarshal.
Reserved3 = 0x4000,
Reserved4 = 0x8000,
ReservedMask = 0xf000,
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// ParameterAttributes is an enum defining the attributes that may be
// associated with a Parameter. These are defined in CorHdr.h.
namespace System.Reflection
{
// This Enum matchs the CorParamAttr defined in CorHdr.h
[Flags]
public enum ParameterAttributes
{
None = 0x0000, // no flag is specified
In = 0x0001, // Param is [In]
Out = 0x0002, // Param is [Out]
Lcid = 0x0004, // Param is [lcid]
Retval = 0x0008, // Param is [Retval]
Optional = 0x0010, // Param is optional
HasDefault = 0x1000, // Param has default value.
HasFieldMarshal = 0x2000, // Param has FieldMarshal.
Reserved3 = 0x4000,
Reserved4 = 0x8000,
ReservedMask = 0xf000,
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Symbolic/Unicode/IgnoreCaseRelationGenerator.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.Globalization;
using System.IO;
namespace System.Text.RegularExpressions.Symbolic.Unicode
{
#if DEBUG
[ExcludeFromCodeCoverage]
internal static class IgnoreCaseRelationGenerator
{
private const string DefaultCultureName = "en-US";
public static void Generate(string namespacename, string classname, string path)
{
Debug.Assert(namespacename != null);
Debug.Assert(classname != null);
Debug.Assert(path != null);
using StreamWriter sw = new StreamWriter($"{Path.Combine(path, classname)}.cs");
sw.WriteLine(
$@"// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// This is a programmatically generated file from Regex.GenerateUnicodeTables.
// It provides serialized BDD Unicode category definitions for System.Environment.Version = {Environment.Version}
namespace {namespacename}
{{
internal static class {classname}
{{");
WriteIgnoreCaseBDD(sw);
sw.WriteLine($@" }}
}}");
}
private static void WriteIgnoreCaseBDD(StreamWriter sw)
{
sw.WriteLine(" /// <summary>Serialized BDD for mapping characters to their case-ignoring equivalence classes in the default (en-US) culture.</summary>");
CharSetSolver solver = CharSetSolver.Instance;
List<EquivalenceClass> ignoreCaseEquivalenceClasses = ComputeIgnoreCaseEquivalenceClasses(solver, new CultureInfo(DefaultCultureName));
BDD ignorecase = solver.False;
foreach (EquivalenceClass ec in ignoreCaseEquivalenceClasses)
{
// Create the Cartesian product of ec._set with itself
BDD crossproduct = solver.And(solver.ShiftLeft(ec._set, 16), ec._set);
// Add the product into the overall lookup table
ignorecase = solver.Or(ignorecase, crossproduct);
}
sw.Write(" public static readonly byte[] IgnoreCaseEnUsSerializedBDD = ");
GeneratorHelper.WriteByteArrayInitSyntax(sw, ignorecase.SerializeToBytes());
sw.WriteLine(";");
}
private static List<EquivalenceClass> ComputeIgnoreCaseEquivalenceClasses(CharSetSolver solver, CultureInfo culture)
{
var ignoreCase = new Dictionary<char, EquivalenceClass>();
var sets = new List<EquivalenceClass>();
for (uint i = 65; i <= 0xFFFF; i++)
{
char C = (char)i;
char c = char.ToLower(C, culture);
if (c == C)
{
continue;
}
EquivalenceClass? ec;
if (!ignoreCase.TryGetValue(c, out ec))
{
ec = new EquivalenceClass(solver.CharConstraint(c));
ignoreCase[c] = ec;
sets.Add(ec);
}
ec._set = solver.Or(ec._set, solver.CharConstraint(C));
}
return sets;
}
private sealed class EquivalenceClass
{
public BDD _set;
public EquivalenceClass(BDD set)
{
_set = set;
}
}
};
#endif
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
namespace System.Text.RegularExpressions.Symbolic.Unicode
{
#if DEBUG
[ExcludeFromCodeCoverage]
internal static class IgnoreCaseRelationGenerator
{
private const string DefaultCultureName = "en-US";
public static void Generate(string namespacename, string classname, string path)
{
Debug.Assert(namespacename != null);
Debug.Assert(classname != null);
Debug.Assert(path != null);
using StreamWriter sw = new StreamWriter($"{Path.Combine(path, classname)}.cs");
sw.WriteLine(
$@"// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// This is a programmatically generated file from Regex.GenerateUnicodeTables.
// It provides serialized BDD Unicode category definitions for System.Environment.Version = {Environment.Version}
namespace {namespacename}
{{
internal static class {classname}
{{");
WriteIgnoreCaseBDD(sw);
sw.WriteLine($@" }}
}}");
}
private static void WriteIgnoreCaseBDD(StreamWriter sw)
{
sw.WriteLine(" /// <summary>Serialized BDD for mapping characters to their case-ignoring equivalence classes in the default (en-US) culture.</summary>");
CharSetSolver solver = CharSetSolver.Instance;
List<EquivalenceClass> ignoreCaseEquivalenceClasses = ComputeIgnoreCaseEquivalenceClasses(solver, new CultureInfo(DefaultCultureName));
BDD ignorecase = solver.False;
foreach (EquivalenceClass ec in ignoreCaseEquivalenceClasses)
{
// Create the Cartesian product of ec._set with itself
BDD crossproduct = solver.And(solver.ShiftLeft(ec._set, 16), ec._set);
// Add the product into the overall lookup table
ignorecase = solver.Or(ignorecase, crossproduct);
}
sw.Write(" public static readonly byte[] IgnoreCaseEnUsSerializedBDD = ");
GeneratorHelper.WriteByteArrayInitSyntax(sw, ignorecase.SerializeToBytes());
sw.WriteLine(";");
}
private static List<EquivalenceClass> ComputeIgnoreCaseEquivalenceClasses(CharSetSolver solver, CultureInfo culture)
{
var ignoreCase = new Dictionary<char, EquivalenceClass>();
var sets = new List<EquivalenceClass>();
for (uint i = 65; i <= 0xFFFF; i++)
{
char C = (char)i;
char c = char.ToLower(C, culture);
if (c == C)
{
continue;
}
EquivalenceClass? ec;
if (!ignoreCase.TryGetValue(c, out ec))
{
ec = new EquivalenceClass(solver.CharConstraint(c));
ignoreCase[c] = ec;
sets.Add(ec);
}
ec._set = solver.Or(ec._set, solver.CharConstraint(C));
}
return sets;
}
private sealed class EquivalenceClass
{
public BDD _set;
public EquivalenceClass(BDD set)
{
_set = set;
}
}
};
#endif
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/jit64/valuetypes/nullable/castclass/castclass/castclass025.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;
internal class NullableTest
{
private static bool BoxUnboxToNQ(object o)
{
return Helper.Compare((NotEmptyStructQA)(ValueType)o, Helper.Create(default(NotEmptyStructQA)));
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((NotEmptyStructQA?)(ValueType)o, Helper.Create(default(NotEmptyStructQA)));
}
private static int Main()
{
NotEmptyStructQA? s = Helper.Create(default(NotEmptyStructQA));
if (BoxUnboxToNQ(s) && BoxUnboxToQ(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.
using System.Runtime.InteropServices;
using System;
internal class NullableTest
{
private static bool BoxUnboxToNQ(object o)
{
return Helper.Compare((NotEmptyStructQA)(ValueType)o, Helper.Create(default(NotEmptyStructQA)));
}
private static bool BoxUnboxToQ(object o)
{
return Helper.Compare((NotEmptyStructQA?)(ValueType)o, Helper.Create(default(NotEmptyStructQA)));
}
private static int Main()
{
NotEmptyStructQA? s = Helper.Create(default(NotEmptyStructQA));
if (BoxUnboxToNQ(s) && BoxUnboxToQ(s))
return ExitCode.Passed;
else
return ExitCode.Failed;
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/MultiplyWideningLowerAndSubtract.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 MultiplyWideningLowerAndSubtract_Vector64_Int32()
{
var test = new SimpleTernaryOpTest__MultiplyWideningLowerAndSubtract_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 SimpleTernaryOpTest__MultiplyWideningLowerAndSubtract_Vector64_Int32
{
private struct DataTable
{
private byte[] inArray1;
private byte[] inArray2;
private byte[] inArray3;
private byte[] outArray;
private GCHandle inHandle1;
private GCHandle inHandle2;
private GCHandle inHandle3;
private GCHandle outHandle;
private ulong alignment;
public DataTable(Int64[] inArray1, Int32[] inArray2, Int32[] inArray3, Int64[] outArray, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int64>();
int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Int32>();
int sizeOfinArray3 = inArray3.Length * Unsafe.SizeOf<Int32>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int64>();
if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfinArray3 || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray1 = new byte[alignment * 2];
this.inArray2 = new byte[alignment * 2];
this.inArray3 = 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.inHandle3 = GCHandle.Alloc(this.inArray3, 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);
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray3Ptr), ref Unsafe.As<Int32, byte>(ref inArray3[0]), (uint)sizeOfinArray3);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment);
public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment);
public void* inArray3Ptr => Align((byte*)(inHandle3.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle1.Free();
inHandle2.Free();
inHandle3.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 Vector64<Int32> _fld3;
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>>());
for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref testStruct._fld3), ref Unsafe.As<Int32, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>());
return testStruct;
}
public void RunStructFldScenario(SimpleTernaryOpTest__MultiplyWideningLowerAndSubtract_Vector64_Int32 testClass)
{
var result = AdvSimd.MultiplyWideningLowerAndSubtract(_fld1, _fld2, _fld3);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(SimpleTernaryOpTest__MultiplyWideningLowerAndSubtract_Vector64_Int32 testClass)
{
fixed (Vector128<Int64>* pFld1 = &_fld1)
fixed (Vector64<Int32>* pFld2 = &_fld2)
fixed (Vector64<Int32>* pFld3 = &_fld3)
{
var result = AdvSimd.MultiplyWideningLowerAndSubtract(
AdvSimd.LoadVector128((Int64*)(pFld1)),
AdvSimd.LoadVector64((Int32*)(pFld2)),
AdvSimd.LoadVector64((Int32*)(pFld3))
);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, _fld2, _fld3, 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 Op3ElementCount = 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 Int32[] _data3 = new Int32[Op3ElementCount];
private static Vector128<Int64> _clsVar1;
private static Vector64<Int32> _clsVar2;
private static Vector64<Int32> _clsVar3;
private Vector128<Int64> _fld1;
private Vector64<Int32> _fld2;
private Vector64<Int32> _fld3;
private DataTable _dataTable;
static SimpleTernaryOpTest__MultiplyWideningLowerAndSubtract_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.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>());
for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref _clsVar3), ref Unsafe.As<Int32, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>());
}
public SimpleTernaryOpTest__MultiplyWideningLowerAndSubtract_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.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 < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref _fld3), ref Unsafe.As<Int32, byte>(ref _data3[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(); }
for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetInt32(); }
_dataTable = new DataTable(_data1, _data2, _data3, 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.MultiplyWideningLowerAndSubtract(
Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector64<Int32>>(_dataTable.inArray2Ptr),
Unsafe.Read<Vector64<Int32>>(_dataTable.inArray3Ptr)
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr);
}
public void RunBasicScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));
var result = AdvSimd.MultiplyWideningLowerAndSubtract(
AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)),
AdvSimd.LoadVector64((Int32*)(_dataTable.inArray2Ptr)),
AdvSimd.LoadVector64((Int32*)(_dataTable.inArray3Ptr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.MultiplyWideningLowerAndSubtract), new Type[] { typeof(Vector128<Int64>), typeof(Vector64<Int32>), typeof(Vector64<Int32>) })
.Invoke(null, new object[] {
Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector64<Int32>>(_dataTable.inArray2Ptr),
Unsafe.Read<Vector64<Int32>>(_dataTable.inArray3Ptr)
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.MultiplyWideningLowerAndSubtract), new Type[] { typeof(Vector128<Int64>), typeof(Vector64<Int32>), typeof(Vector64<Int32>) })
.Invoke(null, new object[] {
AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)),
AdvSimd.LoadVector64((Int32*)(_dataTable.inArray2Ptr)),
AdvSimd.LoadVector64((Int32*)(_dataTable.inArray3Ptr))
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = AdvSimd.MultiplyWideningLowerAndSubtract(
_clsVar1,
_clsVar2,
_clsVar3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _clsVar2, _clsVar3, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector128<Int64>* pClsVar1 = &_clsVar1)
fixed (Vector64<Int32>* pClsVar2 = &_clsVar2)
fixed (Vector64<Int32>* pClsVar3 = &_clsVar3)
{
var result = AdvSimd.MultiplyWideningLowerAndSubtract(
AdvSimd.LoadVector128((Int64*)(pClsVar1)),
AdvSimd.LoadVector64((Int32*)(pClsVar2)),
AdvSimd.LoadVector64((Int32*)(pClsVar3))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _clsVar2, _clsVar3, _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 op3 = Unsafe.Read<Vector64<Int32>>(_dataTable.inArray3Ptr);
var result = AdvSimd.MultiplyWideningLowerAndSubtract(op1, op2, op3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op2, op3, _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 op3 = AdvSimd.LoadVector64((Int32*)(_dataTable.inArray3Ptr));
var result = AdvSimd.MultiplyWideningLowerAndSubtract(op1, op2, op3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op2, op3, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new SimpleTernaryOpTest__MultiplyWideningLowerAndSubtract_Vector64_Int32();
var result = AdvSimd.MultiplyWideningLowerAndSubtract(test._fld1, test._fld2, test._fld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));
var test = new SimpleTernaryOpTest__MultiplyWideningLowerAndSubtract_Vector64_Int32();
fixed (Vector128<Int64>* pFld1 = &test._fld1)
fixed (Vector64<Int32>* pFld2 = &test._fld2)
fixed (Vector64<Int32>* pFld3 = &test._fld3)
{
var result = AdvSimd.MultiplyWideningLowerAndSubtract(
AdvSimd.LoadVector128((Int64*)(pFld1)),
AdvSimd.LoadVector64((Int32*)(pFld2)),
AdvSimd.LoadVector64((Int32*)(pFld3))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = AdvSimd.MultiplyWideningLowerAndSubtract(_fld1, _fld2, _fld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector128<Int64>* pFld1 = &_fld1)
fixed (Vector64<Int32>* pFld2 = &_fld2)
fixed (Vector64<Int32>* pFld3 = &_fld3)
{
var result = AdvSimd.MultiplyWideningLowerAndSubtract(
AdvSimd.LoadVector128((Int64*)(pFld1)),
AdvSimd.LoadVector64((Int32*)(pFld2)),
AdvSimd.LoadVector64((Int32*)(pFld3))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr);
}
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = AdvSimd.MultiplyWideningLowerAndSubtract(test._fld1, test._fld2, test._fld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));
var test = TestStruct.Create();
var result = AdvSimd.MultiplyWideningLowerAndSubtract(
AdvSimd.LoadVector128((Int64*)(&test._fld1)),
AdvSimd.LoadVector64((Int32*)(&test._fld2)),
AdvSimd.LoadVector64((Int32*)(&test._fld3))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld2, test._fld3, _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, Vector64<Int32> op3, void* result, [CallerMemberName] string method = "")
{
Int64[] inArray1 = new Int64[Op1ElementCount];
Int32[] inArray2 = new Int32[Op2ElementCount];
Int32[] inArray3 = new Int32[Op3ElementCount];
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.WriteUnaligned(ref Unsafe.As<Int32, byte>(ref inArray3[0]), op3);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>());
ValidateResult(inArray1, inArray2, inArray3, outArray, method);
}
private void ValidateResult(void* op1, void* op2, void* op3, void* result, [CallerMemberName] string method = "")
{
Int64[] inArray1 = new Int64[Op1ElementCount];
Int32[] inArray2 = new Int32[Op2ElementCount];
Int32[] inArray3 = new Int32[Op3ElementCount];
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<Int32, byte>(ref inArray3[0]), ref Unsafe.AsRef<byte>(op3), (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, inArray3, outArray, method);
}
private void ValidateResult(Int64[] firstOp, Int32[] secondOp, Int32[] thirdOp, Int64[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (var i = 0; i < RetElementCount; i++)
{
if (Helpers.MultiplyWideningAndSubtract(firstOp[i], secondOp[i], thirdOp[i]) != result[i])
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.MultiplyWideningLowerAndSubtract)}<Int64>(Vector128<Int64>, Vector64<Int32>, Vector64<Int32>): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($"secondOp: ({string.Join(", ", secondOp)})");
TestLibrary.TestFramework.LogInformation($" thirdOp: ({string.Join(", ", thirdOp)})");
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 MultiplyWideningLowerAndSubtract_Vector64_Int32()
{
var test = new SimpleTernaryOpTest__MultiplyWideningLowerAndSubtract_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 SimpleTernaryOpTest__MultiplyWideningLowerAndSubtract_Vector64_Int32
{
private struct DataTable
{
private byte[] inArray1;
private byte[] inArray2;
private byte[] inArray3;
private byte[] outArray;
private GCHandle inHandle1;
private GCHandle inHandle2;
private GCHandle inHandle3;
private GCHandle outHandle;
private ulong alignment;
public DataTable(Int64[] inArray1, Int32[] inArray2, Int32[] inArray3, Int64[] outArray, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int64>();
int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Int32>();
int sizeOfinArray3 = inArray3.Length * Unsafe.SizeOf<Int32>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int64>();
if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfinArray3 || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray1 = new byte[alignment * 2];
this.inArray2 = new byte[alignment * 2];
this.inArray3 = 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.inHandle3 = GCHandle.Alloc(this.inArray3, 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);
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray3Ptr), ref Unsafe.As<Int32, byte>(ref inArray3[0]), (uint)sizeOfinArray3);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment);
public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment);
public void* inArray3Ptr => Align((byte*)(inHandle3.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle1.Free();
inHandle2.Free();
inHandle3.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 Vector64<Int32> _fld3;
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>>());
for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref testStruct._fld3), ref Unsafe.As<Int32, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>());
return testStruct;
}
public void RunStructFldScenario(SimpleTernaryOpTest__MultiplyWideningLowerAndSubtract_Vector64_Int32 testClass)
{
var result = AdvSimd.MultiplyWideningLowerAndSubtract(_fld1, _fld2, _fld3);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(SimpleTernaryOpTest__MultiplyWideningLowerAndSubtract_Vector64_Int32 testClass)
{
fixed (Vector128<Int64>* pFld1 = &_fld1)
fixed (Vector64<Int32>* pFld2 = &_fld2)
fixed (Vector64<Int32>* pFld3 = &_fld3)
{
var result = AdvSimd.MultiplyWideningLowerAndSubtract(
AdvSimd.LoadVector128((Int64*)(pFld1)),
AdvSimd.LoadVector64((Int32*)(pFld2)),
AdvSimd.LoadVector64((Int32*)(pFld3))
);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, _fld2, _fld3, 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 Op3ElementCount = 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 Int32[] _data3 = new Int32[Op3ElementCount];
private static Vector128<Int64> _clsVar1;
private static Vector64<Int32> _clsVar2;
private static Vector64<Int32> _clsVar3;
private Vector128<Int64> _fld1;
private Vector64<Int32> _fld2;
private Vector64<Int32> _fld3;
private DataTable _dataTable;
static SimpleTernaryOpTest__MultiplyWideningLowerAndSubtract_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.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>());
for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref _clsVar3), ref Unsafe.As<Int32, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>());
}
public SimpleTernaryOpTest__MultiplyWideningLowerAndSubtract_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.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 < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref _fld3), ref Unsafe.As<Int32, byte>(ref _data3[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(); }
for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetInt32(); }
_dataTable = new DataTable(_data1, _data2, _data3, 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.MultiplyWideningLowerAndSubtract(
Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector64<Int32>>(_dataTable.inArray2Ptr),
Unsafe.Read<Vector64<Int32>>(_dataTable.inArray3Ptr)
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr);
}
public void RunBasicScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));
var result = AdvSimd.MultiplyWideningLowerAndSubtract(
AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)),
AdvSimd.LoadVector64((Int32*)(_dataTable.inArray2Ptr)),
AdvSimd.LoadVector64((Int32*)(_dataTable.inArray3Ptr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.MultiplyWideningLowerAndSubtract), new Type[] { typeof(Vector128<Int64>), typeof(Vector64<Int32>), typeof(Vector64<Int32>) })
.Invoke(null, new object[] {
Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector64<Int32>>(_dataTable.inArray2Ptr),
Unsafe.Read<Vector64<Int32>>(_dataTable.inArray3Ptr)
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));
var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.MultiplyWideningLowerAndSubtract), new Type[] { typeof(Vector128<Int64>), typeof(Vector64<Int32>), typeof(Vector64<Int32>) })
.Invoke(null, new object[] {
AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)),
AdvSimd.LoadVector64((Int32*)(_dataTable.inArray2Ptr)),
AdvSimd.LoadVector64((Int32*)(_dataTable.inArray3Ptr))
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = AdvSimd.MultiplyWideningLowerAndSubtract(
_clsVar1,
_clsVar2,
_clsVar3
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _clsVar2, _clsVar3, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector128<Int64>* pClsVar1 = &_clsVar1)
fixed (Vector64<Int32>* pClsVar2 = &_clsVar2)
fixed (Vector64<Int32>* pClsVar3 = &_clsVar3)
{
var result = AdvSimd.MultiplyWideningLowerAndSubtract(
AdvSimd.LoadVector128((Int64*)(pClsVar1)),
AdvSimd.LoadVector64((Int32*)(pClsVar2)),
AdvSimd.LoadVector64((Int32*)(pClsVar3))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _clsVar2, _clsVar3, _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 op3 = Unsafe.Read<Vector64<Int32>>(_dataTable.inArray3Ptr);
var result = AdvSimd.MultiplyWideningLowerAndSubtract(op1, op2, op3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op2, op3, _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 op3 = AdvSimd.LoadVector64((Int32*)(_dataTable.inArray3Ptr));
var result = AdvSimd.MultiplyWideningLowerAndSubtract(op1, op2, op3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op2, op3, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new SimpleTernaryOpTest__MultiplyWideningLowerAndSubtract_Vector64_Int32();
var result = AdvSimd.MultiplyWideningLowerAndSubtract(test._fld1, test._fld2, test._fld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));
var test = new SimpleTernaryOpTest__MultiplyWideningLowerAndSubtract_Vector64_Int32();
fixed (Vector128<Int64>* pFld1 = &test._fld1)
fixed (Vector64<Int32>* pFld2 = &test._fld2)
fixed (Vector64<Int32>* pFld3 = &test._fld3)
{
var result = AdvSimd.MultiplyWideningLowerAndSubtract(
AdvSimd.LoadVector128((Int64*)(pFld1)),
AdvSimd.LoadVector64((Int32*)(pFld2)),
AdvSimd.LoadVector64((Int32*)(pFld3))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = AdvSimd.MultiplyWideningLowerAndSubtract(_fld1, _fld2, _fld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector128<Int64>* pFld1 = &_fld1)
fixed (Vector64<Int32>* pFld2 = &_fld2)
fixed (Vector64<Int32>* pFld3 = &_fld3)
{
var result = AdvSimd.MultiplyWideningLowerAndSubtract(
AdvSimd.LoadVector128((Int64*)(pFld1)),
AdvSimd.LoadVector64((Int32*)(pFld2)),
AdvSimd.LoadVector64((Int32*)(pFld3))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr);
}
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = AdvSimd.MultiplyWideningLowerAndSubtract(test._fld1, test._fld2, test._fld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));
var test = TestStruct.Create();
var result = AdvSimd.MultiplyWideningLowerAndSubtract(
AdvSimd.LoadVector128((Int64*)(&test._fld1)),
AdvSimd.LoadVector64((Int32*)(&test._fld2)),
AdvSimd.LoadVector64((Int32*)(&test._fld3))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld2, test._fld3, _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, Vector64<Int32> op3, void* result, [CallerMemberName] string method = "")
{
Int64[] inArray1 = new Int64[Op1ElementCount];
Int32[] inArray2 = new Int32[Op2ElementCount];
Int32[] inArray3 = new Int32[Op3ElementCount];
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.WriteUnaligned(ref Unsafe.As<Int32, byte>(ref inArray3[0]), op3);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>());
ValidateResult(inArray1, inArray2, inArray3, outArray, method);
}
private void ValidateResult(void* op1, void* op2, void* op3, void* result, [CallerMemberName] string method = "")
{
Int64[] inArray1 = new Int64[Op1ElementCount];
Int32[] inArray2 = new Int32[Op2ElementCount];
Int32[] inArray3 = new Int32[Op3ElementCount];
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<Int32, byte>(ref inArray3[0]), ref Unsafe.AsRef<byte>(op3), (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, inArray3, outArray, method);
}
private void ValidateResult(Int64[] firstOp, Int32[] secondOp, Int32[] thirdOp, Int64[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (var i = 0; i < RetElementCount; i++)
{
if (Helpers.MultiplyWideningAndSubtract(firstOp[i], secondOp[i], thirdOp[i]) != result[i])
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.MultiplyWideningLowerAndSubtract)}<Int64>(Vector128<Int64>, Vector64<Int32>, Vector64<Int32>): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($"secondOp: ({string.Join(", ", secondOp)})");
TestLibrary.TestFramework.LogInformation($" thirdOp: ({string.Join(", ", thirdOp)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Private.CoreLib/src/System/Threading/SendOrPostCallback.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.Threading
{
public delegate void SendOrPostCallback(object? state);
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Threading
{
public delegate void SendOrPostCallback(object? state);
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/mono/mono/tests/assembly-load-reference/mainanddep/LoadFromMain.cs | using System;
using System.IO;
using System.Reflection;
public class Test {
public static int Main ()
{
var p = Path.Combine (AppDomain.CurrentDomain.BaseDirectory, "middle", "Mid.dll");
var a = Assembly.LoadFrom (p);
var t = a.GetType ("MyType");
Activator.CreateInstance (t);
return 0;
}
}
| using System;
using System.IO;
using System.Reflection;
public class Test {
public static int Main ()
{
var p = Path.Combine (AppDomain.CurrentDomain.BaseDirectory, "middle", "Mid.dll");
var a = Assembly.LoadFrom (p);
var t = a.GetType ("MyType");
Activator.CreateInstance (t);
return 0;
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/Microsoft.Extensions.DependencyModel/src/RuntimeAssetGroup.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Linq;
using System.Collections.Generic;
namespace Microsoft.Extensions.DependencyModel
{
public class RuntimeAssetGroup
{
private IReadOnlyList<string>? _assetPaths;
private IReadOnlyList<RuntimeFile>? _runtimeFiles;
public RuntimeAssetGroup(string? runtime, params string[] assetPaths) : this(runtime, (IEnumerable<string>)assetPaths) { }
public RuntimeAssetGroup(string? runtime, IEnumerable<string> assetPaths)
{
Runtime = runtime;
_assetPaths = assetPaths.ToArray();
}
public RuntimeAssetGroup(string? runtime, IEnumerable<RuntimeFile> runtimeFiles)
{
Runtime = runtime;
_runtimeFiles = runtimeFiles.ToArray();
}
/// <summary>
/// The runtime ID associated with this group (may be empty if the group is runtime-agnostic)
/// </summary>
public string? Runtime { get; }
/// <summary>
/// Gets a list of asset paths provided in this runtime group
/// </summary>
public IReadOnlyList<string> AssetPaths
{
get
{
if (_assetPaths != null)
{
return _assetPaths;
}
return _runtimeFiles!.Select(file => file.Path).ToArray();
}
}
/// <summary>
/// Gets a list of RuntimeFiles provided in this runtime group
/// </summary>
public IReadOnlyList<RuntimeFile> RuntimeFiles
{
get
{
if (_runtimeFiles != null)
{
return _runtimeFiles;
}
return _assetPaths!.Select(path => new RuntimeFile(path, null, null)).ToArray();
}
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Linq;
using System.Collections.Generic;
namespace Microsoft.Extensions.DependencyModel
{
public class RuntimeAssetGroup
{
private IReadOnlyList<string>? _assetPaths;
private IReadOnlyList<RuntimeFile>? _runtimeFiles;
public RuntimeAssetGroup(string? runtime, params string[] assetPaths) : this(runtime, (IEnumerable<string>)assetPaths) { }
public RuntimeAssetGroup(string? runtime, IEnumerable<string> assetPaths)
{
Runtime = runtime;
_assetPaths = assetPaths.ToArray();
}
public RuntimeAssetGroup(string? runtime, IEnumerable<RuntimeFile> runtimeFiles)
{
Runtime = runtime;
_runtimeFiles = runtimeFiles.ToArray();
}
/// <summary>
/// The runtime ID associated with this group (may be empty if the group is runtime-agnostic)
/// </summary>
public string? Runtime { get; }
/// <summary>
/// Gets a list of asset paths provided in this runtime group
/// </summary>
public IReadOnlyList<string> AssetPaths
{
get
{
if (_assetPaths != null)
{
return _assetPaths;
}
return _runtimeFiles!.Select(file => file.Path).ToArray();
}
}
/// <summary>
/// Gets a list of RuntimeFiles provided in this runtime group
/// </summary>
public IReadOnlyList<RuntimeFile> RuntimeFiles
{
get
{
if (_runtimeFiles != null)
{
return _runtimeFiles;
}
return _assetPaths!.Select(path => new RuntimeFile(path, null, null)).ToArray();
}
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Net.NetworkInformation/ref/System.Net.NetworkInformation.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.Net.NetworkInformation
{
public enum DuplicateAddressDetectionState
{
Invalid = 0,
Tentative = 1,
Duplicate = 2,
Deprecated = 3,
Preferred = 4,
}
public abstract partial class GatewayIPAddressInformation
{
protected GatewayIPAddressInformation() { }
public abstract System.Net.IPAddress Address { get; }
}
public partial class GatewayIPAddressInformationCollection : System.Collections.Generic.ICollection<System.Net.NetworkInformation.GatewayIPAddressInformation>, System.Collections.Generic.IEnumerable<System.Net.NetworkInformation.GatewayIPAddressInformation>, System.Collections.IEnumerable
{
protected internal GatewayIPAddressInformationCollection() { }
public virtual int Count { get { throw null; } }
public virtual bool IsReadOnly { get { throw null; } }
public virtual System.Net.NetworkInformation.GatewayIPAddressInformation this[int index] { get { throw null; } }
public virtual void Add(System.Net.NetworkInformation.GatewayIPAddressInformation address) { }
public virtual void Clear() { }
public virtual bool Contains(System.Net.NetworkInformation.GatewayIPAddressInformation address) { throw null; }
public virtual void CopyTo(System.Net.NetworkInformation.GatewayIPAddressInformation[] array, int offset) { }
public virtual System.Collections.Generic.IEnumerator<System.Net.NetworkInformation.GatewayIPAddressInformation> GetEnumerator() { throw null; }
public virtual bool Remove(System.Net.NetworkInformation.GatewayIPAddressInformation address) { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
public abstract partial class IcmpV4Statistics
{
protected IcmpV4Statistics() { }
public abstract long AddressMaskRepliesReceived { get; }
public abstract long AddressMaskRepliesSent { get; }
public abstract long AddressMaskRequestsReceived { get; }
public abstract long AddressMaskRequestsSent { get; }
public abstract long DestinationUnreachableMessagesReceived { get; }
public abstract long DestinationUnreachableMessagesSent { get; }
public abstract long EchoRepliesReceived { get; }
public abstract long EchoRepliesSent { get; }
public abstract long EchoRequestsReceived { get; }
public abstract long EchoRequestsSent { get; }
public abstract long ErrorsReceived { get; }
public abstract long ErrorsSent { get; }
public abstract long MessagesReceived { get; }
public abstract long MessagesSent { get; }
public abstract long ParameterProblemsReceived { get; }
public abstract long ParameterProblemsSent { get; }
public abstract long RedirectsReceived { get; }
public abstract long RedirectsSent { get; }
public abstract long SourceQuenchesReceived { get; }
public abstract long SourceQuenchesSent { get; }
public abstract long TimeExceededMessagesReceived { get; }
public abstract long TimeExceededMessagesSent { get; }
public abstract long TimestampRepliesReceived { get; }
public abstract long TimestampRepliesSent { get; }
public abstract long TimestampRequestsReceived { get; }
public abstract long TimestampRequestsSent { get; }
}
public abstract partial class IcmpV6Statistics
{
protected IcmpV6Statistics() { }
public abstract long DestinationUnreachableMessagesReceived { get; }
public abstract long DestinationUnreachableMessagesSent { get; }
public abstract long EchoRepliesReceived { get; }
public abstract long EchoRepliesSent { get; }
public abstract long EchoRequestsReceived { get; }
public abstract long EchoRequestsSent { get; }
public abstract long ErrorsReceived { get; }
public abstract long ErrorsSent { get; }
public abstract long MembershipQueriesReceived { get; }
public abstract long MembershipQueriesSent { get; }
public abstract long MembershipReductionsReceived { get; }
public abstract long MembershipReductionsSent { get; }
public abstract long MembershipReportsReceived { get; }
public abstract long MembershipReportsSent { get; }
public abstract long MessagesReceived { get; }
public abstract long MessagesSent { get; }
public abstract long NeighborAdvertisementsReceived { get; }
public abstract long NeighborAdvertisementsSent { get; }
public abstract long NeighborSolicitsReceived { get; }
public abstract long NeighborSolicitsSent { get; }
public abstract long PacketTooBigMessagesReceived { get; }
public abstract long PacketTooBigMessagesSent { get; }
public abstract long ParameterProblemsReceived { get; }
public abstract long ParameterProblemsSent { get; }
public abstract long RedirectsReceived { get; }
public abstract long RedirectsSent { get; }
public abstract long RouterAdvertisementsReceived { get; }
public abstract long RouterAdvertisementsSent { get; }
public abstract long RouterSolicitsReceived { get; }
public abstract long RouterSolicitsSent { get; }
public abstract long TimeExceededMessagesReceived { get; }
public abstract long TimeExceededMessagesSent { get; }
}
public abstract partial class IPAddressInformation
{
protected IPAddressInformation() { }
public abstract System.Net.IPAddress Address { get; }
public abstract bool IsDnsEligible { get; }
public abstract bool IsTransient { get; }
}
public partial class IPAddressInformationCollection : System.Collections.Generic.ICollection<System.Net.NetworkInformation.IPAddressInformation>, System.Collections.Generic.IEnumerable<System.Net.NetworkInformation.IPAddressInformation>, System.Collections.IEnumerable
{
internal IPAddressInformationCollection() { }
public virtual int Count { get { throw null; } }
public virtual bool IsReadOnly { get { throw null; } }
public virtual System.Net.NetworkInformation.IPAddressInformation this[int index] { get { throw null; } }
public virtual void Add(System.Net.NetworkInformation.IPAddressInformation address) { }
public virtual void Clear() { }
public virtual bool Contains(System.Net.NetworkInformation.IPAddressInformation address) { throw null; }
public virtual void CopyTo(System.Net.NetworkInformation.IPAddressInformation[] array, int offset) { }
public virtual System.Collections.Generic.IEnumerator<System.Net.NetworkInformation.IPAddressInformation> GetEnumerator() { throw null; }
public virtual bool Remove(System.Net.NetworkInformation.IPAddressInformation address) { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
public abstract partial class IPGlobalProperties
{
protected IPGlobalProperties() { }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract string DhcpScopeName { get; }
public abstract string DomainName { get; }
public abstract string HostName { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract bool IsWinsProxy { get; }
public abstract System.Net.NetworkInformation.NetBiosNodeType NodeType { get; }
public virtual System.IAsyncResult BeginGetUnicastAddresses(System.AsyncCallback? callback, object? state) { throw null; }
public virtual System.Net.NetworkInformation.UnicastIPAddressInformationCollection EndGetUnicastAddresses(System.IAsyncResult asyncResult) { throw null; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.TcpConnectionInformation[] GetActiveTcpConnections();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.IPEndPoint[] GetActiveTcpListeners();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.IPEndPoint[] GetActiveUdpListeners();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.IcmpV4Statistics GetIcmpV4Statistics();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.IcmpV6Statistics GetIcmpV6Statistics();
[System.Runtime.Versioning.UnsupportedOSPlatform("illumos")]
[System.Runtime.Versioning.UnsupportedOSPlatform("solaris")]
public static System.Net.NetworkInformation.IPGlobalProperties GetIPGlobalProperties() { throw null; }
public abstract System.Net.NetworkInformation.IPGlobalStatistics GetIPv4GlobalStatistics();
public abstract System.Net.NetworkInformation.IPGlobalStatistics GetIPv6GlobalStatistics();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.TcpStatistics GetTcpIPv4Statistics();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.TcpStatistics GetTcpIPv6Statistics();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.UdpStatistics GetUdpIPv4Statistics();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.UdpStatistics GetUdpIPv6Statistics();
public virtual System.Net.NetworkInformation.UnicastIPAddressInformationCollection GetUnicastAddresses() { throw null; }
public virtual System.Threading.Tasks.Task<System.Net.NetworkInformation.UnicastIPAddressInformationCollection> GetUnicastAddressesAsync() { throw null; }
}
public abstract partial class IPGlobalStatistics
{
protected IPGlobalStatistics() { }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract int DefaultTtl { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract bool ForwardingEnabled { get; }
public abstract int NumberOfInterfaces { get; }
public abstract int NumberOfIPAddresses { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract int NumberOfRoutes { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long OutputPacketRequests { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long OutputPacketRoutingDiscards { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long OutputPacketsDiscarded { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long OutputPacketsWithNoRoute { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long PacketFragmentFailures { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long PacketReassembliesRequired { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long PacketReassemblyFailures { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long PacketReassemblyTimeout { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long PacketsFragmented { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long PacketsReassembled { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long ReceivedPackets { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long ReceivedPacketsDelivered { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long ReceivedPacketsDiscarded { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long ReceivedPacketsForwarded { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long ReceivedPacketsWithAddressErrors { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long ReceivedPacketsWithHeadersErrors { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long ReceivedPacketsWithUnknownProtocol { get; }
}
public abstract partial class IPInterfaceProperties
{
protected IPInterfaceProperties() { }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.IPAddressInformationCollection AnycastAddresses { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.IPAddressCollection DhcpServerAddresses { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.IPAddressCollection DnsAddresses { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract string DnsSuffix { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.GatewayIPAddressInformationCollection GatewayAddresses { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract bool IsDnsEnabled { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract bool IsDynamicDnsEnabled { get; }
public abstract System.Net.NetworkInformation.MulticastIPAddressInformationCollection MulticastAddresses { get; }
public abstract System.Net.NetworkInformation.UnicastIPAddressInformationCollection UnicastAddresses { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.IPAddressCollection WinsServersAddresses { get; }
public abstract System.Net.NetworkInformation.IPv4InterfaceProperties GetIPv4Properties();
public abstract System.Net.NetworkInformation.IPv6InterfaceProperties GetIPv6Properties();
}
public abstract partial class IPInterfaceStatistics
{
protected IPInterfaceStatistics() { }
public abstract long BytesReceived { get; }
public abstract long BytesSent { get; }
public abstract long IncomingPacketsDiscarded { get; }
public abstract long IncomingPacketsWithErrors { get; }
public abstract long IncomingUnknownProtocolPackets { get; }
public abstract long NonUnicastPacketsReceived { get; }
public abstract long NonUnicastPacketsSent { get; }
public abstract long OutgoingPacketsDiscarded { get; }
public abstract long OutgoingPacketsWithErrors { get; }
public abstract long OutputQueueLength { get; }
public abstract long UnicastPacketsReceived { get; }
public abstract long UnicastPacketsSent { get; }
}
public abstract partial class IPv4InterfaceProperties
{
protected IPv4InterfaceProperties() { }
public abstract int Index { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract bool IsAutomaticPrivateAddressingActive { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract bool IsAutomaticPrivateAddressingEnabled { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract bool IsDhcpEnabled { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract bool IsForwardingEnabled { get; }
public abstract int Mtu { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract bool UsesWins { get; }
}
public abstract partial class IPv4InterfaceStatistics
{
protected IPv4InterfaceStatistics() { }
public abstract long BytesReceived { get; }
public abstract long BytesSent { get; }
public abstract long IncomingPacketsDiscarded { get; }
public abstract long IncomingPacketsWithErrors { get; }
public abstract long IncomingUnknownProtocolPackets { get; }
public abstract long NonUnicastPacketsReceived { get; }
public abstract long NonUnicastPacketsSent { get; }
public abstract long OutgoingPacketsDiscarded { get; }
public abstract long OutgoingPacketsWithErrors { get; }
public abstract long OutputQueueLength { get; }
public abstract long UnicastPacketsReceived { get; }
public abstract long UnicastPacketsSent { get; }
}
public abstract partial class IPv6InterfaceProperties
{
protected IPv6InterfaceProperties() { }
public abstract int Index { get; }
public abstract int Mtu { get; }
public virtual long GetScopeId(System.Net.NetworkInformation.ScopeLevel scopeLevel) { throw null; }
}
public abstract partial class MulticastIPAddressInformation : System.Net.NetworkInformation.IPAddressInformation
{
protected MulticastIPAddressInformation() { }
public abstract long AddressPreferredLifetime { get; }
public abstract long AddressValidLifetime { get; }
public abstract long DhcpLeaseLifetime { get; }
public abstract System.Net.NetworkInformation.DuplicateAddressDetectionState DuplicateAddressDetectionState { get; }
public abstract System.Net.NetworkInformation.PrefixOrigin PrefixOrigin { get; }
public abstract System.Net.NetworkInformation.SuffixOrigin SuffixOrigin { get; }
}
public partial class MulticastIPAddressInformationCollection : System.Collections.Generic.ICollection<System.Net.NetworkInformation.MulticastIPAddressInformation>, System.Collections.Generic.IEnumerable<System.Net.NetworkInformation.MulticastIPAddressInformation>, System.Collections.IEnumerable
{
protected internal MulticastIPAddressInformationCollection() { }
public virtual int Count { get { throw null; } }
public virtual bool IsReadOnly { get { throw null; } }
public virtual System.Net.NetworkInformation.MulticastIPAddressInformation this[int index] { get { throw null; } }
public virtual void Add(System.Net.NetworkInformation.MulticastIPAddressInformation address) { }
public virtual void Clear() { }
public virtual bool Contains(System.Net.NetworkInformation.MulticastIPAddressInformation address) { throw null; }
public virtual void CopyTo(System.Net.NetworkInformation.MulticastIPAddressInformation[] array, int offset) { }
public virtual System.Collections.Generic.IEnumerator<System.Net.NetworkInformation.MulticastIPAddressInformation> GetEnumerator() { throw null; }
public virtual bool Remove(System.Net.NetworkInformation.MulticastIPAddressInformation address) { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
public enum NetBiosNodeType
{
Unknown = 0,
Broadcast = 1,
Peer2Peer = 2,
Mixed = 4,
Hybrid = 8,
}
public delegate void NetworkAddressChangedEventHandler(object? sender, System.EventArgs e);
public delegate void NetworkAvailabilityChangedEventHandler(object? sender, System.Net.NetworkInformation.NetworkAvailabilityEventArgs e);
public partial class NetworkAvailabilityEventArgs : System.EventArgs
{
internal NetworkAvailabilityEventArgs() { }
public bool IsAvailable { get { throw null; } }
}
public partial class NetworkChange
{
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.ObsoleteAttribute("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
public NetworkChange() { }
public static event System.Net.NetworkInformation.NetworkAddressChangedEventHandler? NetworkAddressChanged { add { } remove { } }
public static event System.Net.NetworkInformation.NetworkAvailabilityChangedEventHandler? NetworkAvailabilityChanged { add { } remove { } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.ObsoleteAttribute("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
public static void RegisterNetworkChange(System.Net.NetworkInformation.NetworkChange nc) { }
}
public partial class NetworkInformationException : System.ComponentModel.Win32Exception
{
public NetworkInformationException() { }
public NetworkInformationException(int errorCode) { }
protected NetworkInformationException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { }
public override int ErrorCode { get { throw null; } }
}
public abstract partial class NetworkInterface
{
protected NetworkInterface() { }
public virtual string Description { get { throw null; } }
public virtual string Id { get { throw null; } }
public static int IPv6LoopbackInterfaceIndex { get { throw null; } }
public virtual bool IsReceiveOnly { get { throw null; } }
public static int LoopbackInterfaceIndex { get { throw null; } }
public virtual string Name { get { throw null; } }
public virtual System.Net.NetworkInformation.NetworkInterfaceType NetworkInterfaceType { get { throw null; } }
public virtual System.Net.NetworkInformation.OperationalStatus OperationalStatus { get { throw null; } }
public virtual long Speed { get { throw null; } }
public virtual bool SupportsMulticast { get { throw null; } }
[System.Runtime.Versioning.UnsupportedOSPlatform("illumos")]
[System.Runtime.Versioning.UnsupportedOSPlatform("solaris")]
public static System.Net.NetworkInformation.NetworkInterface[] GetAllNetworkInterfaces() { throw null; }
public virtual System.Net.NetworkInformation.IPInterfaceProperties GetIPProperties() { throw null; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public virtual System.Net.NetworkInformation.IPInterfaceStatistics GetIPStatistics() { throw null; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public virtual System.Net.NetworkInformation.IPv4InterfaceStatistics GetIPv4Statistics() { throw null; }
[System.Runtime.Versioning.UnsupportedOSPlatform("illumos")]
[System.Runtime.Versioning.UnsupportedOSPlatform("solaris")]
public static bool GetIsNetworkAvailable() { throw null; }
public virtual System.Net.NetworkInformation.PhysicalAddress GetPhysicalAddress() { throw null; }
public virtual bool Supports(System.Net.NetworkInformation.NetworkInterfaceComponent networkInterfaceComponent) { throw null; }
}
public enum NetworkInterfaceComponent
{
IPv4 = 0,
IPv6 = 1,
}
public enum NetworkInterfaceType
{
Unknown = 1,
Ethernet = 6,
TokenRing = 9,
Fddi = 15,
BasicIsdn = 20,
PrimaryIsdn = 21,
Ppp = 23,
Loopback = 24,
Ethernet3Megabit = 26,
Slip = 28,
Atm = 37,
GenericModem = 48,
FastEthernetT = 62,
Isdn = 63,
FastEthernetFx = 69,
Wireless80211 = 71,
AsymmetricDsl = 94,
RateAdaptDsl = 95,
SymmetricDsl = 96,
VeryHighSpeedDsl = 97,
IPOverAtm = 114,
GigabitEthernet = 117,
Tunnel = 131,
MultiRateSymmetricDsl = 143,
HighPerformanceSerialBus = 144,
Wman = 237,
Wwanpp = 243,
Wwanpp2 = 244,
}
public enum OperationalStatus
{
Up = 1,
Down = 2,
Testing = 3,
Unknown = 4,
Dormant = 5,
NotPresent = 6,
LowerLayerDown = 7,
}
public partial class PhysicalAddress
{
public static readonly System.Net.NetworkInformation.PhysicalAddress None;
public PhysicalAddress(byte[] address) { }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] object? comparand) { throw null; }
public byte[] GetAddressBytes() { throw null; }
public override int GetHashCode() { throw null; }
public static System.Net.NetworkInformation.PhysicalAddress Parse(string? address) { throw null; }
public static System.Net.NetworkInformation.PhysicalAddress Parse(ReadOnlySpan<char> address) { throw null; }
public static bool TryParse(string? address, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Net.NetworkInformation.PhysicalAddress? value) { throw null; }
public static bool TryParse(ReadOnlySpan<char> address, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Net.NetworkInformation.PhysicalAddress? value) { throw null; }
public override string ToString() { throw null; }
}
public enum PrefixOrigin
{
Other = 0,
Manual = 1,
WellKnown = 2,
Dhcp = 3,
RouterAdvertisement = 4,
}
public enum ScopeLevel
{
None = 0,
Interface = 1,
Link = 2,
Subnet = 3,
Admin = 4,
Site = 5,
Organization = 8,
Global = 14,
}
public enum SuffixOrigin
{
Other = 0,
Manual = 1,
WellKnown = 2,
OriginDhcp = 3,
LinkLayerAddress = 4,
Random = 5,
}
public abstract partial class TcpConnectionInformation
{
protected TcpConnectionInformation() { }
public abstract System.Net.IPEndPoint LocalEndPoint { get; }
public abstract System.Net.IPEndPoint RemoteEndPoint { get; }
public abstract System.Net.NetworkInformation.TcpState State { get; }
}
public enum TcpState
{
Unknown = 0,
Closed = 1,
Listen = 2,
SynSent = 3,
SynReceived = 4,
Established = 5,
FinWait1 = 6,
FinWait2 = 7,
CloseWait = 8,
Closing = 9,
LastAck = 10,
TimeWait = 11,
DeleteTcb = 12,
}
public abstract partial class TcpStatistics
{
protected TcpStatistics() { }
public abstract long ConnectionsAccepted { get; }
public abstract long ConnectionsInitiated { get; }
public abstract long CumulativeConnections { get; }
public abstract long CurrentConnections { get; }
public abstract long ErrorsReceived { get; }
public abstract long FailedConnectionAttempts { get; }
public abstract long MaximumConnections { get; }
public abstract long MaximumTransmissionTimeout { get; }
public abstract long MinimumTransmissionTimeout { get; }
public abstract long ResetConnections { get; }
public abstract long ResetsSent { get; }
public abstract long SegmentsReceived { get; }
public abstract long SegmentsResent { get; }
public abstract long SegmentsSent { get; }
}
public abstract partial class UdpStatistics
{
protected UdpStatistics() { }
public abstract long DatagramsReceived { get; }
public abstract long DatagramsSent { get; }
public abstract long IncomingDatagramsDiscarded { get; }
public abstract long IncomingDatagramsWithErrors { get; }
public abstract int UdpListeners { get; }
}
public abstract partial class UnicastIPAddressInformation : System.Net.NetworkInformation.IPAddressInformation
{
protected UnicastIPAddressInformation() { }
public abstract long AddressPreferredLifetime { get; }
public abstract long AddressValidLifetime { get; }
public abstract long DhcpLeaseLifetime { get; }
public abstract System.Net.NetworkInformation.DuplicateAddressDetectionState DuplicateAddressDetectionState { get; }
public abstract System.Net.IPAddress IPv4Mask { get; }
public virtual int PrefixLength { get { throw null; } }
public abstract System.Net.NetworkInformation.PrefixOrigin PrefixOrigin { get; }
public abstract System.Net.NetworkInformation.SuffixOrigin SuffixOrigin { get; }
}
public partial class UnicastIPAddressInformationCollection : System.Collections.Generic.ICollection<System.Net.NetworkInformation.UnicastIPAddressInformation>, System.Collections.Generic.IEnumerable<System.Net.NetworkInformation.UnicastIPAddressInformation>, System.Collections.IEnumerable
{
protected internal UnicastIPAddressInformationCollection() { }
public virtual int Count { get { throw null; } }
public virtual bool IsReadOnly { get { throw null; } }
public virtual System.Net.NetworkInformation.UnicastIPAddressInformation this[int index] { get { throw null; } }
public virtual void Add(System.Net.NetworkInformation.UnicastIPAddressInformation address) { }
public virtual void Clear() { }
public virtual bool Contains(System.Net.NetworkInformation.UnicastIPAddressInformation address) { throw null; }
public virtual void CopyTo(System.Net.NetworkInformation.UnicastIPAddressInformation[] array, int offset) { }
public virtual System.Collections.Generic.IEnumerator<System.Net.NetworkInformation.UnicastIPAddressInformation> GetEnumerator() { throw null; }
public virtual bool Remove(System.Net.NetworkInformation.UnicastIPAddressInformation address) { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
}
| // 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.Net.NetworkInformation
{
public enum DuplicateAddressDetectionState
{
Invalid = 0,
Tentative = 1,
Duplicate = 2,
Deprecated = 3,
Preferred = 4,
}
public abstract partial class GatewayIPAddressInformation
{
protected GatewayIPAddressInformation() { }
public abstract System.Net.IPAddress Address { get; }
}
public partial class GatewayIPAddressInformationCollection : System.Collections.Generic.ICollection<System.Net.NetworkInformation.GatewayIPAddressInformation>, System.Collections.Generic.IEnumerable<System.Net.NetworkInformation.GatewayIPAddressInformation>, System.Collections.IEnumerable
{
protected internal GatewayIPAddressInformationCollection() { }
public virtual int Count { get { throw null; } }
public virtual bool IsReadOnly { get { throw null; } }
public virtual System.Net.NetworkInformation.GatewayIPAddressInformation this[int index] { get { throw null; } }
public virtual void Add(System.Net.NetworkInformation.GatewayIPAddressInformation address) { }
public virtual void Clear() { }
public virtual bool Contains(System.Net.NetworkInformation.GatewayIPAddressInformation address) { throw null; }
public virtual void CopyTo(System.Net.NetworkInformation.GatewayIPAddressInformation[] array, int offset) { }
public virtual System.Collections.Generic.IEnumerator<System.Net.NetworkInformation.GatewayIPAddressInformation> GetEnumerator() { throw null; }
public virtual bool Remove(System.Net.NetworkInformation.GatewayIPAddressInformation address) { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
public abstract partial class IcmpV4Statistics
{
protected IcmpV4Statistics() { }
public abstract long AddressMaskRepliesReceived { get; }
public abstract long AddressMaskRepliesSent { get; }
public abstract long AddressMaskRequestsReceived { get; }
public abstract long AddressMaskRequestsSent { get; }
public abstract long DestinationUnreachableMessagesReceived { get; }
public abstract long DestinationUnreachableMessagesSent { get; }
public abstract long EchoRepliesReceived { get; }
public abstract long EchoRepliesSent { get; }
public abstract long EchoRequestsReceived { get; }
public abstract long EchoRequestsSent { get; }
public abstract long ErrorsReceived { get; }
public abstract long ErrorsSent { get; }
public abstract long MessagesReceived { get; }
public abstract long MessagesSent { get; }
public abstract long ParameterProblemsReceived { get; }
public abstract long ParameterProblemsSent { get; }
public abstract long RedirectsReceived { get; }
public abstract long RedirectsSent { get; }
public abstract long SourceQuenchesReceived { get; }
public abstract long SourceQuenchesSent { get; }
public abstract long TimeExceededMessagesReceived { get; }
public abstract long TimeExceededMessagesSent { get; }
public abstract long TimestampRepliesReceived { get; }
public abstract long TimestampRepliesSent { get; }
public abstract long TimestampRequestsReceived { get; }
public abstract long TimestampRequestsSent { get; }
}
public abstract partial class IcmpV6Statistics
{
protected IcmpV6Statistics() { }
public abstract long DestinationUnreachableMessagesReceived { get; }
public abstract long DestinationUnreachableMessagesSent { get; }
public abstract long EchoRepliesReceived { get; }
public abstract long EchoRepliesSent { get; }
public abstract long EchoRequestsReceived { get; }
public abstract long EchoRequestsSent { get; }
public abstract long ErrorsReceived { get; }
public abstract long ErrorsSent { get; }
public abstract long MembershipQueriesReceived { get; }
public abstract long MembershipQueriesSent { get; }
public abstract long MembershipReductionsReceived { get; }
public abstract long MembershipReductionsSent { get; }
public abstract long MembershipReportsReceived { get; }
public abstract long MembershipReportsSent { get; }
public abstract long MessagesReceived { get; }
public abstract long MessagesSent { get; }
public abstract long NeighborAdvertisementsReceived { get; }
public abstract long NeighborAdvertisementsSent { get; }
public abstract long NeighborSolicitsReceived { get; }
public abstract long NeighborSolicitsSent { get; }
public abstract long PacketTooBigMessagesReceived { get; }
public abstract long PacketTooBigMessagesSent { get; }
public abstract long ParameterProblemsReceived { get; }
public abstract long ParameterProblemsSent { get; }
public abstract long RedirectsReceived { get; }
public abstract long RedirectsSent { get; }
public abstract long RouterAdvertisementsReceived { get; }
public abstract long RouterAdvertisementsSent { get; }
public abstract long RouterSolicitsReceived { get; }
public abstract long RouterSolicitsSent { get; }
public abstract long TimeExceededMessagesReceived { get; }
public abstract long TimeExceededMessagesSent { get; }
}
public abstract partial class IPAddressInformation
{
protected IPAddressInformation() { }
public abstract System.Net.IPAddress Address { get; }
public abstract bool IsDnsEligible { get; }
public abstract bool IsTransient { get; }
}
public partial class IPAddressInformationCollection : System.Collections.Generic.ICollection<System.Net.NetworkInformation.IPAddressInformation>, System.Collections.Generic.IEnumerable<System.Net.NetworkInformation.IPAddressInformation>, System.Collections.IEnumerable
{
internal IPAddressInformationCollection() { }
public virtual int Count { get { throw null; } }
public virtual bool IsReadOnly { get { throw null; } }
public virtual System.Net.NetworkInformation.IPAddressInformation this[int index] { get { throw null; } }
public virtual void Add(System.Net.NetworkInformation.IPAddressInformation address) { }
public virtual void Clear() { }
public virtual bool Contains(System.Net.NetworkInformation.IPAddressInformation address) { throw null; }
public virtual void CopyTo(System.Net.NetworkInformation.IPAddressInformation[] array, int offset) { }
public virtual System.Collections.Generic.IEnumerator<System.Net.NetworkInformation.IPAddressInformation> GetEnumerator() { throw null; }
public virtual bool Remove(System.Net.NetworkInformation.IPAddressInformation address) { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
public abstract partial class IPGlobalProperties
{
protected IPGlobalProperties() { }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract string DhcpScopeName { get; }
public abstract string DomainName { get; }
public abstract string HostName { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract bool IsWinsProxy { get; }
public abstract System.Net.NetworkInformation.NetBiosNodeType NodeType { get; }
public virtual System.IAsyncResult BeginGetUnicastAddresses(System.AsyncCallback? callback, object? state) { throw null; }
public virtual System.Net.NetworkInformation.UnicastIPAddressInformationCollection EndGetUnicastAddresses(System.IAsyncResult asyncResult) { throw null; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.TcpConnectionInformation[] GetActiveTcpConnections();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.IPEndPoint[] GetActiveTcpListeners();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.IPEndPoint[] GetActiveUdpListeners();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.IcmpV4Statistics GetIcmpV4Statistics();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.IcmpV6Statistics GetIcmpV6Statistics();
[System.Runtime.Versioning.UnsupportedOSPlatform("illumos")]
[System.Runtime.Versioning.UnsupportedOSPlatform("solaris")]
public static System.Net.NetworkInformation.IPGlobalProperties GetIPGlobalProperties() { throw null; }
public abstract System.Net.NetworkInformation.IPGlobalStatistics GetIPv4GlobalStatistics();
public abstract System.Net.NetworkInformation.IPGlobalStatistics GetIPv6GlobalStatistics();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.TcpStatistics GetTcpIPv4Statistics();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.TcpStatistics GetTcpIPv6Statistics();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.UdpStatistics GetUdpIPv4Statistics();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.UdpStatistics GetUdpIPv6Statistics();
public virtual System.Net.NetworkInformation.UnicastIPAddressInformationCollection GetUnicastAddresses() { throw null; }
public virtual System.Threading.Tasks.Task<System.Net.NetworkInformation.UnicastIPAddressInformationCollection> GetUnicastAddressesAsync() { throw null; }
}
public abstract partial class IPGlobalStatistics
{
protected IPGlobalStatistics() { }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract int DefaultTtl { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract bool ForwardingEnabled { get; }
public abstract int NumberOfInterfaces { get; }
public abstract int NumberOfIPAddresses { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract int NumberOfRoutes { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long OutputPacketRequests { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long OutputPacketRoutingDiscards { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long OutputPacketsDiscarded { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long OutputPacketsWithNoRoute { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long PacketFragmentFailures { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long PacketReassembliesRequired { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long PacketReassemblyFailures { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long PacketReassemblyTimeout { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long PacketsFragmented { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long PacketsReassembled { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long ReceivedPackets { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long ReceivedPacketsDelivered { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long ReceivedPacketsDiscarded { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long ReceivedPacketsForwarded { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long ReceivedPacketsWithAddressErrors { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long ReceivedPacketsWithHeadersErrors { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract long ReceivedPacketsWithUnknownProtocol { get; }
}
public abstract partial class IPInterfaceProperties
{
protected IPInterfaceProperties() { }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.IPAddressInformationCollection AnycastAddresses { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.IPAddressCollection DhcpServerAddresses { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.IPAddressCollection DnsAddresses { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract string DnsSuffix { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.GatewayIPAddressInformationCollection GatewayAddresses { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract bool IsDnsEnabled { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract bool IsDynamicDnsEnabled { get; }
public abstract System.Net.NetworkInformation.MulticastIPAddressInformationCollection MulticastAddresses { get; }
public abstract System.Net.NetworkInformation.UnicastIPAddressInformationCollection UnicastAddresses { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.IPAddressCollection WinsServersAddresses { get; }
public abstract System.Net.NetworkInformation.IPv4InterfaceProperties GetIPv4Properties();
public abstract System.Net.NetworkInformation.IPv6InterfaceProperties GetIPv6Properties();
}
public abstract partial class IPInterfaceStatistics
{
protected IPInterfaceStatistics() { }
public abstract long BytesReceived { get; }
public abstract long BytesSent { get; }
public abstract long IncomingPacketsDiscarded { get; }
public abstract long IncomingPacketsWithErrors { get; }
public abstract long IncomingUnknownProtocolPackets { get; }
public abstract long NonUnicastPacketsReceived { get; }
public abstract long NonUnicastPacketsSent { get; }
public abstract long OutgoingPacketsDiscarded { get; }
public abstract long OutgoingPacketsWithErrors { get; }
public abstract long OutputQueueLength { get; }
public abstract long UnicastPacketsReceived { get; }
public abstract long UnicastPacketsSent { get; }
}
public abstract partial class IPv4InterfaceProperties
{
protected IPv4InterfaceProperties() { }
public abstract int Index { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract bool IsAutomaticPrivateAddressingActive { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract bool IsAutomaticPrivateAddressingEnabled { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract bool IsDhcpEnabled { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract bool IsForwardingEnabled { get; }
public abstract int Mtu { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract bool UsesWins { get; }
}
public abstract partial class IPv4InterfaceStatistics
{
protected IPv4InterfaceStatistics() { }
public abstract long BytesReceived { get; }
public abstract long BytesSent { get; }
public abstract long IncomingPacketsDiscarded { get; }
public abstract long IncomingPacketsWithErrors { get; }
public abstract long IncomingUnknownProtocolPackets { get; }
public abstract long NonUnicastPacketsReceived { get; }
public abstract long NonUnicastPacketsSent { get; }
public abstract long OutgoingPacketsDiscarded { get; }
public abstract long OutgoingPacketsWithErrors { get; }
public abstract long OutputQueueLength { get; }
public abstract long UnicastPacketsReceived { get; }
public abstract long UnicastPacketsSent { get; }
}
public abstract partial class IPv6InterfaceProperties
{
protected IPv6InterfaceProperties() { }
public abstract int Index { get; }
public abstract int Mtu { get; }
public virtual long GetScopeId(System.Net.NetworkInformation.ScopeLevel scopeLevel) { throw null; }
}
public abstract partial class MulticastIPAddressInformation : System.Net.NetworkInformation.IPAddressInformation
{
protected MulticastIPAddressInformation() { }
public abstract long AddressPreferredLifetime { get; }
public abstract long AddressValidLifetime { get; }
public abstract long DhcpLeaseLifetime { get; }
public abstract System.Net.NetworkInformation.DuplicateAddressDetectionState DuplicateAddressDetectionState { get; }
public abstract System.Net.NetworkInformation.PrefixOrigin PrefixOrigin { get; }
public abstract System.Net.NetworkInformation.SuffixOrigin SuffixOrigin { get; }
}
public partial class MulticastIPAddressInformationCollection : System.Collections.Generic.ICollection<System.Net.NetworkInformation.MulticastIPAddressInformation>, System.Collections.Generic.IEnumerable<System.Net.NetworkInformation.MulticastIPAddressInformation>, System.Collections.IEnumerable
{
protected internal MulticastIPAddressInformationCollection() { }
public virtual int Count { get { throw null; } }
public virtual bool IsReadOnly { get { throw null; } }
public virtual System.Net.NetworkInformation.MulticastIPAddressInformation this[int index] { get { throw null; } }
public virtual void Add(System.Net.NetworkInformation.MulticastIPAddressInformation address) { }
public virtual void Clear() { }
public virtual bool Contains(System.Net.NetworkInformation.MulticastIPAddressInformation address) { throw null; }
public virtual void CopyTo(System.Net.NetworkInformation.MulticastIPAddressInformation[] array, int offset) { }
public virtual System.Collections.Generic.IEnumerator<System.Net.NetworkInformation.MulticastIPAddressInformation> GetEnumerator() { throw null; }
public virtual bool Remove(System.Net.NetworkInformation.MulticastIPAddressInformation address) { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
public enum NetBiosNodeType
{
Unknown = 0,
Broadcast = 1,
Peer2Peer = 2,
Mixed = 4,
Hybrid = 8,
}
public delegate void NetworkAddressChangedEventHandler(object? sender, System.EventArgs e);
public delegate void NetworkAvailabilityChangedEventHandler(object? sender, System.Net.NetworkInformation.NetworkAvailabilityEventArgs e);
public partial class NetworkAvailabilityEventArgs : System.EventArgs
{
internal NetworkAvailabilityEventArgs() { }
public bool IsAvailable { get { throw null; } }
}
public partial class NetworkChange
{
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.ObsoleteAttribute("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
public NetworkChange() { }
public static event System.Net.NetworkInformation.NetworkAddressChangedEventHandler? NetworkAddressChanged { add { } remove { } }
public static event System.Net.NetworkInformation.NetworkAvailabilityChangedEventHandler? NetworkAvailabilityChanged { add { } remove { } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.ObsoleteAttribute("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
public static void RegisterNetworkChange(System.Net.NetworkInformation.NetworkChange nc) { }
}
public partial class NetworkInformationException : System.ComponentModel.Win32Exception
{
public NetworkInformationException() { }
public NetworkInformationException(int errorCode) { }
protected NetworkInformationException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { }
public override int ErrorCode { get { throw null; } }
}
public abstract partial class NetworkInterface
{
protected NetworkInterface() { }
public virtual string Description { get { throw null; } }
public virtual string Id { get { throw null; } }
public static int IPv6LoopbackInterfaceIndex { get { throw null; } }
public virtual bool IsReceiveOnly { get { throw null; } }
public static int LoopbackInterfaceIndex { get { throw null; } }
public virtual string Name { get { throw null; } }
public virtual System.Net.NetworkInformation.NetworkInterfaceType NetworkInterfaceType { get { throw null; } }
public virtual System.Net.NetworkInformation.OperationalStatus OperationalStatus { get { throw null; } }
public virtual long Speed { get { throw null; } }
public virtual bool SupportsMulticast { get { throw null; } }
[System.Runtime.Versioning.UnsupportedOSPlatform("illumos")]
[System.Runtime.Versioning.UnsupportedOSPlatform("solaris")]
public static System.Net.NetworkInformation.NetworkInterface[] GetAllNetworkInterfaces() { throw null; }
public virtual System.Net.NetworkInformation.IPInterfaceProperties GetIPProperties() { throw null; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public virtual System.Net.NetworkInformation.IPInterfaceStatistics GetIPStatistics() { throw null; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public virtual System.Net.NetworkInformation.IPv4InterfaceStatistics GetIPv4Statistics() { throw null; }
[System.Runtime.Versioning.UnsupportedOSPlatform("illumos")]
[System.Runtime.Versioning.UnsupportedOSPlatform("solaris")]
public static bool GetIsNetworkAvailable() { throw null; }
public virtual System.Net.NetworkInformation.PhysicalAddress GetPhysicalAddress() { throw null; }
public virtual bool Supports(System.Net.NetworkInformation.NetworkInterfaceComponent networkInterfaceComponent) { throw null; }
}
public enum NetworkInterfaceComponent
{
IPv4 = 0,
IPv6 = 1,
}
public enum NetworkInterfaceType
{
Unknown = 1,
Ethernet = 6,
TokenRing = 9,
Fddi = 15,
BasicIsdn = 20,
PrimaryIsdn = 21,
Ppp = 23,
Loopback = 24,
Ethernet3Megabit = 26,
Slip = 28,
Atm = 37,
GenericModem = 48,
FastEthernetT = 62,
Isdn = 63,
FastEthernetFx = 69,
Wireless80211 = 71,
AsymmetricDsl = 94,
RateAdaptDsl = 95,
SymmetricDsl = 96,
VeryHighSpeedDsl = 97,
IPOverAtm = 114,
GigabitEthernet = 117,
Tunnel = 131,
MultiRateSymmetricDsl = 143,
HighPerformanceSerialBus = 144,
Wman = 237,
Wwanpp = 243,
Wwanpp2 = 244,
}
public enum OperationalStatus
{
Up = 1,
Down = 2,
Testing = 3,
Unknown = 4,
Dormant = 5,
NotPresent = 6,
LowerLayerDown = 7,
}
public partial class PhysicalAddress
{
public static readonly System.Net.NetworkInformation.PhysicalAddress None;
public PhysicalAddress(byte[] address) { }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] object? comparand) { throw null; }
public byte[] GetAddressBytes() { throw null; }
public override int GetHashCode() { throw null; }
public static System.Net.NetworkInformation.PhysicalAddress Parse(string? address) { throw null; }
public static System.Net.NetworkInformation.PhysicalAddress Parse(ReadOnlySpan<char> address) { throw null; }
public static bool TryParse(string? address, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Net.NetworkInformation.PhysicalAddress? value) { throw null; }
public static bool TryParse(ReadOnlySpan<char> address, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Net.NetworkInformation.PhysicalAddress? value) { throw null; }
public override string ToString() { throw null; }
}
public enum PrefixOrigin
{
Other = 0,
Manual = 1,
WellKnown = 2,
Dhcp = 3,
RouterAdvertisement = 4,
}
public enum ScopeLevel
{
None = 0,
Interface = 1,
Link = 2,
Subnet = 3,
Admin = 4,
Site = 5,
Organization = 8,
Global = 14,
}
public enum SuffixOrigin
{
Other = 0,
Manual = 1,
WellKnown = 2,
OriginDhcp = 3,
LinkLayerAddress = 4,
Random = 5,
}
public abstract partial class TcpConnectionInformation
{
protected TcpConnectionInformation() { }
public abstract System.Net.IPEndPoint LocalEndPoint { get; }
public abstract System.Net.IPEndPoint RemoteEndPoint { get; }
public abstract System.Net.NetworkInformation.TcpState State { get; }
}
public enum TcpState
{
Unknown = 0,
Closed = 1,
Listen = 2,
SynSent = 3,
SynReceived = 4,
Established = 5,
FinWait1 = 6,
FinWait2 = 7,
CloseWait = 8,
Closing = 9,
LastAck = 10,
TimeWait = 11,
DeleteTcb = 12,
}
public abstract partial class TcpStatistics
{
protected TcpStatistics() { }
public abstract long ConnectionsAccepted { get; }
public abstract long ConnectionsInitiated { get; }
public abstract long CumulativeConnections { get; }
public abstract long CurrentConnections { get; }
public abstract long ErrorsReceived { get; }
public abstract long FailedConnectionAttempts { get; }
public abstract long MaximumConnections { get; }
public abstract long MaximumTransmissionTimeout { get; }
public abstract long MinimumTransmissionTimeout { get; }
public abstract long ResetConnections { get; }
public abstract long ResetsSent { get; }
public abstract long SegmentsReceived { get; }
public abstract long SegmentsResent { get; }
public abstract long SegmentsSent { get; }
}
public abstract partial class UdpStatistics
{
protected UdpStatistics() { }
public abstract long DatagramsReceived { get; }
public abstract long DatagramsSent { get; }
public abstract long IncomingDatagramsDiscarded { get; }
public abstract long IncomingDatagramsWithErrors { get; }
public abstract int UdpListeners { get; }
}
public abstract partial class UnicastIPAddressInformation : System.Net.NetworkInformation.IPAddressInformation
{
protected UnicastIPAddressInformation() { }
public abstract long AddressPreferredLifetime { get; }
public abstract long AddressValidLifetime { get; }
public abstract long DhcpLeaseLifetime { get; }
public abstract System.Net.NetworkInformation.DuplicateAddressDetectionState DuplicateAddressDetectionState { get; }
public abstract System.Net.IPAddress IPv4Mask { get; }
public virtual int PrefixLength { get { throw null; } }
public abstract System.Net.NetworkInformation.PrefixOrigin PrefixOrigin { get; }
public abstract System.Net.NetworkInformation.SuffixOrigin SuffixOrigin { get; }
}
public partial class UnicastIPAddressInformationCollection : System.Collections.Generic.ICollection<System.Net.NetworkInformation.UnicastIPAddressInformation>, System.Collections.Generic.IEnumerable<System.Net.NetworkInformation.UnicastIPAddressInformation>, System.Collections.IEnumerable
{
protected internal UnicastIPAddressInformationCollection() { }
public virtual int Count { get { throw null; } }
public virtual bool IsReadOnly { get { throw null; } }
public virtual System.Net.NetworkInformation.UnicastIPAddressInformation this[int index] { get { throw null; } }
public virtual void Add(System.Net.NetworkInformation.UnicastIPAddressInformation address) { }
public virtual void Clear() { }
public virtual bool Contains(System.Net.NetworkInformation.UnicastIPAddressInformation address) { throw null; }
public virtual void CopyTo(System.Net.NetworkInformation.UnicastIPAddressInformation[] array, int offset) { }
public virtual System.Collections.Generic.IEnumerator<System.Net.NetworkInformation.UnicastIPAddressInformation> GetEnumerator() { throw null; }
public virtual bool Remove(System.Net.NetworkInformation.UnicastIPAddressInformation address) { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/Common/tests/System/Xml/XPath/Common/XPathResultToken.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.Xml.XPath;
namespace XPathTests.Common
{
public class XPathResultToken
{
public XPathNodeType NodeType { get; set; }
public string BaseURI { get; set; }
public bool HasChildren { get; set; }
public bool HasAttributes { get; set; }
public bool IsEmptyElement { get; set; }
public string LocalName { get; set; }
public string Name { get; set; }
public string NamespaceURI { get; set; }
public bool HasNameTable { get; set; }
public string Prefix { get; set; }
public string Value { get; set; }
public string XmlLang { get; set; }
public XPathResultToken()
{
BaseURI = string.Empty;
LocalName = string.Empty;
Name = string.Empty;
NamespaceURI = string.Empty;
Prefix = string.Empty;
Value = string.Empty;
XmlLang = string.Empty;
}
}
}
| // 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.Xml.XPath;
namespace XPathTests.Common
{
public class XPathResultToken
{
public XPathNodeType NodeType { get; set; }
public string BaseURI { get; set; }
public bool HasChildren { get; set; }
public bool HasAttributes { get; set; }
public bool IsEmptyElement { get; set; }
public string LocalName { get; set; }
public string Name { get; set; }
public string NamespaceURI { get; set; }
public bool HasNameTable { get; set; }
public string Prefix { get; set; }
public string Value { get; set; }
public string XmlLang { get; set; }
public XPathResultToken()
{
BaseURI = string.Empty;
LocalName = string.Empty;
Name = string.Empty;
NamespaceURI = string.Empty;
Prefix = string.Empty;
Value = string.Empty;
XmlLang = string.Empty;
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b423721/c1.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 Test
{
public class C1<T>
{
public static string GetString()
{
return "foo";
}
}
public class C1Helper
{
public static bool IsFoo(string val)
{
return ((object)"foo" == (object)val);
}
}
}
| // 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 Test
{
public class C1<T>
{
public static string GetString()
{
return "foo";
}
}
public class C1Helper
{
public static bool IsFoo(string val)
{
return ((object)"foo" == (object)val);
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/jit64/regress/vsw/543229/test.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 AutoGen;
// We were receiving an assert on IA64 because the code we were using to determine if a range
// check statically fails was invalid.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50606.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AutoGen
{
public struct VType1
{
public sbyte f0;
public sbyte f1;
public VType1(int v)
{
f0 = ((sbyte)(v));
f1 = ((sbyte)(v));
}
}
public struct VType2
{
public long f0;
public long f1;
public VType2(int v)
{
f0 = ((long)(v));
f1 = ((long)(v));
}
}
public class Program
{
private int[] _callDepthTable;
private int[] _paramValueTable;
public Program()
{
_callDepthTable = new int[6];
_paramValueTable = new int[12];
int i;
for (i = 0; (i < _callDepthTable.Length); i = (i + 1))
{
_callDepthTable[i] = i;
}
for (i = 0; (i < _paramValueTable.Length); i = (i + 1))
{
_paramValueTable[i] = i;
}
}
public virtual VType1 Func1(VType1 p0, long p1, uint p2, VType2 p3)
{
if ((_callDepthTable[0] < 5))
{
_callDepthTable[0] = (_callDepthTable[0] + 1);
}
else
{
return p0;
}
int acc2 = 0;
int i2 = 0;
int[] arr02 = new int[5];
int[] arr12 = new int[5];
int[] arr22 = new int[5];
int[] arr32 = new int[5];
int[] arr42 = new int[5];
int[] arr52 = new int[5];
for (i2 = 0; (i2 < 5); i2 = (i2 + 1))
{
arr02[i2] = i2;
arr12[i2] = arr02[i2];
arr22[i2] = arr12[i2];
arr32[i2] = arr22[i2];
arr42[i2] = arr32[i2];
arr52[i2] = arr42[i2];
}
i2 = 0;
acc2 = 0;
for (; i2 < 5; i2++)
{
acc2 = (acc2 + arr02[i2]);
}
if ((acc2 == 0))
{
acc2 = arr02[10];
}
if ((acc2 == 1))
{
acc2 = arr12[10];
}
if ((acc2 == 2))
{
acc2 = arr22[10];
}
if ((acc2 == 3))
{
acc2 = arr32[10];
}
if ((acc2 == 4))
{
acc2 = arr42[10];
}
if ((acc2 == 5))
{
acc2 = arr52[10];
}
if ((acc2 == 6))
{
acc2 = arr02[10];
}
if ((acc2 == 7))
{
acc2 = arr12[10];
}
if ((acc2 == 8))
{
acc2 = arr22[10];
}
if ((acc2 == 9))
{
acc2 = arr32[10];
}
int i4 = 0;
int[] arr04 = new int[7];
int[] arr14 = new int[7];
int[] arr24 = new int[7];
int[] arr34 = new int[7];
int[] arr44 = new int[7];
for (i4 = 0; (i4 < 7); i4 = (i4 + 1))
{
arr04[i4] = i4;
arr14[i4] = arr04[i4];
arr24[i4] = arr14[i4];
arr34[i4] = arr24[i4];
arr44[i4] = arr34[i4];
}
int acc5 = 0;
int i5 = 0;
int[] arr05 = new int[3];
int[] arr15 = new int[3];
int[] arr25 = new int[3];
int[] arr35 = new int[3];
int[] arr45 = new int[3];
int[] arr55 = new int[3];
for (i5 = 0; (i5 < 3); i5 = (i5 + 1))
{
arr05[i5] = i5;
arr15[i5] = arr05[i5];
arr25[i5] = arr15[i5];
arr35[i5] = arr25[i5];
arr45[i5] = arr35[i5];
arr55[i5] = arr45[i5];
}
i5 = 0;
acc5 = 0;
for (; (i5 < 3); i5 = (i5 + 1))
{
acc5 = (acc5 + arr05[i5]);
for (; (i5 < 3); i5 = (i5 + 1))
{
acc5 = (acc5 + arr15[i5]);
for (; (i5 < 3); i5 = (i5 + 1))
{
acc5 = (acc5 + arr25[i5]);
for (; (i5 < 3); i5 = (i5 + 1))
{
acc5 = (acc5 + arr35[i5]);
for (; (i5 < 3); i5 = (i5 + 1))
{
acc5 = (acc5 + arr45[i5]);
for (; (i5 < 3); i5 = (i5 + 1))
{
acc5 = (acc5 + arr55[i5]);
}
}
}
}
}
}
if ((acc5 == 0))
{
acc5 = arr05[3];
}
if ((acc5 == 1))
{
acc5 = arr15[3];
}
if ((acc5 == 2))
{
acc5 = arr25[3];
}
if ((arr05.Length < 0))
{
goto L2;
}
acc5 = 0;
bool stop2 = (arr05.Length > 0);
for (i5 = 0; (stop2
&& (i5 <= arr05[i5])); i5 = (i5 + 1))
{
arr05[i5] = i5;
acc5 = (acc5 + arr05[i5]);
for (i5 = 0; (stop2
&& (i5 <= arr15[i5])); i5 = (i5 + 1))
{
acc5 = (acc5 + arr15[i5]);
i5 = arr15[i5];
for (i5 = 0; (stop2
&& (i5 <= arr25[i5])); i5 = (i5 + 1))
{
acc5 = (acc5 + arr25[i5]);
for (i5 = 0; (stop2
&& (i5 <= arr35[i5])); i5 = (i5 + 1))
{
acc5 = (acc5 + arr35[i5]);
for (i5 = 0; (stop2
&& (i5 <= arr45[i5])); i5 = (i5 + 1))
{
acc5 = (acc5 + arr45[i5]);
for (i5 = 0; (stop2
&& (i5 <= arr55[i5])); i5 = (i5 + 1))
{
acc5 = (acc5 + arr55[i5]);
i5 = arr55[i5];
stop2 = (i5 < 2);
}
stop2 = (i5 < 2);
}
stop2 = (i5 < 2);
}
stop2 = (i5 < 2);
}
stop2 = (i5 < 2);
}
stop2 = (i5 < 2);
}
L2:
i5 = 0;
int acc6 = 0;
int i6 = 0;
int[] arr6 = new int[4];
for (i6 = 0; i6 < 4; i6++)
{
arr6[i6] = i6;
}
i6 = 0;
acc6 = 0;
for (; i6 < 4; i6++)
{
acc6 = (acc6 + arr6[i6]);
}
if ((acc6 == 0))
{
acc6 = arr6[6];
}
return p0;
}
public virtual int Run()
{
try
{
this.Func1(new VType1(_paramValueTable[10]), ((long)(_paramValueTable[6])), ((uint)(_paramValueTable[5])), new VType2(_paramValueTable[11]));
}
catch (System.Exception exp)
{
System.Console.WriteLine("Application Check Failed!");
System.Console.WriteLine(exp);
return 1;
}
return 100;
}
public static int Main()
{
Program prog = new Program();
int rc = prog.Run();
System.Console.WriteLine("rc = {0}", rc);
return rc;
}
}
}
| // 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 AutoGen;
// We were receiving an assert on IA64 because the code we were using to determine if a range
// check statically fails was invalid.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50606.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AutoGen
{
public struct VType1
{
public sbyte f0;
public sbyte f1;
public VType1(int v)
{
f0 = ((sbyte)(v));
f1 = ((sbyte)(v));
}
}
public struct VType2
{
public long f0;
public long f1;
public VType2(int v)
{
f0 = ((long)(v));
f1 = ((long)(v));
}
}
public class Program
{
private int[] _callDepthTable;
private int[] _paramValueTable;
public Program()
{
_callDepthTable = new int[6];
_paramValueTable = new int[12];
int i;
for (i = 0; (i < _callDepthTable.Length); i = (i + 1))
{
_callDepthTable[i] = i;
}
for (i = 0; (i < _paramValueTable.Length); i = (i + 1))
{
_paramValueTable[i] = i;
}
}
public virtual VType1 Func1(VType1 p0, long p1, uint p2, VType2 p3)
{
if ((_callDepthTable[0] < 5))
{
_callDepthTable[0] = (_callDepthTable[0] + 1);
}
else
{
return p0;
}
int acc2 = 0;
int i2 = 0;
int[] arr02 = new int[5];
int[] arr12 = new int[5];
int[] arr22 = new int[5];
int[] arr32 = new int[5];
int[] arr42 = new int[5];
int[] arr52 = new int[5];
for (i2 = 0; (i2 < 5); i2 = (i2 + 1))
{
arr02[i2] = i2;
arr12[i2] = arr02[i2];
arr22[i2] = arr12[i2];
arr32[i2] = arr22[i2];
arr42[i2] = arr32[i2];
arr52[i2] = arr42[i2];
}
i2 = 0;
acc2 = 0;
for (; i2 < 5; i2++)
{
acc2 = (acc2 + arr02[i2]);
}
if ((acc2 == 0))
{
acc2 = arr02[10];
}
if ((acc2 == 1))
{
acc2 = arr12[10];
}
if ((acc2 == 2))
{
acc2 = arr22[10];
}
if ((acc2 == 3))
{
acc2 = arr32[10];
}
if ((acc2 == 4))
{
acc2 = arr42[10];
}
if ((acc2 == 5))
{
acc2 = arr52[10];
}
if ((acc2 == 6))
{
acc2 = arr02[10];
}
if ((acc2 == 7))
{
acc2 = arr12[10];
}
if ((acc2 == 8))
{
acc2 = arr22[10];
}
if ((acc2 == 9))
{
acc2 = arr32[10];
}
int i4 = 0;
int[] arr04 = new int[7];
int[] arr14 = new int[7];
int[] arr24 = new int[7];
int[] arr34 = new int[7];
int[] arr44 = new int[7];
for (i4 = 0; (i4 < 7); i4 = (i4 + 1))
{
arr04[i4] = i4;
arr14[i4] = arr04[i4];
arr24[i4] = arr14[i4];
arr34[i4] = arr24[i4];
arr44[i4] = arr34[i4];
}
int acc5 = 0;
int i5 = 0;
int[] arr05 = new int[3];
int[] arr15 = new int[3];
int[] arr25 = new int[3];
int[] arr35 = new int[3];
int[] arr45 = new int[3];
int[] arr55 = new int[3];
for (i5 = 0; (i5 < 3); i5 = (i5 + 1))
{
arr05[i5] = i5;
arr15[i5] = arr05[i5];
arr25[i5] = arr15[i5];
arr35[i5] = arr25[i5];
arr45[i5] = arr35[i5];
arr55[i5] = arr45[i5];
}
i5 = 0;
acc5 = 0;
for (; (i5 < 3); i5 = (i5 + 1))
{
acc5 = (acc5 + arr05[i5]);
for (; (i5 < 3); i5 = (i5 + 1))
{
acc5 = (acc5 + arr15[i5]);
for (; (i5 < 3); i5 = (i5 + 1))
{
acc5 = (acc5 + arr25[i5]);
for (; (i5 < 3); i5 = (i5 + 1))
{
acc5 = (acc5 + arr35[i5]);
for (; (i5 < 3); i5 = (i5 + 1))
{
acc5 = (acc5 + arr45[i5]);
for (; (i5 < 3); i5 = (i5 + 1))
{
acc5 = (acc5 + arr55[i5]);
}
}
}
}
}
}
if ((acc5 == 0))
{
acc5 = arr05[3];
}
if ((acc5 == 1))
{
acc5 = arr15[3];
}
if ((acc5 == 2))
{
acc5 = arr25[3];
}
if ((arr05.Length < 0))
{
goto L2;
}
acc5 = 0;
bool stop2 = (arr05.Length > 0);
for (i5 = 0; (stop2
&& (i5 <= arr05[i5])); i5 = (i5 + 1))
{
arr05[i5] = i5;
acc5 = (acc5 + arr05[i5]);
for (i5 = 0; (stop2
&& (i5 <= arr15[i5])); i5 = (i5 + 1))
{
acc5 = (acc5 + arr15[i5]);
i5 = arr15[i5];
for (i5 = 0; (stop2
&& (i5 <= arr25[i5])); i5 = (i5 + 1))
{
acc5 = (acc5 + arr25[i5]);
for (i5 = 0; (stop2
&& (i5 <= arr35[i5])); i5 = (i5 + 1))
{
acc5 = (acc5 + arr35[i5]);
for (i5 = 0; (stop2
&& (i5 <= arr45[i5])); i5 = (i5 + 1))
{
acc5 = (acc5 + arr45[i5]);
for (i5 = 0; (stop2
&& (i5 <= arr55[i5])); i5 = (i5 + 1))
{
acc5 = (acc5 + arr55[i5]);
i5 = arr55[i5];
stop2 = (i5 < 2);
}
stop2 = (i5 < 2);
}
stop2 = (i5 < 2);
}
stop2 = (i5 < 2);
}
stop2 = (i5 < 2);
}
stop2 = (i5 < 2);
}
L2:
i5 = 0;
int acc6 = 0;
int i6 = 0;
int[] arr6 = new int[4];
for (i6 = 0; i6 < 4; i6++)
{
arr6[i6] = i6;
}
i6 = 0;
acc6 = 0;
for (; i6 < 4; i6++)
{
acc6 = (acc6 + arr6[i6]);
}
if ((acc6 == 0))
{
acc6 = arr6[6];
}
return p0;
}
public virtual int Run()
{
try
{
this.Func1(new VType1(_paramValueTable[10]), ((long)(_paramValueTable[6])), ((uint)(_paramValueTable[5])), new VType2(_paramValueTable[11]));
}
catch (System.Exception exp)
{
System.Console.WriteLine("Application Check Failed!");
System.Console.WriteLine(exp);
return 1;
}
return 100;
}
public static int Main()
{
Program prog = new Program();
int rc = prog.Run();
System.Console.WriteLine("rc = {0}", rc);
return rc;
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/Methodical/explicit/funcptr/seq_funcptr_val.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 extern System.Console
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )
.ver 4:0:0:0
}
.assembly 'seq_funcptr_val'
{
// bool) = ( 01 00 00 01 00 00 )
}
.assembly extern xunit.core {}
// MVID: {CF23CD68-3FF2-4D1F-B49B-866DA656D91D}
.file alignment 512
// Image base: 0x03060000
//
// ============== CLASS STRUCTURE DECLARATION ==================
//
// =============================================================
// =============== GLOBAL FIELDS AND METHODS ===================
// =============================================================
// =============== CLASS MEMBERS DECLARATION ===================
// note that class flags, 'extends' and 'implements' clauses
// are provided here for information only
.class private sequential ansi sealed beforefieldinit AA
extends [mscorlib]System.ValueType
{
.field public unsigned int8 tmp1
.field public unsigned int8 tmp2
.field public unsigned int8 tmp3
.field private native int func_ptr
.field public unsigned int8 tmp4
.method private hidebysig static int32 ret_code() cil managed
{
// Code size 7 (0x7)
.maxstack 1
ldc.i4.s 100
ret
} // end of method AA::ret_code
.method private hidebysig static int32
Main() cil managed
{
.custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = (
01 00 00 00
)
.entrypoint
// Code size 31 (0x1f)
.maxstack 3
.locals init (valuetype AA V_0, int32 V_1)
ldloca.s V_0
ldftn int32 AA::ret_code()
stfld native int AA::func_ptr
ldloca.s V_0
ldfld native int AA::func_ptr
calli int32 *()
ret
} // end of method AA::Main
} // end of class AA
// =============================================================
//*********** DISASSEMBLY COMPLETE ***********************
// WARNING: Created Win32 resource file funcptr_val.res
| // 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 extern System.Console
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )
.ver 4:0:0:0
}
.assembly 'seq_funcptr_val'
{
// bool) = ( 01 00 00 01 00 00 )
}
.assembly extern xunit.core {}
// MVID: {CF23CD68-3FF2-4D1F-B49B-866DA656D91D}
.file alignment 512
// Image base: 0x03060000
//
// ============== CLASS STRUCTURE DECLARATION ==================
//
// =============================================================
// =============== GLOBAL FIELDS AND METHODS ===================
// =============================================================
// =============== CLASS MEMBERS DECLARATION ===================
// note that class flags, 'extends' and 'implements' clauses
// are provided here for information only
.class private sequential ansi sealed beforefieldinit AA
extends [mscorlib]System.ValueType
{
.field public unsigned int8 tmp1
.field public unsigned int8 tmp2
.field public unsigned int8 tmp3
.field private native int func_ptr
.field public unsigned int8 tmp4
.method private hidebysig static int32 ret_code() cil managed
{
// Code size 7 (0x7)
.maxstack 1
ldc.i4.s 100
ret
} // end of method AA::ret_code
.method private hidebysig static int32
Main() cil managed
{
.custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = (
01 00 00 00
)
.entrypoint
// Code size 31 (0x1f)
.maxstack 3
.locals init (valuetype AA V_0, int32 V_1)
ldloca.s V_0
ldftn int32 AA::ret_code()
stfld native int AA::func_ptr
ldloca.s V_0
ldfld native int AA::func_ptr
calli int32 *()
ret
} // end of method AA::Main
} // end of class AA
// =============================================================
//*********** DISASSEMBLY COMPLETE ***********************
// WARNING: Created Win32 resource file funcptr_val.res
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Drawing.Common/tests/Drawing2D/GraphicsPathTests.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
// Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections.Generic;
using System.ComponentModel;
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
namespace System.Drawing.Drawing2D.Tests
{
public class GraphicsPathTests
{
private const float Pi4 = (float)(Math.PI / 4);
private const float Delta = 0.0003f;
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Ctor_Default_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
Assert.Equal(FillMode.Alternate, gp.FillMode);
AssertEmptyGrahicsPath(gp);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Ctor_FillMode_Success()
{
using (GraphicsPath gpa = new GraphicsPath(FillMode.Alternate))
using (GraphicsPath gpw = new GraphicsPath(FillMode.Winding))
{
Assert.Equal(FillMode.Alternate, gpa.FillMode);
AssertEmptyGrahicsPath(gpa);
Assert.Equal(FillMode.Winding, gpw.FillMode);
AssertEmptyGrahicsPath(gpw);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Ctor_SamePoints_Success()
{
byte[] types = new byte[6] { 0, 1, 1, 1, 1, 1 };
Point[] points = new Point[]
{
new Point (1, 1), new Point (1, 1), new Point (1, 1),
new Point (1, 1), new Point (1, 1), new Point (1, 1),
};
PointF[] fPoints = new PointF[]
{
new PointF (1f, 1f), new PointF (1f, 1f), new PointF (1f, 1f),
new PointF (1f, 1f), new PointF (1f, 1f), new PointF (1f, 1f),
};
using (GraphicsPath gp = new GraphicsPath(points, types))
using (GraphicsPath gpf = new GraphicsPath(fPoints, types))
{
Assert.Equal(FillMode.Alternate, gp.FillMode);
Assert.Equal(6, gp.PointCount);
Assert.Equal(FillMode.Alternate, gpf.FillMode);
Assert.Equal(6, gpf.PointCount);
types[0] = 1;
Assert.Equal(FillMode.Alternate, gp.FillMode);
Assert.Equal(6, gp.PointCount);
Assert.Equal(FillMode.Alternate, gpf.FillMode);
Assert.Equal(6, gpf.PointCount);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Ctor_PointsNull_ThrowsArgumentNullException()
{
AssertExtensions.Throws<ArgumentNullException>("pts", () => new GraphicsPath((Point[])null, new byte[1]));
}
public static IEnumerable<object[]> AddCurve_PointsTypesLengthMismatch_TestData()
{
yield return new object[] { 1, 2 };
yield return new object[] { 2, 1 };
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(AddCurve_PointsTypesLengthMismatch_TestData))]
public void Ctor_PointsTypesLengthMismatch_ThrowsArgumentException(int pointsLength, int typesLength)
{
AssertExtensions.Throws<ArgumentException>(null, () => new GraphicsPath(new Point[pointsLength], new byte[typesLength]));
AssertExtensions.Throws<ArgumentException>(null, () => new GraphicsPath(new PointF[pointsLength], new byte[typesLength]));
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Clone_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
Assert.Equal(FillMode.Alternate, clone.FillMode);
AssertEmptyGrahicsPath(clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reset_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.Reset();
Assert.Equal(FillMode.Alternate, gp.FillMode);
AssertEmptyGrahicsPath(gp);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void GraphicsPath_FillModeChange()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.FillMode = FillMode.Winding;
Assert.Equal(FillMode.Winding, gp.FillMode);
}
}
[ConditionalTheory(Helpers.IsWindowsOrAtLeastLibgdiplus6)]
[InlineData(FillMode.Alternate - 1)]
[InlineData(FillMode.Winding + 1)]
public void GraphicsPath_InvalidFillMode_ThrowsInvalidEnumArgumentException(FillMode fillMode)
{
using (GraphicsPath gp = new GraphicsPath())
{
Assert.ThrowsAny<ArgumentException>(() => gp.FillMode = fillMode);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void PathData_ReturnsExpected()
{
using (GraphicsPath gp = new GraphicsPath())
{
Assert.Equal(0, gp.PathData.Points.Length);
Assert.Equal(0, gp.PathData.Types.Length);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void PathData_CannotChange()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddRectangle(new Rectangle(1, 1, 2, 2));
Assert.Equal(1f, gp.PathData.Points[0].X);
Assert.Equal(1f, gp.PathData.Points[0].Y);
gp.PathData.Points[0] = new Point(0, 0);
Assert.Equal(1f, gp.PathData.Points[0].X);
Assert.Equal(1f, gp.PathData.Points[0].Y);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void PathPoints_CannotChange()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddRectangle(new Rectangle(1, 1, 2, 2));
Assert.Equal(1f, gp.PathPoints[0].X);
Assert.Equal(1f, gp.PathPoints[0].Y);
gp.PathPoints[0] = new Point(0, 0);
Assert.Equal(1f, gp.PathPoints[0].X);
Assert.Equal(1f, gp.PathPoints[0].Y);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void PathPoints_EmptyPath_ThrowsArgumentException()
{
using (GraphicsPath gp = new GraphicsPath())
{
Assert.Throws<ArgumentException>(() => gp.PathPoints);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void PathTypes_CannotChange()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddRectangle(new Rectangle(1, 1, 2, 2));
Assert.Equal(0, gp.PathTypes[0]);
gp.PathTypes[0] = 1;
Assert.Equal(0, gp.PathTypes[0]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void PathTypes_EmptyPath_ThrowsArgumentException()
{
using (GraphicsPath gp = new GraphicsPath())
{
Assert.Throws<ArgumentException>(() => gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void GetLastPoint_ReturnsExpected()
{
byte[] types = new byte[3] { 0, 1, 1 };
PointF[] points = new PointF[]
{
new PointF (1f, 1f), new PointF (2f, 2f), new PointF (3f, 3f),
};
using (GraphicsPath gp = new GraphicsPath(points, types))
{
Assert.Equal(gp.GetLastPoint(), points[2]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddLine_Success()
{
using (GraphicsPath gpInt = new GraphicsPath())
using (GraphicsPath gpFloat = new GraphicsPath())
using (GraphicsPath gpPointsInt = new GraphicsPath())
using (GraphicsPath gpfPointsloat = new GraphicsPath())
{
gpInt.AddLine(1, 1, 2, 2);
// AssertLine() method expects line drawn between points with coordinates 1, 1 and 2, 2, here and below.
AssertLine(gpInt);
gpFloat.AddLine(1, 1, 2, 2);
AssertLine(gpFloat);
gpPointsInt.AddLine(new Point(1, 1), new Point(2, 2));
AssertLine(gpPointsInt);
gpfPointsloat.AddLine(new PointF(1, 1), new PointF(2, 2));
AssertLine(gpfPointsloat);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddLine_SamePoints_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddLine(new Point(49, 157), new Point(75, 196));
gpi.AddLine(new Point(75, 196), new Point(102, 209));
Assert.Equal(3, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 1 }, gpi.PathTypes);
gpi.AddLine(new Point(102, 209), new Point(75, 196));
Assert.Equal(4, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 1, 1 }, gpi.PathTypes);
gpf.AddLine(new PointF(49, 157), new PointF(75, 196));
gpf.AddLine(new PointF(75, 196), new PointF(102, 209));
Assert.Equal(3, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 1 }, gpf.PathTypes);
gpf.AddLine(new PointF(102, 209), new PointF(75, 196));
Assert.Equal(4, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 1, 1 }, gpf.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddLines_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddLines(new Point[] { new Point(1, 1), new Point(2, 2) });
AssertLine(gpi);
gpf.AddLines(new PointF[] { new PointF(1, 1), new PointF(2, 2) });
AssertLine(gpf);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddLines_SinglePoint_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddLines(new PointF[] { new PointF(1, 1) });
Assert.Equal(1, gpi.PointCount);
Assert.Equal(0, gpi.PathTypes[0]);
gpf.AddLines(new PointF[] { new PointF(1, 1) });
Assert.Equal(1, gpf.PointCount);
Assert.Equal(0, gpf.PathTypes[0]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddLines_SamePoint_Success()
{
Point[] intPoints = new Point[]
{
new Point(49, 157), new Point(49, 157)
};
PointF[] floatPoints = new PointF[]
{
new PointF(49, 57), new PointF(49, 57),
new PointF(49, 57), new PointF(49, 57)
};
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddLines(intPoints);
Assert.Equal(2, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1 }, gpi.PathTypes);
gpi.AddLines(intPoints);
Assert.Equal(3, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 1 }, gpi.PathTypes);
gpi.AddLines(intPoints);
Assert.Equal(4, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 1, 1 }, gpi.PathTypes);
gpf.AddLines(floatPoints);
Assert.Equal(4, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 1, 1 }, gpf.PathTypes);
gpf.AddLines(floatPoints);
Assert.Equal(7, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 1, 1, 1, 1, 1 }, gpf.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddLines_PointsNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("points", () => new GraphicsPath().AddLines((Point[])null));
AssertExtensions.Throws<ArgumentNullException>("points", () => new GraphicsPath().AddLines((PointF[])null));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddLines_ZeroPoints_ThrowsArgumentException()
{
AssertExtensions.Throws<ArgumentException>("points", null, () => new GraphicsPath().AddLines(new Point[0]));
AssertExtensions.Throws<ArgumentException>("points", null, () => new GraphicsPath().AddLines(new PointF[0]));
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddArc_Values_Success()
{
if (PlatformDetection.IsArmOrArm64Process)
{
//ActiveIssue: 35744
throw new SkipTestException("Precision on float numbers");
}
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddArc(1, 1, 2, 2, Pi4, Pi4);
// AssertArc() method expects added Arc with parameters
// x=1, y=1, width=2, height=2, startAngle=Pi4, seewpAngle=Pi4 here and below.
AssertArc(gpi);
gpf.AddArc(1f, 1f, 2f, 2f, Pi4, Pi4);
AssertArc(gpf);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddArc_Rectangle_Success()
{
if (PlatformDetection.IsArmOrArm64Process)
{
//ActiveIssue: 35744
throw new SkipTestException("Precision on float numbers");
}
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddArc(new Rectangle(1, 1, 2, 2), Pi4, Pi4);
AssertArc(gpi);
gpf.AddArc(new RectangleF(1, 1, 2, 2), Pi4, Pi4);
AssertArc(gpf);
}
}
[ConditionalTheory(Helpers.IsWindowsOrAtLeastLibgdiplus6)]
[InlineData(0, 0)]
[InlineData(1, 0)]
[InlineData(0, 1)]
public void AddArc_ZeroWidthHeight_ThrowsArgumentException(int width, int height)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddArc(1, 1, width, height, Pi4, Pi4));
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddArc(1.0f, 1.0f, (float)width, (float)height, Pi4, Pi4));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddBezier_Points_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddBezier(new Point(1, 1), new Point(2, 2), new Point(3, 3), new Point(4, 4));
// AssertBezier() method expects added Bezier with points (1, 1), (2, 2), (3, 3), (4, 4), here and below.
AssertBezier(gpi);
gpf.AddBezier(new PointF(1, 1), new PointF(2, 2), new PointF(3, 3), new PointF(4, 4));
AssertBezier(gpf);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddBezier_SamePoints_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gp.AddBezier(new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0));
Assert.Equal(4, gp.PointCount);
Assert.Equal(new byte[] { 0, 3, 3, 3 }, gp.PathTypes);
gp.AddBezier(new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0));
Assert.Equal(7, gp.PointCount);
Assert.Equal(new byte[] { 0, 3, 3, 3, 3, 3, 3 }, gp.PathTypes);
gpf.AddBezier(new PointF(0, 0), new PointF(0, 0), new PointF(0, 0), new PointF(0, 0));
Assert.Equal(4, gpf.PointCount);
Assert.Equal(new byte[] { 0, 3, 3, 3 }, gpf.PathTypes);
gpf.AddBezier(new PointF(0, 0), new PointF(0, 0), new PointF(0, 0), new PointF(0, 0));
Assert.Equal(7, gpf.PointCount);
Assert.Equal(new byte[] { 0, 3, 3, 3, 3, 3, 3 }, gpf.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddBezier_Values_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddBezier(1, 1, 2, 2, 3, 3, 4, 4);
AssertBezier(gpi);
gpf.AddBezier(1f, 1f, 2f, 2f, 3f, 3f, 4f, 4f);
AssertBezier(gpf);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddBeziers_Points_Success()
{
PointF[] points = new PointF[]
{
new PointF(1, 1), new PointF(2, 2), new PointF(3, 3), new PointF(4, 4)
};
using (GraphicsPath gpf = new GraphicsPath())
{
gpf.AddBeziers(points);
AssertBezier(gpf);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddBeziers_PointsNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("points", () => gp.AddBeziers((PointF[])null));
AssertExtensions.Throws<ArgumentNullException>("points", () => gp.AddBeziers((Point[])null));
}
}
public static IEnumerable<object[]> AddBeziers_InvalidFloatPointsLength_TestData()
{
yield return new object[] { new PointF[0] };
yield return new object[] { new PointF[1] { new PointF(1f, 1f) } };
yield return new object[] { new PointF[2] { new PointF(1f, 1f), new PointF(2f, 2f) } };
yield return new object[] { new PointF[3] { new PointF(1f, 1f), new PointF(2f, 2f), new PointF(3f, 3f) } };
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(AddBeziers_InvalidFloatPointsLength_TestData))]
public void AddBeziers_InvalidFloatPointsLength_ThrowsArgumentException(PointF[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddBeziers(points));
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddCurve_TwoPoints_Success()
{
Point[] intPoints = new Point[] { new Point(1, 1), new Point(2, 2) };
PointF[] floatPoints = new PointF[] { new PointF(1, 1), new PointF(2, 2) };
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpf.AddCurve(floatPoints);
// AssertCurve() method expects added Curve with points (1, 1), (2, 2), here and below.
AssertCurve(gpf);
gpi.AddCurve(intPoints);
AssertCurve(gpi);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddCurve_TwoPointsWithTension_Success()
{
Point[] intPoints = new Point[] { new Point(1, 1), new Point(2, 2) };
PointF[] floatPoints = new PointF[] { new PointF(1, 1), new PointF(2, 2) };
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddCurve(intPoints, 0.5f);
AssertCurve(gpi);
gpf.AddCurve(floatPoints, 0.5f);
AssertCurve(gpf);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddCurve_SamePoints_Success()
{
Point[] intPoints = new Point[] { new Point(1, 1), new Point(1, 1) };
PointF[] floatPoints = new PointF[] { new PointF(1, 1), new PointF(1, 1) };
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddCurve(intPoints);
Assert.Equal(4, gpi.PointCount);
gpi.AddCurve(intPoints);
Assert.Equal(7, gpi.PointCount);
gpf.AddCurve(floatPoints);
Assert.Equal(4, gpf.PointCount);
gpf.AddCurve(floatPoints);
Assert.Equal(7, gpf.PointCount);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddCurve_LargeTension_Success()
{
Point[] intPoints = new Point[] { new Point(1, 1), new Point(2, 2) };
PointF[] floatPoints = new PointF[] { new PointF(1, 1), new PointF(2, 2) };
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddCurve(intPoints, float.MaxValue);
Assert.Equal(4, gpi.PointCount);
gpf.AddCurve(floatPoints, float.MaxValue);
Assert.Equal(4, gpf.PointCount);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddCurve_Success()
{
PointF[] points = new PointF[]
{
new PointF (37f, 185f),
new PointF (99f, 185f),
new PointF (161f, 159f),
new PointF (223f, 185f),
new PointF (285f, 54f),
};
PointF[] expectedPoints = new PointF[]
{
new PointF (37f, 185f),
new PointF (47.33333f, 185f),
new PointF (78.3333f, 189.3333f),
new PointF (99f, 185f),
new PointF (119.6667f, 180.6667f),
new PointF (140.3333f, 159f),
new PointF (161f, 159f),
new PointF (181.6667f, 159f),
new PointF (202.3333f, 202.5f),
new PointF (223f, 185f),
new PointF (243.6667f, 167.5f),
new PointF (274.6667f, 75.8333f),
new PointF (285f, 54f),
};
byte[] expectedTypes = new byte[] { 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 };
int[] pointsCount = { 4, 7, 10, 13 };
using (GraphicsPath gp = new GraphicsPath())
{
for (int i = 0; i < points.Length - 1; i++)
{
gp.AddCurve(points, i, 1, 0.5f);
Assert.Equal(pointsCount[i], gp.PointCount);
}
AssertPointsSequenceEqual(expectedPoints, gp.PathPoints, Delta);
Assert.Equal(expectedTypes, gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddCurve_PointsNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("points", () => gp.AddCurve((PointF[])null));
AssertExtensions.Throws<ArgumentNullException>("points", () => gp.AddCurve((Point[])null));
}
}
public static IEnumerable<object[]> AddCurve_InvalidFloatPointsLength_TestData()
{
yield return new object[] { new PointF[0] };
yield return new object[] { new PointF[1] { new PointF(1f, 1f) } };
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(AddCurve_InvalidFloatPointsLength_TestData))]
public void AddCurve_InvalidFloatPointsLength_ThrowsArgumentException(PointF[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddCurve(points));
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddCurve(points, 0, 2, 0.5f));
}
}
public static IEnumerable<object[]> AddCurve_InvalidPointsLength_TestData()
{
yield return new object[] { new Point[0] };
yield return new object[] { new Point[1] { new Point(1, 1) } };
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(AddCurve_InvalidPointsLength_TestData))]
public void AddCurve_InvalidPointsLength_ThrowsArgumentException(Point[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddCurve(points));
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddCurve(points, 0, 2, 0.5f));
}
}
public static IEnumerable<object[]> AddCurve_InvalidSegment_TestData()
{
yield return new object[] { 0 };
yield return new object[] { -1 };
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(AddCurve_InvalidSegment_TestData))]
public void AddCurve_InvalidSegment_ThrowsArgumentException(int segment)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddCurve(
new PointF[2] { new PointF(1f, 1f), new PointF(2f, 2f) }, 0, segment, 0.5f));
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddCurve(
new Point[2] { new Point(1, 1), new Point(2, 2) }, 0, segment, 0.5f));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddCurve_OffsetTooLarge_ThrowsArgumentException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddCurve(
new PointF[3] { new PointF(1f, 1f), new PointF(0f, 20f), new PointF(20f, 0f) }, 1, 2, 0.5f));
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddCurve(
new Point[3] { new Point(1, 1), new Point(0, 20), new Point(20, 0) }, 1, 2, 0.5f));
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddClosedCurve_Points_Success()
{
if (PlatformDetection.IsArmOrArm64Process)
{
//ActiveIssue: 35744
throw new SkipTestException("Precision on float numbers");
}
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddClosedCurve(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) });
// AssertClosedCurve() method expects added ClosedCurve with points (1, 1), (2, 2), (3, 3), here and below.
AssertClosedCurve(gpi);
gpf.AddClosedCurve(new PointF[3] { new PointF(1, 1), new PointF(2, 2), new PointF(3, 3) });
AssertClosedCurve(gpf);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddClosedCurve_SamePoints_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddClosedCurve(new Point[3] { new Point(1, 1), new Point(1, 1), new Point(1, 1) });
Assert.Equal(10, gpi.PointCount);
gpi.AddClosedCurve(new Point[3] { new Point(1, 1), new Point(1, 1), new Point(1, 1) });
Assert.Equal(20, gpi.PointCount);
gpf.AddClosedCurve(new PointF[3] { new PointF(1, 1), new PointF(1, 1), new PointF(1, 1) });
Assert.Equal(10, gpf.PointCount);
gpf.AddClosedCurve(new PointF[3] { new PointF(1, 1), new PointF(1, 1), new PointF(1, 1) });
Assert.Equal(20, gpf.PointCount);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddClosedCurve_Tension_Success()
{
if (PlatformDetection.IsArmOrArm64Process)
{
//ActiveIssue: 35744
throw new SkipTestException("Precision on float numbers");
}
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddClosedCurve(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) }, 0.5f);
AssertClosedCurve(gpi);
gpf.AddClosedCurve(new PointF[3] { new PointF(1, 1), new PointF(2, 2), new PointF(3, 3) }, 0.5f);
AssertClosedCurve(gpf);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddClosedCurve_PointsNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("points", () => gp.AddClosedCurve((PointF[])null));
AssertExtensions.Throws<ArgumentNullException>("points", () => gp.AddClosedCurve((Point[])null));
}
}
public static IEnumerable<object[]> AddClosedCurve_InvalidPointsLength_TestData()
{
yield return new object[] { new Point[0] };
yield return new object[] { new Point[1] { new Point(1, 1) } };
yield return new object[] { new Point[2] { new Point(1, 1), new Point(2, 2) } };
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(AddCurve_InvalidPointsLength_TestData))]
public void AddClosedCurve_InvalidPointsLength_ThrowsArgumentException(Point[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddClosedCurve(points));
}
}
public static IEnumerable<object[]> AddClosedCurve_InvalidFloatPointsLength_TestData()
{
yield return new object[] { new PointF[0] };
yield return new object[] { new PointF[1] { new PointF(1f, 1f) } };
yield return new object[] { new PointF[2] { new PointF(1f, 1f), new PointF(2f, 2f) } };
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(AddClosedCurve_InvalidFloatPointsLength_TestData))]
public void AddClosedCurve_InvalidFloatPointsLength_ThrowsArgumentException(PointF[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddClosedCurve(points));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddRectangle_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddRectangle(new Rectangle(1, 1, 2, 2));
// AssertRectangle() method expects added Rectangle with parameters x=1, y=1, width=2, height=2, here and below.
AssertRectangle(gpi);
gpf.AddRectangle(new RectangleF(1, 1, 2, 2));
AssertRectangle(gpf);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddRectangle_SameRectangles_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddRectangle(new Rectangle(1, 1, 1, 1));
Assert.Equal(4, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 1, 129 }, gpi.PathTypes);
PointF endI = gpi.PathPoints[3];
gpi.AddRectangle(new Rectangle((int)endI.X, (int)endI.Y, 1, 1));
Assert.Equal(8, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 1, 129, 0, 1, 1, 129 }, gpi.PathTypes);
gpf.AddRectangle(new RectangleF(1, 1, 1, 1));
Assert.Equal(4, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 1, 129 }, gpf.PathTypes);
Assert.Equal(129, gpf.PathTypes[3]);
PointF endF = gpf.PathPoints[3];
gpf.AddRectangle(new RectangleF(endF.X, endF.Y, 1, 1));
Assert.Equal(8, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 1, 129, 0, 1, 1, 129 }, gpf.PathTypes);
}
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[InlineData(0, 0)]
[InlineData(3, 0)]
[InlineData(0, 4)]
public void AddRectangle_ZeroWidthHeight_Success(int width, int height)
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddRectangle(new Rectangle(1, 2, width, height));
Assert.Equal(0, gpi.PathData.Points.Length);
gpf.AddRectangle(new RectangleF(1f, 2f, (float)width, (float)height));
Assert.Equal(0, gpf.PathData.Points.Length);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddRectangles_Success()
{
Rectangle[] rectInt = new Rectangle[] { new Rectangle(1, 1, 2, 2), new Rectangle(3, 3, 4, 4) };
RectangleF[] rectFloat = new RectangleF[] { new RectangleF(1, 1, 2, 2), new RectangleF(3, 3, 4, 4) };
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddRectangles(rectInt);
Assert.Equal(8, gpi.PathPoints.Length);
Assert.Equal(8, gpi.PathTypes.Length);
Assert.Equal(8, gpi.PathData.Points.Length);
gpf.AddRectangles(rectFloat);
Assert.Equal(8, gpf.PathPoints.Length);
Assert.Equal(8, gpf.PathTypes.Length);
Assert.Equal(8, gpf.PathData.Points.Length);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddRectangles_SamePoints_Success()
{
Rectangle[] rectInt = new Rectangle[]
{
new Rectangle(1, 1, 0, 0),
new Rectangle(1, 1, 2, 2),
new Rectangle(1, 1, 2, 2)
};
RectangleF[] rectFloat = new RectangleF[]
{
new RectangleF(1, 1, 0f, 0f),
new RectangleF(1, 1, 2, 2),
new RectangleF(1, 1, 2, 2)
};
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddRectangles(rectInt);
Assert.Equal(8, gpi.PathPoints.Length);
Assert.Equal(8, gpi.PathTypes.Length);
Assert.Equal(8, gpi.PathData.Points.Length);
gpf.AddRectangles(rectFloat);
Assert.Equal(8, gpf.PathPoints.Length);
Assert.Equal(8, gpf.PathTypes.Length);
Assert.Equal(8, gpf.PathData.Points.Length);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddRectangles_RectangleNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("rects", () => gp.AddRectangles((RectangleF[])null));
AssertExtensions.Throws<ArgumentNullException>("rects", () => gp.AddRectangles((Rectangle[])null));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddEllipse_Rectangle_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddEllipse(new Rectangle(1, 1, 2, 2));
// AssertEllipse() method expects added Ellipse with parameters x=1, y=1, width=2, height=2, here and below.
AssertEllipse(gpi);
gpf.AddEllipse(new RectangleF(1, 1, 2, 2));
AssertEllipse(gpf);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddEllipse_Values_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddEllipse(1, 1, 2, 2);
AssertEllipse(gpi);
gpf.AddEllipse(1f, 1f, 2f, 2f);
AssertEllipse(gpf);
}
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[InlineData(0, 0)]
[InlineData(2, 0)]
[InlineData(0, 2)]
public void AddEllipse_ZeroWidthHeight_Success(int width, int height)
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddEllipse(1, 1, width, height);
Assert.Equal(13, gpi.PathData.Points.Length);
gpf.AddEllipse(1f, 2f, (float)width, (float)height);
Assert.Equal(13, gpf.PathData.Points.Length);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddPie_Rectangle_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
{
gpi.AddPie(new Rectangle(1, 1, 2, 2), Pi4, Pi4);
// AssertPie() method expects added Pie with parameters
// x=1, y=1, width=2, height=2, startAngle=Pi4, seewpAngle=Pi4 here and below.
AssertPie(gpi);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddPie_Values_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddPie(1, 1, 2, 2, Pi4, Pi4);
AssertPie(gpi);
gpf.AddPie(1f, 1f, 2f, 2f, Pi4, Pi4);
AssertPie(gpf);
}
}
[ConditionalTheory(Helpers.IsWindowsOrAtLeastLibgdiplus6)]
[InlineData(0, 0)]
[InlineData(2, 0)]
[InlineData(0, 2)]
public void AddPie_ZeroWidthHeight_ThrowsArgumentException(int width, int height)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddPie(1, 1, height, width, Pi4, Pi4));
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddPie(1f, 1f, height, width, Pi4, Pi4));
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddPie(new Rectangle(1, 1, height, width), Pi4, Pi4));
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddPolygon_Points_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddPolygon(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) });
// AssertPolygon() method expects added Polygon with points (1, 1), (2, 2), (3, 3), here and below.
AssertPolygon(gpi);
gpf.AddPolygon(new PointF[3] { new PointF(1, 1), new PointF(2, 2), new PointF(3, 3) });
AssertPolygon(gpf);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddPolygon_SamePoints_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddPolygon(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) });
Assert.Equal(3, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 129 }, gpi.PathTypes);
gpi.AddPolygon(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) });
Assert.Equal(6, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 129, 0, 1, 129 }, gpi.PathTypes);
gpi.AddPolygon(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) });
Assert.Equal(9, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 129, 0, 1, 129, 0, 1, 129 }, gpi.PathTypes);
gpi.AddPolygon(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) });
Assert.Equal(12, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 129, 0, 1, 129, 0, 1, 129, 0, 1, 129 }, gpi.PathTypes);
gpf.AddPolygon(new PointF[3] { new PointF(1, 1), new PointF(2, 2), new PointF(3, 3) });
Assert.Equal(3, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 129 }, gpf.PathTypes);
gpf.AddPolygon(new PointF[3] { new PointF(1, 1), new PointF(2, 2), new PointF(3, 3) });
Assert.Equal(6, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 129, 0, 1, 129 }, gpf.PathTypes);
gpf.AddPolygon(new PointF[3] { new PointF(1, 1), new PointF(2, 2), new PointF(3, 3) });
Assert.Equal(9, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 129, 0, 1, 129, 0, 1, 129 }, gpf.PathTypes);
gpf.AddPolygon(new PointF[3] { new PointF(1, 1), new PointF(2, 2), new PointF(3, 3) });
Assert.Equal(12, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 129, 0, 1, 129, 0, 1, 129, 0, 1, 129 }, gpf.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddPolygon_PointsNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("points", () => new GraphicsPath().AddPolygon((Point[])null));
AssertExtensions.Throws<ArgumentNullException>("points", () => new GraphicsPath().AddPolygon((PointF[])null));
}
}
public static IEnumerable<object[]> AddPolygon_InvalidFloadPointsLength_TestData()
{
yield return new object[] { new PointF[0] };
yield return new object[] { new PointF[1] { new PointF(1f, 1f) } };
yield return new object[] { new PointF[2] { new PointF(1f, 1f), new PointF(2f, 2f) } };
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(AddPolygon_InvalidFloadPointsLength_TestData))]
public void AddPolygon_InvalidFloadPointsLength_ThrowsArgumentException(PointF[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddPolygon(points));
}
}
public static IEnumerable<object[]> AddPolygon_InvalidPointsLength_TestData()
{
yield return new object[] { new Point[0] };
yield return new object[] { new Point[1] { new Point(1, 1) } };
yield return new object[] { new Point[2] { new Point(1, 1), new Point(2, 2) } };
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(AddPolygon_InvalidPointsLength_TestData))]
public void AddPolygon_InvalidPointsLength_ThrowsArgumentException(Point[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddPolygon(points));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddPath_Success()
{
using (GraphicsPath inner = new GraphicsPath())
using (GraphicsPath gp = new GraphicsPath())
{
inner.AddRectangle(new Rectangle(1, 1, 2, 2));
gp.AddPath(inner, true);
AssertRectangle(gp);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddPath_PathNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("addingPath", () => new GraphicsPath().AddPath(null, false));
}
}
[ConditionalFact(Helpers.IsWindowsOrAtLeastLibgdiplus6)]
public void AddString_Point_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddString("mono", FontFamily.GenericMonospace, 0, 10, new Point(10, 10), StringFormat.GenericDefault);
AssertExtensions.GreaterThan(gpi.PointCount, 0);
gpf.AddString("mono", FontFamily.GenericMonospace, 0, 10, new PointF(10f, 10f), StringFormat.GenericDefault);
AssertExtensions.GreaterThan(gpf.PointCount, 0);
}
}
[ConditionalFact(Helpers.IsWindowsOrAtLeastLibgdiplus6)]
public void AddString_Rectangle_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddString("mono", FontFamily.GenericMonospace, 0, 10, new Rectangle(10, 10, 10, 10), StringFormat.GenericDefault);
AssertExtensions.GreaterThan(gpi.PointCount, 0);
gpf.AddString("mono", FontFamily.GenericMonospace, 0, 10, new RectangleF(10f, 10f, 10f, 10f), StringFormat.GenericDefault);
AssertExtensions.GreaterThan(gpf.PointCount, 0);
}
}
[ConditionalFact(Helpers.IsWindowsOrAtLeastLibgdiplus6)]
public void AddString_NegativeSize_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddString("mono", FontFamily.GenericMonospace, 0, -10, new Point(10, 10), StringFormat.GenericDefault);
AssertExtensions.GreaterThan(gpi.PointCount, 0);
int gpiLenghtOld = gpi.PathPoints.Length;
gpi.AddString("mono", FontFamily.GenericMonospace, 0, -10, new Rectangle(10, 10, 10, 10), StringFormat.GenericDefault);
AssertExtensions.GreaterThan(gpi.PointCount, gpiLenghtOld);
gpf.AddString("mono", FontFamily.GenericMonospace, 0, -10, new PointF(10f, 10f), StringFormat.GenericDefault);
AssertExtensions.GreaterThan(gpf.PointCount, 0);
int pgfLenghtOld = gpf.PathPoints.Length;
gpf.AddString("mono", FontFamily.GenericMonospace, 0, -10, new RectangleF(10f, 10f, 10f, 10f), StringFormat.GenericDefault);
AssertExtensions.GreaterThan(gpf.PointCount, pgfLenghtOld);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddString_StringFormat_Success()
{
using (GraphicsPath gp1 = new GraphicsPath())
using (GraphicsPath gp2 = new GraphicsPath())
using (GraphicsPath gp3 = new GraphicsPath())
{
gp1.AddString("mono", FontFamily.GenericMonospace, 0, 10, new RectangleF(10f, 10f, 10f, 10f), null);
AssertExtensions.GreaterThan(gp1.PointCount, 0);
gp2.AddString("mono", FontFamily.GenericMonospace, 0, 10, new RectangleF(10f, 10f, 10f, 10f), StringFormat.GenericDefault);
Assert.Equal(gp1.PointCount, gp2.PointCount);
gp3.AddString("mono", FontFamily.GenericMonospace, 0, 10, new RectangleF(10f, 10f, 10f, 10f), StringFormat.GenericTypographic);
Assert.NotEqual(gp1.PointCount, gp3.PointCount);
}
}
[ConditionalFact(Helpers.IsWindowsOrAtLeastLibgdiplus6)]
public void AddString_EmptyString_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddString(string.Empty, FontFamily.GenericMonospace, 0, 10, new Point(10, 10), StringFormat.GenericDefault);
Assert.Equal(0, gpi.PointCount);
gpi.AddString(string.Empty, FontFamily.GenericMonospace, 0, 10, new PointF(10f, 10f), StringFormat.GenericDefault);
Assert.Equal(0, gpf.PointCount);
}
}
[ConditionalFact(Helpers.IsWindowsOrAtLeastLibgdiplus6)]
public void AddString_StringNull_ThrowsNullReferenceException()
{
using (GraphicsPath gp = new GraphicsPath())
{
Assert.Throws<NullReferenceException>(() =>
gp.AddString(null, FontFamily.GenericMonospace, 0, 10, new Point(10, 10), StringFormat.GenericDefault));
Assert.Throws<NullReferenceException>(() =>
gp.AddString(null, FontFamily.GenericMonospace, 0, 10, new PointF(10f, 10f), StringFormat.GenericDefault));
Assert.Throws<NullReferenceException>(() =>
gp.AddString(null, FontFamily.GenericMonospace, 0, 10, new Rectangle(10, 10, 10, 10), StringFormat.GenericDefault));
Assert.Throws<NullReferenceException>(() =>
gp.AddString(null, FontFamily.GenericMonospace, 0, 10, new RectangleF(10f, 10f, 10f, 10f), StringFormat.GenericDefault));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddString_FontFamilyNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException, ArgumentException>("family", null, () =>
new GraphicsPath().AddString("mono", null, 0, 10, new Point(10, 10), StringFormat.GenericDefault));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Transform_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (Matrix matrix = new Matrix(1f, 1f, 2f, 2f, 3f, 3f))
{
gp.AddRectangle(new Rectangle(1, 1, 2, 2));
AssertRectangle(gp);
gp.Transform(matrix);
Assert.Equal(new float[] { 1f, 1f, 2f, 2f, 3f, 3f }, matrix.Elements);
Assert.Equal(new RectangleF(6f, 6f, 6f, 6f), gp.GetBounds());
Assert.Equal(new PointF[] { new PointF(6f, 6f), new PointF(8f, 8f), new PointF(12f, 12f), new PointF(10f, 10f) }, gp.PathPoints);
Assert.Equal(new byte[] { 0, 1, 1, 129 }, gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Transform_PathEmpty_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (Matrix matrix = new Matrix(1f, 1f, 2f, 2f, 3f, 3f))
{
gp.Transform(matrix);
Assert.Equal(new float[] { 1f, 1f, 2f, 2f, 3f, 3f }, matrix.Elements);
AssertEmptyGrahicsPath(gp);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Transform_MatrixNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("matrix", () => gp.Transform(null));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void GetBounds_PathEmpty_ReturnsExpected()
{
using (GraphicsPath gp = new GraphicsPath())
{
Assert.Equal(new RectangleF(0f, 0f, 0f, 0f), gp.GetBounds());
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void GetBounds_Rectangle_ReturnsExpected()
{
using (GraphicsPath gp = new GraphicsPath())
using (Matrix matrix = new Matrix())
{
RectangleF rectangle = new RectangleF(1f, 1f, 2f, 2f);
gp.AddRectangle(rectangle);
Assert.Equal(rectangle, gp.GetBounds());
Assert.Equal(rectangle, gp.GetBounds(null));
Assert.Equal(rectangle, gp.GetBounds(matrix));
Assert.Equal(rectangle, gp.GetBounds(null, null));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void GetBounds_Pie_ReturnsExpected()
{
using (GraphicsPath gp = new GraphicsPath())
using (Matrix matrix = new Matrix())
{
Rectangle rectangle = new Rectangle(10, 10, 100, 100);
gp.AddPie(rectangle, 30, 45);
AssertRectangleEqual(new RectangleF(60f, 60f, 43.3f, 48.3f), gp.GetBounds(), 0.1f);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_Empty_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.Flatten();
Assert.Equal(gp.PointCount, clone.PointCount);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_MatrixNull_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.Flatten(null);
Assert.Equal(gp.PointCount, clone.PointCount);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_MatrixNullFloat_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.Flatten(null, 1f);
Assert.Equal(gp.PointCount, clone.PointCount);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_Arc_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.AddArc(0f, 0f, 100f, 100f, 30, 30);
gp.Flatten();
AssertFlats(gp, clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_Bezier_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.AddBezier(0, 0, 100, 100, 30, 30, 60, 60);
gp.Flatten();
AssertFlats(gp, clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_ClosedCurve_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.AddClosedCurve(new Point[4]
{
new Point (0, 0), new Point (40, 20),
new Point (20, 40), new Point (40, 40)
});
gp.Flatten();
AssertFlats(gp, clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_Curve_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.AddCurve(new Point[4]
{
new Point (0, 0), new Point (40, 20),
new Point (20, 40), new Point (40, 40)
});
gp.Flatten();
AssertFlats(gp, clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_Ellipse_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.AddEllipse(10f, 10f, 100f, 100f);
gp.Flatten();
AssertFlats(gp, clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_Line_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.AddLine(10f, 10f, 100f, 100f);
gp.Flatten();
AssertFlats(gp, clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_Pie_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.AddPie(0, 0, 100, 100, 30, 30);
gp.Flatten();
AssertFlats(gp, clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_Polygon_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.AddPolygon(new Point[4]
{
new Point (0, 0), new Point (10, 10),
new Point (20, 20), new Point (40, 40)
});
gp.Flatten();
AssertFlats(gp, clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_Rectangle_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.AddRectangle(new Rectangle(0, 0, 100, 100));
gp.Flatten();
AssertFlats(gp, clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Warp_DestinationPointsNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("destPoints", () => gp.Warp(null, new RectangleF()));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Warp_DestinationPointsZero_ThrowsArgumentException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => new GraphicsPath().Warp(new PointF[0], new RectangleF()));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Warp_PathEmpty_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (Matrix matrix = new Matrix())
{
Assert.Equal(0, gp.PointCount);
gp.Warp(new PointF[1] { new PointF(0, 0) }, new RectangleF(10, 20, 30, 40), matrix);
Assert.Equal(0, gp.PointCount);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Warp_WarpModeInvalid_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (Matrix matrix = new Matrix())
{
gp.AddPolygon(new Point[3] { new Point(5, 5), new Point(15, 5), new Point(10, 15) });
gp.Warp(new PointF[1] { new PointF(0, 0) }, new RectangleF(10, 20, 30, 40), matrix, (WarpMode)int.MinValue);
Assert.Equal(0, gp.PointCount);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Warp_RectangleEmpty_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddPolygon(new Point[3] { new Point(5, 5), new Point(15, 5), new Point(10, 15) });
gp.Warp(new PointF[1] { new PointF(0, 0) }, new Rectangle(), null);
AssertWrapNaN(gp);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void SetMarkers_EmptyPath_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.SetMarkers();
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void SetMarkers_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(new Point(1, 1), new Point(2, 2));
Assert.Equal(1, gp.PathTypes[1]);
gp.SetMarkers();
Assert.Equal(33, gp.PathTypes[1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void ClearMarkers_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(new Point(1, 1), new Point(2, 2));
Assert.Equal(1, gp.PathTypes[1]);
gp.SetMarkers();
Assert.Equal(33, gp.PathTypes[1]);
gp.ClearMarkers();
Assert.Equal(1, gp.PathTypes[1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void ClearMarkers_EmptyPath_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.ClearMarkers();
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void CloseFigure_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(new Point(1, 1), new Point(2, 2));
Assert.Equal(1, gp.PathTypes[1]);
gp.CloseFigure();
Assert.Equal(129, gp.PathTypes[1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void CloseFigure_EmptyPath_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.CloseFigure();
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void CloseAllFigures_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(new Point(1, 1), new Point(2, 2));
gp.StartFigure();
gp.AddLine(new Point(3, 3), new Point(4, 4));
Assert.Equal(1, gp.PathTypes[1]);
Assert.Equal(1, gp.PathTypes[3]);
gp.CloseAllFigures();
Assert.Equal(129, gp.PathTypes[1]);
Assert.Equal(129, gp.PathTypes[3]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void CloseAllFigures_EmptyPath_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.CloseAllFigures();
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddArc()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddArc(10, 10, 100, 100, 90, 180);
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(1, types[2]);
Assert.Equal(3, types[gp.PointCount - 3]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddBezier()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddBezier(10, 10, 100, 100, 20, 20, 200, 200);
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(1, types[2]);
Assert.Equal(3, types[gp.PointCount - 3]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddBeziers()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddBeziers(new Point[7]
{
new Point (10, 10), new Point (20, 10), new Point (20, 20),
new Point (30, 20), new Point (40, 40), new Point (50, 40),
new Point (50, 50)
});
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(1, types[2]);
Assert.Equal(3, types[gp.PointCount - 3]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddClosedCurve()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddClosedCurve(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) });
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(0, types[2]);
Assert.Equal(131, types[gp.PointCount - 3]);
Assert.Equal(0, types[gp.PointCount - 2]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddCurve()
{
using (GraphicsPath path = new GraphicsPath())
{
path.AddLine(1, 1, 2, 2);
path.AddCurve(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) });
path.AddLine(10, 10, 20, 20);
byte[] types = path.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(1, types[2]);
Assert.Equal(3, types[path.PointCount - 3]);
Assert.Equal(1, types[path.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddEllipse()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddEllipse(10, 10, 100, 100);
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(0, types[2]);
Assert.Equal(131, types[gp.PointCount - 3]);
Assert.Equal(0, types[gp.PointCount - 2]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddLine()
{
using (GraphicsPath path = new GraphicsPath())
{
path.AddLine(1, 1, 2, 2);
path.AddLine(5, 5, 10, 10);
path.AddLine(10, 10, 20, 20);
byte[] types = path.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(1, types[2]);
Assert.Equal(1, types[path.PointCount - 3]);
Assert.Equal(1, types[path.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddLines()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddLines(new Point[4] { new Point(10, 10), new Point(20, 10), new Point(20, 20), new Point(30, 20) });
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(1, types[2]);
Assert.Equal(1, types[gp.PointCount - 3]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddPath_Connect()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath inner = new GraphicsPath())
{
inner.AddArc(10, 10, 100, 100, 90, 180);
gp.AddLine(1, 1, 2, 2);
gp.AddPath(inner, true);
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(1, types[2]);
Assert.Equal(3, types[gp.PointCount - 3]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddPath_NoConnect()
{
using (GraphicsPath inner = new GraphicsPath())
using (GraphicsPath path = new GraphicsPath())
{
inner.AddArc(10, 10, 100, 100, 90, 180);
path.AddLine(1, 1, 2, 2);
path.AddPath(inner, false);
path.AddLine(10, 10, 20, 20);
byte[] types = path.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(0, types[2]);
Assert.Equal(3, types[path.PointCount - 3]);
Assert.Equal(1, types[path.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddPie()
{
using (GraphicsPath path = new GraphicsPath())
{
path.AddLine(1, 1, 2, 2);
path.AddPie(10, 10, 10, 10, 90, 180);
path.AddLine(10, 10, 20, 20);
byte[] types = path.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(0, types[2]);
Assert.Equal(128, (types[path.PointCount - 3] & 128));
Assert.Equal(0, types[path.PointCount - 2]);
Assert.Equal(1, types[path.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddPolygon()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddPolygon(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) });
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(0, types[2]);
Assert.Equal(129, types[gp.PointCount - 3]);
Assert.Equal(0, types[gp.PointCount - 2]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddRectangle()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddRectangle(new RectangleF(10, 10, 20, 20));
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(0, types[2]);
Assert.Equal(129, types[gp.PointCount - 3]);
Assert.Equal(0, types[gp.PointCount - 2]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddRectangles()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddRectangles(new RectangleF[2]
{
new RectangleF (10, 10, 20, 20),
new RectangleF (20, 20, 10, 10)
});
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(0, types[2]);
Assert.Equal(129, types[gp.PointCount - 3]);
Assert.Equal(0, types[gp.PointCount - 2]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddString()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddString("mono", FontFamily.GenericMonospace, 0, 10, new Point(20, 20), StringFormat.GenericDefault);
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(0, types[2]);
Assert.Equal(163, types[gp.PointCount - 3]);
Assert.Equal(1, types[gp.PointCount - 2]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Widen_Pen_Success()
{
PointF[] expectedPoints = new PointF[]
{
new PointF(0.5f, 0.5f), new PointF(3.5f, 0.5f), new PointF(3.5f, 3.5f),
new PointF(0.5f, 3.5f), new PointF(1.5f, 3.0f), new PointF(1.0f, 2.5f),
new PointF(3.0f, 2.5f), new PointF(2.5f, 3.0f), new PointF(2.5f, 1.0f),
new PointF(3.0f, 1.5f), new PointF(1.0f, 1.5f), new PointF(1.5f, 1.0f),
};
byte[] expectedTypes = new byte[] { 0, 1, 1, 129, 0, 1, 1, 1, 1, 1, 1, 129 };
using (GraphicsPath gp = new GraphicsPath())
using (Pen pen = new Pen(Color.Blue))
{
gp.AddRectangle(new Rectangle(1, 1, 2, 2));
Assert.Equal(4, gp.PointCount);
gp.Widen(pen);
Assert.Equal(12, gp.PointCount);
AssertPointsSequenceEqual(expectedPoints, gp.PathPoints, Delta);
Assert.Equal(expectedTypes, gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Widen_EmptyPath_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (Pen pen = new Pen(Color.Blue))
{
Assert.Equal(0, gp.PointCount);
gp.Widen(pen);
Assert.Equal(0, gp.PointCount);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Widen_PenNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("pen", () => gp.Widen(null));
AssertExtensions.Throws<ArgumentNullException>("pen", () => gp.Widen(null, new Matrix()));
AssertExtensions.Throws<ArgumentNullException>("pen", () => gp.Widen(null, new Matrix(), 0.67f));
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Widen_MatrixNull_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (Pen pen = new Pen(Color.Blue))
{
gp.AddPolygon(new Point[3] { new Point(5, 5), new Point(15, 5), new Point(10, 15) });
gp.Widen(pen, null);
Assert.Equal(9, gp.PointCount);
AssertWiden3(gp);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Widen_MatrixEmpty_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (Pen pen = new Pen(Color.Blue))
using (Matrix matrix = new Matrix())
{
gp.AddPolygon(new Point[3] { new Point(5, 5), new Point(15, 5), new Point(10, 15) });
gp.Widen(pen, new Matrix());
Assert.Equal(9, gp.PointCount);
AssertWiden3(gp);
}
}
public static IEnumerable<object[]> Widen_PenSmallWidth_TestData()
{
yield return new object[] { new Rectangle(1, 1, 2, 2), 0f, new RectangleF(0.5f, 0.5f, 3.0f, 3.0f) };
yield return new object[] { new Rectangle(1, 1, 2, 2), 0.5f, new RectangleF(0.5f, 0.5f, 3.0f, 3.0f) };
yield return new object[] { new Rectangle(1, 1, 2, 2), 1.0f, new RectangleF(0.5f, 0.5f, 3.0f, 3.0f) };
yield return new object[] { new Rectangle(1, 1, 2, 2), 1.1f, new RectangleF(0.45f, 0.45f, 3.10f, 3.10f) };
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(Widen_PenSmallWidth_TestData))]
public void Widen_Pen_SmallWidth_Succes(
Rectangle rectangle, float penWidth, RectangleF expectedBounds)
{
using (GraphicsPath gp = new GraphicsPath())
using (Pen pen = new Pen(Color.Aqua, 0))
using (Matrix matrix = new Matrix())
{
pen.Width = penWidth;
gp.AddRectangle(rectangle);
gp.Widen(pen);
AssertRectangleEqual(expectedBounds, gp.GetBounds(null), Delta);
AssertRectangleEqual(expectedBounds, gp.GetBounds(matrix), Delta);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsOutlineVisible_PenNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("pen", () => gp.IsOutlineVisible(1, 1, null));
AssertExtensions.Throws<ArgumentNullException>("pen", () => gp.IsOutlineVisible(1.0f, 1.0f, null));
AssertExtensions.Throws<ArgumentNullException>("pen", () => gp.IsOutlineVisible(new Point(), null));
AssertExtensions.Throws<ArgumentNullException>("pen", () => gp.IsOutlineVisible(new PointF(), null));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsOutlineVisible_LineWithoutGraphics_ReturnsExpected()
{
AssertIsOutlineVisibleLine(null);
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsOutlineVisible_LineInsideGraphics_ReturnsExpected()
{
using (Bitmap bitmap = new Bitmap(20, 20))
using (Graphics graphics = Graphics.FromImage(bitmap))
{
AssertIsOutlineVisibleLine(graphics);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsOutlineVisible_LineOutsideGraphics_ReturnsExpected()
{
using (Bitmap bitmap = new Bitmap(5, 5))
using (Graphics graphics = Graphics.FromImage(bitmap))
{
AssertIsOutlineVisibleLine(graphics);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsOutlineVisible_LineWithGraphicsTransform_ReturnsExpected()
{
using (Bitmap bitmap = new Bitmap(20, 20))
using (Graphics graphics = Graphics.FromImage(bitmap))
using (Matrix matrix = new Matrix(2, 0, 0, 2, 50, -50))
{
graphics.Transform = matrix;
AssertIsOutlineVisibleLine(graphics);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsOutlineVisible_LineWithGraphicsPageUnit_ReturnsExpected()
{
using (Bitmap bitmap = new Bitmap(20, 20))
using (Graphics graphics = Graphics.FromImage(bitmap))
{
graphics.PageUnit = GraphicsUnit.Millimeter;
AssertIsOutlineVisibleLine(graphics);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsOutlineVisible_LineWithGraphicsPageScale_ReturnsExpected()
{
using (Bitmap bitmap = new Bitmap(20, 20))
using (Graphics graphics = Graphics.FromImage(bitmap))
{
graphics.PageScale = 2.0f;
AssertIsOutlineVisibleLine(graphics);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsOutlineVisible_RectangleWithoutGraphics_ReturnsExpected()
{
AssertIsOutlineVisibleRectangle(null);
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsVisible_RectangleWithoutGraphics_ReturnsExpected()
{
AssertIsVisibleRectangle(null);
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsVisible_RectangleWithGraphics_ReturnsExpected()
{
using (Bitmap bitmap = new Bitmap(40, 40))
using (Graphics graphics = Graphics.FromImage(bitmap))
{
AssertIsVisibleRectangle(graphics);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsVisible_EllipseWithoutGraphics_ReturnsExpected()
{
AssertIsVisibleEllipse(null);
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsVisible_EllipseWithGraphics_ReturnsExpected()
{
using (Bitmap bitmap = new Bitmap(40, 40))
using (Graphics graphics = Graphics.FromImage(bitmap))
{
AssertIsVisibleEllipse(graphics);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_Arc_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddArc(1f, 1f, 2f, 2f, Pi4, Pi4);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_Bezier_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddBezier(1, 2, 3, 4, 5, 6, 7, 8);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
public static IEnumerable<object[]> Reverse_TestData()
{
yield return new object[]
{
new Point[]
{
new Point (1,2), new Point (3,4), new Point (5,6), new Point (7,8),
new Point (9,10), new Point (11,12), new Point (13,14)
}
};
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(Reverse_TestData))]
public void Reverse_Beziers_Succes(Point[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddBeziers(points);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(Reverse_TestData))]
public void Reverse_ClosedCurve_Succes(Point[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddClosedCurve(points);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(Reverse_TestData))]
public void Reverse_Curve_Succes(Point[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddCurve(points);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_Ellipse_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddEllipse(1, 2, 3, 4);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_Line_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 2, 3, 4);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_LineClosed_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 2, 3, 4);
gp.CloseFigure();
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(Reverse_TestData))]
public void Reverse_Lines_Succes(Point[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLines(points);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(Reverse_TestData))]
public void Reverse_Polygon_Succes(Point[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddPolygon(points);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_Rectangle_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddRectangle(new Rectangle(1, 2, 3, 4));
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_Rectangles_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
Rectangle[] rects = new Rectangle[] { new Rectangle(1, 2, 3, 4), new Rectangle(5, 6, 7, 8) };
gp.AddRectangles(rects);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_Pie_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddPie(1, 2, 3, 4, 10, 20);
byte[] expectedTypes = new byte[] { 0, 3, 3, 3, 129 };
AssertReverse(gp, gp.PathPoints, expectedTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_ArcLineInnerPath_Succes()
{
using (GraphicsPath inner = new GraphicsPath())
using (GraphicsPath gp = new GraphicsPath())
{
inner.AddArc(1f, 1f, 2f, 2f, Pi4, Pi4);
inner.AddLine(1, 2, 3, 4);
byte[] expectedTypes = new byte[] { 0, 1, 1, 3, 3, 3 };
gp.AddPath(inner, true);
AssertReverse(gp, gp.PathPoints, expectedTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_EllipseRectangle_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddEllipse(50, 51, 50, 100);
gp.AddRectangle(new Rectangle(200, 201, 60, 61));
byte[] expectedTypes = new byte[] { 0, 1, 1, 129, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 131 };
AssertReverse(gp, gp.PathPoints, expectedTypes);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_String_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddString("Mono::", FontFamily.GenericMonospace, 0, 10, new Point(10, 10), StringFormat.GenericDefault);
byte[] expectedTypes = new byte[]
{
0,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,129,
0,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,161,
0,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,129,
0,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,161,
0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,131,0,3,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,163,0,3,3,3,
3,3,3,3,3,3,3,3,3,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,
3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,
3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,
3,3,3,3,3,3,3,3,3,3,3,161,0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
3,3,3,3,3,3,3,3,3,131,0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
3,3,3,3,3,3,3,163,0,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,
3,3,3,3,3,3,3,3,3,3,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,
1,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,
1,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,129
};
AssertReverse(gp, gp.PathPoints, expectedTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_Marker_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddRectangle(new Rectangle(200, 201, 60, 61));
gp.SetMarkers();
byte[] expectedTypes = new byte[] { 0, 1, 1, 129 };
AssertReverse(gp, gp.PathPoints, expectedTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_SubpathMarker_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(0, 1, 2, 3);
gp.SetMarkers();
gp.CloseFigure();
gp.AddBezier(5, 6, 7, 8, 9, 10, 11, 12);
gp.CloseFigure();
byte[] expectedTypes = new byte[] { 0, 3, 3, 163, 0, 129 };
AssertReverse(gp, gp.PathPoints, expectedTypes);
}
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(0, 1, 2, 3);
gp.SetMarkers();
gp.StartFigure();
gp.AddLine(20, 21, 22, 23);
gp.AddBezier(5, 6, 7, 8, 9, 10, 11, 12);
byte[] expectedTypes = new byte[] { 0, 3, 3, 3, 1, 33, 0, 1 };
AssertReverse(gp, gp.PathPoints, expectedTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Ctor_PointsTypes_Succes()
{
int dX = 520;
int dY = 320;
Point[] expectedPoints = new Point[]
{
new Point(dX-64, dY-24), new Point(dX-59, dY-34), new Point(dX-52, dY-54),
new Point(dX-18, dY-66), new Point(dX-34, dY-47), new Point(dX-43, dY-27),
new Point(dX-44, dY-8),
};
byte[] expectedTypes = new byte[]
{
(byte)PathPointType.Start, (byte)PathPointType.Bezier, (byte)PathPointType.Bezier,
(byte)PathPointType.Bezier, (byte)PathPointType.Bezier, (byte)PathPointType.Bezier,
(byte)PathPointType.Bezier
};
using (GraphicsPath path = new GraphicsPath(expectedPoints, expectedTypes))
{
Assert.Equal(7, path.PointCount);
byte[] actualTypes = path.PathTypes;
Assert.Equal(expectedTypes, actualTypes);
}
}
private void AssertEmptyGrahicsPath(GraphicsPath gp)
{
Assert.Equal(0, gp.PathData.Points.Length);
Assert.Equal(0, gp.PathData.Types.Length);
Assert.Equal(0, gp.PointCount);
}
private void AssertEqual(float expexted, float actual, float tollerance)
{
AssertExtensions.LessThanOrEqualTo(Math.Abs(expexted - actual), tollerance);
}
private void AssertLine(GraphicsPath path)
{
PointF[] expectedPoints = new PointF[]
{
new PointF(1f, 1f), new PointF(2f, 2f)
};
Assert.Equal(2, path.PathPoints.Length);
Assert.Equal(2, path.PathTypes.Length);
Assert.Equal(2, path.PathData.Points.Length);
Assert.Equal(new RectangleF(1f, 1f, 1f, 1f), path.GetBounds());
Assert.Equal(expectedPoints, path.PathPoints);
Assert.Equal(new byte[] { 0, 1 }, path.PathTypes);
}
private void AssertArc(GraphicsPath path)
{
PointF[] expectedPoints = new PointF[]
{
new PointF(2.99990582f, 2.01370716f), new PointF(2.99984312f, 2.018276f),
new PointF(2.99974918f, 2.02284455f), new PointF(2.999624f, 2.027412f),
};
Assert.Equal(4, path.PathPoints.Length);
Assert.Equal(4, path.PathTypes.Length);
Assert.Equal(4, path.PathData.Points.Length);
Assert.Equal(new RectangleF(2.99962401f, 2.01370716f, 0f, 0.0137047768f), path.GetBounds());
Assert.Equal(expectedPoints, path.PathPoints);
Assert.Equal(new byte[] { 0, 3, 3, 3 }, path.PathTypes);
}
private void AssertBezier(GraphicsPath path)
{
PointF[] expectedPoints = new PointF[]
{
new PointF(1f, 1f), new PointF(2f, 2f),
new PointF(3f, 3f), new PointF(4f, 4f),
};
Assert.Equal(4, path.PointCount);
Assert.Equal(4, path.PathPoints.Length);
Assert.Equal(4, path.PathTypes.Length);
Assert.Equal(4, path.PathData.Points.Length);
Assert.Equal(new RectangleF(1f, 1f, 3f, 3f), path.GetBounds());
Assert.Equal(expectedPoints, path.PathPoints);
Assert.Equal(new byte[] { 0, 3, 3, 3 }, path.PathTypes);
}
private void AssertCurve(GraphicsPath path)
{
PointF[] expectedPoints = new PointF[]
{
new PointF(1f, 1f), new PointF(1.16666663f, 1.16666663f),
new PointF(1.83333325f, 1.83333325f), new PointF(2f, 2f)
};
Assert.Equal(4, path.PathPoints.Length);
Assert.Equal(4, path.PathTypes.Length);
Assert.Equal(4, path.PathData.Points.Length);
Assert.Equal(new RectangleF(1f, 1f, 1f, 1f), path.GetBounds());
AssertPointsSequenceEqual(expectedPoints, path.PathPoints, Delta);
Assert.Equal(new byte[] { 0, 3, 3, 3 }, path.PathTypes);
}
private void AssertClosedCurve(GraphicsPath path)
{
Assert.Equal(10, path.PathPoints.Length);
Assert.Equal(10, path.PathTypes.Length);
Assert.Equal(10, path.PathData.Points.Length);
Assert.Equal(new RectangleF(0.8333333f, 0.8333333f, 2.33333278f, 2.33333278f), path.GetBounds());
Assert.Equal(new byte[] { 0, 3, 3, 3, 3, 3, 3, 3, 3, 131 }, path.PathTypes);
}
private void AssertRectangle(GraphicsPath path)
{
PointF[] expectedPoints = new PointF[]
{
new PointF(1f, 1f), new PointF(3f, 1f),
new PointF(3f, 3f), new PointF(1f, 3f)
};
Assert.Equal(4, path.PathPoints.Length);
Assert.Equal(4, path.PathTypes.Length);
Assert.Equal(4, path.PathData.Points.Length);
Assert.Equal(new RectangleF(1f, 1f, 2f, 2f), path.GetBounds());
Assert.Equal(expectedPoints, path.PathPoints);
Assert.Equal(new byte[] { 0, 1, 1, 129 }, path.PathTypes);
}
private void AssertEllipse(GraphicsPath path)
{
Assert.Equal(13, path.PathPoints.Length);
Assert.Equal(13, path.PathTypes.Length);
Assert.Equal(13, path.PathData.Points.Length);
Assert.Equal(new RectangleF(1f, 1f, 2f, 2f), path.GetBounds());
Assert.Equal(new byte[] { 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 131 }, path.PathTypes);
}
private void AssertPie(GraphicsPath path)
{
PointF[] expectedPoints = new PointF[]
{
new PointF(2f, 2f), new PointF(2.99990582f, 2.01370716f),
new PointF(2.99984312f, 2.018276f), new PointF(2.99974918f, 2.02284455f),
new PointF(2.999624f, 2.027412f)
};
Assert.Equal(5, path.PathPoints.Length);
Assert.Equal(5, path.PathTypes.Length);
Assert.Equal(5, path.PathData.Points.Length);
AssertRectangleEqual(new RectangleF(2f, 2f, 0.9999058f, 0.0274119377f), path.GetBounds(), Delta);
AssertPointsSequenceEqual(expectedPoints, path.PathPoints, Delta);
Assert.Equal(new byte[] { 0, 1, 3, 3, 131 }, path.PathTypes);
}
private void AssertPolygon(GraphicsPath path)
{
PointF[] expectedPoints = new PointF[]
{
new PointF(1f, 1f),
new PointF(2f, 2f),
new PointF(3f, 3f)
};
Assert.Equal(3, path.PathPoints.Length);
Assert.Equal(3, path.PathTypes.Length);
Assert.Equal(3, path.PathData.Points.Length);
Assert.Equal(new RectangleF(1f, 1f, 2f, 2f), path.GetBounds());
Assert.Equal(expectedPoints, path.PathPoints);
Assert.Equal(new byte[] { 0, 1, 129 }, path.PathTypes);
}
private void AssertFlats(GraphicsPath flat, GraphicsPath original)
{
AssertExtensions.GreaterThanOrEqualTo(flat.PointCount, original.PointCount);
for (int i = 0; i < flat.PointCount; i++)
{
Assert.NotEqual(3, flat.PathTypes[i]);
}
}
private void AssertWrapNaN(GraphicsPath path)
{
byte[] expectedTypes = new byte[] { 0, 1, 129 };
Assert.Equal(3, path.PointCount);
Assert.Equal(float.NaN, path.PathPoints[0].X);
Assert.Equal(float.NaN, path.PathPoints[0].Y);
Assert.Equal(float.NaN, path.PathPoints[1].X);
Assert.Equal(float.NaN, path.PathPoints[1].Y);
Assert.Equal(float.NaN, path.PathPoints[2].X);
Assert.Equal(float.NaN, path.PathPoints[2].Y);
Assert.Equal(expectedTypes, path.PathTypes);
}
private void AssertWiden3(GraphicsPath path)
{
PointF[] expectedPoints = new PointF[]
{
new PointF(4.2f, 4.5f), new PointF(15.8f, 4.5f),
new PointF(10.0f, 16.1f), new PointF(10.4f, 14.8f),
new PointF(9.6f, 14.8f), new PointF(14.6f, 4.8f),
new PointF(15.0f, 5.5f), new PointF(5.0f, 5.5f),
new PointF(5.4f, 4.8f)
};
AssertPointsSequenceEqual(expectedPoints, path.PathPoints, 0.25f);
Assert.Equal(new byte[] { 0, 1, 129, 0, 1, 1, 1, 1, 129 }, path.PathTypes);
}
private void AssertIsOutlineVisibleLine(Graphics graphics)
{
using (GraphicsPath gp = new GraphicsPath())
using (Pen pen = new Pen(Color.Red, 3.0f))
{
gp.AddLine(10, 1, 14, 1);
Assert.True(gp.IsOutlineVisible(10, 1, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(10, 2, pen, graphics));
Assert.False(gp.IsOutlineVisible(10, 2, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(11.0f, 1.0f, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(11.0f, 1.0f, pen, graphics));
Assert.False(gp.IsOutlineVisible(11.0f, 2.0f, Pens.Red, graphics));
Point point = new Point(12, 2);
Assert.False(gp.IsOutlineVisible(point, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(point, pen, graphics));
point.Y = 1;
Assert.True(gp.IsOutlineVisible(point, Pens.Red, graphics));
PointF fPoint = new PointF(13.0f, 2.0f);
Assert.False(gp.IsOutlineVisible(fPoint, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(fPoint, pen, graphics));
fPoint.Y = 1;
Assert.True(gp.IsOutlineVisible(fPoint, Pens.Red, graphics));
}
}
private void AssertIsOutlineVisibleRectangle(Graphics graphics)
{
using (Pen pen = new Pen(Color.Red, 3.0f))
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddRectangle(new Rectangle(10, 10, 20, 20));
Assert.True(gp.IsOutlineVisible(10, 10, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(10, 11, pen, graphics));
Assert.False(gp.IsOutlineVisible(11, 11, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(11.0f, 10.0f, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(11.0f, 11.0f, pen, graphics));
Assert.False(gp.IsOutlineVisible(11.0f, 11.0f, Pens.Red, graphics));
Point point = new Point(15, 10);
Assert.True(gp.IsOutlineVisible(point, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(point, pen, graphics));
point.Y = 15;
Assert.False(gp.IsOutlineVisible(point, Pens.Red, graphics));
PointF fPoint = new PointF(29.0f, 29.0f);
Assert.False(gp.IsOutlineVisible(fPoint, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(fPoint, pen, graphics));
fPoint.Y = 31.0f;
Assert.True(gp.IsOutlineVisible(fPoint, pen, graphics));
}
}
private void AssertIsVisibleRectangle(Graphics graphics)
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddRectangle(new Rectangle(10, 10, 20, 20));
Assert.False(gp.IsVisible(9, 9, graphics));
Assert.True(gp.IsVisible(10, 10, graphics));
Assert.True(gp.IsVisible(20, 20, graphics));
Assert.True(gp.IsVisible(29, 29, graphics));
Assert.False(gp.IsVisible(30, 29, graphics));
Assert.False(gp.IsVisible(29, 30, graphics));
Assert.False(gp.IsVisible(30, 30, graphics));
Assert.False(gp.IsVisible(9.4f, 9.4f, graphics));
Assert.True(gp.IsVisible(9.5f, 9.5f, graphics));
Assert.True(gp.IsVisible(10f, 10f, graphics));
Assert.True(gp.IsVisible(20f, 20f, graphics));
Assert.True(gp.IsVisible(29.4f, 29.4f, graphics));
Assert.False(gp.IsVisible(29.5f, 29.5f, graphics));
Assert.False(gp.IsVisible(29.5f, 29.4f, graphics));
Assert.False(gp.IsVisible(29.4f, 29.5f, graphics));
}
}
private void AssertIsVisibleEllipse(Graphics graphics)
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddEllipse(new Rectangle(10, 10, 20, 20));
Assert.False(gp.IsVisible(10, 10, graphics));
Assert.True(gp.IsVisible(20, 20, graphics));
Assert.False(gp.IsVisible(29, 29, graphics));
Assert.False(gp.IsVisible(10f, 10f, graphics));
Assert.True(gp.IsVisible(20f, 20f, graphics));
Assert.False(gp.IsVisible(29.4f, 29.4f, graphics));
}
}
private void AssertReverse(GraphicsPath gp, PointF[] expectedPoints, byte[] expectedTypes)
{
gp.Reverse();
PointF[] reversedPoints = gp.PathPoints;
byte[] reversedTypes = gp.PathTypes;
int count = gp.PointCount;
Assert.Equal(expectedPoints.Length, gp.PointCount);
Assert.Equal(expectedTypes, gp.PathTypes);
for (int i = 0; i < count; i++)
{
Assert.Equal(expectedPoints[i], reversedPoints[count - i - 1]);
Assert.Equal(expectedTypes[i], reversedTypes[i]);
}
}
private void AssertPointsSequenceEqual(PointF[] expected, PointF[] actual, float tolerance)
{
int count = expected.Length;
Assert.Equal(expected.Length, actual.Length);
for (int i = 0; i < count; i++)
{
AssertExtensions.LessThanOrEqualTo(Math.Abs(expected[i].X - actual[i].X), tolerance);
AssertExtensions.LessThanOrEqualTo(Math.Abs(expected[i].Y - actual[i].Y), tolerance);
}
}
private void AssertRectangleEqual(RectangleF expected, RectangleF actual, float tolerance)
{
AssertExtensions.LessThanOrEqualTo(Math.Abs(expected.X - actual.X), tolerance);
AssertExtensions.LessThanOrEqualTo(Math.Abs(expected.Y - actual.Y), tolerance);
AssertExtensions.LessThanOrEqualTo(Math.Abs(expected.Width - actual.Width), tolerance);
AssertExtensions.LessThanOrEqualTo(Math.Abs(expected.Height - actual.Height), tolerance);
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
// Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections.Generic;
using System.ComponentModel;
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
namespace System.Drawing.Drawing2D.Tests
{
public class GraphicsPathTests
{
private const float Pi4 = (float)(Math.PI / 4);
private const float Delta = 0.0003f;
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Ctor_Default_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
Assert.Equal(FillMode.Alternate, gp.FillMode);
AssertEmptyGrahicsPath(gp);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Ctor_FillMode_Success()
{
using (GraphicsPath gpa = new GraphicsPath(FillMode.Alternate))
using (GraphicsPath gpw = new GraphicsPath(FillMode.Winding))
{
Assert.Equal(FillMode.Alternate, gpa.FillMode);
AssertEmptyGrahicsPath(gpa);
Assert.Equal(FillMode.Winding, gpw.FillMode);
AssertEmptyGrahicsPath(gpw);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Ctor_SamePoints_Success()
{
byte[] types = new byte[6] { 0, 1, 1, 1, 1, 1 };
Point[] points = new Point[]
{
new Point (1, 1), new Point (1, 1), new Point (1, 1),
new Point (1, 1), new Point (1, 1), new Point (1, 1),
};
PointF[] fPoints = new PointF[]
{
new PointF (1f, 1f), new PointF (1f, 1f), new PointF (1f, 1f),
new PointF (1f, 1f), new PointF (1f, 1f), new PointF (1f, 1f),
};
using (GraphicsPath gp = new GraphicsPath(points, types))
using (GraphicsPath gpf = new GraphicsPath(fPoints, types))
{
Assert.Equal(FillMode.Alternate, gp.FillMode);
Assert.Equal(6, gp.PointCount);
Assert.Equal(FillMode.Alternate, gpf.FillMode);
Assert.Equal(6, gpf.PointCount);
types[0] = 1;
Assert.Equal(FillMode.Alternate, gp.FillMode);
Assert.Equal(6, gp.PointCount);
Assert.Equal(FillMode.Alternate, gpf.FillMode);
Assert.Equal(6, gpf.PointCount);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Ctor_PointsNull_ThrowsArgumentNullException()
{
AssertExtensions.Throws<ArgumentNullException>("pts", () => new GraphicsPath((Point[])null, new byte[1]));
}
public static IEnumerable<object[]> AddCurve_PointsTypesLengthMismatch_TestData()
{
yield return new object[] { 1, 2 };
yield return new object[] { 2, 1 };
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(AddCurve_PointsTypesLengthMismatch_TestData))]
public void Ctor_PointsTypesLengthMismatch_ThrowsArgumentException(int pointsLength, int typesLength)
{
AssertExtensions.Throws<ArgumentException>(null, () => new GraphicsPath(new Point[pointsLength], new byte[typesLength]));
AssertExtensions.Throws<ArgumentException>(null, () => new GraphicsPath(new PointF[pointsLength], new byte[typesLength]));
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Clone_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
Assert.Equal(FillMode.Alternate, clone.FillMode);
AssertEmptyGrahicsPath(clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reset_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.Reset();
Assert.Equal(FillMode.Alternate, gp.FillMode);
AssertEmptyGrahicsPath(gp);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void GraphicsPath_FillModeChange()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.FillMode = FillMode.Winding;
Assert.Equal(FillMode.Winding, gp.FillMode);
}
}
[ConditionalTheory(Helpers.IsWindowsOrAtLeastLibgdiplus6)]
[InlineData(FillMode.Alternate - 1)]
[InlineData(FillMode.Winding + 1)]
public void GraphicsPath_InvalidFillMode_ThrowsInvalidEnumArgumentException(FillMode fillMode)
{
using (GraphicsPath gp = new GraphicsPath())
{
Assert.ThrowsAny<ArgumentException>(() => gp.FillMode = fillMode);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void PathData_ReturnsExpected()
{
using (GraphicsPath gp = new GraphicsPath())
{
Assert.Equal(0, gp.PathData.Points.Length);
Assert.Equal(0, gp.PathData.Types.Length);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void PathData_CannotChange()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddRectangle(new Rectangle(1, 1, 2, 2));
Assert.Equal(1f, gp.PathData.Points[0].X);
Assert.Equal(1f, gp.PathData.Points[0].Y);
gp.PathData.Points[0] = new Point(0, 0);
Assert.Equal(1f, gp.PathData.Points[0].X);
Assert.Equal(1f, gp.PathData.Points[0].Y);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void PathPoints_CannotChange()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddRectangle(new Rectangle(1, 1, 2, 2));
Assert.Equal(1f, gp.PathPoints[0].X);
Assert.Equal(1f, gp.PathPoints[0].Y);
gp.PathPoints[0] = new Point(0, 0);
Assert.Equal(1f, gp.PathPoints[0].X);
Assert.Equal(1f, gp.PathPoints[0].Y);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void PathPoints_EmptyPath_ThrowsArgumentException()
{
using (GraphicsPath gp = new GraphicsPath())
{
Assert.Throws<ArgumentException>(() => gp.PathPoints);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void PathTypes_CannotChange()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddRectangle(new Rectangle(1, 1, 2, 2));
Assert.Equal(0, gp.PathTypes[0]);
gp.PathTypes[0] = 1;
Assert.Equal(0, gp.PathTypes[0]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void PathTypes_EmptyPath_ThrowsArgumentException()
{
using (GraphicsPath gp = new GraphicsPath())
{
Assert.Throws<ArgumentException>(() => gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void GetLastPoint_ReturnsExpected()
{
byte[] types = new byte[3] { 0, 1, 1 };
PointF[] points = new PointF[]
{
new PointF (1f, 1f), new PointF (2f, 2f), new PointF (3f, 3f),
};
using (GraphicsPath gp = new GraphicsPath(points, types))
{
Assert.Equal(gp.GetLastPoint(), points[2]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddLine_Success()
{
using (GraphicsPath gpInt = new GraphicsPath())
using (GraphicsPath gpFloat = new GraphicsPath())
using (GraphicsPath gpPointsInt = new GraphicsPath())
using (GraphicsPath gpfPointsloat = new GraphicsPath())
{
gpInt.AddLine(1, 1, 2, 2);
// AssertLine() method expects line drawn between points with coordinates 1, 1 and 2, 2, here and below.
AssertLine(gpInt);
gpFloat.AddLine(1, 1, 2, 2);
AssertLine(gpFloat);
gpPointsInt.AddLine(new Point(1, 1), new Point(2, 2));
AssertLine(gpPointsInt);
gpfPointsloat.AddLine(new PointF(1, 1), new PointF(2, 2));
AssertLine(gpfPointsloat);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddLine_SamePoints_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddLine(new Point(49, 157), new Point(75, 196));
gpi.AddLine(new Point(75, 196), new Point(102, 209));
Assert.Equal(3, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 1 }, gpi.PathTypes);
gpi.AddLine(new Point(102, 209), new Point(75, 196));
Assert.Equal(4, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 1, 1 }, gpi.PathTypes);
gpf.AddLine(new PointF(49, 157), new PointF(75, 196));
gpf.AddLine(new PointF(75, 196), new PointF(102, 209));
Assert.Equal(3, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 1 }, gpf.PathTypes);
gpf.AddLine(new PointF(102, 209), new PointF(75, 196));
Assert.Equal(4, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 1, 1 }, gpf.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddLines_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddLines(new Point[] { new Point(1, 1), new Point(2, 2) });
AssertLine(gpi);
gpf.AddLines(new PointF[] { new PointF(1, 1), new PointF(2, 2) });
AssertLine(gpf);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddLines_SinglePoint_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddLines(new PointF[] { new PointF(1, 1) });
Assert.Equal(1, gpi.PointCount);
Assert.Equal(0, gpi.PathTypes[0]);
gpf.AddLines(new PointF[] { new PointF(1, 1) });
Assert.Equal(1, gpf.PointCount);
Assert.Equal(0, gpf.PathTypes[0]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddLines_SamePoint_Success()
{
Point[] intPoints = new Point[]
{
new Point(49, 157), new Point(49, 157)
};
PointF[] floatPoints = new PointF[]
{
new PointF(49, 57), new PointF(49, 57),
new PointF(49, 57), new PointF(49, 57)
};
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddLines(intPoints);
Assert.Equal(2, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1 }, gpi.PathTypes);
gpi.AddLines(intPoints);
Assert.Equal(3, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 1 }, gpi.PathTypes);
gpi.AddLines(intPoints);
Assert.Equal(4, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 1, 1 }, gpi.PathTypes);
gpf.AddLines(floatPoints);
Assert.Equal(4, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 1, 1 }, gpf.PathTypes);
gpf.AddLines(floatPoints);
Assert.Equal(7, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 1, 1, 1, 1, 1 }, gpf.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddLines_PointsNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("points", () => new GraphicsPath().AddLines((Point[])null));
AssertExtensions.Throws<ArgumentNullException>("points", () => new GraphicsPath().AddLines((PointF[])null));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddLines_ZeroPoints_ThrowsArgumentException()
{
AssertExtensions.Throws<ArgumentException>("points", null, () => new GraphicsPath().AddLines(new Point[0]));
AssertExtensions.Throws<ArgumentException>("points", null, () => new GraphicsPath().AddLines(new PointF[0]));
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddArc_Values_Success()
{
if (PlatformDetection.IsArmOrArm64Process)
{
//ActiveIssue: 35744
throw new SkipTestException("Precision on float numbers");
}
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddArc(1, 1, 2, 2, Pi4, Pi4);
// AssertArc() method expects added Arc with parameters
// x=1, y=1, width=2, height=2, startAngle=Pi4, seewpAngle=Pi4 here and below.
AssertArc(gpi);
gpf.AddArc(1f, 1f, 2f, 2f, Pi4, Pi4);
AssertArc(gpf);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddArc_Rectangle_Success()
{
if (PlatformDetection.IsArmOrArm64Process)
{
//ActiveIssue: 35744
throw new SkipTestException("Precision on float numbers");
}
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddArc(new Rectangle(1, 1, 2, 2), Pi4, Pi4);
AssertArc(gpi);
gpf.AddArc(new RectangleF(1, 1, 2, 2), Pi4, Pi4);
AssertArc(gpf);
}
}
[ConditionalTheory(Helpers.IsWindowsOrAtLeastLibgdiplus6)]
[InlineData(0, 0)]
[InlineData(1, 0)]
[InlineData(0, 1)]
public void AddArc_ZeroWidthHeight_ThrowsArgumentException(int width, int height)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddArc(1, 1, width, height, Pi4, Pi4));
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddArc(1.0f, 1.0f, (float)width, (float)height, Pi4, Pi4));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddBezier_Points_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddBezier(new Point(1, 1), new Point(2, 2), new Point(3, 3), new Point(4, 4));
// AssertBezier() method expects added Bezier with points (1, 1), (2, 2), (3, 3), (4, 4), here and below.
AssertBezier(gpi);
gpf.AddBezier(new PointF(1, 1), new PointF(2, 2), new PointF(3, 3), new PointF(4, 4));
AssertBezier(gpf);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddBezier_SamePoints_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gp.AddBezier(new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0));
Assert.Equal(4, gp.PointCount);
Assert.Equal(new byte[] { 0, 3, 3, 3 }, gp.PathTypes);
gp.AddBezier(new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0));
Assert.Equal(7, gp.PointCount);
Assert.Equal(new byte[] { 0, 3, 3, 3, 3, 3, 3 }, gp.PathTypes);
gpf.AddBezier(new PointF(0, 0), new PointF(0, 0), new PointF(0, 0), new PointF(0, 0));
Assert.Equal(4, gpf.PointCount);
Assert.Equal(new byte[] { 0, 3, 3, 3 }, gpf.PathTypes);
gpf.AddBezier(new PointF(0, 0), new PointF(0, 0), new PointF(0, 0), new PointF(0, 0));
Assert.Equal(7, gpf.PointCount);
Assert.Equal(new byte[] { 0, 3, 3, 3, 3, 3, 3 }, gpf.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddBezier_Values_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddBezier(1, 1, 2, 2, 3, 3, 4, 4);
AssertBezier(gpi);
gpf.AddBezier(1f, 1f, 2f, 2f, 3f, 3f, 4f, 4f);
AssertBezier(gpf);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddBeziers_Points_Success()
{
PointF[] points = new PointF[]
{
new PointF(1, 1), new PointF(2, 2), new PointF(3, 3), new PointF(4, 4)
};
using (GraphicsPath gpf = new GraphicsPath())
{
gpf.AddBeziers(points);
AssertBezier(gpf);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddBeziers_PointsNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("points", () => gp.AddBeziers((PointF[])null));
AssertExtensions.Throws<ArgumentNullException>("points", () => gp.AddBeziers((Point[])null));
}
}
public static IEnumerable<object[]> AddBeziers_InvalidFloatPointsLength_TestData()
{
yield return new object[] { new PointF[0] };
yield return new object[] { new PointF[1] { new PointF(1f, 1f) } };
yield return new object[] { new PointF[2] { new PointF(1f, 1f), new PointF(2f, 2f) } };
yield return new object[] { new PointF[3] { new PointF(1f, 1f), new PointF(2f, 2f), new PointF(3f, 3f) } };
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(AddBeziers_InvalidFloatPointsLength_TestData))]
public void AddBeziers_InvalidFloatPointsLength_ThrowsArgumentException(PointF[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddBeziers(points));
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddCurve_TwoPoints_Success()
{
Point[] intPoints = new Point[] { new Point(1, 1), new Point(2, 2) };
PointF[] floatPoints = new PointF[] { new PointF(1, 1), new PointF(2, 2) };
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpf.AddCurve(floatPoints);
// AssertCurve() method expects added Curve with points (1, 1), (2, 2), here and below.
AssertCurve(gpf);
gpi.AddCurve(intPoints);
AssertCurve(gpi);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddCurve_TwoPointsWithTension_Success()
{
Point[] intPoints = new Point[] { new Point(1, 1), new Point(2, 2) };
PointF[] floatPoints = new PointF[] { new PointF(1, 1), new PointF(2, 2) };
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddCurve(intPoints, 0.5f);
AssertCurve(gpi);
gpf.AddCurve(floatPoints, 0.5f);
AssertCurve(gpf);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddCurve_SamePoints_Success()
{
Point[] intPoints = new Point[] { new Point(1, 1), new Point(1, 1) };
PointF[] floatPoints = new PointF[] { new PointF(1, 1), new PointF(1, 1) };
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddCurve(intPoints);
Assert.Equal(4, gpi.PointCount);
gpi.AddCurve(intPoints);
Assert.Equal(7, gpi.PointCount);
gpf.AddCurve(floatPoints);
Assert.Equal(4, gpf.PointCount);
gpf.AddCurve(floatPoints);
Assert.Equal(7, gpf.PointCount);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddCurve_LargeTension_Success()
{
Point[] intPoints = new Point[] { new Point(1, 1), new Point(2, 2) };
PointF[] floatPoints = new PointF[] { new PointF(1, 1), new PointF(2, 2) };
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddCurve(intPoints, float.MaxValue);
Assert.Equal(4, gpi.PointCount);
gpf.AddCurve(floatPoints, float.MaxValue);
Assert.Equal(4, gpf.PointCount);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddCurve_Success()
{
PointF[] points = new PointF[]
{
new PointF (37f, 185f),
new PointF (99f, 185f),
new PointF (161f, 159f),
new PointF (223f, 185f),
new PointF (285f, 54f),
};
PointF[] expectedPoints = new PointF[]
{
new PointF (37f, 185f),
new PointF (47.33333f, 185f),
new PointF (78.3333f, 189.3333f),
new PointF (99f, 185f),
new PointF (119.6667f, 180.6667f),
new PointF (140.3333f, 159f),
new PointF (161f, 159f),
new PointF (181.6667f, 159f),
new PointF (202.3333f, 202.5f),
new PointF (223f, 185f),
new PointF (243.6667f, 167.5f),
new PointF (274.6667f, 75.8333f),
new PointF (285f, 54f),
};
byte[] expectedTypes = new byte[] { 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 };
int[] pointsCount = { 4, 7, 10, 13 };
using (GraphicsPath gp = new GraphicsPath())
{
for (int i = 0; i < points.Length - 1; i++)
{
gp.AddCurve(points, i, 1, 0.5f);
Assert.Equal(pointsCount[i], gp.PointCount);
}
AssertPointsSequenceEqual(expectedPoints, gp.PathPoints, Delta);
Assert.Equal(expectedTypes, gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddCurve_PointsNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("points", () => gp.AddCurve((PointF[])null));
AssertExtensions.Throws<ArgumentNullException>("points", () => gp.AddCurve((Point[])null));
}
}
public static IEnumerable<object[]> AddCurve_InvalidFloatPointsLength_TestData()
{
yield return new object[] { new PointF[0] };
yield return new object[] { new PointF[1] { new PointF(1f, 1f) } };
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(AddCurve_InvalidFloatPointsLength_TestData))]
public void AddCurve_InvalidFloatPointsLength_ThrowsArgumentException(PointF[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddCurve(points));
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddCurve(points, 0, 2, 0.5f));
}
}
public static IEnumerable<object[]> AddCurve_InvalidPointsLength_TestData()
{
yield return new object[] { new Point[0] };
yield return new object[] { new Point[1] { new Point(1, 1) } };
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(AddCurve_InvalidPointsLength_TestData))]
public void AddCurve_InvalidPointsLength_ThrowsArgumentException(Point[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddCurve(points));
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddCurve(points, 0, 2, 0.5f));
}
}
public static IEnumerable<object[]> AddCurve_InvalidSegment_TestData()
{
yield return new object[] { 0 };
yield return new object[] { -1 };
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(AddCurve_InvalidSegment_TestData))]
public void AddCurve_InvalidSegment_ThrowsArgumentException(int segment)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddCurve(
new PointF[2] { new PointF(1f, 1f), new PointF(2f, 2f) }, 0, segment, 0.5f));
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddCurve(
new Point[2] { new Point(1, 1), new Point(2, 2) }, 0, segment, 0.5f));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddCurve_OffsetTooLarge_ThrowsArgumentException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddCurve(
new PointF[3] { new PointF(1f, 1f), new PointF(0f, 20f), new PointF(20f, 0f) }, 1, 2, 0.5f));
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddCurve(
new Point[3] { new Point(1, 1), new Point(0, 20), new Point(20, 0) }, 1, 2, 0.5f));
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddClosedCurve_Points_Success()
{
if (PlatformDetection.IsArmOrArm64Process)
{
//ActiveIssue: 35744
throw new SkipTestException("Precision on float numbers");
}
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddClosedCurve(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) });
// AssertClosedCurve() method expects added ClosedCurve with points (1, 1), (2, 2), (3, 3), here and below.
AssertClosedCurve(gpi);
gpf.AddClosedCurve(new PointF[3] { new PointF(1, 1), new PointF(2, 2), new PointF(3, 3) });
AssertClosedCurve(gpf);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddClosedCurve_SamePoints_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddClosedCurve(new Point[3] { new Point(1, 1), new Point(1, 1), new Point(1, 1) });
Assert.Equal(10, gpi.PointCount);
gpi.AddClosedCurve(new Point[3] { new Point(1, 1), new Point(1, 1), new Point(1, 1) });
Assert.Equal(20, gpi.PointCount);
gpf.AddClosedCurve(new PointF[3] { new PointF(1, 1), new PointF(1, 1), new PointF(1, 1) });
Assert.Equal(10, gpf.PointCount);
gpf.AddClosedCurve(new PointF[3] { new PointF(1, 1), new PointF(1, 1), new PointF(1, 1) });
Assert.Equal(20, gpf.PointCount);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddClosedCurve_Tension_Success()
{
if (PlatformDetection.IsArmOrArm64Process)
{
//ActiveIssue: 35744
throw new SkipTestException("Precision on float numbers");
}
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddClosedCurve(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) }, 0.5f);
AssertClosedCurve(gpi);
gpf.AddClosedCurve(new PointF[3] { new PointF(1, 1), new PointF(2, 2), new PointF(3, 3) }, 0.5f);
AssertClosedCurve(gpf);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddClosedCurve_PointsNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("points", () => gp.AddClosedCurve((PointF[])null));
AssertExtensions.Throws<ArgumentNullException>("points", () => gp.AddClosedCurve((Point[])null));
}
}
public static IEnumerable<object[]> AddClosedCurve_InvalidPointsLength_TestData()
{
yield return new object[] { new Point[0] };
yield return new object[] { new Point[1] { new Point(1, 1) } };
yield return new object[] { new Point[2] { new Point(1, 1), new Point(2, 2) } };
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(AddCurve_InvalidPointsLength_TestData))]
public void AddClosedCurve_InvalidPointsLength_ThrowsArgumentException(Point[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddClosedCurve(points));
}
}
public static IEnumerable<object[]> AddClosedCurve_InvalidFloatPointsLength_TestData()
{
yield return new object[] { new PointF[0] };
yield return new object[] { new PointF[1] { new PointF(1f, 1f) } };
yield return new object[] { new PointF[2] { new PointF(1f, 1f), new PointF(2f, 2f) } };
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(AddClosedCurve_InvalidFloatPointsLength_TestData))]
public void AddClosedCurve_InvalidFloatPointsLength_ThrowsArgumentException(PointF[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddClosedCurve(points));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddRectangle_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddRectangle(new Rectangle(1, 1, 2, 2));
// AssertRectangle() method expects added Rectangle with parameters x=1, y=1, width=2, height=2, here and below.
AssertRectangle(gpi);
gpf.AddRectangle(new RectangleF(1, 1, 2, 2));
AssertRectangle(gpf);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddRectangle_SameRectangles_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddRectangle(new Rectangle(1, 1, 1, 1));
Assert.Equal(4, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 1, 129 }, gpi.PathTypes);
PointF endI = gpi.PathPoints[3];
gpi.AddRectangle(new Rectangle((int)endI.X, (int)endI.Y, 1, 1));
Assert.Equal(8, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 1, 129, 0, 1, 1, 129 }, gpi.PathTypes);
gpf.AddRectangle(new RectangleF(1, 1, 1, 1));
Assert.Equal(4, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 1, 129 }, gpf.PathTypes);
Assert.Equal(129, gpf.PathTypes[3]);
PointF endF = gpf.PathPoints[3];
gpf.AddRectangle(new RectangleF(endF.X, endF.Y, 1, 1));
Assert.Equal(8, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 1, 129, 0, 1, 1, 129 }, gpf.PathTypes);
}
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[InlineData(0, 0)]
[InlineData(3, 0)]
[InlineData(0, 4)]
public void AddRectangle_ZeroWidthHeight_Success(int width, int height)
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddRectangle(new Rectangle(1, 2, width, height));
Assert.Equal(0, gpi.PathData.Points.Length);
gpf.AddRectangle(new RectangleF(1f, 2f, (float)width, (float)height));
Assert.Equal(0, gpf.PathData.Points.Length);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddRectangles_Success()
{
Rectangle[] rectInt = new Rectangle[] { new Rectangle(1, 1, 2, 2), new Rectangle(3, 3, 4, 4) };
RectangleF[] rectFloat = new RectangleF[] { new RectangleF(1, 1, 2, 2), new RectangleF(3, 3, 4, 4) };
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddRectangles(rectInt);
Assert.Equal(8, gpi.PathPoints.Length);
Assert.Equal(8, gpi.PathTypes.Length);
Assert.Equal(8, gpi.PathData.Points.Length);
gpf.AddRectangles(rectFloat);
Assert.Equal(8, gpf.PathPoints.Length);
Assert.Equal(8, gpf.PathTypes.Length);
Assert.Equal(8, gpf.PathData.Points.Length);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddRectangles_SamePoints_Success()
{
Rectangle[] rectInt = new Rectangle[]
{
new Rectangle(1, 1, 0, 0),
new Rectangle(1, 1, 2, 2),
new Rectangle(1, 1, 2, 2)
};
RectangleF[] rectFloat = new RectangleF[]
{
new RectangleF(1, 1, 0f, 0f),
new RectangleF(1, 1, 2, 2),
new RectangleF(1, 1, 2, 2)
};
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddRectangles(rectInt);
Assert.Equal(8, gpi.PathPoints.Length);
Assert.Equal(8, gpi.PathTypes.Length);
Assert.Equal(8, gpi.PathData.Points.Length);
gpf.AddRectangles(rectFloat);
Assert.Equal(8, gpf.PathPoints.Length);
Assert.Equal(8, gpf.PathTypes.Length);
Assert.Equal(8, gpf.PathData.Points.Length);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddRectangles_RectangleNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("rects", () => gp.AddRectangles((RectangleF[])null));
AssertExtensions.Throws<ArgumentNullException>("rects", () => gp.AddRectangles((Rectangle[])null));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddEllipse_Rectangle_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddEllipse(new Rectangle(1, 1, 2, 2));
// AssertEllipse() method expects added Ellipse with parameters x=1, y=1, width=2, height=2, here and below.
AssertEllipse(gpi);
gpf.AddEllipse(new RectangleF(1, 1, 2, 2));
AssertEllipse(gpf);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddEllipse_Values_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddEllipse(1, 1, 2, 2);
AssertEllipse(gpi);
gpf.AddEllipse(1f, 1f, 2f, 2f);
AssertEllipse(gpf);
}
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[InlineData(0, 0)]
[InlineData(2, 0)]
[InlineData(0, 2)]
public void AddEllipse_ZeroWidthHeight_Success(int width, int height)
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddEllipse(1, 1, width, height);
Assert.Equal(13, gpi.PathData.Points.Length);
gpf.AddEllipse(1f, 2f, (float)width, (float)height);
Assert.Equal(13, gpf.PathData.Points.Length);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddPie_Rectangle_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
{
gpi.AddPie(new Rectangle(1, 1, 2, 2), Pi4, Pi4);
// AssertPie() method expects added Pie with parameters
// x=1, y=1, width=2, height=2, startAngle=Pi4, seewpAngle=Pi4 here and below.
AssertPie(gpi);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddPie_Values_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddPie(1, 1, 2, 2, Pi4, Pi4);
AssertPie(gpi);
gpf.AddPie(1f, 1f, 2f, 2f, Pi4, Pi4);
AssertPie(gpf);
}
}
[ConditionalTheory(Helpers.IsWindowsOrAtLeastLibgdiplus6)]
[InlineData(0, 0)]
[InlineData(2, 0)]
[InlineData(0, 2)]
public void AddPie_ZeroWidthHeight_ThrowsArgumentException(int width, int height)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddPie(1, 1, height, width, Pi4, Pi4));
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddPie(1f, 1f, height, width, Pi4, Pi4));
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddPie(new Rectangle(1, 1, height, width), Pi4, Pi4));
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddPolygon_Points_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddPolygon(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) });
// AssertPolygon() method expects added Polygon with points (1, 1), (2, 2), (3, 3), here and below.
AssertPolygon(gpi);
gpf.AddPolygon(new PointF[3] { new PointF(1, 1), new PointF(2, 2), new PointF(3, 3) });
AssertPolygon(gpf);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddPolygon_SamePoints_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddPolygon(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) });
Assert.Equal(3, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 129 }, gpi.PathTypes);
gpi.AddPolygon(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) });
Assert.Equal(6, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 129, 0, 1, 129 }, gpi.PathTypes);
gpi.AddPolygon(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) });
Assert.Equal(9, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 129, 0, 1, 129, 0, 1, 129 }, gpi.PathTypes);
gpi.AddPolygon(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) });
Assert.Equal(12, gpi.PointCount);
Assert.Equal(new byte[] { 0, 1, 129, 0, 1, 129, 0, 1, 129, 0, 1, 129 }, gpi.PathTypes);
gpf.AddPolygon(new PointF[3] { new PointF(1, 1), new PointF(2, 2), new PointF(3, 3) });
Assert.Equal(3, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 129 }, gpf.PathTypes);
gpf.AddPolygon(new PointF[3] { new PointF(1, 1), new PointF(2, 2), new PointF(3, 3) });
Assert.Equal(6, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 129, 0, 1, 129 }, gpf.PathTypes);
gpf.AddPolygon(new PointF[3] { new PointF(1, 1), new PointF(2, 2), new PointF(3, 3) });
Assert.Equal(9, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 129, 0, 1, 129, 0, 1, 129 }, gpf.PathTypes);
gpf.AddPolygon(new PointF[3] { new PointF(1, 1), new PointF(2, 2), new PointF(3, 3) });
Assert.Equal(12, gpf.PointCount);
Assert.Equal(new byte[] { 0, 1, 129, 0, 1, 129, 0, 1, 129, 0, 1, 129 }, gpf.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddPolygon_PointsNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("points", () => new GraphicsPath().AddPolygon((Point[])null));
AssertExtensions.Throws<ArgumentNullException>("points", () => new GraphicsPath().AddPolygon((PointF[])null));
}
}
public static IEnumerable<object[]> AddPolygon_InvalidFloadPointsLength_TestData()
{
yield return new object[] { new PointF[0] };
yield return new object[] { new PointF[1] { new PointF(1f, 1f) } };
yield return new object[] { new PointF[2] { new PointF(1f, 1f), new PointF(2f, 2f) } };
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(AddPolygon_InvalidFloadPointsLength_TestData))]
public void AddPolygon_InvalidFloadPointsLength_ThrowsArgumentException(PointF[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddPolygon(points));
}
}
public static IEnumerable<object[]> AddPolygon_InvalidPointsLength_TestData()
{
yield return new object[] { new Point[0] };
yield return new object[] { new Point[1] { new Point(1, 1) } };
yield return new object[] { new Point[2] { new Point(1, 1), new Point(2, 2) } };
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(AddPolygon_InvalidPointsLength_TestData))]
public void AddPolygon_InvalidPointsLength_ThrowsArgumentException(Point[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => gp.AddPolygon(points));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddPath_Success()
{
using (GraphicsPath inner = new GraphicsPath())
using (GraphicsPath gp = new GraphicsPath())
{
inner.AddRectangle(new Rectangle(1, 1, 2, 2));
gp.AddPath(inner, true);
AssertRectangle(gp);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddPath_PathNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("addingPath", () => new GraphicsPath().AddPath(null, false));
}
}
[ConditionalFact(Helpers.IsWindowsOrAtLeastLibgdiplus6)]
public void AddString_Point_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddString("mono", FontFamily.GenericMonospace, 0, 10, new Point(10, 10), StringFormat.GenericDefault);
AssertExtensions.GreaterThan(gpi.PointCount, 0);
gpf.AddString("mono", FontFamily.GenericMonospace, 0, 10, new PointF(10f, 10f), StringFormat.GenericDefault);
AssertExtensions.GreaterThan(gpf.PointCount, 0);
}
}
[ConditionalFact(Helpers.IsWindowsOrAtLeastLibgdiplus6)]
public void AddString_Rectangle_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddString("mono", FontFamily.GenericMonospace, 0, 10, new Rectangle(10, 10, 10, 10), StringFormat.GenericDefault);
AssertExtensions.GreaterThan(gpi.PointCount, 0);
gpf.AddString("mono", FontFamily.GenericMonospace, 0, 10, new RectangleF(10f, 10f, 10f, 10f), StringFormat.GenericDefault);
AssertExtensions.GreaterThan(gpf.PointCount, 0);
}
}
[ConditionalFact(Helpers.IsWindowsOrAtLeastLibgdiplus6)]
public void AddString_NegativeSize_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddString("mono", FontFamily.GenericMonospace, 0, -10, new Point(10, 10), StringFormat.GenericDefault);
AssertExtensions.GreaterThan(gpi.PointCount, 0);
int gpiLenghtOld = gpi.PathPoints.Length;
gpi.AddString("mono", FontFamily.GenericMonospace, 0, -10, new Rectangle(10, 10, 10, 10), StringFormat.GenericDefault);
AssertExtensions.GreaterThan(gpi.PointCount, gpiLenghtOld);
gpf.AddString("mono", FontFamily.GenericMonospace, 0, -10, new PointF(10f, 10f), StringFormat.GenericDefault);
AssertExtensions.GreaterThan(gpf.PointCount, 0);
int pgfLenghtOld = gpf.PathPoints.Length;
gpf.AddString("mono", FontFamily.GenericMonospace, 0, -10, new RectangleF(10f, 10f, 10f, 10f), StringFormat.GenericDefault);
AssertExtensions.GreaterThan(gpf.PointCount, pgfLenghtOld);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddString_StringFormat_Success()
{
using (GraphicsPath gp1 = new GraphicsPath())
using (GraphicsPath gp2 = new GraphicsPath())
using (GraphicsPath gp3 = new GraphicsPath())
{
gp1.AddString("mono", FontFamily.GenericMonospace, 0, 10, new RectangleF(10f, 10f, 10f, 10f), null);
AssertExtensions.GreaterThan(gp1.PointCount, 0);
gp2.AddString("mono", FontFamily.GenericMonospace, 0, 10, new RectangleF(10f, 10f, 10f, 10f), StringFormat.GenericDefault);
Assert.Equal(gp1.PointCount, gp2.PointCount);
gp3.AddString("mono", FontFamily.GenericMonospace, 0, 10, new RectangleF(10f, 10f, 10f, 10f), StringFormat.GenericTypographic);
Assert.NotEqual(gp1.PointCount, gp3.PointCount);
}
}
[ConditionalFact(Helpers.IsWindowsOrAtLeastLibgdiplus6)]
public void AddString_EmptyString_Success()
{
using (GraphicsPath gpi = new GraphicsPath())
using (GraphicsPath gpf = new GraphicsPath())
{
gpi.AddString(string.Empty, FontFamily.GenericMonospace, 0, 10, new Point(10, 10), StringFormat.GenericDefault);
Assert.Equal(0, gpi.PointCount);
gpi.AddString(string.Empty, FontFamily.GenericMonospace, 0, 10, new PointF(10f, 10f), StringFormat.GenericDefault);
Assert.Equal(0, gpf.PointCount);
}
}
[ConditionalFact(Helpers.IsWindowsOrAtLeastLibgdiplus6)]
public void AddString_StringNull_ThrowsNullReferenceException()
{
using (GraphicsPath gp = new GraphicsPath())
{
Assert.Throws<NullReferenceException>(() =>
gp.AddString(null, FontFamily.GenericMonospace, 0, 10, new Point(10, 10), StringFormat.GenericDefault));
Assert.Throws<NullReferenceException>(() =>
gp.AddString(null, FontFamily.GenericMonospace, 0, 10, new PointF(10f, 10f), StringFormat.GenericDefault));
Assert.Throws<NullReferenceException>(() =>
gp.AddString(null, FontFamily.GenericMonospace, 0, 10, new Rectangle(10, 10, 10, 10), StringFormat.GenericDefault));
Assert.Throws<NullReferenceException>(() =>
gp.AddString(null, FontFamily.GenericMonospace, 0, 10, new RectangleF(10f, 10f, 10f, 10f), StringFormat.GenericDefault));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void AddString_FontFamilyNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException, ArgumentException>("family", null, () =>
new GraphicsPath().AddString("mono", null, 0, 10, new Point(10, 10), StringFormat.GenericDefault));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Transform_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (Matrix matrix = new Matrix(1f, 1f, 2f, 2f, 3f, 3f))
{
gp.AddRectangle(new Rectangle(1, 1, 2, 2));
AssertRectangle(gp);
gp.Transform(matrix);
Assert.Equal(new float[] { 1f, 1f, 2f, 2f, 3f, 3f }, matrix.Elements);
Assert.Equal(new RectangleF(6f, 6f, 6f, 6f), gp.GetBounds());
Assert.Equal(new PointF[] { new PointF(6f, 6f), new PointF(8f, 8f), new PointF(12f, 12f), new PointF(10f, 10f) }, gp.PathPoints);
Assert.Equal(new byte[] { 0, 1, 1, 129 }, gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Transform_PathEmpty_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (Matrix matrix = new Matrix(1f, 1f, 2f, 2f, 3f, 3f))
{
gp.Transform(matrix);
Assert.Equal(new float[] { 1f, 1f, 2f, 2f, 3f, 3f }, matrix.Elements);
AssertEmptyGrahicsPath(gp);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Transform_MatrixNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("matrix", () => gp.Transform(null));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void GetBounds_PathEmpty_ReturnsExpected()
{
using (GraphicsPath gp = new GraphicsPath())
{
Assert.Equal(new RectangleF(0f, 0f, 0f, 0f), gp.GetBounds());
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void GetBounds_Rectangle_ReturnsExpected()
{
using (GraphicsPath gp = new GraphicsPath())
using (Matrix matrix = new Matrix())
{
RectangleF rectangle = new RectangleF(1f, 1f, 2f, 2f);
gp.AddRectangle(rectangle);
Assert.Equal(rectangle, gp.GetBounds());
Assert.Equal(rectangle, gp.GetBounds(null));
Assert.Equal(rectangle, gp.GetBounds(matrix));
Assert.Equal(rectangle, gp.GetBounds(null, null));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void GetBounds_Pie_ReturnsExpected()
{
using (GraphicsPath gp = new GraphicsPath())
using (Matrix matrix = new Matrix())
{
Rectangle rectangle = new Rectangle(10, 10, 100, 100);
gp.AddPie(rectangle, 30, 45);
AssertRectangleEqual(new RectangleF(60f, 60f, 43.3f, 48.3f), gp.GetBounds(), 0.1f);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_Empty_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.Flatten();
Assert.Equal(gp.PointCount, clone.PointCount);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_MatrixNull_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.Flatten(null);
Assert.Equal(gp.PointCount, clone.PointCount);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_MatrixNullFloat_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.Flatten(null, 1f);
Assert.Equal(gp.PointCount, clone.PointCount);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_Arc_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.AddArc(0f, 0f, 100f, 100f, 30, 30);
gp.Flatten();
AssertFlats(gp, clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_Bezier_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.AddBezier(0, 0, 100, 100, 30, 30, 60, 60);
gp.Flatten();
AssertFlats(gp, clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_ClosedCurve_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.AddClosedCurve(new Point[4]
{
new Point (0, 0), new Point (40, 20),
new Point (20, 40), new Point (40, 40)
});
gp.Flatten();
AssertFlats(gp, clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_Curve_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.AddCurve(new Point[4]
{
new Point (0, 0), new Point (40, 20),
new Point (20, 40), new Point (40, 40)
});
gp.Flatten();
AssertFlats(gp, clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_Ellipse_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.AddEllipse(10f, 10f, 100f, 100f);
gp.Flatten();
AssertFlats(gp, clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_Line_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.AddLine(10f, 10f, 100f, 100f);
gp.Flatten();
AssertFlats(gp, clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_Pie_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.AddPie(0, 0, 100, 100, 30, 30);
gp.Flatten();
AssertFlats(gp, clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_Polygon_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.AddPolygon(new Point[4]
{
new Point (0, 0), new Point (10, 10),
new Point (20, 20), new Point (40, 40)
});
gp.Flatten();
AssertFlats(gp, clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Flatten_Rectangle_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath clone = Assert.IsType<GraphicsPath>(gp.Clone()))
{
gp.AddRectangle(new Rectangle(0, 0, 100, 100));
gp.Flatten();
AssertFlats(gp, clone);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Warp_DestinationPointsNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("destPoints", () => gp.Warp(null, new RectangleF()));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Warp_DestinationPointsZero_ThrowsArgumentException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentException>(null, () => new GraphicsPath().Warp(new PointF[0], new RectangleF()));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Warp_PathEmpty_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (Matrix matrix = new Matrix())
{
Assert.Equal(0, gp.PointCount);
gp.Warp(new PointF[1] { new PointF(0, 0) }, new RectangleF(10, 20, 30, 40), matrix);
Assert.Equal(0, gp.PointCount);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Warp_WarpModeInvalid_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (Matrix matrix = new Matrix())
{
gp.AddPolygon(new Point[3] { new Point(5, 5), new Point(15, 5), new Point(10, 15) });
gp.Warp(new PointF[1] { new PointF(0, 0) }, new RectangleF(10, 20, 30, 40), matrix, (WarpMode)int.MinValue);
Assert.Equal(0, gp.PointCount);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Warp_RectangleEmpty_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddPolygon(new Point[3] { new Point(5, 5), new Point(15, 5), new Point(10, 15) });
gp.Warp(new PointF[1] { new PointF(0, 0) }, new Rectangle(), null);
AssertWrapNaN(gp);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void SetMarkers_EmptyPath_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.SetMarkers();
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void SetMarkers_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(new Point(1, 1), new Point(2, 2));
Assert.Equal(1, gp.PathTypes[1]);
gp.SetMarkers();
Assert.Equal(33, gp.PathTypes[1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void ClearMarkers_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(new Point(1, 1), new Point(2, 2));
Assert.Equal(1, gp.PathTypes[1]);
gp.SetMarkers();
Assert.Equal(33, gp.PathTypes[1]);
gp.ClearMarkers();
Assert.Equal(1, gp.PathTypes[1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void ClearMarkers_EmptyPath_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.ClearMarkers();
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void CloseFigure_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(new Point(1, 1), new Point(2, 2));
Assert.Equal(1, gp.PathTypes[1]);
gp.CloseFigure();
Assert.Equal(129, gp.PathTypes[1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void CloseFigure_EmptyPath_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.CloseFigure();
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void CloseAllFigures_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(new Point(1, 1), new Point(2, 2));
gp.StartFigure();
gp.AddLine(new Point(3, 3), new Point(4, 4));
Assert.Equal(1, gp.PathTypes[1]);
Assert.Equal(1, gp.PathTypes[3]);
gp.CloseAllFigures();
Assert.Equal(129, gp.PathTypes[1]);
Assert.Equal(129, gp.PathTypes[3]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void CloseAllFigures_EmptyPath_Success()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.CloseAllFigures();
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddArc()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddArc(10, 10, 100, 100, 90, 180);
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(1, types[2]);
Assert.Equal(3, types[gp.PointCount - 3]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddBezier()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddBezier(10, 10, 100, 100, 20, 20, 200, 200);
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(1, types[2]);
Assert.Equal(3, types[gp.PointCount - 3]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddBeziers()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddBeziers(new Point[7]
{
new Point (10, 10), new Point (20, 10), new Point (20, 20),
new Point (30, 20), new Point (40, 40), new Point (50, 40),
new Point (50, 50)
});
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(1, types[2]);
Assert.Equal(3, types[gp.PointCount - 3]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddClosedCurve()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddClosedCurve(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) });
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(0, types[2]);
Assert.Equal(131, types[gp.PointCount - 3]);
Assert.Equal(0, types[gp.PointCount - 2]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddCurve()
{
using (GraphicsPath path = new GraphicsPath())
{
path.AddLine(1, 1, 2, 2);
path.AddCurve(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) });
path.AddLine(10, 10, 20, 20);
byte[] types = path.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(1, types[2]);
Assert.Equal(3, types[path.PointCount - 3]);
Assert.Equal(1, types[path.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddEllipse()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddEllipse(10, 10, 100, 100);
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(0, types[2]);
Assert.Equal(131, types[gp.PointCount - 3]);
Assert.Equal(0, types[gp.PointCount - 2]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddLine()
{
using (GraphicsPath path = new GraphicsPath())
{
path.AddLine(1, 1, 2, 2);
path.AddLine(5, 5, 10, 10);
path.AddLine(10, 10, 20, 20);
byte[] types = path.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(1, types[2]);
Assert.Equal(1, types[path.PointCount - 3]);
Assert.Equal(1, types[path.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddLines()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddLines(new Point[4] { new Point(10, 10), new Point(20, 10), new Point(20, 20), new Point(30, 20) });
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(1, types[2]);
Assert.Equal(1, types[gp.PointCount - 3]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddPath_Connect()
{
using (GraphicsPath gp = new GraphicsPath())
using (GraphicsPath inner = new GraphicsPath())
{
inner.AddArc(10, 10, 100, 100, 90, 180);
gp.AddLine(1, 1, 2, 2);
gp.AddPath(inner, true);
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(1, types[2]);
Assert.Equal(3, types[gp.PointCount - 3]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddPath_NoConnect()
{
using (GraphicsPath inner = new GraphicsPath())
using (GraphicsPath path = new GraphicsPath())
{
inner.AddArc(10, 10, 100, 100, 90, 180);
path.AddLine(1, 1, 2, 2);
path.AddPath(inner, false);
path.AddLine(10, 10, 20, 20);
byte[] types = path.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(0, types[2]);
Assert.Equal(3, types[path.PointCount - 3]);
Assert.Equal(1, types[path.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddPie()
{
using (GraphicsPath path = new GraphicsPath())
{
path.AddLine(1, 1, 2, 2);
path.AddPie(10, 10, 10, 10, 90, 180);
path.AddLine(10, 10, 20, 20);
byte[] types = path.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(0, types[2]);
Assert.Equal(128, (types[path.PointCount - 3] & 128));
Assert.Equal(0, types[path.PointCount - 2]);
Assert.Equal(1, types[path.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddPolygon()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddPolygon(new Point[3] { new Point(1, 1), new Point(2, 2), new Point(3, 3) });
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(0, types[2]);
Assert.Equal(129, types[gp.PointCount - 3]);
Assert.Equal(0, types[gp.PointCount - 2]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddRectangle()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddRectangle(new RectangleF(10, 10, 20, 20));
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(0, types[2]);
Assert.Equal(129, types[gp.PointCount - 3]);
Assert.Equal(0, types[gp.PointCount - 2]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddRectangles()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddRectangles(new RectangleF[2]
{
new RectangleF (10, 10, 20, 20),
new RectangleF (20, 20, 10, 10)
});
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(0, types[2]);
Assert.Equal(129, types[gp.PointCount - 3]);
Assert.Equal(0, types[gp.PointCount - 2]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void StartClose_AddString()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 1, 2, 2);
gp.AddString("mono", FontFamily.GenericMonospace, 0, 10, new Point(20, 20), StringFormat.GenericDefault);
gp.AddLine(10, 10, 20, 20);
byte[] types = gp.PathTypes;
Assert.Equal(0, types[0]);
Assert.Equal(0, types[2]);
Assert.Equal(163, types[gp.PointCount - 3]);
Assert.Equal(1, types[gp.PointCount - 2]);
Assert.Equal(1, types[gp.PointCount - 1]);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Widen_Pen_Success()
{
PointF[] expectedPoints = new PointF[]
{
new PointF(0.5f, 0.5f), new PointF(3.5f, 0.5f), new PointF(3.5f, 3.5f),
new PointF(0.5f, 3.5f), new PointF(1.5f, 3.0f), new PointF(1.0f, 2.5f),
new PointF(3.0f, 2.5f), new PointF(2.5f, 3.0f), new PointF(2.5f, 1.0f),
new PointF(3.0f, 1.5f), new PointF(1.0f, 1.5f), new PointF(1.5f, 1.0f),
};
byte[] expectedTypes = new byte[] { 0, 1, 1, 129, 0, 1, 1, 1, 1, 1, 1, 129 };
using (GraphicsPath gp = new GraphicsPath())
using (Pen pen = new Pen(Color.Blue))
{
gp.AddRectangle(new Rectangle(1, 1, 2, 2));
Assert.Equal(4, gp.PointCount);
gp.Widen(pen);
Assert.Equal(12, gp.PointCount);
AssertPointsSequenceEqual(expectedPoints, gp.PathPoints, Delta);
Assert.Equal(expectedTypes, gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Widen_EmptyPath_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (Pen pen = new Pen(Color.Blue))
{
Assert.Equal(0, gp.PointCount);
gp.Widen(pen);
Assert.Equal(0, gp.PointCount);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Widen_PenNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("pen", () => gp.Widen(null));
AssertExtensions.Throws<ArgumentNullException>("pen", () => gp.Widen(null, new Matrix()));
AssertExtensions.Throws<ArgumentNullException>("pen", () => gp.Widen(null, new Matrix(), 0.67f));
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Widen_MatrixNull_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (Pen pen = new Pen(Color.Blue))
{
gp.AddPolygon(new Point[3] { new Point(5, 5), new Point(15, 5), new Point(10, 15) });
gp.Widen(pen, null);
Assert.Equal(9, gp.PointCount);
AssertWiden3(gp);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Widen_MatrixEmpty_Success()
{
using (GraphicsPath gp = new GraphicsPath())
using (Pen pen = new Pen(Color.Blue))
using (Matrix matrix = new Matrix())
{
gp.AddPolygon(new Point[3] { new Point(5, 5), new Point(15, 5), new Point(10, 15) });
gp.Widen(pen, new Matrix());
Assert.Equal(9, gp.PointCount);
AssertWiden3(gp);
}
}
public static IEnumerable<object[]> Widen_PenSmallWidth_TestData()
{
yield return new object[] { new Rectangle(1, 1, 2, 2), 0f, new RectangleF(0.5f, 0.5f, 3.0f, 3.0f) };
yield return new object[] { new Rectangle(1, 1, 2, 2), 0.5f, new RectangleF(0.5f, 0.5f, 3.0f, 3.0f) };
yield return new object[] { new Rectangle(1, 1, 2, 2), 1.0f, new RectangleF(0.5f, 0.5f, 3.0f, 3.0f) };
yield return new object[] { new Rectangle(1, 1, 2, 2), 1.1f, new RectangleF(0.45f, 0.45f, 3.10f, 3.10f) };
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(Widen_PenSmallWidth_TestData))]
public void Widen_Pen_SmallWidth_Succes(
Rectangle rectangle, float penWidth, RectangleF expectedBounds)
{
using (GraphicsPath gp = new GraphicsPath())
using (Pen pen = new Pen(Color.Aqua, 0))
using (Matrix matrix = new Matrix())
{
pen.Width = penWidth;
gp.AddRectangle(rectangle);
gp.Widen(pen);
AssertRectangleEqual(expectedBounds, gp.GetBounds(null), Delta);
AssertRectangleEqual(expectedBounds, gp.GetBounds(matrix), Delta);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsOutlineVisible_PenNull_ThrowsArgumentNullException()
{
using (GraphicsPath gp = new GraphicsPath())
{
AssertExtensions.Throws<ArgumentNullException>("pen", () => gp.IsOutlineVisible(1, 1, null));
AssertExtensions.Throws<ArgumentNullException>("pen", () => gp.IsOutlineVisible(1.0f, 1.0f, null));
AssertExtensions.Throws<ArgumentNullException>("pen", () => gp.IsOutlineVisible(new Point(), null));
AssertExtensions.Throws<ArgumentNullException>("pen", () => gp.IsOutlineVisible(new PointF(), null));
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsOutlineVisible_LineWithoutGraphics_ReturnsExpected()
{
AssertIsOutlineVisibleLine(null);
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsOutlineVisible_LineInsideGraphics_ReturnsExpected()
{
using (Bitmap bitmap = new Bitmap(20, 20))
using (Graphics graphics = Graphics.FromImage(bitmap))
{
AssertIsOutlineVisibleLine(graphics);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsOutlineVisible_LineOutsideGraphics_ReturnsExpected()
{
using (Bitmap bitmap = new Bitmap(5, 5))
using (Graphics graphics = Graphics.FromImage(bitmap))
{
AssertIsOutlineVisibleLine(graphics);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsOutlineVisible_LineWithGraphicsTransform_ReturnsExpected()
{
using (Bitmap bitmap = new Bitmap(20, 20))
using (Graphics graphics = Graphics.FromImage(bitmap))
using (Matrix matrix = new Matrix(2, 0, 0, 2, 50, -50))
{
graphics.Transform = matrix;
AssertIsOutlineVisibleLine(graphics);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsOutlineVisible_LineWithGraphicsPageUnit_ReturnsExpected()
{
using (Bitmap bitmap = new Bitmap(20, 20))
using (Graphics graphics = Graphics.FromImage(bitmap))
{
graphics.PageUnit = GraphicsUnit.Millimeter;
AssertIsOutlineVisibleLine(graphics);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsOutlineVisible_LineWithGraphicsPageScale_ReturnsExpected()
{
using (Bitmap bitmap = new Bitmap(20, 20))
using (Graphics graphics = Graphics.FromImage(bitmap))
{
graphics.PageScale = 2.0f;
AssertIsOutlineVisibleLine(graphics);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsOutlineVisible_RectangleWithoutGraphics_ReturnsExpected()
{
AssertIsOutlineVisibleRectangle(null);
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsVisible_RectangleWithoutGraphics_ReturnsExpected()
{
AssertIsVisibleRectangle(null);
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsVisible_RectangleWithGraphics_ReturnsExpected()
{
using (Bitmap bitmap = new Bitmap(40, 40))
using (Graphics graphics = Graphics.FromImage(bitmap))
{
AssertIsVisibleRectangle(graphics);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsVisible_EllipseWithoutGraphics_ReturnsExpected()
{
AssertIsVisibleEllipse(null);
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void IsVisible_EllipseWithGraphics_ReturnsExpected()
{
using (Bitmap bitmap = new Bitmap(40, 40))
using (Graphics graphics = Graphics.FromImage(bitmap))
{
AssertIsVisibleEllipse(graphics);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_Arc_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddArc(1f, 1f, 2f, 2f, Pi4, Pi4);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_Bezier_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddBezier(1, 2, 3, 4, 5, 6, 7, 8);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
public static IEnumerable<object[]> Reverse_TestData()
{
yield return new object[]
{
new Point[]
{
new Point (1,2), new Point (3,4), new Point (5,6), new Point (7,8),
new Point (9,10), new Point (11,12), new Point (13,14)
}
};
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(Reverse_TestData))]
public void Reverse_Beziers_Succes(Point[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddBeziers(points);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(Reverse_TestData))]
public void Reverse_ClosedCurve_Succes(Point[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddClosedCurve(points);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(Reverse_TestData))]
public void Reverse_Curve_Succes(Point[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddCurve(points);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_Ellipse_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddEllipse(1, 2, 3, 4);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_Line_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 2, 3, 4);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_LineClosed_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(1, 2, 3, 4);
gp.CloseFigure();
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(Reverse_TestData))]
public void Reverse_Lines_Succes(Point[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLines(points);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalTheory(Helpers.IsDrawingSupported)]
[MemberData(nameof(Reverse_TestData))]
public void Reverse_Polygon_Succes(Point[] points)
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddPolygon(points);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_Rectangle_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddRectangle(new Rectangle(1, 2, 3, 4));
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_Rectangles_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
Rectangle[] rects = new Rectangle[] { new Rectangle(1, 2, 3, 4), new Rectangle(5, 6, 7, 8) };
gp.AddRectangles(rects);
AssertReverse(gp, gp.PathPoints, gp.PathTypes);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_Pie_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddPie(1, 2, 3, 4, 10, 20);
byte[] expectedTypes = new byte[] { 0, 3, 3, 3, 129 };
AssertReverse(gp, gp.PathPoints, expectedTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_ArcLineInnerPath_Succes()
{
using (GraphicsPath inner = new GraphicsPath())
using (GraphicsPath gp = new GraphicsPath())
{
inner.AddArc(1f, 1f, 2f, 2f, Pi4, Pi4);
inner.AddLine(1, 2, 3, 4);
byte[] expectedTypes = new byte[] { 0, 1, 1, 3, 3, 3 };
gp.AddPath(inner, true);
AssertReverse(gp, gp.PathPoints, expectedTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_EllipseRectangle_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddEllipse(50, 51, 50, 100);
gp.AddRectangle(new Rectangle(200, 201, 60, 61));
byte[] expectedTypes = new byte[] { 0, 1, 1, 129, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 131 };
AssertReverse(gp, gp.PathPoints, expectedTypes);
}
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_String_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddString("Mono::", FontFamily.GenericMonospace, 0, 10, new Point(10, 10), StringFormat.GenericDefault);
byte[] expectedTypes = new byte[]
{
0,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,129,
0,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,161,
0,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,129,
0,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,161,
0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,131,0,3,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,163,0,3,3,3,
3,3,3,3,3,3,3,3,3,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,
3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,
3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,
3,3,3,3,3,3,3,3,3,3,3,161,0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
3,3,3,3,3,3,3,3,3,131,0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
3,3,3,3,3,3,3,163,0,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,
3,3,3,3,3,3,3,3,3,3,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,
1,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,
1,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,129
};
AssertReverse(gp, gp.PathPoints, expectedTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_Marker_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddRectangle(new Rectangle(200, 201, 60, 61));
gp.SetMarkers();
byte[] expectedTypes = new byte[] { 0, 1, 1, 129 };
AssertReverse(gp, gp.PathPoints, expectedTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Reverse_SubpathMarker_Succes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(0, 1, 2, 3);
gp.SetMarkers();
gp.CloseFigure();
gp.AddBezier(5, 6, 7, 8, 9, 10, 11, 12);
gp.CloseFigure();
byte[] expectedTypes = new byte[] { 0, 3, 3, 163, 0, 129 };
AssertReverse(gp, gp.PathPoints, expectedTypes);
}
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(0, 1, 2, 3);
gp.SetMarkers();
gp.StartFigure();
gp.AddLine(20, 21, 22, 23);
gp.AddBezier(5, 6, 7, 8, 9, 10, 11, 12);
byte[] expectedTypes = new byte[] { 0, 3, 3, 3, 1, 33, 0, 1 };
AssertReverse(gp, gp.PathPoints, expectedTypes);
}
}
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Ctor_PointsTypes_Succes()
{
int dX = 520;
int dY = 320;
Point[] expectedPoints = new Point[]
{
new Point(dX-64, dY-24), new Point(dX-59, dY-34), new Point(dX-52, dY-54),
new Point(dX-18, dY-66), new Point(dX-34, dY-47), new Point(dX-43, dY-27),
new Point(dX-44, dY-8),
};
byte[] expectedTypes = new byte[]
{
(byte)PathPointType.Start, (byte)PathPointType.Bezier, (byte)PathPointType.Bezier,
(byte)PathPointType.Bezier, (byte)PathPointType.Bezier, (byte)PathPointType.Bezier,
(byte)PathPointType.Bezier
};
using (GraphicsPath path = new GraphicsPath(expectedPoints, expectedTypes))
{
Assert.Equal(7, path.PointCount);
byte[] actualTypes = path.PathTypes;
Assert.Equal(expectedTypes, actualTypes);
}
}
private void AssertEmptyGrahicsPath(GraphicsPath gp)
{
Assert.Equal(0, gp.PathData.Points.Length);
Assert.Equal(0, gp.PathData.Types.Length);
Assert.Equal(0, gp.PointCount);
}
private void AssertEqual(float expexted, float actual, float tollerance)
{
AssertExtensions.LessThanOrEqualTo(Math.Abs(expexted - actual), tollerance);
}
private void AssertLine(GraphicsPath path)
{
PointF[] expectedPoints = new PointF[]
{
new PointF(1f, 1f), new PointF(2f, 2f)
};
Assert.Equal(2, path.PathPoints.Length);
Assert.Equal(2, path.PathTypes.Length);
Assert.Equal(2, path.PathData.Points.Length);
Assert.Equal(new RectangleF(1f, 1f, 1f, 1f), path.GetBounds());
Assert.Equal(expectedPoints, path.PathPoints);
Assert.Equal(new byte[] { 0, 1 }, path.PathTypes);
}
private void AssertArc(GraphicsPath path)
{
PointF[] expectedPoints = new PointF[]
{
new PointF(2.99990582f, 2.01370716f), new PointF(2.99984312f, 2.018276f),
new PointF(2.99974918f, 2.02284455f), new PointF(2.999624f, 2.027412f),
};
Assert.Equal(4, path.PathPoints.Length);
Assert.Equal(4, path.PathTypes.Length);
Assert.Equal(4, path.PathData.Points.Length);
Assert.Equal(new RectangleF(2.99962401f, 2.01370716f, 0f, 0.0137047768f), path.GetBounds());
Assert.Equal(expectedPoints, path.PathPoints);
Assert.Equal(new byte[] { 0, 3, 3, 3 }, path.PathTypes);
}
private void AssertBezier(GraphicsPath path)
{
PointF[] expectedPoints = new PointF[]
{
new PointF(1f, 1f), new PointF(2f, 2f),
new PointF(3f, 3f), new PointF(4f, 4f),
};
Assert.Equal(4, path.PointCount);
Assert.Equal(4, path.PathPoints.Length);
Assert.Equal(4, path.PathTypes.Length);
Assert.Equal(4, path.PathData.Points.Length);
Assert.Equal(new RectangleF(1f, 1f, 3f, 3f), path.GetBounds());
Assert.Equal(expectedPoints, path.PathPoints);
Assert.Equal(new byte[] { 0, 3, 3, 3 }, path.PathTypes);
}
private void AssertCurve(GraphicsPath path)
{
PointF[] expectedPoints = new PointF[]
{
new PointF(1f, 1f), new PointF(1.16666663f, 1.16666663f),
new PointF(1.83333325f, 1.83333325f), new PointF(2f, 2f)
};
Assert.Equal(4, path.PathPoints.Length);
Assert.Equal(4, path.PathTypes.Length);
Assert.Equal(4, path.PathData.Points.Length);
Assert.Equal(new RectangleF(1f, 1f, 1f, 1f), path.GetBounds());
AssertPointsSequenceEqual(expectedPoints, path.PathPoints, Delta);
Assert.Equal(new byte[] { 0, 3, 3, 3 }, path.PathTypes);
}
private void AssertClosedCurve(GraphicsPath path)
{
Assert.Equal(10, path.PathPoints.Length);
Assert.Equal(10, path.PathTypes.Length);
Assert.Equal(10, path.PathData.Points.Length);
Assert.Equal(new RectangleF(0.8333333f, 0.8333333f, 2.33333278f, 2.33333278f), path.GetBounds());
Assert.Equal(new byte[] { 0, 3, 3, 3, 3, 3, 3, 3, 3, 131 }, path.PathTypes);
}
private void AssertRectangle(GraphicsPath path)
{
PointF[] expectedPoints = new PointF[]
{
new PointF(1f, 1f), new PointF(3f, 1f),
new PointF(3f, 3f), new PointF(1f, 3f)
};
Assert.Equal(4, path.PathPoints.Length);
Assert.Equal(4, path.PathTypes.Length);
Assert.Equal(4, path.PathData.Points.Length);
Assert.Equal(new RectangleF(1f, 1f, 2f, 2f), path.GetBounds());
Assert.Equal(expectedPoints, path.PathPoints);
Assert.Equal(new byte[] { 0, 1, 1, 129 }, path.PathTypes);
}
private void AssertEllipse(GraphicsPath path)
{
Assert.Equal(13, path.PathPoints.Length);
Assert.Equal(13, path.PathTypes.Length);
Assert.Equal(13, path.PathData.Points.Length);
Assert.Equal(new RectangleF(1f, 1f, 2f, 2f), path.GetBounds());
Assert.Equal(new byte[] { 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 131 }, path.PathTypes);
}
private void AssertPie(GraphicsPath path)
{
PointF[] expectedPoints = new PointF[]
{
new PointF(2f, 2f), new PointF(2.99990582f, 2.01370716f),
new PointF(2.99984312f, 2.018276f), new PointF(2.99974918f, 2.02284455f),
new PointF(2.999624f, 2.027412f)
};
Assert.Equal(5, path.PathPoints.Length);
Assert.Equal(5, path.PathTypes.Length);
Assert.Equal(5, path.PathData.Points.Length);
AssertRectangleEqual(new RectangleF(2f, 2f, 0.9999058f, 0.0274119377f), path.GetBounds(), Delta);
AssertPointsSequenceEqual(expectedPoints, path.PathPoints, Delta);
Assert.Equal(new byte[] { 0, 1, 3, 3, 131 }, path.PathTypes);
}
private void AssertPolygon(GraphicsPath path)
{
PointF[] expectedPoints = new PointF[]
{
new PointF(1f, 1f),
new PointF(2f, 2f),
new PointF(3f, 3f)
};
Assert.Equal(3, path.PathPoints.Length);
Assert.Equal(3, path.PathTypes.Length);
Assert.Equal(3, path.PathData.Points.Length);
Assert.Equal(new RectangleF(1f, 1f, 2f, 2f), path.GetBounds());
Assert.Equal(expectedPoints, path.PathPoints);
Assert.Equal(new byte[] { 0, 1, 129 }, path.PathTypes);
}
private void AssertFlats(GraphicsPath flat, GraphicsPath original)
{
AssertExtensions.GreaterThanOrEqualTo(flat.PointCount, original.PointCount);
for (int i = 0; i < flat.PointCount; i++)
{
Assert.NotEqual(3, flat.PathTypes[i]);
}
}
private void AssertWrapNaN(GraphicsPath path)
{
byte[] expectedTypes = new byte[] { 0, 1, 129 };
Assert.Equal(3, path.PointCount);
Assert.Equal(float.NaN, path.PathPoints[0].X);
Assert.Equal(float.NaN, path.PathPoints[0].Y);
Assert.Equal(float.NaN, path.PathPoints[1].X);
Assert.Equal(float.NaN, path.PathPoints[1].Y);
Assert.Equal(float.NaN, path.PathPoints[2].X);
Assert.Equal(float.NaN, path.PathPoints[2].Y);
Assert.Equal(expectedTypes, path.PathTypes);
}
private void AssertWiden3(GraphicsPath path)
{
PointF[] expectedPoints = new PointF[]
{
new PointF(4.2f, 4.5f), new PointF(15.8f, 4.5f),
new PointF(10.0f, 16.1f), new PointF(10.4f, 14.8f),
new PointF(9.6f, 14.8f), new PointF(14.6f, 4.8f),
new PointF(15.0f, 5.5f), new PointF(5.0f, 5.5f),
new PointF(5.4f, 4.8f)
};
AssertPointsSequenceEqual(expectedPoints, path.PathPoints, 0.25f);
Assert.Equal(new byte[] { 0, 1, 129, 0, 1, 1, 1, 1, 129 }, path.PathTypes);
}
private void AssertIsOutlineVisibleLine(Graphics graphics)
{
using (GraphicsPath gp = new GraphicsPath())
using (Pen pen = new Pen(Color.Red, 3.0f))
{
gp.AddLine(10, 1, 14, 1);
Assert.True(gp.IsOutlineVisible(10, 1, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(10, 2, pen, graphics));
Assert.False(gp.IsOutlineVisible(10, 2, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(11.0f, 1.0f, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(11.0f, 1.0f, pen, graphics));
Assert.False(gp.IsOutlineVisible(11.0f, 2.0f, Pens.Red, graphics));
Point point = new Point(12, 2);
Assert.False(gp.IsOutlineVisible(point, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(point, pen, graphics));
point.Y = 1;
Assert.True(gp.IsOutlineVisible(point, Pens.Red, graphics));
PointF fPoint = new PointF(13.0f, 2.0f);
Assert.False(gp.IsOutlineVisible(fPoint, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(fPoint, pen, graphics));
fPoint.Y = 1;
Assert.True(gp.IsOutlineVisible(fPoint, Pens.Red, graphics));
}
}
private void AssertIsOutlineVisibleRectangle(Graphics graphics)
{
using (Pen pen = new Pen(Color.Red, 3.0f))
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddRectangle(new Rectangle(10, 10, 20, 20));
Assert.True(gp.IsOutlineVisible(10, 10, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(10, 11, pen, graphics));
Assert.False(gp.IsOutlineVisible(11, 11, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(11.0f, 10.0f, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(11.0f, 11.0f, pen, graphics));
Assert.False(gp.IsOutlineVisible(11.0f, 11.0f, Pens.Red, graphics));
Point point = new Point(15, 10);
Assert.True(gp.IsOutlineVisible(point, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(point, pen, graphics));
point.Y = 15;
Assert.False(gp.IsOutlineVisible(point, Pens.Red, graphics));
PointF fPoint = new PointF(29.0f, 29.0f);
Assert.False(gp.IsOutlineVisible(fPoint, Pens.Red, graphics));
Assert.True(gp.IsOutlineVisible(fPoint, pen, graphics));
fPoint.Y = 31.0f;
Assert.True(gp.IsOutlineVisible(fPoint, pen, graphics));
}
}
private void AssertIsVisibleRectangle(Graphics graphics)
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddRectangle(new Rectangle(10, 10, 20, 20));
Assert.False(gp.IsVisible(9, 9, graphics));
Assert.True(gp.IsVisible(10, 10, graphics));
Assert.True(gp.IsVisible(20, 20, graphics));
Assert.True(gp.IsVisible(29, 29, graphics));
Assert.False(gp.IsVisible(30, 29, graphics));
Assert.False(gp.IsVisible(29, 30, graphics));
Assert.False(gp.IsVisible(30, 30, graphics));
Assert.False(gp.IsVisible(9.4f, 9.4f, graphics));
Assert.True(gp.IsVisible(9.5f, 9.5f, graphics));
Assert.True(gp.IsVisible(10f, 10f, graphics));
Assert.True(gp.IsVisible(20f, 20f, graphics));
Assert.True(gp.IsVisible(29.4f, 29.4f, graphics));
Assert.False(gp.IsVisible(29.5f, 29.5f, graphics));
Assert.False(gp.IsVisible(29.5f, 29.4f, graphics));
Assert.False(gp.IsVisible(29.4f, 29.5f, graphics));
}
}
private void AssertIsVisibleEllipse(Graphics graphics)
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddEllipse(new Rectangle(10, 10, 20, 20));
Assert.False(gp.IsVisible(10, 10, graphics));
Assert.True(gp.IsVisible(20, 20, graphics));
Assert.False(gp.IsVisible(29, 29, graphics));
Assert.False(gp.IsVisible(10f, 10f, graphics));
Assert.True(gp.IsVisible(20f, 20f, graphics));
Assert.False(gp.IsVisible(29.4f, 29.4f, graphics));
}
}
private void AssertReverse(GraphicsPath gp, PointF[] expectedPoints, byte[] expectedTypes)
{
gp.Reverse();
PointF[] reversedPoints = gp.PathPoints;
byte[] reversedTypes = gp.PathTypes;
int count = gp.PointCount;
Assert.Equal(expectedPoints.Length, gp.PointCount);
Assert.Equal(expectedTypes, gp.PathTypes);
for (int i = 0; i < count; i++)
{
Assert.Equal(expectedPoints[i], reversedPoints[count - i - 1]);
Assert.Equal(expectedTypes[i], reversedTypes[i]);
}
}
private void AssertPointsSequenceEqual(PointF[] expected, PointF[] actual, float tolerance)
{
int count = expected.Length;
Assert.Equal(expected.Length, actual.Length);
for (int i = 0; i < count; i++)
{
AssertExtensions.LessThanOrEqualTo(Math.Abs(expected[i].X - actual[i].X), tolerance);
AssertExtensions.LessThanOrEqualTo(Math.Abs(expected[i].Y - actual[i].Y), tolerance);
}
}
private void AssertRectangleEqual(RectangleF expected, RectangleF actual, float tolerance)
{
AssertExtensions.LessThanOrEqualTo(Math.Abs(expected.X - actual.X), tolerance);
AssertExtensions.LessThanOrEqualTo(Math.Abs(expected.Y - actual.Y), tolerance);
AssertExtensions.LessThanOrEqualTo(Math.Abs(expected.Width - actual.Width), tolerance);
AssertExtensions.LessThanOrEqualTo(Math.Abs(expected.Height - actual.Height), tolerance);
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/Common/tests/StaticTestGenerator/StaticTestGenerator.csproj | <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<LangVersion>preview</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn />
<Nullable>enable</Nullable>
<ImportDirectoryBuildTargets>false</ImportDirectoryBuildTargets>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="3.8.0-4.final" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.8.0-4.final" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
<PackageReference Include="xunit.console" Version="2.4.1" />
<PackageReference Include="xunit.core" Version="2.4.1" />
<PackageReference Include="xunit.runner.utility" Version="2.4.1" />
</ItemGroup>
</Project>
| <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<LangVersion>preview</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn />
<Nullable>enable</Nullable>
<ImportDirectoryBuildTargets>false</ImportDirectoryBuildTargets>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="3.8.0-4.final" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.8.0-4.final" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
<PackageReference Include="xunit.console" Version="2.4.1" />
<PackageReference Include="xunit.core" Version="2.4.1" />
<PackageReference Include="xunit.runner.utility" Version="2.4.1" />
</ItemGroup>
</Project>
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/coreclr/pal/tests/palsuite/threading/CreateThread/test3/test3.cpp | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/*===========================================================
**
** Source: test3.c
**
** Purpose: Check to see that the handle CreateThread returns
** can be closed while the thread is still running.
**
**
**=========================================================*/
#include <palsuite.h>
HANDLE hThread_CreateThread_test3;
HANDLE hEvent_CreateThread_test3;
DWORD PALAPI Thread_CreateThread_test3( LPVOID lpParameter)
{
DWORD dwRet;
dwRet = WaitForSingleObject(hEvent_CreateThread_test3, INFINITE);
/* if this thread continues beyond here, fail */
Fail("");
return 0;
}
PALTEST(threading_CreateThread_test3_paltest_createthread_test3, "threading/CreateThread/test3/paltest_createthread_test3")
{
DWORD dwThreadId;
DWORD dwRet;
if(0 != (PAL_Initialize(argc, argv)))
{
return (FAIL);
}
hEvent_CreateThread_test3 = CreateEvent(NULL, TRUE, FALSE, NULL);
if (hEvent_CreateThread_test3 == NULL)
{
Fail("PALSUITE ERROR: CreateEvent call #0 failed. GetLastError "
"returned %u.\n", GetLastError());
}
/* pass the index as the thread argument */
hThread_CreateThread_test3 = CreateThread( NULL,
0,
&Thread_CreateThread_test3,
(LPVOID) 0,
0,
&dwThreadId);
if (hThread_CreateThread_test3 == NULL)
{
Trace("PALSUITE ERROR: CreateThread('%p' '%d' '%p' '%p' '%d' '%p') "
"call failed.\nGetLastError returned '%u'.\n", NULL,
0, &Thread_CreateThread_test3, (LPVOID) 0, 0, &dwThreadId, GetLastError());
if (0 == CloseHandle(hEvent_CreateThread_test3))
{
Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during "
"clean up.\nGetLastError returned '%u'.\n", hEvent_CreateThread_test3);
}
Fail("");
}
dwRet = WaitForSingleObject(hThread_CreateThread_test3, 10000);
if (dwRet != WAIT_TIMEOUT)
{
Trace ("PALSUITE ERROR: WaitForSingleObject('%p' '%d') "
"call returned %d instead of WAIT_TIMEOUT ('%d').\n"
"GetLastError returned '%u'.\n", hThread_CreateThread_test3, 10000,
dwRet, WAIT_TIMEOUT, GetLastError());
Fail("");
}
if (0 == CloseHandle(hThread_CreateThread_test3))
{
Trace("PALSUITE ERROR: Unable to CloseHandle(%p) on a running thread."
"\nGetLastError returned '%u'.\n", hThread_CreateThread_test3, GetLastError());
if (0 == CloseHandle(hEvent_CreateThread_test3))
{
Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during "
"cleanup.\nGetLastError returned '%u'.\n", hEvent_CreateThread_test3,
GetLastError());
}
Fail("");
}
if (0 == CloseHandle(hEvent_CreateThread_test3))
{
Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during "
"cleanup.\nGetLastError returned '%u'.\n", hEvent_CreateThread_test3,
GetLastError());
Fail("");
}
PAL_Terminate();
return (PASS);
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/*===========================================================
**
** Source: test3.c
**
** Purpose: Check to see that the handle CreateThread returns
** can be closed while the thread is still running.
**
**
**=========================================================*/
#include <palsuite.h>
HANDLE hThread_CreateThread_test3;
HANDLE hEvent_CreateThread_test3;
DWORD PALAPI Thread_CreateThread_test3( LPVOID lpParameter)
{
DWORD dwRet;
dwRet = WaitForSingleObject(hEvent_CreateThread_test3, INFINITE);
/* if this thread continues beyond here, fail */
Fail("");
return 0;
}
PALTEST(threading_CreateThread_test3_paltest_createthread_test3, "threading/CreateThread/test3/paltest_createthread_test3")
{
DWORD dwThreadId;
DWORD dwRet;
if(0 != (PAL_Initialize(argc, argv)))
{
return (FAIL);
}
hEvent_CreateThread_test3 = CreateEvent(NULL, TRUE, FALSE, NULL);
if (hEvent_CreateThread_test3 == NULL)
{
Fail("PALSUITE ERROR: CreateEvent call #0 failed. GetLastError "
"returned %u.\n", GetLastError());
}
/* pass the index as the thread argument */
hThread_CreateThread_test3 = CreateThread( NULL,
0,
&Thread_CreateThread_test3,
(LPVOID) 0,
0,
&dwThreadId);
if (hThread_CreateThread_test3 == NULL)
{
Trace("PALSUITE ERROR: CreateThread('%p' '%d' '%p' '%p' '%d' '%p') "
"call failed.\nGetLastError returned '%u'.\n", NULL,
0, &Thread_CreateThread_test3, (LPVOID) 0, 0, &dwThreadId, GetLastError());
if (0 == CloseHandle(hEvent_CreateThread_test3))
{
Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during "
"clean up.\nGetLastError returned '%u'.\n", hEvent_CreateThread_test3);
}
Fail("");
}
dwRet = WaitForSingleObject(hThread_CreateThread_test3, 10000);
if (dwRet != WAIT_TIMEOUT)
{
Trace ("PALSUITE ERROR: WaitForSingleObject('%p' '%d') "
"call returned %d instead of WAIT_TIMEOUT ('%d').\n"
"GetLastError returned '%u'.\n", hThread_CreateThread_test3, 10000,
dwRet, WAIT_TIMEOUT, GetLastError());
Fail("");
}
if (0 == CloseHandle(hThread_CreateThread_test3))
{
Trace("PALSUITE ERROR: Unable to CloseHandle(%p) on a running thread."
"\nGetLastError returned '%u'.\n", hThread_CreateThread_test3, GetLastError());
if (0 == CloseHandle(hEvent_CreateThread_test3))
{
Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during "
"cleanup.\nGetLastError returned '%u'.\n", hEvent_CreateThread_test3,
GetLastError());
}
Fail("");
}
if (0 == CloseHandle(hEvent_CreateThread_test3))
{
Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during "
"cleanup.\nGetLastError returned '%u'.\n", hEvent_CreateThread_test3,
GetLastError());
Fail("");
}
PAL_Terminate();
return (PASS);
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/Loader/classloader/generics/GenericMethods/arity01.il | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
.assembly extern System.Console { }
.assembly extern xunit.core {}
// Microsoft (R) .NET Framework IL Disassembler. Version 1.1.2019.0
// Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.
// Metadata version: v1.1.2019
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.hash = (73 26 79 1F 31 96 69 CE 57 B9 48 24 EE A8 34 F1 // s&y.1.i.W.H$..4.
42 87 88 29 ) // B..)
.ver 1:1:3300:0
}
.assembly arity01
{
// --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(bool,
// bool) = ( 01 00 00 01 00 00 )
.hash algorithm 0x00008004
.ver 0:0:0:0
}
// MVID: {076E2FBD-6901-448E-AD54-697AB5AE59C9}
.imagebase 0x00400000
.subsystem 0x00000003
.file alignment 512
.corflags 0x00000001
// Image base: 0x034B0000
// =============== CLASS MEMBERS DECLARATION ===================
.class private auto ansi beforefieldinit Foo
extends [mscorlib]System.Object
{
.method public hidebysig instance string
Function() cil managed
{
// Code size 20 (0x14)
.maxstack 1
.locals init (string V_0)
IL_0000: ldstr "0 TPs"
IL_0005: call void [System.Console]System.Console::WriteLine(string)
IL_000a: ldstr ""
IL_000f: stloc.0
IL_0010: br.s IL_0012
IL_0012: ldloc.0
IL_0013: ret
} // end of method Foo::Function
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 1
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method Foo::.ctor
.method public hidebysig instance string
Function<([mscorlib]System.Object) T>(!!0 t) cil managed
{
// Code size 26 (0x1a)
.maxstack 1
.locals init (string V_0)
IL_0000: ldstr "1 TPs"
IL_0005: call void [System.Console]System.Console::WriteLine(string)
IL_000a: ldarg.1
IL_000b: box !!0
IL_0010: callvirt instance string [mscorlib]System.Object::ToString()
IL_0015: stloc.0
IL_0016: br.s IL_0018
IL_0018: ldloc.0
IL_0019: ret
} // end of method Foo01::Function
.method public hidebysig instance string
Function<([mscorlib]System.Object) T,([mscorlib]System.Object) U>(!!0 t,
!!1 u) cil managed
{
// Code size 42 (0x2a)
.maxstack 2
.locals init (string V_0)
IL_0000: ldstr "2 TPs"
IL_0005: call void [System.Console]System.Console::WriteLine(string)
IL_000a: ldarg.1
IL_000b: box !!0
IL_0010: callvirt instance string [mscorlib]System.Object::ToString()
IL_0015: ldarg.2
IL_0016: box !!1
IL_001b: callvirt instance string [mscorlib]System.Object::ToString()
IL_0020: call string [mscorlib]System.String::Concat(string,
string)
IL_0025: stloc.0
IL_0026: br.s IL_0028
IL_0028: ldloc.0
IL_0029: ret
} // end of method Foo02::Function
.method public hidebysig instance string
Function<([mscorlib]System.Object) T,([mscorlib]System.Object) U,([mscorlib]System.Object) V>(!!0 t,
!!1 u,
!!2 v) cil managed
{
// Code size 53 (0x35)
.maxstack 3
.locals init (string V_0)
IL_0000: ldstr "3 TPs"
IL_0005: call void [System.Console]System.Console::WriteLine(string)
IL_000a: ldarg.1
IL_000b: box !!0
IL_0010: callvirt instance string [mscorlib]System.Object::ToString()
IL_0015: ldarg.2
IL_0016: box !!1
IL_001b: callvirt instance string [mscorlib]System.Object::ToString()
IL_0020: ldarg.3
IL_0021: box !!2
IL_0026: callvirt instance string [mscorlib]System.Object::ToString()
IL_002b: call string [mscorlib]System.String::Concat(string,
string,
string)
IL_0030: stloc.0
IL_0031: br.s IL_0033
IL_0033: ldloc.0
IL_0034: ret
} // end of method Foo03::Function
} // end of class Foo03
.class public auto ansi beforefieldinit Test_arity01
extends [mscorlib]System.Object
{
.field public static int32 counter
.field public static bool result
.method public hidebysig static void Eval(bool exp) cil managed
{
// Code size 47 (0x2f)
.maxstack 2
IL_0000: ldsfld int32 Test_arity01::counter
IL_0005: ldc.i4.1
IL_0006: add
IL_0007: stsfld int32 Test_arity01::counter
IL_000c: ldarg.0
IL_000d: brtrue.s IL_002e
IL_000f: ldarg.0
IL_0010: stsfld bool Test_arity01::result
IL_0015: ldstr "Test Failed at location: "
IL_001a: ldsfld int32 Test_arity01::counter
IL_001f: box [mscorlib]System.Int32
IL_0024: call string [mscorlib]System.String::Concat(object,
object)
IL_0029: call void [System.Console]System.Console::WriteLine(string)
IL_002e: ret
} // end of method Test::Eval
.method public hidebysig static int32 Main() cil managed
{
.custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = (
01 00 00 00
)
.entrypoint
// Code size 478 (0x1de)
.maxstack 4
.locals init (class Foo V_0,
class Foo V_1,
class Foo V_2,
class Foo V_3,
int32 V_4)
IL_0000: newobj instance void Foo::.ctor()
IL_0005: stloc.0
IL_0006: newobj instance void Foo::.ctor()
IL_000b: stloc.1
IL_000c: newobj instance void Foo::.ctor()
IL_0011: stloc.2
IL_0012: newobj instance void Foo::.ctor()
IL_0017: stloc.3
IL_0018: ldloc.0
IL_0019: callvirt instance string Foo::Function()
IL_001e: ldstr ""
IL_0023: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0028: call void Test_arity01::Eval(bool)
IL_002d: ldloc.0
IL_002e: ldstr "1"
IL_0033: callvirt instance string Foo::Function<string>(!!0)
IL_0038: ldstr "1"
IL_003d: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0042: call void Test_arity01::Eval(bool)
IL_0047: ldloc.0
IL_0048: ldc.i4.1
IL_0049: callvirt instance string Foo::Function<int32>(!!0)
IL_004e: ldstr "1"
IL_0053: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0058: call void Test_arity01::Eval(bool)
IL_005d: ldloc.0
IL_005e: ldstr "1"
IL_0063: ldstr "2"
IL_0068: callvirt instance string Foo::Function<string,string>(!!0,
!!1)
IL_006d: ldstr "12"
IL_0072: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0077: call void Test_arity01::Eval(bool)
IL_007c: ldloc.0
IL_007d: ldc.i4.1
IL_007e: ldc.i4.2
IL_007f: callvirt instance string Foo::Function<int32,int32>(!!0,
!!1)
IL_0084: ldstr "12"
IL_0089: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_008e: call void Test_arity01::Eval(bool)
IL_0093: ldloc.0
IL_0094: ldc.i4.1
IL_0095: ldstr "2"
IL_009a: callvirt instance string Foo::Function<int32,string>(!!0,
!!1)
IL_009f: ldstr "12"
IL_00a4: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_00a9: call void Test_arity01::Eval(bool)
IL_00ae: ldloc.0
IL_00af: ldstr "1"
IL_00b4: ldc.i4.2
IL_00b5: callvirt instance string Foo::Function<string,int32>(!!0,
!!1)
IL_00ba: ldstr "12"
IL_00bf: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_00c4: call void Test_arity01::Eval(bool)
IL_00c9: ldloc.0
IL_00ca: ldstr "1"
IL_00cf: ldstr "2"
IL_00d4: ldstr "3"
IL_00d9: callvirt instance string Foo::Function<string,string,string>(!!0,
!!1,
!!2)
IL_00de: ldstr "123"
IL_00e3: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_00e8: call void Test_arity01::Eval(bool)
IL_00ed: ldloc.0
IL_00ee: ldstr "1"
IL_00f3: ldstr "2"
IL_00f8: ldc.i4.3
IL_00f9: callvirt instance string Foo::Function<string,string,int32>(!!0,
!!1,
!!2)
IL_00fe: ldstr "123"
IL_0103: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0108: call void Test_arity01::Eval(bool)
IL_010d: ldloc.0
IL_010e: ldstr "1"
IL_0113: ldc.i4.2
IL_0114: ldc.i4.3
IL_0115: callvirt instance string Foo::Function<string,int32,int32>(!!0,
!!1,
!!2)
IL_011a: ldstr "123"
IL_011f: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0124: call void Test_arity01::Eval(bool)
IL_0129: ldloc.0
IL_012a: ldstr "1"
IL_012f: ldc.i4.2
IL_0130: ldstr "3"
IL_0135: callvirt instance string Foo::Function<string,int32,string>(!!0,
!!1,
!!2)
IL_013a: ldstr "123"
IL_013f: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0144: call void Test_arity01::Eval(bool)
IL_0149: ldloc.0
IL_014a: ldc.i4.1
IL_014b: ldc.i4.2
IL_014c: ldc.i4.3
IL_014d: callvirt instance string Foo::Function<int32,int32,int32>(!!0,
!!1,
!!2)
IL_0152: ldstr "123"
IL_0157: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_015c: call void Test_arity01::Eval(bool)
IL_0161: ldloc.0
IL_0162: ldc.i4.1
IL_0163: ldc.i4.2
IL_0164: ldstr "3"
IL_0169: callvirt instance string Foo::Function<int32,int32,string>(!!0,
!!1,
!!2)
IL_016e: ldstr "123"
IL_0173: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0178: call void Test_arity01::Eval(bool)
IL_017d: ldloc.0
IL_017e: ldc.i4.1
IL_017f: ldstr "2"
IL_0184: ldc.i4.3
IL_0185: callvirt instance string Foo::Function<int32,string,int32>(!!0,
!!1,
!!2)
IL_018a: ldstr "123"
IL_018f: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0194: call void Test_arity01::Eval(bool)
IL_0199: ldloc.0
IL_019a: ldstr "1"
IL_019f: ldc.i4.2
IL_01a0: ldc.i4.3
IL_01a1: callvirt instance string Foo::Function<string,int32,int32>(!!0,
!!1,
!!2)
IL_01a6: ldstr "123"
IL_01ab: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_01b0: call void Test_arity01::Eval(bool)
IL_01b5: ldsfld bool Test_arity01::result
IL_01ba: brfalse.s IL_01cc
IL_01bc: ldstr "Test Passed"
IL_01c1: call void [System.Console]System.Console::WriteLine(string)
IL_01c6: ldc.i4.s 100
IL_01c8: stloc.s V_4
IL_01ca: br.s IL_01db
IL_01cc: ldstr "Test Failed"
IL_01d1: call void [System.Console]System.Console::WriteLine(string)
IL_01d6: ldc.i4.1
IL_01d7: stloc.s V_4
IL_01d9: br.s IL_01db
IL_01db: ldloc.s V_4
IL_01dd: ret
} // end of method Test::Main
.method private hidebysig specialname rtspecialname static
void .cctor() cil managed
{
// Code size 13 (0xd)
.maxstack 1
IL_0000: ldc.i4.0
IL_0001: stsfld int32 Test_arity01::counter
IL_0006: ldc.i4.1
IL_0007: stsfld bool Test_arity01::result
IL_000c: ret
} // end of method Test::.cctor
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 1
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method Test::.ctor
} // end of class Test
// =============================================================
//*********** DISASSEMBLY COMPLETE ***********************
// WARNING: Created Win32 resource file arity01.res
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
.assembly extern System.Console { }
.assembly extern xunit.core {}
// Microsoft (R) .NET Framework IL Disassembler. Version 1.1.2019.0
// Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.
// Metadata version: v1.1.2019
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.hash = (73 26 79 1F 31 96 69 CE 57 B9 48 24 EE A8 34 F1 // s&y.1.i.W.H$..4.
42 87 88 29 ) // B..)
.ver 1:1:3300:0
}
.assembly arity01
{
// --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(bool,
// bool) = ( 01 00 00 01 00 00 )
.hash algorithm 0x00008004
.ver 0:0:0:0
}
// MVID: {076E2FBD-6901-448E-AD54-697AB5AE59C9}
.imagebase 0x00400000
.subsystem 0x00000003
.file alignment 512
.corflags 0x00000001
// Image base: 0x034B0000
// =============== CLASS MEMBERS DECLARATION ===================
.class private auto ansi beforefieldinit Foo
extends [mscorlib]System.Object
{
.method public hidebysig instance string
Function() cil managed
{
// Code size 20 (0x14)
.maxstack 1
.locals init (string V_0)
IL_0000: ldstr "0 TPs"
IL_0005: call void [System.Console]System.Console::WriteLine(string)
IL_000a: ldstr ""
IL_000f: stloc.0
IL_0010: br.s IL_0012
IL_0012: ldloc.0
IL_0013: ret
} // end of method Foo::Function
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 1
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method Foo::.ctor
.method public hidebysig instance string
Function<([mscorlib]System.Object) T>(!!0 t) cil managed
{
// Code size 26 (0x1a)
.maxstack 1
.locals init (string V_0)
IL_0000: ldstr "1 TPs"
IL_0005: call void [System.Console]System.Console::WriteLine(string)
IL_000a: ldarg.1
IL_000b: box !!0
IL_0010: callvirt instance string [mscorlib]System.Object::ToString()
IL_0015: stloc.0
IL_0016: br.s IL_0018
IL_0018: ldloc.0
IL_0019: ret
} // end of method Foo01::Function
.method public hidebysig instance string
Function<([mscorlib]System.Object) T,([mscorlib]System.Object) U>(!!0 t,
!!1 u) cil managed
{
// Code size 42 (0x2a)
.maxstack 2
.locals init (string V_0)
IL_0000: ldstr "2 TPs"
IL_0005: call void [System.Console]System.Console::WriteLine(string)
IL_000a: ldarg.1
IL_000b: box !!0
IL_0010: callvirt instance string [mscorlib]System.Object::ToString()
IL_0015: ldarg.2
IL_0016: box !!1
IL_001b: callvirt instance string [mscorlib]System.Object::ToString()
IL_0020: call string [mscorlib]System.String::Concat(string,
string)
IL_0025: stloc.0
IL_0026: br.s IL_0028
IL_0028: ldloc.0
IL_0029: ret
} // end of method Foo02::Function
.method public hidebysig instance string
Function<([mscorlib]System.Object) T,([mscorlib]System.Object) U,([mscorlib]System.Object) V>(!!0 t,
!!1 u,
!!2 v) cil managed
{
// Code size 53 (0x35)
.maxstack 3
.locals init (string V_0)
IL_0000: ldstr "3 TPs"
IL_0005: call void [System.Console]System.Console::WriteLine(string)
IL_000a: ldarg.1
IL_000b: box !!0
IL_0010: callvirt instance string [mscorlib]System.Object::ToString()
IL_0015: ldarg.2
IL_0016: box !!1
IL_001b: callvirt instance string [mscorlib]System.Object::ToString()
IL_0020: ldarg.3
IL_0021: box !!2
IL_0026: callvirt instance string [mscorlib]System.Object::ToString()
IL_002b: call string [mscorlib]System.String::Concat(string,
string,
string)
IL_0030: stloc.0
IL_0031: br.s IL_0033
IL_0033: ldloc.0
IL_0034: ret
} // end of method Foo03::Function
} // end of class Foo03
.class public auto ansi beforefieldinit Test_arity01
extends [mscorlib]System.Object
{
.field public static int32 counter
.field public static bool result
.method public hidebysig static void Eval(bool exp) cil managed
{
// Code size 47 (0x2f)
.maxstack 2
IL_0000: ldsfld int32 Test_arity01::counter
IL_0005: ldc.i4.1
IL_0006: add
IL_0007: stsfld int32 Test_arity01::counter
IL_000c: ldarg.0
IL_000d: brtrue.s IL_002e
IL_000f: ldarg.0
IL_0010: stsfld bool Test_arity01::result
IL_0015: ldstr "Test Failed at location: "
IL_001a: ldsfld int32 Test_arity01::counter
IL_001f: box [mscorlib]System.Int32
IL_0024: call string [mscorlib]System.String::Concat(object,
object)
IL_0029: call void [System.Console]System.Console::WriteLine(string)
IL_002e: ret
} // end of method Test::Eval
.method public hidebysig static int32 Main() cil managed
{
.custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = (
01 00 00 00
)
.entrypoint
// Code size 478 (0x1de)
.maxstack 4
.locals init (class Foo V_0,
class Foo V_1,
class Foo V_2,
class Foo V_3,
int32 V_4)
IL_0000: newobj instance void Foo::.ctor()
IL_0005: stloc.0
IL_0006: newobj instance void Foo::.ctor()
IL_000b: stloc.1
IL_000c: newobj instance void Foo::.ctor()
IL_0011: stloc.2
IL_0012: newobj instance void Foo::.ctor()
IL_0017: stloc.3
IL_0018: ldloc.0
IL_0019: callvirt instance string Foo::Function()
IL_001e: ldstr ""
IL_0023: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0028: call void Test_arity01::Eval(bool)
IL_002d: ldloc.0
IL_002e: ldstr "1"
IL_0033: callvirt instance string Foo::Function<string>(!!0)
IL_0038: ldstr "1"
IL_003d: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0042: call void Test_arity01::Eval(bool)
IL_0047: ldloc.0
IL_0048: ldc.i4.1
IL_0049: callvirt instance string Foo::Function<int32>(!!0)
IL_004e: ldstr "1"
IL_0053: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0058: call void Test_arity01::Eval(bool)
IL_005d: ldloc.0
IL_005e: ldstr "1"
IL_0063: ldstr "2"
IL_0068: callvirt instance string Foo::Function<string,string>(!!0,
!!1)
IL_006d: ldstr "12"
IL_0072: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0077: call void Test_arity01::Eval(bool)
IL_007c: ldloc.0
IL_007d: ldc.i4.1
IL_007e: ldc.i4.2
IL_007f: callvirt instance string Foo::Function<int32,int32>(!!0,
!!1)
IL_0084: ldstr "12"
IL_0089: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_008e: call void Test_arity01::Eval(bool)
IL_0093: ldloc.0
IL_0094: ldc.i4.1
IL_0095: ldstr "2"
IL_009a: callvirt instance string Foo::Function<int32,string>(!!0,
!!1)
IL_009f: ldstr "12"
IL_00a4: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_00a9: call void Test_arity01::Eval(bool)
IL_00ae: ldloc.0
IL_00af: ldstr "1"
IL_00b4: ldc.i4.2
IL_00b5: callvirt instance string Foo::Function<string,int32>(!!0,
!!1)
IL_00ba: ldstr "12"
IL_00bf: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_00c4: call void Test_arity01::Eval(bool)
IL_00c9: ldloc.0
IL_00ca: ldstr "1"
IL_00cf: ldstr "2"
IL_00d4: ldstr "3"
IL_00d9: callvirt instance string Foo::Function<string,string,string>(!!0,
!!1,
!!2)
IL_00de: ldstr "123"
IL_00e3: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_00e8: call void Test_arity01::Eval(bool)
IL_00ed: ldloc.0
IL_00ee: ldstr "1"
IL_00f3: ldstr "2"
IL_00f8: ldc.i4.3
IL_00f9: callvirt instance string Foo::Function<string,string,int32>(!!0,
!!1,
!!2)
IL_00fe: ldstr "123"
IL_0103: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0108: call void Test_arity01::Eval(bool)
IL_010d: ldloc.0
IL_010e: ldstr "1"
IL_0113: ldc.i4.2
IL_0114: ldc.i4.3
IL_0115: callvirt instance string Foo::Function<string,int32,int32>(!!0,
!!1,
!!2)
IL_011a: ldstr "123"
IL_011f: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0124: call void Test_arity01::Eval(bool)
IL_0129: ldloc.0
IL_012a: ldstr "1"
IL_012f: ldc.i4.2
IL_0130: ldstr "3"
IL_0135: callvirt instance string Foo::Function<string,int32,string>(!!0,
!!1,
!!2)
IL_013a: ldstr "123"
IL_013f: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0144: call void Test_arity01::Eval(bool)
IL_0149: ldloc.0
IL_014a: ldc.i4.1
IL_014b: ldc.i4.2
IL_014c: ldc.i4.3
IL_014d: callvirt instance string Foo::Function<int32,int32,int32>(!!0,
!!1,
!!2)
IL_0152: ldstr "123"
IL_0157: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_015c: call void Test_arity01::Eval(bool)
IL_0161: ldloc.0
IL_0162: ldc.i4.1
IL_0163: ldc.i4.2
IL_0164: ldstr "3"
IL_0169: callvirt instance string Foo::Function<int32,int32,string>(!!0,
!!1,
!!2)
IL_016e: ldstr "123"
IL_0173: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0178: call void Test_arity01::Eval(bool)
IL_017d: ldloc.0
IL_017e: ldc.i4.1
IL_017f: ldstr "2"
IL_0184: ldc.i4.3
IL_0185: callvirt instance string Foo::Function<int32,string,int32>(!!0,
!!1,
!!2)
IL_018a: ldstr "123"
IL_018f: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0194: call void Test_arity01::Eval(bool)
IL_0199: ldloc.0
IL_019a: ldstr "1"
IL_019f: ldc.i4.2
IL_01a0: ldc.i4.3
IL_01a1: callvirt instance string Foo::Function<string,int32,int32>(!!0,
!!1,
!!2)
IL_01a6: ldstr "123"
IL_01ab: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_01b0: call void Test_arity01::Eval(bool)
IL_01b5: ldsfld bool Test_arity01::result
IL_01ba: brfalse.s IL_01cc
IL_01bc: ldstr "Test Passed"
IL_01c1: call void [System.Console]System.Console::WriteLine(string)
IL_01c6: ldc.i4.s 100
IL_01c8: stloc.s V_4
IL_01ca: br.s IL_01db
IL_01cc: ldstr "Test Failed"
IL_01d1: call void [System.Console]System.Console::WriteLine(string)
IL_01d6: ldc.i4.1
IL_01d7: stloc.s V_4
IL_01d9: br.s IL_01db
IL_01db: ldloc.s V_4
IL_01dd: ret
} // end of method Test::Main
.method private hidebysig specialname rtspecialname static
void .cctor() cil managed
{
// Code size 13 (0xd)
.maxstack 1
IL_0000: ldc.i4.0
IL_0001: stsfld int32 Test_arity01::counter
IL_0006: ldc.i4.1
IL_0007: stsfld bool Test_arity01::result
IL_000c: ret
} // end of method Test::.cctor
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 1
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method Test::.ctor
} // end of class Test
// =============================================================
//*********** DISASSEMBLY COMPLETE ***********************
// WARNING: Created Win32 resource file arity01.res
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/Common/src/System/Security/Cryptography/Asn1/AlgorithmIdentifierAsn.manual.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.InteropServices;
namespace System.Security.Cryptography.Asn1
{
internal partial struct AlgorithmIdentifierAsn
{
internal static readonly ReadOnlyMemory<byte> ExplicitDerNull = new byte[] { 0x05, 0x00 };
internal bool Equals(ref AlgorithmIdentifierAsn other)
{
if (Algorithm != other.Algorithm)
{
return false;
}
bool isNull = RepresentsNull(Parameters);
bool isOtherNull = RepresentsNull(other.Parameters);
if (isNull != isOtherNull)
{
return false;
}
if (isNull)
{
return true;
}
return Parameters!.Value.Span.SequenceEqual(other.Parameters!.Value.Span);
}
internal readonly bool HasNullEquivalentParameters()
{
return RepresentsNull(Parameters);
}
internal static bool RepresentsNull(ReadOnlyMemory<byte>? parameters)
{
if (parameters == null)
{
return true;
}
ReadOnlySpan<byte> span = parameters.Value.Span;
if (span.Length != 2)
{
return false;
}
if (span[0] != 0x05)
{
return false;
}
return span[1] == 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.Runtime.InteropServices;
namespace System.Security.Cryptography.Asn1
{
internal partial struct AlgorithmIdentifierAsn
{
internal static readonly ReadOnlyMemory<byte> ExplicitDerNull = new byte[] { 0x05, 0x00 };
internal bool Equals(ref AlgorithmIdentifierAsn other)
{
if (Algorithm != other.Algorithm)
{
return false;
}
bool isNull = RepresentsNull(Parameters);
bool isOtherNull = RepresentsNull(other.Parameters);
if (isNull != isOtherNull)
{
return false;
}
if (isNull)
{
return true;
}
return Parameters!.Value.Span.SequenceEqual(other.Parameters!.Value.Span);
}
internal readonly bool HasNullEquivalentParameters()
{
return RepresentsNull(Parameters);
}
internal static bool RepresentsNull(ReadOnlyMemory<byte>? parameters)
{
if (parameters == null)
{
return true;
}
ReadOnlySpan<byte> span = parameters.Value.Span;
if (span.Length != 2)
{
return false;
}
if (span[0] != 0x05)
{
return false;
}
return span[1] == 0;
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/Fakes/FakeTwoMultipleService.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.DependencyInjection.Specification.Fakes
{
public class FakeTwoMultipleService : IFakeMultipleService
{
}
}
| // 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.DependencyInjection.Specification.Fakes
{
public class FakeTwoMultipleService : IFakeMultipleService
{
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/IL_Conformance/Old/Conformance_Base/bne_u4.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 {}
.class public bne_un {
.field public static int32 all
.field public static int32 none
.field public static int32 odd
.field public static int32 even
.method public static void initialize() {
.maxstack 10
ldc.i4 0xFFFFFFFF
stsfld int32 bne_un::all
ldc.i4 0x00000000
stsfld int32 bne_un::none
ldc.i4 0x55555555
stsfld int32 bne_un::odd
ldc.i4 0xAAAAAAAA
stsfld int32 bne_un::even
ret
}
.method public static int32 main(class [mscorlib]System.String[]) {
.entrypoint
.maxstack 10
call void bne_un::initialize()
ldsfld int32 bne_un::all
ldsfld int32 bne_un::all
bne.un FAIL
ldsfld int32 bne_un::all
ldsfld int32 bne_un::none
bne.un A
br FAIL
A:
ldsfld int32 bne_un::all
ldsfld int32 bne_un::odd
bne.un B
br FAIL
B:
ldsfld int32 bne_un::all
ldsfld int32 bne_un::even
bne.un C
br FAIL
C:
ldsfld int32 bne_un::none
ldsfld int32 bne_un::all
bne.un D
br FAIL
D:
ldsfld int32 bne_un::none
ldsfld int32 bne_un::none
bne.un FAIL
ldsfld int32 bne_un::none
ldsfld int32 bne_un::odd
bne.un E
br FAIL
E:
ldsfld int32 bne_un::none
ldsfld int32 bne_un::even
bne.un F
br FAIL
F:
ldsfld int32 bne_un::odd
ldsfld int32 bne_un::all
bne.un G
br FAIL
G:
ldsfld int32 bne_un::odd
ldsfld int32 bne_un::none
bne.un H
br FAIL
H:
ldsfld int32 bne_un::odd
ldsfld int32 bne_un::odd
bne.un FAIL
ldsfld int32 bne_un::odd
ldsfld int32 bne_un::even
bne.un I
br FAIL
I:
ldsfld int32 bne_un::even
ldsfld int32 bne_un::all
bne.un J
br FAIL
J:
ldsfld int32 bne_un::even
ldsfld int32 bne_un::none
bne.un K
br FAIL
K:
ldsfld int32 bne_un::even
ldsfld int32 bne_un::odd
bne.un L
L: ldsfld int32 bne_un::even
ldsfld int32 bne_un::even
bne.un FAIL
br BACKCHECK
TOPASS:
br PASS
BACKCHECK:
ldc.i4 0x0
ldc.i4 0x1
bne.un TOPASS
br FAIL
PASS:
ldc.i4 100
ret
FAIL:
ldc.i4 0x0
ret
}
}
.assembly bne_u4{}
| // 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 {}
.class public bne_un {
.field public static int32 all
.field public static int32 none
.field public static int32 odd
.field public static int32 even
.method public static void initialize() {
.maxstack 10
ldc.i4 0xFFFFFFFF
stsfld int32 bne_un::all
ldc.i4 0x00000000
stsfld int32 bne_un::none
ldc.i4 0x55555555
stsfld int32 bne_un::odd
ldc.i4 0xAAAAAAAA
stsfld int32 bne_un::even
ret
}
.method public static int32 main(class [mscorlib]System.String[]) {
.entrypoint
.maxstack 10
call void bne_un::initialize()
ldsfld int32 bne_un::all
ldsfld int32 bne_un::all
bne.un FAIL
ldsfld int32 bne_un::all
ldsfld int32 bne_un::none
bne.un A
br FAIL
A:
ldsfld int32 bne_un::all
ldsfld int32 bne_un::odd
bne.un B
br FAIL
B:
ldsfld int32 bne_un::all
ldsfld int32 bne_un::even
bne.un C
br FAIL
C:
ldsfld int32 bne_un::none
ldsfld int32 bne_un::all
bne.un D
br FAIL
D:
ldsfld int32 bne_un::none
ldsfld int32 bne_un::none
bne.un FAIL
ldsfld int32 bne_un::none
ldsfld int32 bne_un::odd
bne.un E
br FAIL
E:
ldsfld int32 bne_un::none
ldsfld int32 bne_un::even
bne.un F
br FAIL
F:
ldsfld int32 bne_un::odd
ldsfld int32 bne_un::all
bne.un G
br FAIL
G:
ldsfld int32 bne_un::odd
ldsfld int32 bne_un::none
bne.un H
br FAIL
H:
ldsfld int32 bne_un::odd
ldsfld int32 bne_un::odd
bne.un FAIL
ldsfld int32 bne_un::odd
ldsfld int32 bne_un::even
bne.un I
br FAIL
I:
ldsfld int32 bne_un::even
ldsfld int32 bne_un::all
bne.un J
br FAIL
J:
ldsfld int32 bne_un::even
ldsfld int32 bne_un::none
bne.un K
br FAIL
K:
ldsfld int32 bne_un::even
ldsfld int32 bne_un::odd
bne.un L
L: ldsfld int32 bne_un::even
ldsfld int32 bne_un::even
bne.un FAIL
br BACKCHECK
TOPASS:
br PASS
BACKCHECK:
ldc.i4 0x0
ldc.i4 0x1
bne.un TOPASS
br FAIL
PASS:
ldc.i4 100
ret
FAIL:
ldc.i4 0x0
ret
}
}
.assembly bne_u4{}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StringMarshaller.Utf8.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 Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
using static Microsoft.Interop.MarshallerHelpers;
namespace Microsoft.Interop
{
public sealed class Utf8StringMarshaller : ConditionalStackallocMarshallingGenerator
{
// [Compat] Equivalent of MAX_PATH on Windows to match built-in system
// The assumption is file paths are the most common case for marshalling strings,
// so the threshold for optimized allocation is based on that length.
private const int StackAllocBytesThreshold = 260;
// Conversion from a 2-byte 'char' in UTF-16 to bytes in UTF-8 has a maximum of 3 bytes per 'char'
// Two bytes ('char') in UTF-16 can be either:
// - Code point in the Basic Multilingual Plane: all 16 bits are that of the code point
// - Part of a pair for a code point in the Supplementary Planes: 10 bits are that of the code point
// In UTF-8, 3 bytes are need to represent the code point in first and 4 bytes in the second. Thus, the
// maximum number of bytes per 'char' is 3.
private const int MaxByteCountPerChar = 3;
private static readonly TypeSyntax s_nativeType = PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword)));
private static readonly TypeSyntax s_utf8EncodingType = ParseTypeName("System.Text.Encoding.UTF8");
public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context)
{
string identifier = context.GetIdentifiers(info).native;
if (info.IsByRef)
{
return Argument(
PrefixUnaryExpression(
SyntaxKind.AddressOfExpression,
IdentifierName(identifier)));
}
return Argument(IdentifierName(identifier));
}
public override TypeSyntax AsNativeType(TypePositionInfo info) => s_nativeType;
public override ParameterSyntax AsParameter(TypePositionInfo info)
{
TypeSyntax type = info.IsByRef
? PointerType(AsNativeType(info))
: AsNativeType(info);
return Parameter(Identifier(info.InstanceIdentifier))
.WithType(type);
}
public override IEnumerable<StatementSyntax> Generate(TypePositionInfo info, StubCodeContext context)
{
(string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info);
switch (context.CurrentStage)
{
case StubCodeContext.Stage.Setup:
if (TryGenerateSetupSyntax(info, context, out StatementSyntax conditionalAllocSetup))
yield return conditionalAllocSetup;
break;
case StubCodeContext.Stage.Marshal:
if (info.RefKind != RefKind.Out)
{
foreach (StatementSyntax statement in GenerateConditionalAllocationSyntax(
info,
context,
StackAllocBytesThreshold))
{
yield return statement;
}
}
break;
case StubCodeContext.Stage.Unmarshal:
if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In))
{
// <managedIdentifier> = Marshal.PtrToStringUTF8((IntPtr)<nativeIdentifier>);
yield return ExpressionStatement(
AssignmentExpression(
SyntaxKind.SimpleAssignmentExpression,
IdentifierName(managedIdentifier),
InvocationExpression(
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
InteropServicesMarshalType,
IdentifierName("PtrToStringUTF8")),
ArgumentList(SingletonSeparatedList<ArgumentSyntax>(
Argument(
CastExpression(
SystemIntPtrType,
IdentifierName(nativeIdentifier))))))));
}
break;
case StubCodeContext.Stage.Cleanup:
yield return GenerateConditionalAllocationFreeSyntax(info, context);
break;
}
}
public override bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true;
public override bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false;
protected override ExpressionSyntax GenerateAllocationExpression(
TypePositionInfo info,
StubCodeContext context,
SyntaxToken byteLengthIdentifier,
out bool allocationRequiresByteLength)
{
allocationRequiresByteLength = false;
return CastExpression(
AsNativeType(info),
StringMarshaller.AllocationExpression(CharEncoding.Utf8, context.GetIdentifiers(info).managed));
}
protected override ExpressionSyntax GenerateByteLengthCalculationExpression(TypePositionInfo info, StubCodeContext context)
{
// + 1 for number of characters in case left over high surrogate is ?
// * <MaxByteCountPerChar> (3 for UTF-8)
// +1 for null terminator
// int <byteLen> = (<managed>.Length + 1) * 3 + 1;
return BinaryExpression(
SyntaxKind.AddExpression,
BinaryExpression(
SyntaxKind.MultiplyExpression,
ParenthesizedExpression(
BinaryExpression(
SyntaxKind.AddExpression,
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName(context.GetIdentifiers(info).managed),
IdentifierName("Length")),
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1)))),
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(MaxByteCountPerChar))),
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1)));
}
protected override StatementSyntax GenerateStackallocOnlyValueMarshalling(
TypePositionInfo info,
StubCodeContext context,
SyntaxToken byteLengthIdentifier,
SyntaxToken stackAllocPtrIdentifier)
{
return Block(
// <byteLen> = Encoding.UTF8.GetBytes(<managed>, new Span<byte>(<stackAllocPtr>, <byteLen>));
ExpressionStatement(
AssignmentExpression(
SyntaxKind.SimpleAssignmentExpression,
IdentifierName(byteLengthIdentifier),
InvocationExpression(
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
s_utf8EncodingType,
IdentifierName("GetBytes")),
ArgumentList(
SeparatedList(new ArgumentSyntax[] {
Argument(IdentifierName(context.GetIdentifiers(info).managed)),
Argument(
ObjectCreationExpression(
GenericName(Identifier(TypeNames.System_Span),
TypeArgumentList(SingletonSeparatedList<TypeSyntax>(
PredefinedType(Token(SyntaxKind.ByteKeyword))))),
ArgumentList(
SeparatedList(new ArgumentSyntax[]{
Argument(IdentifierName(stackAllocPtrIdentifier)),
Argument(IdentifierName(byteLengthIdentifier))})),
initializer: null))}))))),
// <stackAllocPtr>[<byteLen>] = 0;
ExpressionStatement(
AssignmentExpression(
SyntaxKind.SimpleAssignmentExpression,
ElementAccessExpression(
IdentifierName(stackAllocPtrIdentifier),
BracketedArgumentList(
SingletonSeparatedList<ArgumentSyntax>(
Argument(IdentifierName(byteLengthIdentifier))))),
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)))));
}
protected override ExpressionSyntax GenerateFreeExpression(
TypePositionInfo info,
StubCodeContext context)
{
return StringMarshaller.FreeExpression(context.GetIdentifiers(info).native);
}
}
}
| // 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 Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
using static Microsoft.Interop.MarshallerHelpers;
namespace Microsoft.Interop
{
public sealed class Utf8StringMarshaller : ConditionalStackallocMarshallingGenerator
{
// [Compat] Equivalent of MAX_PATH on Windows to match built-in system
// The assumption is file paths are the most common case for marshalling strings,
// so the threshold for optimized allocation is based on that length.
private const int StackAllocBytesThreshold = 260;
// Conversion from a 2-byte 'char' in UTF-16 to bytes in UTF-8 has a maximum of 3 bytes per 'char'
// Two bytes ('char') in UTF-16 can be either:
// - Code point in the Basic Multilingual Plane: all 16 bits are that of the code point
// - Part of a pair for a code point in the Supplementary Planes: 10 bits are that of the code point
// In UTF-8, 3 bytes are need to represent the code point in first and 4 bytes in the second. Thus, the
// maximum number of bytes per 'char' is 3.
private const int MaxByteCountPerChar = 3;
private static readonly TypeSyntax s_nativeType = PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword)));
private static readonly TypeSyntax s_utf8EncodingType = ParseTypeName("System.Text.Encoding.UTF8");
public override ArgumentSyntax AsArgument(TypePositionInfo info, StubCodeContext context)
{
string identifier = context.GetIdentifiers(info).native;
if (info.IsByRef)
{
return Argument(
PrefixUnaryExpression(
SyntaxKind.AddressOfExpression,
IdentifierName(identifier)));
}
return Argument(IdentifierName(identifier));
}
public override TypeSyntax AsNativeType(TypePositionInfo info) => s_nativeType;
public override ParameterSyntax AsParameter(TypePositionInfo info)
{
TypeSyntax type = info.IsByRef
? PointerType(AsNativeType(info))
: AsNativeType(info);
return Parameter(Identifier(info.InstanceIdentifier))
.WithType(type);
}
public override IEnumerable<StatementSyntax> Generate(TypePositionInfo info, StubCodeContext context)
{
(string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info);
switch (context.CurrentStage)
{
case StubCodeContext.Stage.Setup:
if (TryGenerateSetupSyntax(info, context, out StatementSyntax conditionalAllocSetup))
yield return conditionalAllocSetup;
break;
case StubCodeContext.Stage.Marshal:
if (info.RefKind != RefKind.Out)
{
foreach (StatementSyntax statement in GenerateConditionalAllocationSyntax(
info,
context,
StackAllocBytesThreshold))
{
yield return statement;
}
}
break;
case StubCodeContext.Stage.Unmarshal:
if (info.IsManagedReturnPosition || (info.IsByRef && info.RefKind != RefKind.In))
{
// <managedIdentifier> = Marshal.PtrToStringUTF8((IntPtr)<nativeIdentifier>);
yield return ExpressionStatement(
AssignmentExpression(
SyntaxKind.SimpleAssignmentExpression,
IdentifierName(managedIdentifier),
InvocationExpression(
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
InteropServicesMarshalType,
IdentifierName("PtrToStringUTF8")),
ArgumentList(SingletonSeparatedList<ArgumentSyntax>(
Argument(
CastExpression(
SystemIntPtrType,
IdentifierName(nativeIdentifier))))))));
}
break;
case StubCodeContext.Stage.Cleanup:
yield return GenerateConditionalAllocationFreeSyntax(info, context);
break;
}
}
public override bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true;
public override bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false;
protected override ExpressionSyntax GenerateAllocationExpression(
TypePositionInfo info,
StubCodeContext context,
SyntaxToken byteLengthIdentifier,
out bool allocationRequiresByteLength)
{
allocationRequiresByteLength = false;
return CastExpression(
AsNativeType(info),
StringMarshaller.AllocationExpression(CharEncoding.Utf8, context.GetIdentifiers(info).managed));
}
protected override ExpressionSyntax GenerateByteLengthCalculationExpression(TypePositionInfo info, StubCodeContext context)
{
// + 1 for number of characters in case left over high surrogate is ?
// * <MaxByteCountPerChar> (3 for UTF-8)
// +1 for null terminator
// int <byteLen> = (<managed>.Length + 1) * 3 + 1;
return BinaryExpression(
SyntaxKind.AddExpression,
BinaryExpression(
SyntaxKind.MultiplyExpression,
ParenthesizedExpression(
BinaryExpression(
SyntaxKind.AddExpression,
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName(context.GetIdentifiers(info).managed),
IdentifierName("Length")),
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1)))),
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(MaxByteCountPerChar))),
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1)));
}
protected override StatementSyntax GenerateStackallocOnlyValueMarshalling(
TypePositionInfo info,
StubCodeContext context,
SyntaxToken byteLengthIdentifier,
SyntaxToken stackAllocPtrIdentifier)
{
return Block(
// <byteLen> = Encoding.UTF8.GetBytes(<managed>, new Span<byte>(<stackAllocPtr>, <byteLen>));
ExpressionStatement(
AssignmentExpression(
SyntaxKind.SimpleAssignmentExpression,
IdentifierName(byteLengthIdentifier),
InvocationExpression(
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
s_utf8EncodingType,
IdentifierName("GetBytes")),
ArgumentList(
SeparatedList(new ArgumentSyntax[] {
Argument(IdentifierName(context.GetIdentifiers(info).managed)),
Argument(
ObjectCreationExpression(
GenericName(Identifier(TypeNames.System_Span),
TypeArgumentList(SingletonSeparatedList<TypeSyntax>(
PredefinedType(Token(SyntaxKind.ByteKeyword))))),
ArgumentList(
SeparatedList(new ArgumentSyntax[]{
Argument(IdentifierName(stackAllocPtrIdentifier)),
Argument(IdentifierName(byteLengthIdentifier))})),
initializer: null))}))))),
// <stackAllocPtr>[<byteLen>] = 0;
ExpressionStatement(
AssignmentExpression(
SyntaxKind.SimpleAssignmentExpression,
ElementAccessExpression(
IdentifierName(stackAllocPtrIdentifier),
BracketedArgumentList(
SingletonSeparatedList<ArgumentSyntax>(
Argument(IdentifierName(byteLengthIdentifier))))),
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)))));
}
protected override ExpressionSyntax GenerateFreeExpression(
TypePositionInfo info,
StubCodeContext context)
{
return StringMarshaller.FreeExpression(context.GetIdentifiers(info).native);
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/System.DirectoryServices/src/Interop/AdsSearchColumn.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;
namespace System.DirectoryServices.Interop
{
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct AdsSearchColumn
{
public IntPtr pszAttrName;
public int/*AdsType*/ dwADsType;
public AdsValue* pADsValues;
public int dwNumValues;
public IntPtr hReserved;
}
}
| // 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;
namespace System.DirectoryServices.Interop
{
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct AdsSearchColumn
{
public IntPtr pszAttrName;
public int/*AdsType*/ dwADsType;
public AdsValue* pADsValues;
public int dwNumValues;
public IntPtr hReserved;
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Syntax/NameTable.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.Diagnostics;
namespace Microsoft.CSharp.RuntimeBinder.Syntax
{
internal sealed class NameTable
{
private sealed class Entry
{
public readonly Name Name;
public readonly int HashCode;
public Entry Next;
public Entry(Name name, int hashCode, Entry next)
{
Name = name;
HashCode = hashCode;
Next = next;
}
}
private Entry[] _entries;
private int _count;
private int _mask;
internal NameTable()
{
_mask = 31;
_entries = new Entry[_mask + 1];
}
public Name Add(string key)
{
int hashCode = ComputeHashCode(key);
for (Entry e = _entries[hashCode & _mask]; e != null; e = e.Next)
{
if (e.HashCode == hashCode && e.Name.Text.Equals(key))
{
return e.Name;
}
}
return AddEntry(new Name(key), hashCode);
}
public Name Add(string key, int length)
{
int hashCode = ComputeHashCode(key, length);
for (Entry e = _entries[hashCode & _mask]; e != null; e = e.Next)
{
if (e.HashCode == hashCode && Equals(e.Name.Text, key, length))
{
return e.Name;
}
}
return AddEntry(new Name(key.Substring(0, length)), hashCode);
}
internal void Add(Name name)
{
int hashCode = ComputeHashCode(name.Text);
// make sure it doesn't already exist
Debug.Assert(Array.TrueForAll(_entries, e => e?.Name.Text != name.Text));
AddEntry(name, hashCode);
}
private static int ComputeHashCode(string key)
{
unchecked
{
int hashCode = key.Length;
// use key.Length to eliminate the range check
for (int i = 0; i < key.Length; i++)
{
hashCode += (hashCode << 7) ^ key[i];
}
// mix it a bit more
hashCode -= hashCode >> 17;
hashCode -= hashCode >> 11;
hashCode -= hashCode >> 5;
return hashCode;
}
}
private static int ComputeHashCode(string key, int length)
{
Debug.Assert(key != null);
Debug.Assert(length <= key.Length);
unchecked
{
int hashCode = length;
for (int i = 0; i < length; i++)
{
hashCode += (hashCode << 7) ^ key[i];
}
// mix it a bit more
hashCode -= hashCode >> 17;
hashCode -= hashCode >> 11;
hashCode -= hashCode >> 5;
return hashCode;
}
}
private static bool Equals(string candidate, string key, int length)
{
Debug.Assert(candidate != null);
Debug.Assert(key != null);
Debug.Assert(length <= key.Length);
if (candidate.Length != length)
{
return false;
}
for (int i = 0; i < candidate.Length; i++)
{
if (candidate[i] != key[i])
{
return false;
}
}
return true;
}
private Name AddEntry(Name name, int hashCode)
{
int index = hashCode & _mask;
Entry e = new Entry(name, hashCode, _entries[index]);
_entries[index] = e;
if (_count++ == _mask)
{
Grow();
}
return e.Name;
}
private void Grow()
{
int newMask = _mask * 2 + 1;
Entry[] oldEntries = _entries;
Entry[] newEntries = new Entry[newMask + 1];
// use oldEntries.Length to eliminate the range check
for (int i = 0; i < oldEntries.Length; i++)
{
Entry e = oldEntries[i];
while (e != null)
{
int newIndex = e.HashCode & newMask;
Entry tmp = e.Next;
e.Next = newEntries[newIndex];
newEntries[newIndex] = e;
e = tmp;
}
}
_entries = newEntries;
_mask = newMask;
}
}
}
| // 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.Diagnostics;
namespace Microsoft.CSharp.RuntimeBinder.Syntax
{
internal sealed class NameTable
{
private sealed class Entry
{
public readonly Name Name;
public readonly int HashCode;
public Entry Next;
public Entry(Name name, int hashCode, Entry next)
{
Name = name;
HashCode = hashCode;
Next = next;
}
}
private Entry[] _entries;
private int _count;
private int _mask;
internal NameTable()
{
_mask = 31;
_entries = new Entry[_mask + 1];
}
public Name Add(string key)
{
int hashCode = ComputeHashCode(key);
for (Entry e = _entries[hashCode & _mask]; e != null; e = e.Next)
{
if (e.HashCode == hashCode && e.Name.Text.Equals(key))
{
return e.Name;
}
}
return AddEntry(new Name(key), hashCode);
}
public Name Add(string key, int length)
{
int hashCode = ComputeHashCode(key, length);
for (Entry e = _entries[hashCode & _mask]; e != null; e = e.Next)
{
if (e.HashCode == hashCode && Equals(e.Name.Text, key, length))
{
return e.Name;
}
}
return AddEntry(new Name(key.Substring(0, length)), hashCode);
}
internal void Add(Name name)
{
int hashCode = ComputeHashCode(name.Text);
// make sure it doesn't already exist
Debug.Assert(Array.TrueForAll(_entries, e => e?.Name.Text != name.Text));
AddEntry(name, hashCode);
}
private static int ComputeHashCode(string key)
{
unchecked
{
int hashCode = key.Length;
// use key.Length to eliminate the range check
for (int i = 0; i < key.Length; i++)
{
hashCode += (hashCode << 7) ^ key[i];
}
// mix it a bit more
hashCode -= hashCode >> 17;
hashCode -= hashCode >> 11;
hashCode -= hashCode >> 5;
return hashCode;
}
}
private static int ComputeHashCode(string key, int length)
{
Debug.Assert(key != null);
Debug.Assert(length <= key.Length);
unchecked
{
int hashCode = length;
for (int i = 0; i < length; i++)
{
hashCode += (hashCode << 7) ^ key[i];
}
// mix it a bit more
hashCode -= hashCode >> 17;
hashCode -= hashCode >> 11;
hashCode -= hashCode >> 5;
return hashCode;
}
}
private static bool Equals(string candidate, string key, int length)
{
Debug.Assert(candidate != null);
Debug.Assert(key != null);
Debug.Assert(length <= key.Length);
if (candidate.Length != length)
{
return false;
}
for (int i = 0; i < candidate.Length; i++)
{
if (candidate[i] != key[i])
{
return false;
}
}
return true;
}
private Name AddEntry(Name name, int hashCode)
{
int index = hashCode & _mask;
Entry e = new Entry(name, hashCode, _entries[index]);
_entries[index] = e;
if (_count++ == _mask)
{
Grow();
}
return e.Name;
}
private void Grow()
{
int newMask = _mask * 2 + 1;
Entry[] oldEntries = _entries;
Entry[] newEntries = new Entry[newMask + 1];
// use oldEntries.Length to eliminate the range check
for (int i = 0; i < oldEntries.Length; i++)
{
Entry e = oldEntries[i];
while (e != null)
{
int newIndex = e.HashCode & newMask;
Entry tmp = e.Next;
e.Next = newEntries[newIndex];
newEntries[newIndex] = e;
e = tmp;
}
}
_entries = newEntries;
_mask = newMask;
}
}
}
| -1 |
dotnet/runtime | 66,111 | Update RegexGenerator to require LangVersion > 10 | We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | stephentoub | 2022-03-02T21:41:16Z | 2022-03-03T04:10:47Z | 83adfae6a6273d8fb4c69554aa3b1cc7cbf01c71 | c4541b3f4f66209aed77c7d7d0fd9d8511e3ac5e | Update RegexGenerator to require LangVersion > 10. We plan to take a dependency on a C# 11 language feature. For now, reserve that right by requiring a version > 10. We can downgrade it later if possible and desired. | ./src/tests/JIT/HardwareIntrinsics/General/Vector128/Min.Single.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/******************************************************************************
* This file is auto-generated from a template file by the GenerateTests.csx *
* script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make *
* changes, please update the corresponding template and run according to the *
* directions listed in the file. *
******************************************************************************/
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
namespace JIT.HardwareIntrinsics.General
{
public static partial class Program
{
private static void MinSingle()
{
var test = new VectorBinaryOpTest__MinSingle();
// 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__MinSingle
{
private struct DataTable
{
private byte[] inArray1;
private byte[] inArray2;
private byte[] outArray;
private GCHandle inHandle1;
private GCHandle inHandle2;
private GCHandle outHandle;
private ulong alignment;
public DataTable(Single[] inArray1, Single[] inArray2, Single[] outArray, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Single>();
int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Single>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Single>();
if ((alignment != 32 && alignment != 16 && alignment != 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<Single, byte>(ref inArray1[0]), (uint)sizeOfinArray1);
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Single, byte>(ref inArray2[0]), (uint)sizeOfinArray2);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment);
public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle1.Free();
inHandle2.Free();
outHandle.Free();
}
private static unsafe void* Align(byte* buffer, ulong expectedAlignment)
{
return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1));
}
}
private struct TestStruct
{
public Vector128<Single> _fld1;
public Vector128<Single> _fld2;
public static TestStruct Create()
{
var testStruct = new TestStruct();
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref testStruct._fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Single>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref testStruct._fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Single>>());
return testStruct;
}
public void RunStructFldScenario(VectorBinaryOpTest__MinSingle testClass)
{
var result = Vector128.Min(_fld1, _fld2);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr);
}
}
private static readonly int LargestVectorSize = 16;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Single>>() / sizeof(Single);
private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Single>>() / sizeof(Single);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Single>>() / sizeof(Single);
private static Single[] _data1 = new Single[Op1ElementCount];
private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
private DataTable _dataTable;
static VectorBinaryOpTest__MinSingle()
{
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Single>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Single>>());
}
public VectorBinaryOpTest__MinSingle()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Single>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Single>>());
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); }
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); }
_dataTable = new DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize);
}
public bool Succeeded { get; set; }
public void RunBasicScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));
var result = Vector128.Min(
Unsafe.Read<Vector128<Single>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector128<Single>>(_dataTable.inArray2Ptr)
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
var method = typeof(Vector128).GetMethod(nameof(Vector128.Min), new Type[] {
typeof(Vector128<Single>),
typeof(Vector128<Single>)
});
if (method is null)
{
method = typeof(Vector128).GetMethod(nameof(Vector128.Min), 1, new Type[] {
typeof(Vector128<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
typeof(Vector128<>).MakeGenericType(Type.MakeGenericMethodParameter(0))
});
}
if (method.IsGenericMethodDefinition)
{
method = method.MakeGenericMethod(typeof(Single));
}
var result = method.Invoke(null, new object[] {
Unsafe.Read<Vector128<Single>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector128<Single>>(_dataTable.inArray2Ptr)
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Single>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = Vector128.Min(
_clsVar1,
_clsVar2
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var op1 = Unsafe.Read<Vector128<Single>>(_dataTable.inArray1Ptr);
var op2 = Unsafe.Read<Vector128<Single>>(_dataTable.inArray2Ptr);
var result = Vector128.Min(op1, op2);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op2, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new VectorBinaryOpTest__MinSingle();
var result = Vector128.Min(test._fld1, test._fld2);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = Vector128.Min(_fld1, _fld2);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = Vector128.Min(test._fld1, test._fld2);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
}
public void RunStructFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario));
var test = TestStruct.Create();
test.RunStructFldScenario(this);
}
private void ValidateResult(Vector128<Single> op1, Vector128<Single> op2, void* result, [CallerMemberName] string method = "")
{
Single[] inArray1 = new Single[Op1ElementCount];
Single[] inArray2 = new Single[Op2ElementCount];
Single[] outArray = new Single[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), op1);
Unsafe.WriteUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), op2);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Single>>());
ValidateResult(inArray1, inArray2, outArray, method);
}
private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "")
{
Single[] inArray1 = new Single[Op1ElementCount];
Single[] inArray2 = new Single[Op2ElementCount];
Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Single>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Single>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Single>>());
ValidateResult(inArray1, inArray2, outArray, method);
}
private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
if (result[0] != ((left[0] < right[0]) ? left[0] : right[0]))
{
succeeded = false;
}
else
{
for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] < right[i]) ? left[i] : right[i]))
{
succeeded = false;
break;
}
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(Vector128)}.{nameof(Vector128.Min)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})");
TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/******************************************************************************
* This file is auto-generated from a template file by the GenerateTests.csx *
* script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make *
* changes, please update the corresponding template and run according to the *
* directions listed in the file. *
******************************************************************************/
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
namespace JIT.HardwareIntrinsics.General
{
public static partial class Program
{
private static void MinSingle()
{
var test = new VectorBinaryOpTest__MinSingle();
// 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__MinSingle
{
private struct DataTable
{
private byte[] inArray1;
private byte[] inArray2;
private byte[] outArray;
private GCHandle inHandle1;
private GCHandle inHandle2;
private GCHandle outHandle;
private ulong alignment;
public DataTable(Single[] inArray1, Single[] inArray2, Single[] outArray, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Single>();
int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Single>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Single>();
if ((alignment != 32 && alignment != 16 && alignment != 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<Single, byte>(ref inArray1[0]), (uint)sizeOfinArray1);
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Single, byte>(ref inArray2[0]), (uint)sizeOfinArray2);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment);
public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle1.Free();
inHandle2.Free();
outHandle.Free();
}
private static unsafe void* Align(byte* buffer, ulong expectedAlignment)
{
return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1));
}
}
private struct TestStruct
{
public Vector128<Single> _fld1;
public Vector128<Single> _fld2;
public static TestStruct Create()
{
var testStruct = new TestStruct();
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref testStruct._fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Single>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref testStruct._fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Single>>());
return testStruct;
}
public void RunStructFldScenario(VectorBinaryOpTest__MinSingle testClass)
{
var result = Vector128.Min(_fld1, _fld2);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr);
}
}
private static readonly int LargestVectorSize = 16;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Single>>() / sizeof(Single);
private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Single>>() / sizeof(Single);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Single>>() / sizeof(Single);
private static Single[] _data1 = new Single[Op1ElementCount];
private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
private DataTable _dataTable;
static VectorBinaryOpTest__MinSingle()
{
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Single>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Single>>());
}
public VectorBinaryOpTest__MinSingle()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Single>>());
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Single>>());
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); }
for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); }
_dataTable = new DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize);
}
public bool Succeeded { get; set; }
public void RunBasicScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));
var result = Vector128.Min(
Unsafe.Read<Vector128<Single>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector128<Single>>(_dataTable.inArray2Ptr)
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
var method = typeof(Vector128).GetMethod(nameof(Vector128.Min), new Type[] {
typeof(Vector128<Single>),
typeof(Vector128<Single>)
});
if (method is null)
{
method = typeof(Vector128).GetMethod(nameof(Vector128.Min), 1, new Type[] {
typeof(Vector128<>).MakeGenericType(Type.MakeGenericMethodParameter(0)),
typeof(Vector128<>).MakeGenericType(Type.MakeGenericMethodParameter(0))
});
}
if (method.IsGenericMethodDefinition)
{
method = method.MakeGenericMethod(typeof(Single));
}
var result = method.Invoke(null, new object[] {
Unsafe.Read<Vector128<Single>>(_dataTable.inArray1Ptr),
Unsafe.Read<Vector128<Single>>(_dataTable.inArray2Ptr)
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Single>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = Vector128.Min(
_clsVar1,
_clsVar2
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var op1 = Unsafe.Read<Vector128<Single>>(_dataTable.inArray1Ptr);
var op2 = Unsafe.Read<Vector128<Single>>(_dataTable.inArray2Ptr);
var result = Vector128.Min(op1, op2);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, op2, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new VectorBinaryOpTest__MinSingle();
var result = Vector128.Min(test._fld1, test._fld2);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = Vector128.Min(_fld1, _fld2);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = Vector128.Min(test._fld1, test._fld2);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
}
public void RunStructFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario));
var test = TestStruct.Create();
test.RunStructFldScenario(this);
}
private void ValidateResult(Vector128<Single> op1, Vector128<Single> op2, void* result, [CallerMemberName] string method = "")
{
Single[] inArray1 = new Single[Op1ElementCount];
Single[] inArray2 = new Single[Op2ElementCount];
Single[] outArray = new Single[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), op1);
Unsafe.WriteUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), op2);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Single>>());
ValidateResult(inArray1, inArray2, outArray, method);
}
private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "")
{
Single[] inArray1 = new Single[Op1ElementCount];
Single[] inArray2 = new Single[Op2ElementCount];
Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Single>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Single>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Single>>());
ValidateResult(inArray1, inArray2, outArray, method);
}
private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
if (result[0] != ((left[0] < right[0]) ? left[0] : right[0]))
{
succeeded = false;
}
else
{
for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] < right[i]) ? left[i] : right[i]))
{
succeeded = false;
break;
}
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(Vector128)}.{nameof(Vector128.Min)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})");
TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.