当前位置: 首页>>代码示例>>C#>>正文


C# DkmClrRuntimeInstance.GetType方法代码示例

本文整理汇总了C#中Microsoft.VisualStudio.Debugger.Clr.DkmClrRuntimeInstance.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# DkmClrRuntimeInstance.GetType方法的具体用法?C# DkmClrRuntimeInstance.GetType怎么用?C# DkmClrRuntimeInstance.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.VisualStudio.Debugger.Clr.DkmClrRuntimeInstance的用法示例。


在下文中一共展示了DkmClrRuntimeInstance.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IEnumerableOfTPattern

        public void IEnumerableOfTPattern()
        {
            var source =
@"using System.Collections.Generic;
class C<T>
{
    private readonly IEnumerable<T> e;
    internal C(IEnumerable<T> e)
    {
        this.e = e;
    }
    public IEnumerator<T> GetEnumerator()
    {
        return this.e.GetEnumerator();
    }
}";
            var assembly = GetAssembly(source);
            var assemblies = ReflectionUtilities.GetMscorlibAndSystemCore(assembly);
            using (ReflectionUtilities.LoadAssemblies(assemblies))
            {
                var runtime = new DkmClrRuntimeInstance(assemblies);
                var type = assembly.GetType("C`1").MakeGenericType(typeof(int));
                var value = CreateDkmClrValue(
                    value: type.Instantiate(new[] { 1, 2 }),
                    type: runtime.GetType((TypeImpl)type));
                var evalResult = FormatResult("o", value);
                Verify(evalResult,
                    EvalResult("o", "{C<int>}", "C<int>", "o", DkmEvaluationResultFlags.Expandable));
                var children = GetChildren(evalResult);
                Verify(children,
                    EvalResult("e", "{int[2]}", "System.Collections.Generic.IEnumerable<int> {int[]}", "o.e", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly));
            }
        }
开发者ID:gustavoasoares,项目名称:roslyn,代码行数:33,代码来源:ResultsViewTests.cs

示例2: NoQuotes_Char

        public void NoQuotes_Char()
        {
            var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlib());
            var inspectionContext = CreateDkmInspectionContext(DkmEvaluationFlags.NoQuotes);
            var charType = runtime.GetType(typeof(char));

            // 0
            var value = CreateDkmClrValue((char)0, type: charType, inspectionContext: inspectionContext);
            var evalResult = FormatResult("c", value);
            Verify(evalResult,
                EvalResult("c", "0 \\0", "char", "c", editableValue: "'\\0'", flags: DkmEvaluationResultFlags.None));

            // '\''
            value = CreateDkmClrValue('\'', type: charType, inspectionContext: inspectionContext);
            evalResult = FormatResult("c", value);
            Verify(evalResult,
                EvalResult("c", "39 '", "char", "c", editableValue: "'\\''", flags: DkmEvaluationResultFlags.None));

            // '"'
            value = CreateDkmClrValue('"', type: charType, inspectionContext: inspectionContext);
            evalResult = FormatResult("c", value);
            Verify(evalResult,
                EvalResult("c", "34 \"", "char", "c", editableValue: "'\"'", flags: DkmEvaluationResultFlags.None));

            // array
            value = CreateDkmClrValue(new char[] { '1' }, type: charType.MakeArrayType(), inspectionContext: inspectionContext);
            evalResult = FormatResult("a", value);
            Verify(evalResult,
                EvalResult("a", "{char[1]}", "char[]", "a", editableValue: null, flags: DkmEvaluationResultFlags.Expandable));
            var children = GetChildren(evalResult);
            // TODO: InspectionContext should not be inherited. See IDkmClrFormatter.GetValueString.
            Verify(children,
                EvalResult("[0]", "49 1", "char", "a[0]", editableValue: "'1'", flags: DkmEvaluationResultFlags.None));
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:34,代码来源:FormatSpecifierTests.cs

示例3: 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));
            }
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:27,代码来源:FunctionPointerTests.cs

示例4: NoQuotes_String

        public void NoQuotes_String()
        {
            var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlib());
            var inspectionContext = CreateDkmInspectionContext(DkmEvaluationFlags.NoQuotes);
            var stringType = runtime.GetType(typeof(string));

            // null
            var value = CreateDkmClrValue(null, type: stringType, inspectionContext: inspectionContext);
            var evalResult = FormatResult("s", value);
            Verify(evalResult,
                EvalResult("s", "null", "string", "s", editableValue: null, flags: DkmEvaluationResultFlags.None));

            // ""
            value = CreateDkmClrValue(string.Empty, type: stringType, inspectionContext: inspectionContext);
            evalResult = FormatResult("s", value);
            Verify(evalResult,
                EvalResult("s", "", "string", "s", editableValue: "\"\"", flags: DkmEvaluationResultFlags.RawString));

            // "'"
            value = CreateDkmClrValue("'", type: stringType, inspectionContext: inspectionContext);
            evalResult = FormatResult("s", value);
            Verify(evalResult,
                EvalResult("s", "'", "string", "s", editableValue: "\"'\"", flags: DkmEvaluationResultFlags.RawString));

            // "\""
            value = CreateDkmClrValue("\"", type: stringType, inspectionContext: inspectionContext);
            evalResult = FormatResult("s", value);
            Verify(evalResult,
                EvalResult("s", "\"", "string", "s", editableValue: "\"\\\"\"", flags: DkmEvaluationResultFlags.RawString));

            // " " with alias
            value = CreateDkmClrValue(" ", type: stringType, alias: "1", evalFlags: DkmEvaluationResultFlags.HasObjectId, inspectionContext: inspectionContext);
            evalResult = FormatResult("s", value);
            Verify(evalResult,
                EvalResult("s", "  {$1}", "string", "s", editableValue: "\" \"", flags: DkmEvaluationResultFlags.RawString | DkmEvaluationResultFlags.HasObjectId));

            // array
            value = CreateDkmClrValue(new string[] { "1" }, type: stringType.MakeArrayType(), inspectionContext: inspectionContext);
            evalResult = FormatResult("a", value);
            Verify(evalResult,
                EvalResult("a", "{string[1]}", "string[]", "a", editableValue: null, flags: DkmEvaluationResultFlags.Expandable));
            var children = GetChildren(evalResult);
            // TODO: InspectionContext should not be inherited. See IDkmClrFormatter.GetValueString.
            Verify(children,
                EvalResult("[0]", "1", "string", "a[0]", editableValue: "\"1\"", flags: DkmEvaluationResultFlags.RawString));
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:46,代码来源:FormatSpecifierTests.cs

示例5: 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));
            }
        }
开发者ID:slamj1,项目名称:roslyn,代码行数:22,代码来源:FunctionPointerTests.cs

示例6: TestNativeView

        private void TestNativeView(bool enableNativeDebugging)
        {
            var source =
@"class C
{
}";
            using (new EnsureEnglishUICulture())
            {
                var assembly = GetAssembly(source);
                var assemblies = ReflectionUtilities.GetMscorlibAndSystemCore(assembly);
                using (ReflectionUtilities.LoadAssemblies(assemblies))
                {
                    var runtime = new DkmClrRuntimeInstance(assemblies, enableNativeDebugging: enableNativeDebugging);
                    var inspectionContext = CreateDkmInspectionContext(runtimeInstance: runtime);
                    var type = assembly.GetType("C");
                    var value = CreateDkmClrValue(
                        value: type.Instantiate(),
                        type: runtime.GetType((TypeImpl)type),
                        nativeComPointer: 0xfe);
                    var evalResult = FormatResult("o", value, inspectionContext: inspectionContext);
                    Verify(evalResult,
                        EvalResult("o", "{C}", "C", "o", DkmEvaluationResultFlags.Expandable));
                    var children = GetChildren(evalResult, inspectionContext);
                    if (enableNativeDebugging)
                    {
                        string pointerString = $"(IUnknown*){PointerToString(new IntPtr(0xfe))}";
                        DkmLanguage language = new DkmLanguage(new DkmCompilerId(DkmVendorId.Microsoft, DkmLanguageId.Cpp));
                        Verify(children,
                            EvalIntermediateResult("Native View", "{C++}" + pointerString, pointerString, language));
                    }
                    else
                    {
                        Verify(children,
                            EvalFailedResult("Native View", "To inspect the native object, enable native code debugging."));
                    }
                }
            }
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:38,代码来源:NativeViewTests.cs

示例7: NamesFromTypeArguments

        public void NamesFromTypeArguments()
        {
            var source =
@"class A<T, U>
{
    T F;
    U[] G = new U[0];
}
class B<T>
{
    internal struct S { }
    (dynamic X, T Y) F = (null, default(T));
}
class C
{
    A<(dynamic A, object B)[], (object C, dynamic[] D)> F = new A<(dynamic A, object B)[], (object, dynamic[])>();
    B<(object E, B<(object F, dynamic G)>.S H)> G = new B<(object E, B<(object F, dynamic G)>.S H)>();
}";
            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", "{A<(object, object)[], (object, object[])>}", "A<(dynamic A, object B)[], (object C, dynamic[] D)> {A<(object, object)[], (object, object[])>}", "o.F", DkmEvaluationResultFlags.Expandable),
                    EvalResult("G", "{B<(object, B<(object, object)>.S)>}", "B<(object E, B<(object F, dynamic G)>.S H)> {B<(object, B<(object, object)>.S)>}", "o.G", DkmEvaluationResultFlags.Expandable));
                var moreChildren = GetChildren(children[0]);
                Verify(moreChildren,
                    EvalResult("F", "null", "(dynamic A, object B)[] {(object, object)[]}", "o.F.F"),
                    EvalResult("G", "{(object, object[])[0]}", "(object C, dynamic[] D)[] {(object, object[])[]}", "o.F.G"));
                moreChildren = GetChildren(children[1]);
                Verify(moreChildren,
                    EvalResult("F", "(null, (null, {B<(object, object)>.S}))", "(dynamic X, (object E, B<(object F, dynamic G)>.S H) Y) {(object, (object, B<(object, object)>.S))}", "o.G.F", DkmEvaluationResultFlags.Expandable));
                moreChildren = GetChildren(moreChildren[0]);
                Verify(moreChildren,
                    EvalResult("X", "null", "dynamic {object}", "o.G.F.Item1"),
                    EvalResult("Y", "(null, {B<(object, object)>.S})", "(object E, B<(object F, dynamic G)>.S H) {(object, B<(object, object)>.S)}", "o.G.F.Item2", DkmEvaluationResultFlags.Expandable),
                    EvalResult("Raw View", "(null, (null, {B<(object, object)>.S}))", "(dynamic X, (object E, B<(object F, dynamic G)>.S H) Y) {(object, (object, B<(object, object)>.S))}", "o.G.F, raw", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly));
                moreChildren = GetChildren(moreChildren[1]);
                Verify(moreChildren,
                    EvalResult("E", "null", "object", "o.G.F.Item2.Item1"),
                    EvalResult("H", "{B<(object, object)>.S}", "B<(object F, dynamic G)>.S {B<(object, object)>.S}", "o.G.F.Item2.Item2"),
                    EvalResult("Raw View", "(null, {B<(object, object)>.S})", "(object E, B<(object F, dynamic G)>.S H) {(object, B<(object, object)>.S)}", "o.G.F.Item2, raw", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly));
            }
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:51,代码来源:TupleTests.cs

示例8: 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"));
            }
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:35,代码来源:TupleTests.cs

示例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));
            }
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:28,代码来源:TupleTests.cs

示例10: ResultsView_TypeProxy

        public void ResultsView_TypeProxy()
        {
            var source =
@"using System.Collections;
using System.Diagnostics;
[DebuggerTypeProxy(typeof(P))]
class C : IEnumerable
{
    public IEnumerator GetEnumerator()
    {
        yield return 1;
    }
}
class P
{
    public P(C c)
    {
    }
    public object F
    {
        get { return 2; }
    }
}";
            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", value);
                Verify(evalResult,
                    EvalResult("o", "Expanding the Results View will enumerate the IEnumerable", "", "o, results", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly, DkmEvaluationResultCategory.Method));
            }
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:36,代码来源:FormatSpecifierTests.cs

示例11: ResultsView_Error

        public void ResultsView_Error()
        {
            var source =
@"using System.Collections;
class C
{
    bool f;
    internal ArrayList P
    {
        get { while (!this.f) { } return new ArrayList(); }
    }
    internal int Q
    {
        get { while (!this.f) { } return 3; }
    }
}";
            DkmClrRuntimeInstance runtime = null;
            GetMemberValueDelegate getMemberValue = (v, m) =>
                {
                    switch (m)
                    {
                        case "P":
                            return CreateErrorValue(runtime.GetType(typeof(System.Collections.ArrayList)), "Property 'P' evaluation timed out");
                        case "Q":
                            return CreateErrorValue(runtime.GetType(typeof(string)), "Property 'Q' evaluation timed out");
                        default:
                            return null;
                    }
                };
            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 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", "Property 'P' evaluation timed out"));
                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", "Property 'Q' evaluation timed out"));
            }
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:46,代码来源:FormatSpecifierTests.cs

示例12: ResultsView_FrameworkTypes

        public void ResultsView_FrameworkTypes()
        {
            var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlibAndSystemCore());
            var inspectionContext = CreateDkmInspectionContext(DkmEvaluationFlags.ResultsOnly);

            // object: not enumerable
            var value = CreateDkmClrValue(new object(), type: runtime.GetType(typeof(object)), inspectionContext: inspectionContext);
            var evalResult = FormatResult("o", value);
            Verify(evalResult,
                EvalFailedResult("o", "Only Enumerable types can have Results View"));

            // string: not considered enumerable which is consistent with legacy EE
            value = CreateDkmClrValue("", type: runtime.GetType(typeof(string)), inspectionContext: inspectionContext);
            evalResult = FormatResult("s", value);
            Verify(evalResult,
                EvalFailedResult("s", "Only Enumerable types can have Results View"));

            // Array: not considered enumerable which is consistent with legacy EE
            value = CreateDkmClrValue(new[] { 1 }, type: runtime.GetType(typeof(int[])), inspectionContext: inspectionContext);
            evalResult = FormatResult("i", value);
            Verify(evalResult,
                EvalFailedResult("i", "Only Enumerable types can have Results View"));

            // ArrayList
            value = CreateDkmClrValue(new System.Collections.ArrayList(new[] { 2 }), type: runtime.GetType(typeof(System.Collections.ArrayList)), inspectionContext: inspectionContext);
            evalResult = FormatResult("a", value);
            Verify(evalResult,
                EvalResult("a", "Expanding the Results View will enumerate the IEnumerable", "", "a, results", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly, DkmEvaluationResultCategory.Method));
            var children = GetChildren(evalResult);
            Verify(children,
                EvalResult("[0]", "2", "object {int}", "new System.Linq.SystemCore_EnumerableDebugView(a).Items[0]"));

            // List<object>
            value = CreateDkmClrValue(new System.Collections.Generic.List<object>(new object[] { 3 }), type: runtime.GetType(typeof(System.Collections.Generic.List<object>)), inspectionContext: inspectionContext);
            evalResult = FormatResult("l", value);
            Verify(evalResult,
                EvalResult("l", "Expanding the Results View will enumerate the IEnumerable", "", "l, results", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly, DkmEvaluationResultCategory.Method));
            children = GetChildren(evalResult);
            Verify(children,
                EvalResult("[0]", "3", "object {int}", "new System.Linq.SystemCore_EnumerableDebugView<object>(l).Items[0]"));

            // int?
            value = CreateDkmClrValue(1, type: runtime.GetType(typeof(System.Nullable<>)).MakeGenericType(runtime.GetType(typeof(int))), inspectionContext: inspectionContext);
            evalResult = FormatResult("i", value);
            Verify(evalResult,
                EvalFailedResult("i", "Only Enumerable types can have Results View"));
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:47,代码来源:FormatSpecifierTests.cs

示例13: ResultsView_IEnumerableOfT

        public void ResultsView_IEnumerableOfT()
        {
            var source =
@"using System;
using System.Collections;
using System.Collections.Generic;
struct S<T> : IEnumerable<T>
{
    private readonly T t;
    internal S(T t)
    {
        this.t = t;
    }
    IEnumerator<T> IEnumerable<T>.GetEnumerator()
    {
        yield return t;
    }
    IEnumerator IEnumerable.GetEnumerator()
    {
        throw new NotImplementedException();
    }
}";
            var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlibAndSystemCore(GetAssembly(source)));
            using (runtime.Load())
            {
                var type = runtime.GetType("S`1").MakeGenericType(runtime.GetType(typeof(int)));
                var value = CreateDkmClrValue(
                    value: type.Instantiate(2),
                    type: type,
                    inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.ResultsOnly));
                var evalResult = FormatResult("o", "o, results", 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);
                Verify(children,
                    EvalResult("[0]", "2", "int", "new System.Linq.SystemCore_EnumerableDebugView<int>(o).Items[0]"));
            }
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:38,代码来源:FormatSpecifierTests.cs

示例14: RawView_NoProxy

        public void RawView_NoProxy()
        {
            var runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlib());
            var inspectionContext = CreateDkmInspectionContext(DkmEvaluationFlags.ShowValueRaw);

            // int
            var value = CreateDkmClrValue(1, type: runtime.GetType(typeof(int)), inspectionContext: inspectionContext);
            var evalResult = FormatResult("i", value);
            Verify(evalResult,
                EvalResult("i", "1", "int", "i, raw", editableValue: null, flags: DkmEvaluationResultFlags.None));

            // string
            value = CreateDkmClrValue(string.Empty, type: runtime.GetType(typeof(string)), inspectionContext: inspectionContext);
            evalResult = FormatResult("s", value);
            Verify(evalResult,
                EvalResult("s", "\"\"", "string", "s, raw", editableValue: "\"\"", flags: DkmEvaluationResultFlags.RawString));

            // object[]
            value = CreateDkmClrValue(new object[] { 1, 2, 3 }, type: runtime.GetType(typeof(object)).MakeArrayType(), inspectionContext: inspectionContext);
            evalResult = FormatResult("a", value);
            Verify(evalResult,
                EvalResult("a", "{object[3]}", "object[]", "a, raw", editableValue: null, flags: DkmEvaluationResultFlags.Expandable));
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:23,代码来源:FormatSpecifierTests.cs

示例15: NamesAndDynamic_Other

        public void NamesAndDynamic_Other()
        {
            var source =
@"class C1 { }
class C2 { }
class C3 { }
class C4 { }
class C5 { }
class C6 { }
class C7 { }
class C8 { }
class C9 { }
class C10 { }
class C11 { }
class C12 { }
class C
{
    (((C1 C1, dynamic C2) B1, (C3 C3, dynamic C4)) A1, (dynamic B3, (C7 C7, C8 C8) B4) A2, ((C9 C9, C10 C10), dynamic B6) A3) F =
        ((
            ((new C1(), new C2()), (new C3(), new C4())),
            ((new C5(), new C6()), (new C7(), new C8())),
            ((new C9(), new C10()), (new C11(), new C12()))
        ));
}";
            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",
                        "((({C1}, {C2}), ({C3}, {C4})), (({C5}, {C6}), ({C7}, {C8})), (({C9}, {C10}), ({C11}, {C12})))",
                        "(((C1 C1, dynamic C2) B1, (C3 C3, dynamic C4)) A1, (dynamic B3, (C7 C7, C8 C8) B4) A2, ((C9 C9, C10 C10), dynamic B6) A3) {(((C1, object), (C3, object)), (object, (C7, C8)), ((C9, C10), object))}",
                        "o.F",
                        DkmEvaluationResultFlags.Expandable));
            }
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:44,代码来源:TupleTests.cs


注:本文中的Microsoft.VisualStudio.Debugger.Clr.DkmClrRuntimeInstance.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。