本文整理汇总了C#中Microsoft.VisualStudio.Debugger.Clr.DkmClrRuntimeInstance.Load方法的典型用法代码示例。如果您正苦于以下问题:C# DkmClrRuntimeInstance.Load方法的具体用法?C# DkmClrRuntimeInstance.Load怎么用?C# DkmClrRuntimeInstance.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.Debugger.Clr.DkmClrRuntimeInstance
的用法示例。
在下文中一共展示了DkmClrRuntimeInstance.Load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Member
public void Member()
{
var source =
@"unsafe class C
{
internal C(long p)
{
this.pfn = (int*)p;
}
int* pfn;
}";
var assembly = GetUnsafeAssembly(source);
const long ptr = 0x0;
GetMemberValueDelegate getMemberValue = (v, m) => (m == "pfn") ? GetFunctionPointerField(v, m) : null;
var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlibAndSystemCore(assembly), getMemberValue: getMemberValue);
using (runtime.Load())
{
var type = runtime.GetType("C");
var value = type.Instantiate(ptr);
var evalResult = FormatResult("o", value);
Verify(evalResult,
EvalResult("o", "{C}", "C", "o", DkmEvaluationResultFlags.Expandable, DkmEvaluationResultCategory.Other));
var children = GetChildren(evalResult);
Verify(children,
EvalResult("pfn", PointerToString(new IntPtr(ptr)), "int*", "o.pfn", DkmEvaluationResultFlags.None, DkmEvaluationResultCategory.Other));
}
}
示例2: Member
public void Member()
{
var source =
@"class C
{
object pfn;
}";
const int ptr = 0x0;
GetMemberValueDelegate getMemberValue = (v, m) => (m == "pfn") ? CreateDkmClrValue(ptr, type: new DkmClrType(FunctionPointerType.Instance)) : null;
var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlibAndSystemCore(GetAssembly(source)), getMemberValue: getMemberValue);
using (runtime.Load())
{
var type = runtime.GetType("C");
var value = CreateDkmClrValue(type.Instantiate(), type: type);
var evalResult = FormatResult("o", value);
Verify(evalResult,
EvalResult("o", "{C}", "C", "o", DkmEvaluationResultFlags.Expandable, DkmEvaluationResultCategory.Other));
var children = GetChildren(evalResult);
Verify(children,
EvalResult("pfn", PointerToString(new IntPtr(ptr)), "object {System.Object*}", "o.pfn", DkmEvaluationResultFlags.None, DkmEvaluationResultCategory.Other));
}
}
示例3: ResultsView_NoSystemCore
public void ResultsView_NoSystemCore()
{
var source =
@"using System.Collections;
class C : IEnumerable
{
public IEnumerator GetEnumerator()
{
yield return 1;
}
}";
var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlib(GetAssembly(source)));
using (runtime.Load())
{
var type = runtime.GetType("C");
var value = CreateDkmClrValue(
value: type.Instantiate(),
type: type,
inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.ResultsOnly));
var evalResult = FormatResult("o", "o, results", value);
Verify(evalResult,
EvalFailedResult("o", "Results View requires System.Core.dll to be referenced"));
}
}
示例4: ResultsView_ExceptionThrown
public void ResultsView_ExceptionThrown()
{
var source =
@"using System;
using System.Collections;
class E : Exception, IEnumerable
{
IEnumerator IEnumerable.GetEnumerator()
{
yield return 1;
}
}
class C
{
internal ArrayList P
{
get { throw new NotImplementedException(); }
}
internal ArrayList Q
{
get { throw new E(); }
}
}";
var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlibAndSystemCore(GetAssembly(source)));
using (runtime.Load())
{
var type = runtime.GetType("C");
var value = CreateDkmClrValue(type.Instantiate(), type: type);
var memberValue = value.GetMemberValue("P", (int)System.Reflection.MemberTypes.Property, "C").
WithInspectionContext(CreateDkmInspectionContext(DkmEvaluationFlags.ResultsOnly));
var evalResult = FormatResult("o.P", "o.P, results", memberValue);
Verify(evalResult,
EvalFailedResult("o.P", "'o.P' threw an exception of type 'System.NotImplementedException'"));
memberValue = value.GetMemberValue("Q", (int)System.Reflection.MemberTypes.Property, "C").
WithInspectionContext(CreateDkmInspectionContext(DkmEvaluationFlags.ResultsOnly));
evalResult = FormatResult("o.Q", "o.Q, results", memberValue);
Verify(evalResult,
EvalFailedResult("o.Q", "'o.Q' threw an exception of type 'E'"));
}
}
示例5: ResultsView_GetChildren
public void ResultsView_GetChildren()
{
var source =
@"using System.Collections;
using System.Collections.Generic;
class C
{
IEnumerable<int> F
{
get { yield return 1; }
}
IEnumerable G
{
get { yield return 2; }
}
int H
{
get { return 3; }
}
}";
var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlibAndSystemCore(GetAssembly(source)));
using (runtime.Load())
{
var type = runtime.GetType("C");
var value = CreateDkmClrValue(type.Instantiate(), type: type);
var evalResult = FormatResult("o", "o", value);
Verify(evalResult,
EvalResult("o", "{C}", "C", "o", DkmEvaluationResultFlags.Expandable));
// GetChildren without ResultsOnly
var children = GetChildren(evalResult, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.None));
Verify(children,
EvalResult("F", "{C.<get_F>d__1}", "System.Collections.Generic.IEnumerable<int> {C.<get_F>d__1}", "o.F", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly),
EvalResult("G", "{C.<get_G>d__3}", "System.Collections.IEnumerable {C.<get_G>d__3}", "o.G", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly),
EvalResult("H", "3", "int", "o.H", DkmEvaluationResultFlags.ReadOnly));
// GetChildren with ResultsOnly
children = GetChildren(evalResult, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.ResultsOnly));
Verify(children,
EvalResult("F", "{C.<get_F>d__1}", "System.Collections.Generic.IEnumerable<int> {C.<get_F>d__1}", "o.F", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly),
EvalResult("G", "{C.<get_G>d__3}", "System.Collections.IEnumerable {C.<get_G>d__3}", "o.G", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly),
EvalResult("H", "3", "int", "o.H", DkmEvaluationResultFlags.ReadOnly));
}
}
示例6: ResultsView_IEnumerable
public void ResultsView_IEnumerable()
{
var source =
@"using System.Collections;
class C : IEnumerable
{
public IEnumerator GetEnumerator()
{
yield return new C();
}
}";
var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlibAndSystemCore(GetAssembly(source)));
using (runtime.Load())
{
var type = runtime.GetType("C");
var value = CreateDkmClrValue(
value: type.Instantiate(),
type: type,
inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.ResultsOnly));
var evalResult = FormatResult("o", "o, results, d", value);
Verify(evalResult,
EvalResult("o", "Expanding the Results View will enumerate the IEnumerable", "", "o, results", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly, DkmEvaluationResultCategory.Method));
var children = GetChildren(evalResult);
// ResultsOnly is not inherited.
Verify(children,
EvalResult("[0]", "{C}", "object {C}", "new System.Linq.SystemCore_EnumerableDebugView(o).Items[0]"));
}
}
示例7: Keywords
public void Keywords()
{
var source =
@"namespace @namespace
{
struct @struct
{
}
}
class async
{
static (async @var, @[email protected] @class) F() => (null, default(@[email protected]));
object _f = F();
}";
var assembly0 = GenerateTupleAssembly();
var reference0 = AssemblyMetadata.CreateFromImage(assembly0).GetReference();
var compilation1 = CSharpTestBaseBase.CreateCompilationWithMscorlib(source, references: new[] { reference0 });
var assembly1 = compilation1.EmitToArray();
var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlib(ReflectionUtilities.Load(assembly0), ReflectionUtilities.Load(assembly1)));
using (runtime.Load())
{
var type = runtime.GetType("async");
var value = type.Instantiate();
var evalResult = FormatResult("o", value);
Verify(evalResult,
EvalResult("o", "{async}", "async", "o", DkmEvaluationResultFlags.Expandable));
var children = GetChildren(evalResult);
Verify(children,
EvalResult("_f", "(null, {namespace.struct})", "object {(async, namespace.struct)}", "o._f", DkmEvaluationResultFlags.Expandable));
children = GetChildren(children[0]);
Verify(children,
EvalResult("Item1", "null", "async", "(((@async, @[email protected]))o._f).Item1"),
EvalResult("Item2", "{namespace.struct}", "namespace.struct", "(((@async, @[email protected]))o._f).Item2"));
}
}
示例8: IsTupleCompatible_NonStruct
public void IsTupleCompatible_NonStruct()
{
var source =
@"namespace System
{
class ValueTuple<T1, T2> { }
delegate void ValueTuple<T1, T2, T3>();
}";
var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlib(GetAssembly(source)));
using (runtime.Load())
{
var type = runtime.GetType("System.ValueTuple`2", typeof(object), typeof(object));
int cardinality;
Assert.True(type.GetLmrType().IsTupleCompatible(out cardinality));
Assert.Equal(2, cardinality);
type = runtime.GetType("System.ValueTuple`3", typeof(object), typeof(object), typeof(object));
Assert.True(type.GetLmrType().IsTupleCompatible(out cardinality));
Assert.Equal(3, cardinality);
}
}
示例9: Names_LongTuple
public void Names_LongTuple()
{
var source =
@"class C
{
((int A, (int B, int C) D, int E, int F, int G, int H, int I, int J) K, (int L, int M, int N) O) F =
((1, (2, 3), 4, 5, 6, 7, 8, 9), (10, 11, 12));
}";
var assembly0 = GenerateTupleAssembly();
var reference0 = AssemblyMetadata.CreateFromImage(assembly0).GetReference();
var compilation1 = CSharpTestBaseBase.CreateCompilationWithMscorlib45AndCSruntime(source, additionalRefs: new[] { reference0 });
var assembly1 = compilation1.EmitToArray();
var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlib(ReflectionUtilities.Load(assembly0), ReflectionUtilities.Load(assembly1)));
using (runtime.Load())
{
var type = runtime.GetType("C");
var value = type.Instantiate();
var evalResult = FormatResult("o", value);
var children = GetChildren(evalResult);
Verify(children,
EvalResult(
"F",
"((1, (2, 3), 4, 5, 6, 7, 8, 9), (10, 11, 12))",
"((int A, (int B, int C) D, int E, int F, int G, int H, int I, int J) K, (int L, int M, int N) O)",
"o.F",
DkmEvaluationResultFlags.Expandable));
}
}
示例10: Dynamic
public void Dynamic()
{
var source =
@"class C
{
(dynamic, (object, dynamic)) F = (1, (2, 3));
(object, object, object, object, object, object, dynamic[], dynamic[]) G = (1, 2, 3, 4, 5, 6, new object[] { 7 }, new object[] { 8 });
}";
var assembly0 = GenerateTupleAssembly();
var reference0 = AssemblyMetadata.CreateFromImage(assembly0).GetReference();
var compilation1 = CSharpTestBaseBase.CreateCompilationWithMscorlib45AndCSruntime(source, additionalRefs: new[] { reference0 });
var assembly1 = compilation1.EmitToArray();
var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlib(ReflectionUtilities.Load(assembly0), ReflectionUtilities.Load(assembly1)));
using (runtime.Load())
{
var type = runtime.GetType("C");
var value = type.Instantiate();
var evalResult = FormatResult("o", value);
var children = GetChildren(evalResult);
Verify(children,
EvalResult(
"F",
"(1, (2, 3))",
"(dynamic, (object, dynamic)) {(object, (object, object))}",
"o.F",
DkmEvaluationResultFlags.Expandable),
EvalResult(
"G",
"(1, 2, 3, 4, 5, 6, {object[1]}, {object[1]})",
"(object, object, object, object, object, object, dynamic[], dynamic[]) {(object, object, object, object, object, object, object[], object[])}",
"o.G",
DkmEvaluationResultFlags.Expandable));
}
}
示例11: NullNullableAndArray
public void NullNullableAndArray()
{
var source =
@"using System;
namespace System
{
struct ValueTuple<T1, T2>
{
public T1 Item1;
public T2 Item2;
}
struct ValueTuple<T1, T2, T3>
{
public T1 Item1;
public T2 Item2;
public T3 Item3;
}
}
class C
{
ValueTuple<object, int> _1 = default(ValueTuple<object, int>);
ValueTuple<object, int, object>? _2 = new ValueTuple<object, int, object>();
ValueTuple<object, int>[] _3 = new ValueTuple<object, int>[1];
}";
var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlib(GetAssembly(source)));
using (runtime.Load())
{
var type = runtime.GetType("C");
var value = type.Instantiate();
var evalResult = FormatResult("o", value);
Verify(evalResult,
EvalResult("o", "{C}", "C", "o", DkmEvaluationResultFlags.Expandable));
var children = GetChildren(evalResult);
Verify(children,
EvalResult("_1", "(null, 0)", "(object, int)", "o._1", DkmEvaluationResultFlags.Expandable),
EvalResult("_2", "(null, 0, null)", "(object, int, object)?", "o._2", DkmEvaluationResultFlags.Expandable),
EvalResult("_3", "{(object, int)[1]}", "(object, int)[]", "o._3", DkmEvaluationResultFlags.Expandable));
}
}
示例12: MissingFields
public void MissingFields()
{
var source =
@"namespace System
{
public struct ValueTuple<T1, T2>
{
public T1 Item1;
// No Item2.
public ValueTuple(T1 _1, T2 _2)
{
Item1 = _1;
}
}
public struct ValueTuple<T1, T2, T3>
{
// No Item*.
public ValueTuple(T1 _1, T2 _2, T3 _3)
{
}
}
public struct ValueTuple<T1, T2, T3, T4, T5, T6, T7, T8>
{
public T1 Item1;
public T2 Item2;
public T3 Item3;
public T4 Item4;
public T5 Item5;
public T6 Item6;
public T7 Item7;
// No Rest.
public ValueTuple(T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8)
{
Item1 = _1;
Item2 = _2;
Item3 = _3;
Item4 = _4;
Item5 = _5;
Item6 = _6;
Item7 = _7;
}
}
}
namespace System.Runtime.CompilerServices
{
public class TupleElementNamesAttribute : Attribute
{
public TupleElementNamesAttribute(string[] names)
{
}
}
}
class C
{
(int A, int B) F = (1, 2);
(int, int, int C) G = (1, 2, 3);
(int, int B, int, int D, int, int F, int, int H, int) H = (1, 2, 3, 4, 5, 6, 7, 8, 9);
}";
var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlib(GetAssembly(source)));
using (runtime.Load())
{
var type = runtime.GetType("C");
var value = type.Instantiate();
var evalResult = FormatResult("o", value);
Verify(evalResult,
EvalResult("o", "{C}", "C", "o", DkmEvaluationResultFlags.Expandable));
var children = GetChildren(evalResult);
Verify(children,
EvalResult("F", "{(int, int)}", "(int A, int B)", "o.F", DkmEvaluationResultFlags.Expandable),
EvalResult("G", "{(int, int, int)}", "(int, int, int C)", "o.G", DkmEvaluationResultFlags.Expandable), // expandable, but with no children
EvalResult("H", "{(int, int, int, int, int, int, int, int, int)}", "(int, int B, int, int D, int, int F, int, int H, int)", "o.H", DkmEvaluationResultFlags.Expandable));
var moreChildren = GetChildren(children[0]);
Verify(moreChildren,
EvalResult("A", "1", "int", "o.F.Item1"),
EvalResult("Raw View", "{(int, int)}", "(int A, int B)", "o.F, raw", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly));
moreChildren = GetChildren(children[1]);
Verify(moreChildren);
moreChildren = GetChildren(children[2]);
Verify(moreChildren,
EvalResult("Item1", "1", "int", "o.H.Item1"),
EvalResult("B", "2", "int", "o.H.Item2"),
EvalResult("Item3", "3", "int", "o.H.Item3"),
EvalResult("D", "4", "int", "o.H.Item4"),
EvalResult("Item5", "5", "int", "o.H.Item5"),
EvalResult("F", "6", "int", "o.H.Item6"),
EvalResult("Item7", "7", "int", "o.H.Item7"),
EvalResult("Raw View", "{(int, int, int, int, int, int, int, int, int)}", "(int, int B, int, int D, int, int F, int, int H, int)", "o.H, raw", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly));
}
}
示例13: LongTuple_NoNames
public void LongTuple_NoNames()
{
var source =
@"class C
{
(short, short, short, short, short, short, short, short, short, short, short, short, short, short, short, short, short) _17 =
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
}";
var assembly0 = GenerateTupleAssembly();
var reference0 = AssemblyMetadata.CreateFromImage(assembly0).GetReference();
var compilation1 = CSharpTestBaseBase.CreateCompilationWithMscorlib(source, references: new[] { reference0 });
var assembly1 = compilation1.EmitToArray();
var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlib(ReflectionUtilities.Load(assembly0), ReflectionUtilities.Load(assembly1)));
using (runtime.Load())
{
var inspectionContext = CreateDkmInspectionContext(radix: 16);
var type = runtime.GetType("C");
var value = type.Instantiate();
var evalResult = FormatResult("o", value, inspectionContext: inspectionContext);
Verify(evalResult,
EvalResult("o", "{C}", "C", "o", DkmEvaluationResultFlags.Expandable));
var children = GetChildren(evalResult, inspectionContext);
Verify(children,
EvalResult(
"_17",
"(0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010, 0x0011)",
"(short, short, short, short, short, short, short, short, short, short, short, short, short, short, short, short, short)",
"o._17",
DkmEvaluationResultFlags.Expandable));
children = GetChildren(children[0], inspectionContext);
Verify(children,
EvalResult("Item1", "0x0001", "short", "o._17.Item1"),
EvalResult("Item2", "0x0002", "short", "o._17.Item2"),
EvalResult("Item3", "0x0003", "short", "o._17.Item3"),
EvalResult("Item4", "0x0004", "short", "o._17.Item4"),
EvalResult("Item5", "0x0005", "short", "o._17.Item5"),
EvalResult("Item6", "0x0006", "short", "o._17.Item6"),
EvalResult("Item7", "0x0007", "short", "o._17.Item7"),
EvalResult("Item8", "0x0008", "short", "o._17.Rest.Item1"),
EvalResult("Item9", "0x0009", "short", "o._17.Rest.Item2"),
EvalResult("Item10", "0x000a", "short", "o._17.Rest.Item3"),
EvalResult("Item11", "0x000b", "short", "o._17.Rest.Item4"),
EvalResult("Item12", "0x000c", "short", "o._17.Rest.Item5"),
EvalResult("Item13", "0x000d", "short", "o._17.Rest.Item6"),
EvalResult("Item14", "0x000e", "short", "o._17.Rest.Item7"),
EvalResult("Item15", "0x000f", "short", "o._17.Rest.Rest.Item1"),
EvalResult("Item16", "0x0010", "short", "o._17.Rest.Rest.Item2"),
EvalResult("Item17", "0x0011", "short", "o._17.Rest.Rest.Item3"),
EvalResult(
"Raw View",
"(0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010, 0x0011)",
"(short, short, short, short, short, short, short, short, short, short, short, short, short, short, short, short, short)",
"o._17, raw",
DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly));
children = GetChildren(children[children.Length - 1], inspectionContext);
Verify(children,
EvalResult("Item1", "0x0001", "short", "o._17.Item1"),
EvalResult("Item2", "0x0002", "short", "o._17.Item2"),
EvalResult("Item3", "0x0003", "short", "o._17.Item3"),
EvalResult("Item4", "0x0004", "short", "o._17.Item4"),
EvalResult("Item5", "0x0005", "short", "o._17.Item5"),
EvalResult("Item6", "0x0006", "short", "o._17.Item6"),
EvalResult("Item7", "0x0007", "short", "o._17.Item7"),
EvalResult("Rest", "(0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010, 0x0011)", "(short, short, short, short, short, short, short, short, short, short)", "o._17.Rest, raw", DkmEvaluationResultFlags.Expandable));
children = GetChildren(children[children.Length - 1], inspectionContext);
Verify(children,
EvalResult("Item1", "0x0008", "short", "o._17.Rest.Item1"),
EvalResult("Item2", "0x0009", "short", "o._17.Rest.Item2"),
EvalResult("Item3", "0x000a", "short", "o._17.Rest.Item3"),
EvalResult("Item4", "0x000b", "short", "o._17.Rest.Item4"),
EvalResult("Item5", "0x000c", "short", "o._17.Rest.Item5"),
EvalResult("Item6", "0x000d", "short", "o._17.Rest.Item6"),
EvalResult("Item7", "0x000e", "short", "o._17.Rest.Item7"),
EvalResult("Rest", "(0x000f, 0x0010, 0x0011)", "(short, short, short)", "o._17.Rest.Rest, raw", DkmEvaluationResultFlags.Expandable));
children = GetChildren(children[children.Length - 1], inspectionContext);
Verify(children,
EvalResult("Item1", "0x000f", "short", "o._17.Rest.Rest.Item1"),
EvalResult("Item2", "0x0010", "short", "o._17.Rest.Rest.Item2"),
EvalResult("Item3", "0x0011", "short", "o._17.Rest.Rest.Item3"));
}
}
示例14: IsTupleCompatible
public void IsTupleCompatible()
{
var source =
@"namespace System
{
struct ValueTuple { }
struct ValueTuple<T1> { }
struct ValueTuple<T1, T2> { }
struct ValueTuple<T1, T2, T3> { }
struct ValueTuple<T1, T2, T3, T4> { }
struct ValueTuple<T1, T2, T3, T4, T5> { }
struct ValueTuple<T1, T2, T3, T4, T5, T6> { }
struct ValueTuple<T1, T2, T3, T4, T5, T6, T7> { }
struct ValueTuple<T1, T2, T3, T4, T5, T6, T7, T8> { }
struct ValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> { }
}";
var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlib(GetAssembly(source)));
using (runtime.Load())
{
var type = runtime.GetType("System.ValueTuple");
int cardinality;
Assert.False(type.GetLmrType().IsTupleCompatible(out cardinality));
Assert.Equal(0, cardinality);
type = runtime.GetType("System.ValueTuple`1", typeof(int));
Assert.True(type.GetLmrType().IsTupleCompatible(out cardinality));
Assert.Equal(1, cardinality);
type = runtime.GetType("System.ValueTuple`2", typeof(int), typeof(string));
Assert.True(type.GetLmrType().IsTupleCompatible(out cardinality));
Assert.Equal(2, cardinality);
type = runtime.GetType("System.ValueTuple`3", typeof(int), typeof(string), typeof(int));
Assert.True(type.GetLmrType().IsTupleCompatible(out cardinality));
Assert.Equal(3, cardinality);
type = runtime.GetType("System.ValueTuple`4", typeof(int), typeof(string), typeof(int), typeof(string));
Assert.True(type.GetLmrType().IsTupleCompatible(out cardinality));
Assert.Equal(4, cardinality);
type = runtime.GetType("System.ValueTuple`5", typeof(int), typeof(string), typeof(int), typeof(string), typeof(int));
Assert.True(type.GetLmrType().IsTupleCompatible(out cardinality));
Assert.Equal(5, cardinality);
type = runtime.GetType("System.ValueTuple`6", typeof(int), typeof(string), typeof(int), typeof(string), typeof(int), typeof(string));
Assert.True(type.GetLmrType().IsTupleCompatible(out cardinality));
Assert.Equal(6, cardinality);
type = runtime.GetType("System.ValueTuple`7", typeof(int), typeof(string), typeof(int), typeof(string), typeof(int), typeof(string), typeof(int));
Assert.True(type.GetLmrType().IsTupleCompatible(out cardinality));
Assert.Equal(7, cardinality);
type = runtime.GetType("System.ValueTuple`8", typeof(int), typeof(string), typeof(int), typeof(string), typeof(int), typeof(string), typeof(int), typeof(string));
Assert.False(type.GetLmrType().IsTupleCompatible(out cardinality));
Assert.Equal(0, cardinality);
type = runtime.GetType("System.ValueTuple`1", typeof(string));
type = runtime.GetType("System.ValueTuple`8", typeof(int), typeof(string), typeof(int), typeof(string), typeof(int), typeof(string), typeof(int), ((TypeImpl)type.GetLmrType()).Type);
Assert.True(type.GetLmrType().IsTupleCompatible(out cardinality));
Assert.Equal(8, cardinality);
type = runtime.GetType("System.ValueTuple`9", typeof(int), typeof(string), typeof(int), typeof(string), typeof(int), typeof(string), typeof(int), typeof(string), typeof(int));
Assert.False(type.GetLmrType().IsTupleCompatible(out cardinality));
Assert.Equal(0, cardinality);
}
}
示例15: Tuples
public void Tuples()
{
var source =
@"using System;
class C
{
object _1 = new ValueTuple<int>(1);
object _2 = new ValueTuple<int, int>(1, 2);
object _3 = new ValueTuple<int, int, int>(1, 2, 3);
object _4 = new ValueTuple<int, int, int, int>(1, 2, 3, 4);
object _5 = new ValueTuple<int, int, int, int, int>(1, 2, 3, 4, 5);
object _6 = new ValueTuple<int, int, int, int, int, int>(1, 2, 3, 4, 5, 6);
object _7 = new ValueTuple<int, int, int, int, int, int, int>(1, 2, 3, 4, 5, 6, 7);
object _8 = new ValueTuple<int, int, int, int, int, int, int, ValueTuple<int>>(1, 2, 3, 4, 5, 6, 7, new ValueTuple<int>(8));
object _8A = new ValueTuple<int, int, int, int, int, int, int, int>(1, 2, 3, 4, 5, 6, 7, 8);
object _9 = new ValueTuple<int, int, int, int, int, int, int, ValueTuple<int, int>>(1, 2, 3, 4, 5, 6, 7, new ValueTuple<int, int>(8, 9));
}";
var assembly0 = GenerateTupleAssembly();
var reference0 = AssemblyMetadata.CreateFromImage(assembly0).GetReference();
var compilation1 = CSharpTestBaseBase.CreateCompilationWithMscorlib(source, references: new[] { reference0 });
var assembly1 = compilation1.EmitToArray();
var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlib(ReflectionUtilities.Load(assembly0), ReflectionUtilities.Load(assembly1)));
using (runtime.Load())
{
var type = runtime.GetType("C");
var value = type.Instantiate();
var evalResult = FormatResult("o", value);
Verify(evalResult,
EvalResult("o", "{C}", "C", "o", DkmEvaluationResultFlags.Expandable));
var children = GetChildren(evalResult);
Verify(children,
EvalResult("_1", "{System.ValueTuple<int>}", "object {System.ValueTuple<int>}", "o._1", DkmEvaluationResultFlags.Expandable),
EvalResult("_2", "(1, 2)", "object {(int, int)}", "o._2", DkmEvaluationResultFlags.Expandable),
EvalResult("_3", "(1, 2, 3)", "object {(int, int, int)}", "o._3", DkmEvaluationResultFlags.Expandable),
EvalResult("_4", "(1, 2, 3, 4)", "object {(int, int, int, int)}", "o._4", DkmEvaluationResultFlags.Expandable),
EvalResult("_5", "(1, 2, 3, 4, 5)", "object {(int, int, int, int, int)}", "o._5", DkmEvaluationResultFlags.Expandable),
EvalResult("_6", "(1, 2, 3, 4, 5, 6)", "object {(int, int, int, int, int, int)}", "o._6", DkmEvaluationResultFlags.Expandable),
EvalResult("_7", "(1, 2, 3, 4, 5, 6, 7)", "object {(int, int, int, int, int, int, int)}", "o._7", DkmEvaluationResultFlags.Expandable),
EvalResult("_8", "(1, 2, 3, 4, 5, 6, 7, 8)", "object {(int, int, int, int, int, int, int, int)}", "o._8", DkmEvaluationResultFlags.Expandable),
EvalResult("_8A", "{System.ValueTuple<int, int, int, int, int, int, int, int>}", "object {System.ValueTuple<int, int, int, int, int, int, int, int>}", "o._8A", DkmEvaluationResultFlags.Expandable),
EvalResult("_9", "(1, 2, 3, 4, 5, 6, 7, 8, 9)", "object {(int, int, int, int, int, int, int, int, int)}", "o._9", DkmEvaluationResultFlags.Expandable));
}
}