From 2fc666c368464cd21eaf2a863a5033ad165912d7 Mon Sep 17 00:00:00 2001 From: Kevin Halverson Date: Fri, 20 Feb 2015 09:24:20 -0800 Subject: [PATCH] Refactor ResultProvider (incorporating Concord API changes)... 1. DkmClrValue.InspectionContext has been removed, so a separate instance needs to be passed to all the methods that need it. 2. DkmClrValue.EvaluateDebuggerDisplayString is now async. In order to avoid complicated plumbing of completion routines through result expansion, I've moved the creation of DkmEvaluationResults from *Expansion to the ResultProvider. Expansion now produces EvalResultDataItems that contain all the information necessary to produce DkmEvaluatoinResults in a single place, just before returning from the ResultProvider entry points. New async plumbing/Exception handling is localized to the entry points. 3. There are several places that the API now allows passing format specifiers. We do not intend to support those scenarios in C#/VB, so we will ignore them. --- .../CSharpResultProvider.csproj | 2 +- .../Test/ResultProvider/AccessibilityTests.cs | 23 +- .../DebuggerBrowsableAttributeTests.cs | 10 +- .../DebuggerDisplayAttributeTests.cs | 22 +- .../Test/ResultProvider/ExpansionTests.cs | 24 +- .../ResultProvider/FormatSpecifierTests.cs | 141 +++--- .../Test/ResultProvider/ObjectIdTests.cs | 4 +- .../Microsoft.VisualStudio.Debugger.Engine.il | 242 ++++++---- .../Expansion/AggregateExpansion.cs | 2 +- .../Expansion/ArrayExpansion.cs | 11 +- .../Expansion/DebuggerTypeProxyExpansion.cs | 47 +- .../ResultProvider/Expansion/Expansion.cs | 2 +- .../Expansion/MemberExpansion.cs | 80 ++-- .../Expansion/PointerDereferenceExpansion.cs | 42 +- .../Expansion/ResultsViewExpansion.cs | 49 +-- .../Expansion/TypeVariablesExpansion.cs | 43 +- .../Source/ResultProvider/Formatter.Values.cs | 42 +- .../Core/Source/ResultProvider/Formatter.cs | 21 +- .../Helpers/DebuggerDisplayInfo.cs | 19 + .../Helpers/EvalResultDataItem.cs | 59 ++- .../ResultProvider/Helpers/TypeHelpers.cs | 34 +- .../Source/ResultProvider/ResultProvider.cs | 413 +++++++++++++----- .../ResultProvider/ResultProvider.csproj | 1 + .../Debugger/Engine/DkmClrValue.cs | 132 +++--- ...valuateDebuggerDisplayStringAsyncResult.cs | 27 ++ .../Engine/DkmEvaluationAsyncResult.cs | 35 ++ .../Debugger/Engine/DkmInspectionContext.cs | 8 +- .../ResultProvider/Debugger/Engine/DkmMisc.cs | 13 +- .../Debugger/Engine/DkmWorkList.cs | 47 ++ .../Debugger/Engine/IDkmClrFormatter.cs | 12 +- .../Debugger/Engine/IDkmClrResultProvider.cs | 6 +- .../ResultProvider/ResultProviderTestBase.cs | 86 ++-- .../ResultProviderTestUtilities.csproj | 9 +- .../ResultProvider/VisualBasicFormatter.vb | 19 +- .../Test/ResultProvider/ExpansionTests.vb | 4 +- .../ResultProvider/FormatSpecifierTests.vb | 48 +- .../Test/ResultProvider/ObjectIdTests.vb | 4 +- 37 files changed, 1110 insertions(+), 673 deletions(-) create mode 100644 src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/DebuggerDisplayInfo.cs create mode 100644 src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluateDebuggerDisplayStringAsyncResult.cs create mode 100644 src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationAsyncResult.cs create mode 100644 src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmWorkList.cs diff --git a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpResultProvider.csproj b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpResultProvider.csproj index 2bc3b28c5c2..61132b07d9e 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpResultProvider.csproj +++ b/src/ExpressionEvaluator/CSharp/Source/ResultProvider/CSharpResultProvider.csproj @@ -82,4 +82,4 @@ - \ No newline at end of file + diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/AccessibilityTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/AccessibilityTests.cs index 0b787f993f2..b8b773e97a2 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/AccessibilityTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/AccessibilityTests.cs @@ -88,20 +88,19 @@ class C var bytesB = compilationB.EmitToArray(); var assemblyA = ReflectionUtilities.Load(bytesA); var assemblyB = ReflectionUtilities.Load(bytesB); - DkmClrValue valueWithNonPublicHidden; + DkmClrValue value; using (ReflectionUtilities.LoadAssemblies(assemblyA, assemblyB)) { var runtime = new DkmClrRuntimeInstance(new[] { assemblyB }); var type = assemblyB.GetType("C", throwOnError: true); - valueWithNonPublicHidden = CreateDkmClrValue( + value = CreateDkmClrValue( Activator.CreateInstance(type), - runtime.GetType((TypeImpl)type), - inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.HideNonPublicMembers)); + runtime.GetType((TypeImpl)type)); } var rootExpr = "new C()"; - var evalResult = FormatResult(rootExpr, valueWithNonPublicHidden); + var evalResult = FormatResult(rootExpr, value, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.HideNonPublicMembers)); Verify(evalResult, EvalResult(rootExpr, "{C}", "C", rootExpr, DkmEvaluationResultFlags.Expandable)); @@ -250,20 +249,19 @@ class C var bytesB = compilationB.EmitToArray(); var assemblyA = ReflectionUtilities.Load(bytesA); var assemblyB = ReflectionUtilities.Load(bytesB); - DkmClrValue valueWithNonPublicHidden; + DkmClrValue value; using (ReflectionUtilities.LoadAssemblies(assemblyA, assemblyB)) { var runtime = new DkmClrRuntimeInstance(new[] { assemblyA }); var type = assemblyB.GetType("C", throwOnError: true); - valueWithNonPublicHidden = CreateDkmClrValue( + value = CreateDkmClrValue( Activator.CreateInstance(type), - runtime.GetType((TypeImpl)type), - inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.HideNonPublicMembers)); + runtime.GetType((TypeImpl)type)); } var rootExpr = "new C()"; - var evalResult = FormatResult(rootExpr, valueWithNonPublicHidden); + var evalResult = FormatResult(rootExpr, value, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.HideNonPublicMembers)); Verify(evalResult, EvalResult(rootExpr, "{C}", "C", rootExpr, DkmEvaluationResultFlags.Expandable)); @@ -360,9 +358,8 @@ public void NoModule() var type = assembly.GetType("C"); var value = CreateDkmClrValue( Activator.CreateInstance(type), - runtime.GetType((TypeImpl)type), - inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.HideNonPublicMembers)); - var evalResult = FormatResult("o", value); + runtime.GetType((TypeImpl)type)); + var evalResult = FormatResult("o", value, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.HideNonPublicMembers)); Verify(evalResult, EvalResult("o", "{C}", "C", "o", DkmEvaluationResultFlags.Expandable)); } diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/DebuggerBrowsableAttributeTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/DebuggerBrowsableAttributeTests.cs index 93f0555320b..71f53094678 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/DebuggerBrowsableAttributeTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/DebuggerBrowsableAttributeTests.cs @@ -520,9 +520,8 @@ public C(params T[] items) var value = CreateDkmClrValue( value: type.Instantiate(1, 2, 3), type: new DkmClrType(runtime.DefaultModule, runtime.DefaultAppDomain, (TypeImpl)type), - evalFlags: DkmEvaluationResultFlags.None, - inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.HideNonPublicMembers)); - var evalResult = FormatResult("o", value); + evalFlags: DkmEvaluationResultFlags.None); + var evalResult = FormatResult("o", value, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.HideNonPublicMembers)); Verify(evalResult, EvalResult("o", "{C}", "C", "o", DkmEvaluationResultFlags.Expandable)); var children = GetChildren(evalResult); @@ -566,9 +565,8 @@ public class C var value = CreateDkmClrValue( value: type.Instantiate(), type: new DkmClrType(runtime.DefaultModule, runtime.DefaultAppDomain, (TypeImpl)type), - evalFlags: DkmEvaluationResultFlags.None, - inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.HideNonPublicMembers)); - var evalResult = FormatResult("o", value); + evalFlags: DkmEvaluationResultFlags.None); + var evalResult = FormatResult("o", value, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.HideNonPublicMembers)); Verify(evalResult, EvalResult("o", "{C}", "C", "o", DkmEvaluationResultFlags.Expandable)); var children = GetChildren(evalResult); diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/DebuggerDisplayAttributeTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/DebuggerDisplayAttributeTests.cs index 35a24a21303..0c544c5b7b2 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/DebuggerDisplayAttributeTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/DebuggerDisplayAttributeTests.cs @@ -595,7 +595,8 @@ class B bool f; internal A P { get { return new A(); } } internal A Q { get { while(f) { } return new A(); } } -}"; +} +"; DkmClrRuntimeInstance runtime = null; GetMemberValueDelegate getMemberValue = (v, m) => (m == "Q") ? CreateErrorValue(runtime.GetType("A"), "Function evaluation timed out") : null; runtime = new DkmClrRuntimeInstance(ReflectionUtilities.GetMscorlibAndSystemCore(GetAssembly(source)), getMemberValue: getMemberValue); @@ -612,6 +613,25 @@ class B } } + [Fact] + public void Exception() + { + var source = +@"using System.Diagnostics; +[DebuggerDisplay(""Value}"")] +class A +{ + internal int Value; +} +"; + var assembly = GetAssembly(source); + var typeA = assembly.GetType("A"); + var instanceA = typeA.Instantiate(); + var result = FormatResult("a", CreateDkmClrValue(instanceA)); + Verify(result, + EvalFailedResult("a", "Unmatched closing brace in 'Value}'", null, null, DkmEvaluationResultFlags.None)); + } + private IReadOnlyList DepthFirstSearch(DkmEvaluationResult root, int maxDepth) { var builder = ArrayBuilder.GetInstance(); diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ExpansionTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ExpansionTests.cs index 76884949623..df92d6f957c 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ExpansionTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ExpansionTests.cs @@ -885,17 +885,15 @@ class D // Non-null value. var value = CreateDkmClrValue(Activator.CreateInstance(type), - type: type, - inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.NoExpansion)); - var evalResult = FormatResult("o", value); + type: type); + var evalResult = FormatResult("o", value, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.NoExpansion)); Verify(evalResult, EvalResult("o", "{C}", "C", "o", DkmEvaluationResultFlags.None)); // Null value. value = CreateDkmClrValue(null, - type: type, - inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.NoExpansion)); - evalResult = FormatResult("o", value); + type: type); + evalResult = FormatResult("o", value, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.NoExpansion)); Verify(evalResult, EvalResult("o", "null", "C", "o", DkmEvaluationResultFlags.None)); @@ -940,9 +938,8 @@ public object PF var assembly = GetAssembly(source); var type = assembly.GetType("C"); var value = CreateDkmClrValue(Activator.CreateInstance(type), - type: type, - inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.NoExpansion)); - var evalResult = FormatResult("o", value); + type: type); + var evalResult = FormatResult("o", value, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.NoExpansion)); Verify(evalResult, EvalResult("o", "{C}", "C", "o", DkmEvaluationResultFlags.None)); @@ -961,9 +958,8 @@ public object PF [Fact] public void NoExpansion_Array() { - var value = CreateDkmClrValue(new[] { 1, 2, 3 }, - inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.NoExpansion)); - var evalResult = FormatResult("a", value); + var value = CreateDkmClrValue(new[] { 1, 2, 3 }); + var evalResult = FormatResult("a", value, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.NoExpansion)); Verify(evalResult, EvalResult("a", "{int[3]}", "int[]", "a", DkmEvaluationResultFlags.None)); } @@ -1677,8 +1673,8 @@ public void UnicodeChar() EvalResult("c", "4660 '\u1234'", "char", "c", editableValue: "'\u1234'")); // This char is not printable, so we expect the EditableValue to be the unicode escape representation. - value = CreateDkmClrValue('\u0007', typeof(char), inspectionContext: CreateDkmInspectionContext(radix: 16)); - evalResult = FormatResult("c", value); + value = CreateDkmClrValue('\u0007', typeof(char)); + evalResult = FormatResult("c", value, inspectionContext: CreateDkmInspectionContext(radix: 16)); Verify(evalResult, EvalResult("c", "0x0007 '\u0007'", "char", "c", editableValue: "'\\u0007'")); } diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/FormatSpecifierTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/FormatSpecifierTests.cs index f7327d19bc9..1dd4cdba2d5 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/FormatSpecifierTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/FormatSpecifierTests.cs @@ -17,44 +17,44 @@ public void NoQuotes_String() var stringType = runtime.GetType(typeof(string)); // null - var value = CreateDkmClrValue(null, type: stringType, inspectionContext: inspectionContext); - var evalResult = FormatResult("s", value); + var value = CreateDkmClrValue(null, type: stringType); + var evalResult = FormatResult("s", value, inspectionContext: inspectionContext); Verify(evalResult, EvalResult("s", "null", "string", "s", editableValue: null, flags: DkmEvaluationResultFlags.None)); // "" - value = CreateDkmClrValue(string.Empty, type: stringType, inspectionContext: inspectionContext); - evalResult = FormatResult("s", value); + value = CreateDkmClrValue(string.Empty, type: stringType); + evalResult = FormatResult("s", value, inspectionContext: inspectionContext); Verify(evalResult, EvalResult("s", "", "string", "s", editableValue: "\"\"", flags: DkmEvaluationResultFlags.RawString)); // "'" - value = CreateDkmClrValue("'", type: stringType, inspectionContext: inspectionContext); - evalResult = FormatResult("s", value); + value = CreateDkmClrValue("'", type: stringType); + evalResult = FormatResult("s", value, inspectionContext: inspectionContext); Verify(evalResult, EvalResult("s", "'", "string", "s", editableValue: "\"'\"", flags: DkmEvaluationResultFlags.RawString)); // "\"" - value = CreateDkmClrValue("\"", type: stringType, inspectionContext: inspectionContext); - evalResult = FormatResult("s", value); + value = CreateDkmClrValue("\"", type: stringType); + evalResult = FormatResult("s", value, inspectionContext: inspectionContext); 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); + value = CreateDkmClrValue(" ", type: stringType, alias: "1", evalFlags: DkmEvaluationResultFlags.HasObjectId); + evalResult = FormatResult("s", value, inspectionContext: inspectionContext); 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); + value = CreateDkmClrValue(new string[] { "1" }, type: stringType.MakeArrayType()); + evalResult = FormatResult("a", value, inspectionContext: inspectionContext); 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. + // DkmInspectionContext should not be inherited. Verify(children, - EvalResult("[0]", "1", "string", "a[0]", editableValue: "\"1\"", flags: DkmEvaluationResultFlags.RawString)); + EvalResult("[0]", "\"1\"", "string", "a[0]", editableValue: "\"1\"", flags: DkmEvaluationResultFlags.RawString)); } [Fact] @@ -65,32 +65,32 @@ public void NoQuotes_Char() var charType = runtime.GetType(typeof(char)); // 0 - var value = CreateDkmClrValue((char)0, type: charType, inspectionContext: inspectionContext); - var evalResult = FormatResult("c", value); + var value = CreateDkmClrValue((char)0, type: charType); + var evalResult = FormatResult("c", value, inspectionContext: inspectionContext); Verify(evalResult, EvalResult("c", "0 \\0", "char", "c", editableValue: "'\\0'", flags: DkmEvaluationResultFlags.None)); // '\'' - value = CreateDkmClrValue('\'', type: charType, inspectionContext: inspectionContext); - evalResult = FormatResult("c", value); + value = CreateDkmClrValue('\'', type: charType); + evalResult = FormatResult("c", value, inspectionContext: inspectionContext); Verify(evalResult, EvalResult("c", "39 '", "char", "c", editableValue: "'\\''", flags: DkmEvaluationResultFlags.None)); // '"' - value = CreateDkmClrValue('"', type: charType, inspectionContext: inspectionContext); - evalResult = FormatResult("c", value); + value = CreateDkmClrValue('"', type: charType); + evalResult = FormatResult("c", value, inspectionContext: inspectionContext); 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); + value = CreateDkmClrValue(new char[] { '1' }, type: charType.MakeArrayType()); + evalResult = FormatResult("a", value, inspectionContext: inspectionContext); 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. + // DkmInspectionContext should not be inherited. Verify(children, - EvalResult("[0]", "49 1", "char", "a[0]", editableValue: "'1'", flags: DkmEvaluationResultFlags.None)); + EvalResult("[0]", "49 '1'", "char", "a[0]", editableValue: "'1'", flags: DkmEvaluationResultFlags.None)); } [Fact] @@ -110,9 +110,8 @@ class C var type = runtime.GetType("C"); var value = CreateDkmClrValue( value: type.Instantiate(), - type: type, - inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.NoQuotes)); - var evalResult = FormatResult("o", value); + type: type); + var evalResult = FormatResult("o", value, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.NoQuotes)); Verify(evalResult, EvalResult("o", "f+103 g", "C", "o", DkmEvaluationResultFlags.Expandable)); } @@ -125,20 +124,20 @@ public void RawView_NoProxy() var inspectionContext = CreateDkmInspectionContext(DkmEvaluationFlags.ShowValueRaw); // int - var value = CreateDkmClrValue(1, type: runtime.GetType(typeof(int)), inspectionContext: inspectionContext); - var evalResult = FormatResult("i", value); + var value = CreateDkmClrValue(1, type: runtime.GetType(typeof(int))); + var evalResult = FormatResult("i", value, inspectionContext: inspectionContext); 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); + value = CreateDkmClrValue(string.Empty, type: runtime.GetType(typeof(string))); + evalResult = FormatResult("s", value, inspectionContext: inspectionContext); 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); + value = CreateDkmClrValue(new object[] { 1, 2, 3 }, type: runtime.GetType(typeof(object)).MakeArrayType()); + evalResult = FormatResult("a", value, inspectionContext: inspectionContext); Verify(evalResult, EvalResult("a", "{object[3]}", "object[]", "a, raw", editableValue: null, flags: DkmEvaluationResultFlags.Expandable)); } @@ -184,9 +183,8 @@ static void Main() // Non-null value. var value = CreateDkmClrValue( value: type.Instantiate(), - type: type, - inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.ShowValueRaw)); - var evalResult = FormatResult("o", "o, raw", value); + type: type); + var evalResult = FormatResult("o", "o, raw", value, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.ShowValueRaw)); Verify(evalResult, EvalResult("o", "{C}", "C", "o, raw", DkmEvaluationResultFlags.Expandable)); var children = GetChildren(evalResult); @@ -201,9 +199,8 @@ static void Main() // Null value. value = CreateDkmClrValue( value: null, - type: type, - inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.ShowValueRaw)); - evalResult = FormatResult("o", "o, raw", value); + type: type); + evalResult = FormatResult("o", "o, raw", value, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.ShowValueRaw)); Verify(evalResult, EvalResult("o", "null", "C", "o, raw")); } @@ -216,26 +213,26 @@ public void ResultsView_FrameworkTypes() 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); + var value = CreateDkmClrValue(new object(), type: runtime.GetType(typeof(object))); + var evalResult = FormatResult("o", value, inspectionContext: inspectionContext); Verify(evalResult, - EvalFailedResult("o", "Only Enumerable types can have Results View")); + EvalFailedResult("o", "Only Enumerable types can have Results View", fullName: null)); // string: not considered enumerable which is consistent with legacy EE - value = CreateDkmClrValue("", type: runtime.GetType(typeof(string)), inspectionContext: inspectionContext); - evalResult = FormatResult("s", value); + value = CreateDkmClrValue("", type: runtime.GetType(typeof(string))); + evalResult = FormatResult("s", value, inspectionContext: inspectionContext); 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); + value = CreateDkmClrValue(new[] { 1 }, type: runtime.GetType(typeof(int[]))); + evalResult = FormatResult("i", value, inspectionContext: inspectionContext); 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); + value = CreateDkmClrValue(new System.Collections.ArrayList(new[] { 2 }), type: runtime.GetType(typeof(System.Collections.ArrayList))); + evalResult = FormatResult("a", value, inspectionContext: inspectionContext); Verify(evalResult, EvalResult("a", "Expanding the Results View will enumerate the IEnumerable", "", "a, results", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly, DkmEvaluationResultCategory.Method)); var children = GetChildren(evalResult); @@ -243,8 +240,8 @@ public void ResultsView_FrameworkTypes() EvalResult("[0]", "2", "object {int}", "new System.Linq.SystemCore_EnumerableDebugView(a).Items[0]")); // List - value = CreateDkmClrValue(new System.Collections.Generic.List(new object[] { 3 }), type: runtime.GetType(typeof(System.Collections.Generic.List)), inspectionContext: inspectionContext); - evalResult = FormatResult("l", value); + value = CreateDkmClrValue(new System.Collections.Generic.List(new object[] { 3 }), type: runtime.GetType(typeof(System.Collections.Generic.List))); + evalResult = FormatResult("l", value, inspectionContext: inspectionContext); Verify(evalResult, EvalResult("l", "Expanding the Results View will enumerate the IEnumerable", "", "l, results", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly, DkmEvaluationResultCategory.Method)); children = GetChildren(evalResult); @@ -252,8 +249,8 @@ public void ResultsView_FrameworkTypes() EvalResult("[0]", "3", "object {int}", "new System.Linq.SystemCore_EnumerableDebugView(l).Items[0]")); // int? - value = CreateDkmClrValue(1, type: runtime.GetType(typeof(System.Nullable<>)).MakeGenericType(runtime.GetType(typeof(int))), inspectionContext: inspectionContext); - evalResult = FormatResult("i", value); + value = CreateDkmClrValue(1, type: runtime.GetType(typeof(System.Nullable<>)).MakeGenericType(runtime.GetType(typeof(int)))); + evalResult = FormatResult("i", value, inspectionContext: inspectionContext); Verify(evalResult, EvalFailedResult("i", "Only Enumerable types can have Results View")); } @@ -276,9 +273,8 @@ public IEnumerator GetEnumerator() 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); + type: type); + var evalResult = FormatResult("o", "o, results, d", value, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.ResultsOnly)); Verify(evalResult, EvalResult("o", "Expanding the Results View will enumerate the IEnumerable", "", "o, results", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly, DkmEvaluationResultCategory.Method)); var children = GetChildren(evalResult); @@ -317,9 +313,8 @@ IEnumerator IEnumerable.GetEnumerator() 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); + type: type); + var evalResult = FormatResult("o", "o, results", value, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.ResultsOnly)); Verify(evalResult, EvalResult("o", "Expanding the Results View will enumerate the IEnumerable", "", "o, results", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly, DkmEvaluationResultCategory.Method)); var children = GetChildren(evalResult); @@ -408,9 +403,8 @@ public object F var type = runtime.GetType("C"); var value = CreateDkmClrValue( value: type.Instantiate(), - type: type, - inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.ResultsOnly)); - var evalResult = FormatResult("o", "o, results", value); + type: type); + var evalResult = FormatResult("o", "o, results", value, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.ResultsOnly)); Verify(evalResult, EvalResult("o", "Expanding the Results View will enumerate the IEnumerable", "", "o, results", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly, DkmEvaluationResultCategory.Method)); } @@ -445,14 +439,12 @@ internal ArrayList Q { 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); + var memberValue = value.GetMemberValue("P", (int)System.Reflection.MemberTypes.Property, "C"); + var evalResult = FormatResult("o.P", "o.P, results", memberValue, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.ResultsOnly)); 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); + memberValue = value.GetMemberValue("Q", (int)System.Reflection.MemberTypes.Property, "C"); + evalResult = FormatResult("o.Q", "o.Q, results", memberValue, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.ResultsOnly)); Verify(evalResult, EvalFailedResult("o.Q", "'o.Q' threw an exception of type 'E'")); } @@ -497,14 +489,12 @@ internal int Q { 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); + var memberValue = value.GetMemberValue("P", (int)System.Reflection.MemberTypes.Property, "C"); + var evalResult = FormatResult("o.P", "o.P, results", memberValue, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.ResultsOnly)); 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); + memberValue = value.GetMemberValue("Q", (int)System.Reflection.MemberTypes.Property, "C"); + evalResult = FormatResult("o.Q", "o.Q, results", memberValue, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.ResultsOnly)); Verify(evalResult, EvalFailedResult("o.Q", "Property 'Q' evaluation timed out")); } @@ -528,9 +518,8 @@ public IEnumerator GetEnumerator() var type = runtime.GetType("C"); var value = CreateDkmClrValue( value: type.Instantiate(), - type: type, - inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.ResultsOnly)); - var evalResult = FormatResult("o", "o, results", value); + type: type); + var evalResult = FormatResult("o", "o, results", value, inspectionContext: CreateDkmInspectionContext(DkmEvaluationFlags.ResultsOnly)); Verify(evalResult, EvalFailedResult("o", "Results View requires System.Core.dll to be referenced")); } diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ObjectIdTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ObjectIdTests.cs index f9fbed41231..89368dd4fb6 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ObjectIdTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ObjectIdTests.cs @@ -27,9 +27,9 @@ public void SpecialTypes() FormatResult("c", value, objectType), EvalResult("c", "99 'c' {$2}", "object {char}", "c", DkmEvaluationResultFlags.HasObjectId, editableValue: "'c'")); // char (hex) - value = CreateDkmClrValue(value: 'c', type: typeof(char), alias: "3", evalFlags: DkmEvaluationResultFlags.HasObjectId, inspectionContext: CreateDkmInspectionContext(radix: 16)); + value = CreateDkmClrValue(value: 'c', type: typeof(char), alias: "3", evalFlags: DkmEvaluationResultFlags.HasObjectId); Verify( - FormatResult("c", value, objectType), + FormatResult("c", value, objectType, inspectionContext: CreateDkmInspectionContext(radix: 16)), EvalResult("c", "0x0063 'c' {$3}", "object {char}", "c", DkmEvaluationResultFlags.HasObjectId, editableValue: "'c'")); // enum value = CreateDkmClrValue(value: DkmEvaluationResultFlags.HasObjectId, type: typeof(DkmEvaluationResultFlags), alias: "Four", evalFlags: DkmEvaluationResultFlags.HasObjectId); diff --git a/src/ExpressionEvaluator/Core/Source/Concord/Microsoft.VisualStudio.Debugger.Engine.il b/src/ExpressionEvaluator/Core/Source/Concord/Microsoft.VisualStudio.Debugger.Engine.il index 1f73e11b898..06eb0c1af2c 100644 --- a/src/ExpressionEvaluator/Core/Source/Concord/Microsoft.VisualStudio.Debugger.Engine.il +++ b/src/ExpressionEvaluator/Core/Source/Concord/Microsoft.VisualStudio.Debugger.Engine.il @@ -1,5 +1,5 @@ -// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.33440 +// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.34209 // Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,13 +39,13 @@ .ver 1:0:0:0 } .module Microsoft.VisualStudio.Debugger.Engine.dll -// MVID: {BB1B6E42-3DA2-43F2-B3F7-A9FF0EF43DA1} +// MVID: {6ACEF75E-71AE-4A5E-A3C0-CAD7BC16BC75} .imagebase 0x00400000 .file alignment 0x00000200 .stackreserve 0x00100000 .subsystem 0x0003 // WINDOWS_CUI .corflags 0x00000001 // ILONLY -// Image base: 0x01180000 +// Image base: 0x02880000 // =============== CLASS MEMBERS DECLARATION =================== @@ -22082,7 +22082,8 @@ } // end of method DkmInspectionContext::GetClrLocalVariableQuery .method public hidebysig instance string - GetTypeName(class Microsoft.VisualStudio.Debugger.Clr.DkmClrType ClrType) cil managed + GetTypeName(class Microsoft.VisualStudio.Debugger.Clr.DkmClrType ClrType, + class [mscorlib]System.Collections.ObjectModel.ReadOnlyCollection`1 FormatSpecifiers) cil managed { // Code size 1 (0x1) .maxstack 8 @@ -22667,23 +22668,28 @@ .class interface public abstract auto ansi Microsoft.VisualStudio.Debugger.ComponentInterfaces.IDkmClrFormatter { .method public hidebysig newslot abstract virtual - instance string GetValueString(class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue clrValue) cil managed + instance string GetValueString(class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue clrValue, + class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext inspectionContext, + class [mscorlib]System.Collections.ObjectModel.ReadOnlyCollection`1 formatSpecifiers) cil managed { } // end of method IDkmClrFormatter::GetValueString .method public hidebysig newslot abstract virtual instance string GetTypeName(class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext inspectionContext, - class Microsoft.VisualStudio.Debugger.Clr.DkmClrType clrType) cil managed + class Microsoft.VisualStudio.Debugger.Clr.DkmClrType clrType, + class [mscorlib]System.Collections.ObjectModel.ReadOnlyCollection`1 formatSpecifiers) cil managed { } // end of method IDkmClrFormatter::GetTypeName .method public hidebysig newslot abstract virtual - instance bool HasUnderlyingString(class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue clrValue) cil managed + instance bool HasUnderlyingString(class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue clrValue, + class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext inspectionContext) cil managed { } // end of method IDkmClrFormatter::HasUnderlyingString .method public hidebysig newslot abstract virtual - instance string GetUnderlyingString(class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue clrValue) cil managed + instance string GetUnderlyingString(class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue clrValue, + class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext inspectionContext) cil managed { } // end of method IDkmClrFormatter::GetUnderlyingString @@ -22696,29 +22702,29 @@ .custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = ( 01 00 24 38 31 38 36 35 37 30 63 2D 32 35 32 39 // ..$8186570c-2529 2D 65 64 62 35 2D 65 66 30 62 2D 34 65 34 38 35 // -edb5-ef0b-4e485 66 39 30 32 65 38 39 00 00 ) // f902e89.. - .method public hidebysig specialname instance class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext - get_InspectionContext() cil managed + .method public hidebysig specialname instance class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionSession + get_InspectionSession() cil managed { // Code size 1 (0x1) .maxstack 8 IL_0000: ret - } // end of method DkmClrValue::get_InspectionContext + } // end of method DkmClrValue::get_InspectionSession - .method public hidebysig specialname instance class Microsoft.VisualStudio.Debugger.Clr.DkmClrType - get_Type() cil managed + .method public hidebysig specialname instance class Microsoft.VisualStudio.Debugger.Evaluation.DkmLanguage + get_Language() cil managed { // Code size 1 (0x1) .maxstack 8 IL_0000: ret - } // end of method DkmClrValue::get_Type + } // end of method DkmClrValue::get_Language .method public hidebysig specialname instance class Microsoft.VisualStudio.Debugger.Clr.DkmClrType - get_DeclaredType() cil managed + get_Type() cil managed { // Code size 1 (0x1) .maxstack 8 IL_0000: ret - } // end of method DkmClrValue::get_DeclaredType + } // end of method DkmClrValue::get_Type .method public hidebysig specialname instance valuetype Microsoft.VisualStudio.Debugger.Evaluation.DkmEvaluationResultCategory get_Category() cil managed @@ -22832,30 +22838,6 @@ IL_0000: ret } // end of method DkmClrValue::get_UniqueId - .method public hidebysig specialname instance class Microsoft.VisualStudio.Debugger.Evaluation.DkmLanguage - get_Language() cil managed - { - // Code size 1 (0x1) - .maxstack 8 - IL_0000: ret - } // end of method DkmClrValue::get_Language - - .method public hidebysig specialname instance class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionSession - get_InspectionSession() cil managed - { - // Code size 1 (0x1) - .maxstack 8 - IL_0000: ret - } // end of method DkmClrValue::get_InspectionSession - - .method public hidebysig specialname instance class Microsoft.VisualStudio.Debugger.DkmRuntimeInstance - get_RuntimeInstance() cil managed - { - // Code size 1 (0x1) - .maxstack 8 - IL_0000: ret - } // end of method DkmClrValue::get_RuntimeInstance - .method public hidebysig instance void Close() cil managed { @@ -22865,9 +22847,9 @@ } // end of method DkmClrValue::Close .method public hidebysig static class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue - Create(class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext InspectionContext, + Create(class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionSession InspectionSession, + class Microsoft.VisualStudio.Debugger.Evaluation.DkmLanguage Language, class Microsoft.VisualStudio.Debugger.Clr.DkmClrType Type, - class Microsoft.VisualStudio.Debugger.Clr.DkmClrType DeclaredType, valuetype Microsoft.VisualStudio.Debugger.Evaluation.DkmEvaluationResultCategory Category, valuetype Microsoft.VisualStudio.Debugger.Evaluation.DkmEvaluationResultAccessType Access, valuetype Microsoft.VisualStudio.Debugger.Evaluation.DkmEvaluationResultStorageType StorageType, @@ -22889,7 +22871,8 @@ } // end of method DkmClrValue::Create .method public hidebysig instance string - GetValueString() cil managed + GetValueString(class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext InspectionContext, + class [mscorlib]System.Collections.ObjectModel.ReadOnlyCollection`1 FormatSpecifiers) cil managed { // Code size 1 (0x1) .maxstack 8 @@ -22897,7 +22880,7 @@ } // end of method DkmClrValue::GetValueString .method public hidebysig instance bool - HasUnderlyingString() cil managed + HasUnderlyingString(class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext InspectionContext) cil managed { // Code size 1 (0x1) .maxstack 8 @@ -22905,17 +22888,21 @@ } // end of method DkmClrValue::HasUnderlyingString .method public hidebysig instance string - GetUnderlyingString() cil managed + GetUnderlyingString(class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext InspectionContext) cil managed { // Code size 1 (0x1) .maxstack 8 IL_0000: ret } // end of method DkmClrValue::GetUnderlyingString - .method public hidebysig instance class Microsoft.VisualStudio.Debugger.Evaluation.DkmEvaluationResult - GetResult(class [mscorlib]System.Collections.ObjectModel.ReadOnlyCollection`1 FormatSpecifiers, + .method public hidebysig instance void + GetResult(class Microsoft.VisualStudio.Debugger.DkmWorkList WorkList, + class Microsoft.VisualStudio.Debugger.Clr.DkmClrType DeclaredType, + class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext InspectionContext, + class [mscorlib]System.Collections.ObjectModel.ReadOnlyCollection`1 FormatSpecifiers, string ResultName, - string ResultFullName) cil managed + string ResultFullName, + class Microsoft.VisualStudio.Debugger.DkmCompletionRoutine`1 CompletionRoutine) cil managed { // Code size 1 (0x1) .maxstack 8 @@ -22923,15 +22910,19 @@ } // end of method DkmClrValue::GetResult .method public hidebysig instance string - EvaluateToString() cil managed + EvaluateToString(class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext InspectionContext) cil managed { // Code size 1 (0x1) .maxstack 8 IL_0000: ret } // end of method DkmClrValue::EvaluateToString - .method public hidebysig instance string - EvaluateDebuggerDisplayString(string FormatString) cil managed + .method public hidebysig instance void + EvaluateDebuggerDisplayString(class Microsoft.VisualStudio.Debugger.DkmWorkList WorkList, + class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext InspectionContext, + class Microsoft.VisualStudio.Debugger.Clr.DkmClrType TargetType, + string FormatString, + class Microsoft.VisualStudio.Debugger.DkmCompletionRoutine`1 CompletionRoutine) cil managed { // Code size 1 (0x1) .maxstack 8 @@ -22939,7 +22930,8 @@ } // end of method DkmClrValue::EvaluateDebuggerDisplayString .method public hidebysig instance class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue - InstantiateProxyType(class Microsoft.VisualStudio.Debugger.Clr.DkmClrType Type) cil managed + InstantiateProxyType(class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext InspectionContext, + class Microsoft.VisualStudio.Debugger.Clr.DkmClrType Type) cil managed { // Code size 1 (0x1) .maxstack 8 @@ -22947,7 +22939,8 @@ } // end of method DkmClrValue::InstantiateProxyType .method public hidebysig instance class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue - InstantiateResultsViewProxy(class Microsoft.VisualStudio.Debugger.Clr.DkmClrType EnumerableType) cil managed + InstantiateResultsViewProxy(class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext InspectionContext, + class Microsoft.VisualStudio.Debugger.Clr.DkmClrType EnumerableType) cil managed { // Code size 1 (0x1) .maxstack 8 @@ -22965,7 +22958,8 @@ } // end of method DkmClrValue::GetMemberValue .method public hidebysig instance class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue - GetArrayElement(int32[] Index) cil managed + GetArrayElement(int32[] Index, + class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext InspectionContext) cil managed { // Code size 1 (0x1) .maxstack 8 @@ -22973,7 +22967,7 @@ } // end of method DkmClrValue::GetArrayElement .method public hidebysig instance class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue - Dereference() cil managed + Dereference(class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext InspectionContext) cil managed { // Code size 1 (0x1) .maxstack 8 @@ -23009,11 +23003,6 @@ { .get instance valuetype Microsoft.VisualStudio.Debugger.Evaluation.DkmEvaluationResultCategory Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue::get_Category() } // end of property DkmClrValue::Category - .property instance class Microsoft.VisualStudio.Debugger.Clr.DkmClrType - DeclaredType() - { - .get instance class Microsoft.VisualStudio.Debugger.Clr.DkmClrType Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue::get_DeclaredType() - } // end of property DkmClrValue::DeclaredType .property instance valuetype Microsoft.VisualStudio.Debugger.Evaluation.DkmEvaluationResultFlags EvalFlags() { @@ -23023,11 +23012,6 @@ { .get instance object Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue::get_HostObjectValue() } // end of property DkmClrValue::HostObjectValue - .property instance class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext - InspectionContext() - { - .get instance class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue::get_InspectionContext() - } // end of property DkmClrValue::InspectionContext .property instance class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionSession InspectionSession() { @@ -23042,11 +23026,6 @@ { .get instance class Microsoft.VisualStudio.Debugger.Evaluation.DkmLanguage Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue::get_Language() } // end of property DkmClrValue::Language - .property instance class Microsoft.VisualStudio.Debugger.DkmRuntimeInstance - RuntimeInstance() - { - .get instance class Microsoft.VisualStudio.Debugger.DkmRuntimeInstance Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue::get_RuntimeInstance() - } // end of property DkmClrValue::RuntimeInstance .property instance class Microsoft.VisualStudio.Debugger.CallStack.DkmStackWalkFrame StackFrame() { @@ -23440,11 +23419,14 @@ .class interface public abstract auto ansi Microsoft.VisualStudio.Debugger.ComponentInterfaces.IDkmClrResultProvider { .method public hidebysig newslot abstract virtual - instance class Microsoft.VisualStudio.Debugger.Evaluation.DkmEvaluationResult - GetResult(class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue clrValue, - class [mscorlib]System.Collections.ObjectModel.ReadOnlyCollection`1 formatSpecifiers, - string resultName, - string resultFullName) cil managed + instance void GetResult(class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue clrValue, + class Microsoft.VisualStudio.Debugger.DkmWorkList workList, + class Microsoft.VisualStudio.Debugger.Clr.DkmClrType declaredType, + class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext inspectionContext, + class [mscorlib]System.Collections.ObjectModel.ReadOnlyCollection`1 formatSpecifiers, + string resultName, + string resultFullName, + class Microsoft.VisualStudio.Debugger.DkmCompletionRoutine`1 completionRoutine) cil managed { } // end of method IDkmClrResultProvider::GetResult @@ -23479,6 +23461,52 @@ } // end of class Microsoft.VisualStudio.Debugger.ComponentInterfaces.IDkmClrResultProvider +.class public auto ansi sealed Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmEvaluationAsyncResult + extends [mscorlib]System.ValueType +{ + .method public hidebysig static valuetype Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmEvaluationAsyncResult + CreateErrorResult(class [mscorlib]System.Exception exception) cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method DkmEvaluationAsyncResult::CreateErrorResult + + .method public hidebysig specialname instance int32 + get_ErrorCode() cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method DkmEvaluationAsyncResult::get_ErrorCode + + .method public hidebysig specialname instance class Microsoft.VisualStudio.Debugger.Evaluation.DkmEvaluationResult + get_Result() cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method DkmEvaluationAsyncResult::get_Result + + .method public hidebysig specialname rtspecialname + instance void .ctor(class Microsoft.VisualStudio.Debugger.Evaluation.DkmEvaluationResult Result) cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method DkmEvaluationAsyncResult::.ctor + + .property instance int32 ErrorCode() + { + .get instance int32 Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmEvaluationAsyncResult::get_ErrorCode() + } // end of property DkmEvaluationAsyncResult::ErrorCode + .property instance class Microsoft.VisualStudio.Debugger.Evaluation.DkmEvaluationResult + Result() + { + .get instance class Microsoft.VisualStudio.Debugger.Evaluation.DkmEvaluationResult Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmEvaluationAsyncResult::get_Result() + } // end of property DkmEvaluationAsyncResult::Result +} // end of class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmEvaluationAsyncResult + .class public auto ansi sealed Microsoft.VisualStudio.Debugger.Evaluation.DkmGetChildrenAsyncResult extends [mscorlib]System.ValueType { @@ -24062,19 +24090,25 @@ } // end of method IDkmClrValueInspectionCallback::GetEvalAttributes .method public hidebysig newslot abstract virtual - instance string EvaluateToString(class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue clrValue) cil managed + instance string EvaluateToString(class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue clrValue, + class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext inspectionContext) cil managed { } // end of method IDkmClrValueInspectionCallback::EvaluateToString .method public hidebysig newslot abstract virtual - instance string EvaluateDebuggerDisplayString(class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue clrValue, - string formatString) cil managed + instance void EvaluateDebuggerDisplayString(class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue clrValue, + class Microsoft.VisualStudio.Debugger.DkmWorkList workList, + class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext inspectionContext, + class Microsoft.VisualStudio.Debugger.Clr.DkmClrType targetType, + string formatString, + class Microsoft.VisualStudio.Debugger.DkmCompletionRoutine`1 completionRoutine) cil managed { } // end of method IDkmClrValueInspectionCallback::EvaluateDebuggerDisplayString .method public hidebysig newslot abstract virtual instance class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue InstantiateProxyType(class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue clrValue, + class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext inspectionContext, class Microsoft.VisualStudio.Debugger.Clr.DkmClrType 'type') cil managed { } // end of method IDkmClrValueInspectionCallback::InstantiateProxyType @@ -24082,6 +24116,7 @@ .method public hidebysig newslot abstract virtual instance class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue InstantiateResultsViewProxy(class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue clrValue, + class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext inspectionContext, class Microsoft.VisualStudio.Debugger.Clr.DkmClrType enumerableType) cil managed { } // end of method IDkmClrValueInspectionCallback::InstantiateResultsViewProxy @@ -24098,18 +24133,65 @@ .method public hidebysig newslot abstract virtual instance class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue GetArrayElement(class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue clrValue, - int32[] index) cil managed + int32[] index, + class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext inspectionContext) cil managed { } // end of method IDkmClrValueInspectionCallback::GetArrayElement .method public hidebysig newslot abstract virtual instance class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue - Dereference(class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue clrValue) cil managed + Dereference(class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue clrValue, + class Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext inspectionContext) cil managed { } // end of method IDkmClrValueInspectionCallback::Dereference } // end of class Microsoft.VisualStudio.Debugger.ComponentInterfaces.IDkmClrValueInspectionCallback +.class public auto ansi sealed Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmEvaluateDebuggerDisplayStringAsyncResult + extends [mscorlib]System.ValueType +{ + .method public hidebysig static valuetype Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmEvaluateDebuggerDisplayStringAsyncResult + CreateErrorResult(class [mscorlib]System.Exception exception) cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method DkmEvaluateDebuggerDisplayStringAsyncResult::CreateErrorResult + + .method public hidebysig specialname instance int32 + get_ErrorCode() cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method DkmEvaluateDebuggerDisplayStringAsyncResult::get_ErrorCode + + .method public hidebysig specialname instance string + get_Result() cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method DkmEvaluateDebuggerDisplayStringAsyncResult::get_Result + + .method public hidebysig specialname rtspecialname + instance void .ctor(string Result) cil managed + { + // Code size 1 (0x1) + .maxstack 8 + IL_0000: ret + } // end of method DkmEvaluateDebuggerDisplayStringAsyncResult::.ctor + + .property instance int32 ErrorCode() + { + .get instance int32 Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmEvaluateDebuggerDisplayStringAsyncResult::get_ErrorCode() + } // end of property DkmEvaluateDebuggerDisplayStringAsyncResult::ErrorCode + .property instance string Result() + { + .get instance string Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmEvaluateDebuggerDisplayStringAsyncResult::get_Result() + } // end of property DkmEvaluateDebuggerDisplayStringAsyncResult::Result +} // end of class Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmEvaluateDebuggerDisplayStringAsyncResult + .class interface public abstract auto ansi Microsoft.VisualStudio.Debugger.ComponentInterfaces.IDkmCompiledInspectionQueryProcessor { .method public hidebysig newslot abstract virtual diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/AggregateExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/AggregateExpansion.cs index cb294f12f3a..261a826dd8f 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/AggregateExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/AggregateExpansion.cs @@ -29,7 +29,7 @@ internal AggregateExpansion(Expansion[] expansions) internal override void GetRows( ResultProvider resultProvider, - ArrayBuilder rows, + ArrayBuilder rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ArrayExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ArrayExpansion.cs index 145a0434811..899e677ec1a 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ArrayExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ArrayExpansion.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using Microsoft.VisualStudio.Debugger; using Microsoft.VisualStudio.Debugger.Evaluation; using Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation; -using System; using System.Collections.ObjectModel; using System.Diagnostics; @@ -39,7 +39,7 @@ private ArrayExpansion(ReadOnlyCollection sizes, ReadOnlyCollection lo internal override void GetRows( ResultProvider resultProvider, - ArrayBuilder rows, + ArrayBuilder rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, @@ -61,7 +61,7 @@ private ArrayExpansion(ReadOnlyCollection sizes, ReadOnlyCollection lo index += _count; } - private DkmEvaluationResult GetRow( + private EvalResultDataItem GetRow( ResultProvider resultProvider, DkmInspectionContext inspectionContext, DkmClrValue value, @@ -72,9 +72,9 @@ private ArrayExpansion(ReadOnlyCollection sizes, ReadOnlyCollection lo var formatter = resultProvider.Formatter; var name = formatter.GetArrayIndexExpression(indices); var elementType = value.Type.ElementType; - var element = value.GetArrayElement(indices); + var element = value.GetArrayElement(indices, inspectionContext); var fullName = GetFullName(parent, name, formatter); - var dataItem = resultProvider.CreateDataItem( + return resultProvider.CreateDataItem( inspectionContext, name, typeDeclaringMember: null, @@ -88,7 +88,6 @@ private ArrayExpansion(ReadOnlyCollection sizes, ReadOnlyCollection lo category: DkmEvaluationResultCategory.Other, flags: element.EvalFlags, evalFlags: inspectionContext.EvaluationFlags); - return resultProvider.GetResult(dataItem, element.Type, elementType, parent); } private int[] GetIndices(int index) diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/DebuggerTypeProxyExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/DebuggerTypeProxyExpansion.cs index 88a145ffd30..9ed63aa574c 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/DebuggerTypeProxyExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/DebuggerTypeProxyExpansion.cs @@ -52,7 +52,7 @@ internal sealed class DebuggerTypeProxyExpansion : Expansion DkmClrValue proxyValue; try { - proxyValue = value.InstantiateProxyType(proxyType); + proxyValue = value.InstantiateProxyType(inspectionContext, proxyType); } catch { @@ -62,6 +62,7 @@ internal sealed class DebuggerTypeProxyExpansion : Expansion if (proxyValue != null) { return new DebuggerTypeProxyExpansion( + inspectionContext, proxyValue, name, typeDeclaringMemberOpt, @@ -94,6 +95,7 @@ internal sealed class DebuggerTypeProxyExpansion : Expansion private readonly string editableValue; private DebuggerTypeProxyExpansion( + DkmInspectionContext inspectionContext, DkmClrValue proxyValue, string name, Type typeDeclaringMemberOpt, @@ -110,6 +112,7 @@ internal sealed class DebuggerTypeProxyExpansion : Expansion Debug.Assert(proxyValue != null); var proxyType = proxyValue.Type.GetLmrType(); var proxyMembers = MemberExpansion.CreateExpansion( + inspectionContext, proxyType, proxyValue, ExpansionFlags.IncludeBaseMembers, @@ -121,10 +124,13 @@ internal sealed class DebuggerTypeProxyExpansion : Expansion null : formatter.GetObjectCreationExpression(formatter.GetTypeName(proxyType, escapeKeywordIdentifiers: true), childFullNamePrefix); this.proxyItem = new EvalResultDataItem( - name: null, + ExpansionKind.Default, + name: string.Empty, typeDeclaringMember: null, declaredType: proxyType, + parent: null, value: proxyValue, + displayValue: null, expansion: proxyMembers, childShouldParenthesize: false, fullName: null, @@ -132,7 +138,8 @@ internal sealed class DebuggerTypeProxyExpansion : Expansion formatSpecifiers: Formatter.NoFormatSpecifiers, category: default(DkmEvaluationResultCategory), flags: default(DkmEvaluationResultFlags), - editableValue: null); + editableValue: null, + inspectionContext: inspectionContext); } this.name = name; @@ -149,7 +156,7 @@ internal sealed class DebuggerTypeProxyExpansion : Expansion internal override void GetRows( ResultProvider resultProvider, - ArrayBuilder rows, + ArrayBuilder rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, @@ -171,29 +178,27 @@ internal sealed class DebuggerTypeProxyExpansion : Expansion index++; } - private DkmEvaluationResult CreateRawViewRow( + private EvalResultDataItem CreateRawViewRow( ResultProvider resultProvider, DkmInspectionContext inspectionContext) { - var dataItem = new EvalResultDataItem( + return new EvalResultDataItem( + ExpansionKind.RawView, this.name, this.typeDeclaringMemberOpt, _declaredType, - this.value, - CreateRawView(resultProvider, inspectionContext, _declaredType, this.value), - this.childShouldParenthesize, - this.fullName, - this.childFullNamePrefix, - Formatter.AddFormatSpecifier(this.formatSpecifiers, "raw"), - DkmEvaluationResultCategory.Data, - this.flags | DkmEvaluationResultFlags.ReadOnly, - this.editableValue); - return ResultProvider.CreateEvaluationResult( - value, - Resources.RawView, - typeName: "", - display: null, - dataItem: dataItem); + parent: null, + value: this.value, + displayValue: null, + expansion: CreateRawView(resultProvider, inspectionContext, _declaredType, this.value), + childShouldParenthesize: this.childShouldParenthesize, + fullName: this.fullName, + childFullNamePrefixOpt: this.childFullNamePrefix, + formatSpecifiers: Formatter.AddFormatSpecifier(this.formatSpecifiers, "raw"), + category: DkmEvaluationResultCategory.Data, + flags: this.flags | DkmEvaluationResultFlags.ReadOnly, + editableValue: this.editableValue, + inspectionContext: inspectionContext); } private static Expansion CreateRawView( diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/Expansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/Expansion.cs index f6fb5444f77..49301c36f3c 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/Expansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/Expansion.cs @@ -29,7 +29,7 @@ internal abstract class Expansion /// internal abstract void GetRows( ResultProvider resultProvider, - ArrayBuilder rows, + ArrayBuilder rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/MemberExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/MemberExpansion.cs index a1118468238..489a51d4b3a 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/MemberExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/MemberExpansion.cs @@ -3,7 +3,6 @@ using System; using System.Collections.ObjectModel; using System.Diagnostics; -using Microsoft.VisualStudio.Debugger.Clr; using Microsoft.VisualStudio.Debugger.Evaluation; using Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation; using Microsoft.VisualStudio.Debugger.Metadata; @@ -21,6 +20,7 @@ namespace Microsoft.CodeAnalysis.ExpressionEvaluator internal sealed class MemberExpansion : Expansion { internal static Expansion CreateExpansion( + DkmInspectionContext inspectionContext, Type declaredType, DkmClrValue value, ExpansionFlags flags, @@ -46,7 +46,7 @@ internal sealed class MemberExpansion : Expansion // Expand members. (Ideally, this should be done lazily.) var allMembers = ArrayBuilder.GetInstance(); var includeInherited = (flags & ExpansionFlags.IncludeBaseMembers) == ExpansionFlags.IncludeBaseMembers; - var hideNonPublic = (value.InspectionContext.EvaluationFlags & DkmEvaluationFlags.HideNonPublicMembers) == DkmEvaluationFlags.HideNonPublicMembers; + var hideNonPublic = (inspectionContext.EvaluationFlags & DkmEvaluationFlags.HideNonPublicMembers) == DkmEvaluationFlags.HideNonPublicMembers; runtimeType.AppendTypeMembers(allMembers, predicate, declaredType, appDomain, includeInherited, hideNonPublic); foreach (var member in allMembers) @@ -116,7 +116,7 @@ internal sealed class MemberExpansion : Expansion // Include Results View if necessary. if ((flags & ExpansionFlags.IncludeResultsView) != 0) { - var resultsViewExpansion = ResultsViewExpansion.CreateExpansion(value, formatter); + var resultsViewExpansion = ResultsViewExpansion.CreateExpansion(inspectionContext, value, formatter); if (resultsViewExpansion != null) { expansions.Add(resultsViewExpansion); @@ -195,7 +195,7 @@ private MemberExpansion(MemberAndDeclarationInfo[] members) internal override void GetRows( ResultProvider resultProvider, - ArrayBuilder rows, + ArrayBuilder rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, @@ -217,7 +217,7 @@ private MemberExpansion(MemberAndDeclarationInfo[] members) index += _members.Length; } - private static DkmEvaluationResult GetMemberRow( + private static EvalResultDataItem GetMemberRow( ResultProvider resultProvider, DkmInspectionContext inspectionContext, DkmClrValue value, @@ -225,18 +225,13 @@ private MemberExpansion(MemberAndDeclarationInfo[] members) EvalResultDataItem parent) { var memberValue = GetMemberValue(value, member); - var dataItem = CreateMemberDataItem( + return CreateMemberDataItem( resultProvider, inspectionContext, member, memberValue, parent, ExpansionFlags.All); - return resultProvider.GetResult( - dataItem, - memberValue.Type, - DkmClrType.Create(memberValue.Type.AppDomain, member.Type), - parent); } private static DkmClrValue GetMemberValue(DkmClrValue container, MemberAndDeclarationInfo member) @@ -257,7 +252,7 @@ internal RootHiddenExpansion(MemberAndDeclarationInfo member) internal override void GetRows( ResultProvider resultProvider, - ArrayBuilder rows, + ArrayBuilder rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, @@ -271,15 +266,7 @@ internal RootHiddenExpansion(MemberAndDeclarationInfo member) { if (InRange(startIndex, count, index)) { - var row = DkmFailedEvaluationResult.Create( - InspectionContext: value.InspectionContext, - StackFrame: value.StackFrame, - Name: Resources.ErrorName, - FullName: null, - ErrorMessage: (string)memberValue.HostObjectValue, - Flags: DkmEvaluationResultFlags.None, - Type: null, - DataItem: null); + var row = new EvalResultDataItem(Resources.ErrorName, errorMessage: (string)memberValue.HostObjectValue); rows.Add(row); } index++; @@ -319,7 +306,7 @@ internal NonPublicMembersExpansion(Type declaredType, Expansion members) internal override void GetRows( ResultProvider resultProvider, - ArrayBuilder rows, + ArrayBuilder rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, @@ -332,6 +319,7 @@ internal NonPublicMembersExpansion(Type declaredType, Expansion members) { rows.Add(GetRow( resultProvider, + inspectionContext, this.declaredType, value, this.members, @@ -343,18 +331,22 @@ internal NonPublicMembersExpansion(Type declaredType, Expansion members) private static readonly ReadOnlyCollection HiddenFormatSpecifiers = new ReadOnlyCollection(new[] { "hidden" }); - private static DkmEvaluationResult GetRow( + private static EvalResultDataItem GetRow( ResultProvider resultProvider, + DkmInspectionContext inspectionContext, Type declaredType, DkmClrValue value, Expansion expansion, EvalResultDataItem parent) { - var dataItem = new EvalResultDataItem( - name: null, + return new EvalResultDataItem( + ExpansionKind.NonPublicMembers, + name: Resources.NonPublicMembers, typeDeclaringMember: null, declaredType: declaredType, + parent: null, value: value, + displayValue: null, expansion: expansion, childShouldParenthesize: parent.ChildShouldParenthesize, fullName: parent.FullNameWithoutFormatSpecifiers, @@ -362,13 +354,8 @@ internal NonPublicMembersExpansion(Type declaredType, Expansion members) formatSpecifiers: HiddenFormatSpecifiers, category: DkmEvaluationResultCategory.Data, flags: DkmEvaluationResultFlags.ReadOnly, - editableValue: null); - return ResultProvider.CreateEvaluationResult( - value, - Resources.NonPublicMembers, - typeName: "", - display: null, - dataItem: dataItem); + editableValue: null, + inspectionContext: inspectionContext); } } @@ -388,7 +375,7 @@ internal StaticMembersExpansion(Type declaredType, Expansion members) internal override void GetRows( ResultProvider resultProvider, - ArrayBuilder rows, + ArrayBuilder rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, @@ -401,6 +388,7 @@ internal StaticMembersExpansion(Type declaredType, Expansion members) { rows.Add(GetRow( resultProvider, + inspectionContext, this.declaredType, value, this.members)); @@ -409,19 +397,23 @@ internal StaticMembersExpansion(Type declaredType, Expansion members) index++; } - private static DkmEvaluationResult GetRow( + private static EvalResultDataItem GetRow( ResultProvider resultProvider, + DkmInspectionContext inspectionContext, Type declaredType, DkmClrValue value, Expansion expansion) { var formatter = resultProvider.Formatter; var fullName = formatter.GetTypeName(declaredType, escapeKeywordIdentifiers: true); - var dataItem = new EvalResultDataItem( - name: null, + return new EvalResultDataItem( + ExpansionKind.StaticMembers, + name: formatter.StaticMembersString, typeDeclaringMember: null, declaredType: declaredType, + parent: null, value: value, + displayValue: null, expansion: expansion, childShouldParenthesize: false, fullName: fullName, @@ -429,13 +421,8 @@ internal StaticMembersExpansion(Type declaredType, Expansion members) formatSpecifiers: Formatter.NoFormatSpecifiers, category: DkmEvaluationResultCategory.Class, flags: DkmEvaluationResultFlags.ReadOnly, - editableValue: null); - return ResultProvider.CreateEvaluationResult( - value, - formatter.StaticMembersString, - typeName: "", - display: null, - dataItem: dataItem); + editableValue: null, + inspectionContext: inspectionContext); } } @@ -451,11 +438,6 @@ internal StaticMembersExpansion(Type declaredType, Expansion members) string memberName; var typeDeclaringMember = member.GetExplicitlyImplementedInterface(out memberName) ?? member.DeclaringType; memberName = formatter.GetIdentifierEscapingPotentialKeywords(memberName); - // If the value is actually an exception that was thrown, we can't expect it to - // have any relation to the declared type of the value. Therefore, we will - // pretend that the exception type was the declared type for the purposes - // of creating the full name and expansion. - var declaredType = memberValue.EvalFlags.Includes(DkmEvaluationResultFlags.ExceptionThrown) ? memberValue.Type.GetLmrType() : member.Type; var fullName = MakeFullName( formatter, memberName, @@ -467,7 +449,7 @@ internal StaticMembersExpansion(Type declaredType, Expansion members) inspectionContext, memberName, typeDeclaringMember: (member.IncludeTypeInMemberName || typeDeclaringMember.IsInterface) ? typeDeclaringMember : null, - declaredType: declaredType, + declaredType: member.Type, value: memberValue, parent: parent, expansionFlags: flags, diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/PointerDereferenceExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/PointerDereferenceExpansion.cs index 0b7162b1925..d0937690ac3 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/PointerDereferenceExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/PointerDereferenceExpansion.cs @@ -20,7 +20,7 @@ public PointerDereferenceExpansion(Type elementType) internal override void GetRows( ResultProvider resultProvider, - ArrayBuilder rows, + ArrayBuilder rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, @@ -37,37 +37,33 @@ public PointerDereferenceExpansion(Type elementType) index++; } - private static DkmEvaluationResult GetRow( + private static EvalResultDataItem GetRow( ResultProvider resultProvider, DkmInspectionContext inspectionContext, DkmClrValue pointer, Type elementType, EvalResultDataItem parent) { - var value = pointer.Dereference(); - var valueType = value.Type.GetLmrType(); + var value = pointer.Dereference(inspectionContext); var wasExceptionThrown = value.EvalFlags.Includes(DkmEvaluationResultFlags.ExceptionThrown); - string debuggerDisplayName; - string debuggerDisplayValue; - string debuggerDisplayType; - value.GetDebuggerDisplayStrings(out debuggerDisplayName, out debuggerDisplayValue, out debuggerDisplayType); - var declaredType = elementType; - var typeName = debuggerDisplayType ?? pointer.InspectionContext.GetTypeName(DkmClrType.Create(pointer.Type.AppDomain, declaredType)); - var expansion = wasExceptionThrown - ? null - : resultProvider.GetTypeExpansion(inspectionContext, declaredType, value, ExpansionFlags.None); + var expansion = wasExceptionThrown ? + null : + resultProvider.GetTypeExpansion(inspectionContext, declaredType, value, ExpansionFlags.None); var fullName = string.Format("*{0}", parent.ChildFullNamePrefix); - var editableValue = resultProvider.Formatter.GetEditableValue(value); + var editableValue = resultProvider.Formatter.GetEditableValue(value, inspectionContext); // NB: Full name is based on the real (i.e. not DebuggerDisplay) name. This is a change from dev12, // which used the DebuggerDisplay name, causing surprising results in "Add Watch" scenarios. - var dataItem = new EvalResultDataItem( - name: null, // Okay for pointer dereferences. + return new EvalResultDataItem( + ExpansionKind.PointerDereference, + name: fullName, typeDeclaringMember: null, declaredType: declaredType, + parent: null, value: value, + displayValue: wasExceptionThrown ? string.Format(Resources.InvalidPointerDereference, fullName) : null, expansion: expansion, childShouldParenthesize: true, fullName: fullName, @@ -75,18 +71,8 @@ public PointerDereferenceExpansion(Type elementType) formatSpecifiers: Formatter.NoFormatSpecifiers, category: DkmEvaluationResultCategory.Other, flags: DkmEvaluationResultFlags.None, - editableValue: editableValue); - - var name = debuggerDisplayName ?? fullName; - var display = debuggerDisplayValue ?? - (wasExceptionThrown ? string.Format(Resources.InvalidPointerDereference, fullName) : value.GetValueString()); - - return ResultProvider.CreateEvaluationResult( - value, - name, - typeName, - display, - dataItem); + editableValue: editableValue, + inspectionContext: inspectionContext); } } } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ResultsViewExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ResultsViewExpansion.cs index 21302ea760f..1b933975477 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ResultsViewExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/ResultsViewExpansion.cs @@ -10,17 +10,18 @@ namespace Microsoft.CodeAnalysis.ExpressionEvaluator { internal sealed class ResultsViewExpansion : Expansion { - internal static ResultsViewExpansion CreateExpansion(DkmClrValue value, Formatter formatter) + internal static ResultsViewExpansion CreateExpansion(DkmInspectionContext inspectionContext, DkmClrValue value, Formatter formatter) { var enumerableType = GetEnumerableType(value); if (enumerableType == null) { return null; } - return CreateExpansion(value, enumerableType, formatter); + return CreateExpansion(inspectionContext, value, enumerableType, formatter); } - internal static DkmEvaluationResult CreateResultsOnly( + internal static EvalResultDataItem CreateResultsOnlyRow( + DkmInspectionContext inspectionContext, string name, DkmClrType declaredType, DkmClrValue value, @@ -41,10 +42,10 @@ internal static ResultsViewExpansion CreateExpansion(DkmClrValue value, Formatte var enumerableType = GetEnumerableType(value); if (enumerableType != null) { - var expansion = CreateExpansion(value, enumerableType, formatter); + var expansion = CreateExpansion(inspectionContext, value, enumerableType, formatter); if (expansion != null) { - return expansion.CreateEvaluationResult(name, parent, formatter); + return expansion.CreateResultsViewRow(inspectionContext, name, parent, formatter); } errorMessage = Resources.ResultsViewNoSystemCore; } @@ -55,15 +56,7 @@ internal static ResultsViewExpansion CreateExpansion(DkmClrValue value, Formatte } Debug.Assert(errorMessage != null); - return DkmFailedEvaluationResult.Create( - InspectionContext: value.InspectionContext, - StackFrame: value.StackFrame, - Name: name, - FullName: null, - ErrorMessage: errorMessage, - Flags: DkmEvaluationResultFlags.None, - Type: null, - DataItem: null); + return new EvalResultDataItem(name, errorMessage); } private static DkmClrType GetEnumerableType(DkmClrValue value) @@ -92,9 +85,9 @@ private static DkmClrType GetEnumerableType(DkmClrValue value) return DkmClrType.Create(value.Type.AppDomain, enumerableType); } - private static ResultsViewExpansion CreateExpansion(DkmClrValue value, DkmClrType enumerableType, Formatter formatter) + private static ResultsViewExpansion CreateExpansion(DkmInspectionContext inspectionContext, DkmClrValue value, DkmClrType enumerableType, Formatter formatter) { - var proxyValue = value.InstantiateResultsViewProxy(enumerableType); + var proxyValue = value.InstantiateResultsViewProxy(inspectionContext, enumerableType); // InstantiateResultsViewProxy may return null // (if assembly is missing for instance). if (proxyValue == null) @@ -103,6 +96,7 @@ private static ResultsViewExpansion CreateExpansion(DkmClrValue value, DkmClrTyp } var proxyMembers = MemberExpansion.CreateExpansion( + inspectionContext, proxyValue.Type.GetLmrType(), proxyValue, ExpansionFlags.None, @@ -125,7 +119,7 @@ private ResultsViewExpansion(DkmClrValue proxyValue, Expansion proxyMembers) internal override void GetRows( ResultProvider resultProvider, - ArrayBuilder rows, + ArrayBuilder rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, @@ -136,14 +130,13 @@ private ResultsViewExpansion(DkmClrValue proxyValue, Expansion proxyMembers) { if (InRange(startIndex, count, index)) { - var evalResult = CreateEvaluationResult(Resources.ResultsView, parent, resultProvider.Formatter); - rows.Add(evalResult); + rows.Add(CreateResultsViewRow(inspectionContext, Resources.ResultsView, parent, resultProvider.Formatter)); } index++; } - private DkmEvaluationResult CreateEvaluationResult(string name, EvalResultDataItem parent, Formatter formatter) + private EvalResultDataItem CreateResultsViewRow(DkmInspectionContext inspectionContext, string name, EvalResultDataItem parent, Formatter formatter) { var proxyType = _proxyValue.Type.GetLmrType(); string fullName; @@ -165,11 +158,14 @@ private DkmEvaluationResult CreateEvaluationResult(string name, EvalResultDataIt var childFullNamePrefix = (fullName == null) ? null : formatter.GetObjectCreationExpression(formatter.GetTypeName(proxyType, escapeKeywordIdentifiers: true), fullName); - var dataItem = new EvalResultDataItem( - name: name, + return new EvalResultDataItem( + ExpansionKind.ResultsView, + name, typeDeclaringMember: null, declaredType: proxyType, + parent: null, value: _proxyValue, + displayValue: Resources.ResultsViewValueWarning, expansion: _proxyMembers, childShouldParenthesize: childShouldParenthesize, fullName: fullName, @@ -177,13 +173,8 @@ private DkmEvaluationResult CreateEvaluationResult(string name, EvalResultDataIt formatSpecifiers: Formatter.AddFormatSpecifier(formatSpecifiers, "results"), category: DkmEvaluationResultCategory.Method, flags: DkmEvaluationResultFlags.ReadOnly, - editableValue: null); - return ResultProvider.CreateEvaluationResult( - value: _proxyValue, - name: name, - typeName: string.Empty, - display: Resources.ResultsViewValueWarning, - dataItem: dataItem); + editableValue: null, + inspectionContext: inspectionContext); } } } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/TypeVariablesExpansion.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/TypeVariablesExpansion.cs index b61e996f386..6225f7ba909 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/TypeVariablesExpansion.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Expansion/TypeVariablesExpansion.cs @@ -30,7 +30,7 @@ internal TypeVariablesExpansion(Type declaredType) internal override void GetRows( ResultProvider resultProvider, - ArrayBuilder rows, + ArrayBuilder rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, @@ -46,51 +46,34 @@ internal TypeVariablesExpansion(Type declaredType) int offset = startIndex2 - index; for (int i = 0; i < count2; i++) { - rows.Add(GetRow(resultProvider, value, i + offset, parent)); + rows.Add(GetRow(resultProvider, inspectionContext, value, i + offset, parent)); } index += _typeArguments.Length; } - private DkmEvaluationResult GetRow(ResultProvider resultProvider, DkmClrValue value, int index, EvalResultDataItem parent) + private EvalResultDataItem GetRow(ResultProvider resultProvider, DkmInspectionContext inspectionContext, DkmClrValue value, int index, EvalResultDataItem parent) { - var inspectionContext = value.InspectionContext; - var appDomain = value.Type.AppDomain; var typeParameter = _typeParameters[index]; var typeArgument = _typeArguments[index]; - var type = DkmClrType.Create(appDomain, typeArgument); - var name = typeParameter.Name; - var dataItem = new EvalResultDataItem( - name, + var formatSpecifiers = Formatter.NoFormatSpecifiers; + return new EvalResultDataItem( + ExpansionKind.TypeVariables, + typeParameter.Name, typeDeclaringMember: null, declaredType: typeArgument, - value: null, + parent: parent, + value: value, + displayValue: inspectionContext.GetTypeName(DkmClrType.Create(value.Type.AppDomain, typeArgument), formatSpecifiers), expansion: null, childShouldParenthesize: false, fullName: null, childFullNamePrefixOpt: null, - formatSpecifiers: Formatter.NoFormatSpecifiers, + formatSpecifiers: formatSpecifiers, category: DkmEvaluationResultCategory.Data, flags: DkmEvaluationResultFlags.ReadOnly, - editableValue: null); - var typeName = inspectionContext.GetTypeName(DkmClrType.Create(appDomain, typeArgument)); - return DkmSuccessEvaluationResult.Create( - inspectionContext, - value.StackFrame, - name, - dataItem.FullName, - dataItem.Flags, - Value: typeName, - EditableValue: null, - Type: typeName, - Category: dataItem.Category, - Access: value.Access, - StorageType: value.StorageType, - TypeModifierFlags: value.TypeModifierFlags, - Address: value.Address, - CustomUIVisualizers: null, - ExternalModules: null, - DataItem: dataItem); + editableValue: null, + inspectionContext: inspectionContext); } } } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.Values.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.Values.cs index 02b8e0a3a1a..040b7d3ff7a 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.Values.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.Values.cs @@ -22,14 +22,14 @@ internal enum GetValueFlags // This class provides implementation for the "displaying values as strings" aspect of the default (C#) Formatter component. internal abstract partial class Formatter { - internal string GetValueString(DkmClrValue value, ObjectDisplayOptions options, GetValueFlags flags) + internal string GetValueString(DkmClrValue value, DkmInspectionContext inspectionContext, ObjectDisplayOptions options, GetValueFlags flags) { if (value.IsError()) { return (string)value.HostObjectValue; } - if (UsesHexadecimalNumbers(value)) + if (UsesHexadecimalNumbers(inspectionContext)) { options |= ObjectDisplayOptions.UseHexadecimalNumbers; } @@ -96,24 +96,24 @@ internal string GetValueString(DkmClrValue value, ObjectDisplayOptions options, // It should be impossible to nest nullables, so this recursion should introduce only a single extra stack frame. return nullableValue == null ? _nullString - : GetValueString(nullableValue, ObjectDisplayOptions.None, GetValueFlags.IncludeTypeName); + : GetValueString(nullableValue, inspectionContext, ObjectDisplayOptions.None, GetValueFlags.IncludeTypeName); } // "value.EvaluateToString()" will check "Call string-conversion function on objects in variables windows" // (Tools > Options setting) and call "value.ToString()" if appropriate. return IncludeObjectId( value, - string.Format(_defaultFormat, value.EvaluateToString() ?? value.InspectionContext.GetTypeName(value.Type)), + string.Format(_defaultFormat, value.EvaluateToString(inspectionContext) ?? inspectionContext.GetTypeName(value.Type, Formatter.NoFormatSpecifiers)), flags); } /// /// Gets the string representation of a character literal without including the numeric code point. /// - internal string GetValueStringForCharacter(DkmClrValue value, ObjectDisplayOptions options) + internal string GetValueStringForCharacter(DkmClrValue value, DkmInspectionContext inspectionContext, ObjectDisplayOptions options) { Debug.Assert(value.Type.GetLmrType().IsCharacter()); - if (UsesHexadecimalNumbers(value)) + if (UsesHexadecimalNumbers(inspectionContext)) { options |= ObjectDisplayOptions.UseHexadecimalNumbers; } @@ -122,12 +122,12 @@ internal string GetValueStringForCharacter(DkmClrValue value, ObjectDisplayOptio return charTemp; } - internal bool HasUnderlyingString(DkmClrValue value) + internal bool HasUnderlyingString(DkmClrValue value, DkmInspectionContext inspectionContext) { - return GetUnderlyingString(value) != null; + return GetUnderlyingString(value, inspectionContext) != null; } - internal string GetUnderlyingString(DkmClrValue value) + internal string GetUnderlyingString(DkmClrValue value, DkmInspectionContext inspectionContext) { RawStringDataItem dataItem = value.GetDataItem(); if (dataItem != null) @@ -135,13 +135,13 @@ internal string GetUnderlyingString(DkmClrValue value) return dataItem.RawString; } - string underlyingString = GetUnderlyingStringImpl(value); + string underlyingString = GetUnderlyingStringImpl(value, inspectionContext); dataItem = new RawStringDataItem(underlyingString); value.SetDataItem(DkmDataCreationDisposition.CreateNew, dataItem); return underlyingString; } - private string GetUnderlyingStringImpl(DkmClrValue value) + private string GetUnderlyingStringImpl(DkmClrValue value, DkmInspectionContext inspectionContext) { if (value.IsNull) { @@ -157,7 +157,7 @@ private string GetUnderlyingStringImpl(DkmClrValue value) if (lmrType.IsNullable()) { var nullableValue = value.GetNullableValue(); - return nullableValue != null ? GetUnderlyingStringImpl(nullableValue) : null; + return nullableValue != null ? GetUnderlyingStringImpl(nullableValue, inspectionContext) : null; } if (lmrType.IsString()) @@ -177,7 +177,7 @@ private string GetUnderlyingStringImpl(DkmClrValue value) { if (string.Equals(lmrType.FullName, "System.Xml.Linq.XNode", StringComparison.Ordinal)) { - return value.EvaluateToString(); + return value.EvaluateToString(inspectionContext); } lmrType = lmrType.BaseType; @@ -283,11 +283,11 @@ private static bool IsFlagsEnum(Type lmrType) return false; } - private static bool UsesHexadecimalNumbers(DkmClrValue value) + private static bool UsesHexadecimalNumbers(DkmInspectionContext inspectionContext) { - Debug.Assert(value.InspectionContext != null); + Debug.Assert(inspectionContext != null); - return value.InspectionContext.Radix == 16; + return inspectionContext.Radix == 16; } /// @@ -323,7 +323,7 @@ protected static ulong ConvertEnumUnderlyingTypeToUInt64(object value, TypeCode } } - internal string GetEditableValue(DkmClrValue value) + internal string GetEditableValue(DkmClrValue value, DkmInspectionContext inspectionContext) { if (value.IsError()) { @@ -339,11 +339,11 @@ internal string GetEditableValue(DkmClrValue value) if (type.IsEnum) { - return this.GetValueString(value, ObjectDisplayOptions.None, GetValueFlags.IncludeTypeName); + return this.GetValueString(value, inspectionContext, ObjectDisplayOptions.None, GetValueFlags.IncludeTypeName); } else if (type.IsDecimal()) { - return this.GetValueString(value, ObjectDisplayOptions.IncludeTypeSuffix, GetValueFlags.None); + return this.GetValueString(value, inspectionContext, ObjectDisplayOptions.IncludeTypeSuffix, GetValueFlags.None); } // The legacy EE didn't special-case strings or chars (when ",nq" was used, // you had to manually add quotes when editing) but it makes sense to @@ -352,12 +352,12 @@ internal string GetEditableValue(DkmClrValue value) { if (!value.IsNull) { - return this.GetValueString(value, ObjectDisplayOptions.UseQuotes, GetValueFlags.None); + return this.GetValueString(value, inspectionContext, ObjectDisplayOptions.UseQuotes, GetValueFlags.None); } } else if (type.IsCharacter()) { - return this.GetValueStringForCharacter(value, ObjectDisplayOptions.UseQuotes); + return this.GetValueStringForCharacter(value, inspectionContext, ObjectDisplayOptions.UseQuotes); } return null; diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs index fea8a1b2098..06a5d74e62f 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.cs @@ -28,30 +28,27 @@ internal Formatter(string defaultFormat, string nullString, string staticMembers this.StaticMembersString = staticMembersString; } - string IDkmClrFormatter.GetValueString(DkmClrValue clrValue) + string IDkmClrFormatter.GetValueString(DkmClrValue value, DkmInspectionContext inspectionContext, ReadOnlyCollection formatSpecifiers) { - // TODO: IDkmClrFormatter.GetValueString should have - // an explicit InspectionContext parameter that is not - // inherited from the containing DkmClrValue. #1099978 - var options = ((clrValue.InspectionContext.EvaluationFlags & DkmEvaluationFlags.NoQuotes) == 0) ? + var options = ((inspectionContext.EvaluationFlags & DkmEvaluationFlags.NoQuotes) == 0) ? ObjectDisplayOptions.UseQuotes : ObjectDisplayOptions.None; - return GetValueString(clrValue, options, GetValueFlags.IncludeObjectId); + return GetValueString(value, inspectionContext, options, GetValueFlags.IncludeObjectId); } - string IDkmClrFormatter.GetTypeName(DkmInspectionContext inspectionContext, DkmClrType clrType) + string IDkmClrFormatter.GetTypeName(DkmInspectionContext inspectionContext, DkmClrType type, ReadOnlyCollection formatSpecifiers) { - return GetTypeName(clrType.GetLmrType()); + return GetTypeName(type.GetLmrType()); } - bool IDkmClrFormatter.HasUnderlyingString(DkmClrValue clrValue) + bool IDkmClrFormatter.HasUnderlyingString(DkmClrValue value, DkmInspectionContext inspectionContext) { - return HasUnderlyingString(clrValue); + return HasUnderlyingString(value, inspectionContext); } - string IDkmClrFormatter.GetUnderlyingString(DkmClrValue clrValue) + string IDkmClrFormatter.GetUnderlyingString(DkmClrValue value, DkmInspectionContext inspectionContext) { - return GetUnderlyingString(clrValue); + return GetUnderlyingString(value, inspectionContext); } // CONSIDER: If the number or complexity of the "language-specific syntax helpers" grows (or if diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/DebuggerDisplayInfo.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/DebuggerDisplayInfo.cs new file mode 100644 index 00000000000..36381e79f59 --- /dev/null +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/DebuggerDisplayInfo.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.VisualStudio.Debugger.Clr; +using Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation; + +namespace Microsoft.CodeAnalysis.ExpressionEvaluator +{ + internal struct DebuggerDisplayInfo + { + public readonly DkmClrType TargetType; + public readonly DkmClrDebuggerDisplayAttribute Attribute; + + public DebuggerDisplayInfo(DkmClrType targetType, DkmClrDebuggerDisplayAttribute attribute) + { + TargetType = targetType; + Attribute = attribute; + } + } +} diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/EvalResultDataItem.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/EvalResultDataItem.cs index 8dfad2e7f39..db9b9aaadae 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/EvalResultDataItem.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/EvalResultDataItem.cs @@ -9,6 +9,18 @@ namespace Microsoft.CodeAnalysis.ExpressionEvaluator { + internal enum ExpansionKind + { + Default, + Error, + NonPublicMembers, + PointerDereference, + RawView, + ResultsView, + StaticMembers, + TypeVariables + } + /// /// A pair of DkmClrValue and Expansion, used to store /// state on a DkmEvaluationResult. Also computes the @@ -21,13 +33,13 @@ namespace Microsoft.CodeAnalysis.ExpressionEvaluator /// internal sealed class EvalResultDataItem : DkmDataItem { - /// - /// May be null for synthesized nodes like "Results View", etc. - /// - public readonly string NameOpt; + public readonly ExpansionKind Kind; + public readonly string Name; public readonly Type TypeDeclaringMember; public readonly Type DeclaredType; + public readonly EvalResultDataItem Parent; public readonly DkmClrValue Value; + public readonly string DisplayValue; // overrides the "Value" text displayed for certain kinds of DataItems (errors, invalid pointer dereferences, etc)...not to be confused with DebuggerDisplayAttribute Value... public readonly Expansion Expansion; public readonly bool ChildShouldParenthesize; public readonly string FullNameWithoutFormatSpecifiers; @@ -53,11 +65,35 @@ public string FullName } } + public EvalResultDataItem(string name, string errorMessage) + : this( + ExpansionKind.Error, + inspectionContext: null, + name: name, + typeDeclaringMember: null, + declaredType: null, + parent: null, + value: null, + displayValue: errorMessage, + expansion: null, + childShouldParenthesize: false, + fullName: null, + childFullNamePrefixOpt: null, + formatSpecifiers: Formatter.NoFormatSpecifiers, + category: DkmEvaluationResultCategory.Other, + flags: DkmEvaluationResultFlags.None, + editableValue: null) + { + } + public EvalResultDataItem( + ExpansionKind kind, string name, Type typeDeclaringMember, Type declaredType, + EvalResultDataItem parent, DkmClrValue value, + string displayValue, Expansion expansion, bool childShouldParenthesize, string fullName, @@ -65,26 +101,31 @@ public string FullName ReadOnlyCollection formatSpecifiers, DkmEvaluationResultCategory category, DkmEvaluationResultFlags flags, - string editableValue) + string editableValue, + DkmInspectionContext inspectionContext) { + Debug.Assert(name != null); Debug.Assert(formatSpecifiers != null); Debug.Assert((flags & DkmEvaluationResultFlags.Expandable) == 0); - this.NameOpt = name; + this.Kind = kind; + this.Name = name; this.TypeDeclaringMember = typeDeclaringMember; this.DeclaredType = declaredType; + this.Parent = parent; this.Value = value; + this.DisplayValue = displayValue; this.ChildShouldParenthesize = childShouldParenthesize; this.FullNameWithoutFormatSpecifiers = fullName; this.ChildFullNamePrefix = childFullNamePrefixOpt; this.FormatSpecifiers = formatSpecifiers; this.Category = category; this.EditableValue = editableValue; - this.Flags = flags | GetFlags(value) | ((expansion == null) ? DkmEvaluationResultFlags.None : DkmEvaluationResultFlags.Expandable); + this.Flags = flags | GetFlags(value, inspectionContext) | ((expansion == null) ? DkmEvaluationResultFlags.None : DkmEvaluationResultFlags.Expandable); this.Expansion = expansion; } - private static DkmEvaluationResultFlags GetFlags(DkmClrValue value) + private static DkmEvaluationResultFlags GetFlags(DkmClrValue value, DkmInspectionContext inspectionContext) { if (value == null) { @@ -103,7 +144,7 @@ private static DkmEvaluationResultFlags GetFlags(DkmClrValue value) } } - if (!value.IsError() && value.HasUnderlyingString()) + if (!value.IsError() && value.HasUnderlyingString(inspectionContext)) { resultFlags |= DkmEvaluationResultFlags.RawString; } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/TypeHelpers.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/TypeHelpers.cs index f27ef8622d9..48188c614c3 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/TypeHelpers.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/TypeHelpers.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using Microsoft.VisualStudio.Debugger; using Microsoft.VisualStudio.Debugger.Clr; using Microsoft.VisualStudio.Debugger.Evaluation; using Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation; @@ -368,16 +369,15 @@ internal static bool TryGetEvalAttribute(this DkmClrType type, out DkmClrType /// /// Extracts information from the first on the runtime type of , if there is one. /// - internal static void GetDebuggerDisplayStrings(this DkmClrValue value, out string nameString, out string valueString, out string typeString) + internal static bool TryGetDebuggerDisplayInfo(this DkmClrValue value, out DebuggerDisplayInfo displayInfo) { + displayInfo = default(DebuggerDisplayInfo); + // The native EE does not consider DebuggerDisplayAttribute // on null or error instances. if (value.IsError() || value.IsNull) { - nameString = null; - valueString = null; - typeString = null; - return; + return false; } var clrType = value.Type; @@ -386,16 +386,11 @@ internal static void GetDebuggerDisplayStrings(this DkmClrValue value, out strin DkmClrDebuggerDisplayAttribute attribute; if (clrType.TryGetEvalAttribute(out attributeTarget, out attribute)) // First, as in dev12. { - nameString = EvaluateDebuggerDisplayString(value, attribute.Name); - valueString = EvaluateDebuggerDisplayString(value, attribute.Value); - typeString = EvaluateDebuggerDisplayString(value, attribute.TypeName); - } - else - { - nameString = null; - valueString = null; - typeString = null; + displayInfo = new DebuggerDisplayInfo(attributeTarget, attribute); + return true; } + + return false; } /// @@ -439,9 +434,16 @@ internal static DkmCustomUIVisualizerInfo[] GetDebuggerCustomUIVisualizerInfo(th return result; } - private static string EvaluateDebuggerDisplayString(DkmClrValue value, string str) + internal static void EvaluateDebuggerDisplayStringAndContinue(this DkmClrValue value, DkmWorkList workList, DkmInspectionContext inspectionContext, DkmClrType targetType, string str, DkmCompletionRoutine completionRoutine) { - return str == null ? null : value.EvaluateDebuggerDisplayString(str); + if (str == null) + { + completionRoutine(default(DkmEvaluateDebuggerDisplayStringAsyncResult)); + } + else + { + value.EvaluateDebuggerDisplayString(workList, inspectionContext, targetType, str, completionRoutine); + } } internal static DkmClrType GetProxyType(this DkmClrType type) diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs b/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs index 70774ea50f2..110a9d1921a 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs @@ -3,9 +3,11 @@ using System; using System.Collections.ObjectModel; using System.Diagnostics; +using System.Threading; using Microsoft.CodeAnalysis.Collections; using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.VisualStudio.Debugger; +using Microsoft.VisualStudio.Debugger.CallStack; using Microsoft.VisualStudio.Debugger.Clr; using Microsoft.VisualStudio.Debugger.ComponentInterfaces; using Microsoft.VisualStudio.Debugger.Evaluation; @@ -15,6 +17,9 @@ namespace Microsoft.CodeAnalysis.ExpressionEvaluator { + internal delegate void CompletionRoutine(); + internal delegate void CompletionRoutine(TResult result); + /// /// Computes expansion of instances. /// @@ -35,23 +40,13 @@ internal ResultProvider(Formatter formatter) this.Formatter = formatter; } - DkmEvaluationResult IDkmClrResultProvider.GetResult(DkmClrValue value, ReadOnlyCollection formatSpecifiers, string resultName, string resultFullName) - { - var declaredType = value.DeclaredType; // See #1099981 - return GetResult(value, declaredType, formatSpecifiers, resultName, resultFullName); - } - - internal DkmEvaluationResult GetResult(DkmClrValue value, DkmClrType declaredType, ReadOnlyCollection formatSpecifiers, string resultName, string resultFullName) + void IDkmClrResultProvider.GetResult(DkmClrValue value, DkmWorkList workList, DkmClrType declaredType, DkmInspectionContext inspectionContext, ReadOnlyCollection formatSpecifiers, string resultName, string resultFullName, DkmCompletionRoutine completionRoutine) { // TODO: Use full name - try - { - return GetRootResult(value, declaredType, resultName); - } - catch (Exception e) when (ExpressionEvaluatorFatalError.CrashIfFailFastEnabled(e)) - { - throw ExceptionUtilities.Unreachable; - } + GetRootResultAndContinue(value, workList, declaredType, inspectionContext, resultName, + result => ContinueWithExceptionHandling( + () => completionRoutine(new DkmEvaluationAsyncResult(result)), + e => completionRoutine(DkmEvaluationAsyncResult.CreateErrorResult(e)))); } DkmClrValue IDkmClrResultProvider.GetClrValue(DkmSuccessEvaluationResult evaluationResult) @@ -82,27 +77,21 @@ void IDkmClrResultProvider.GetChildren(DkmEvaluationResult evaluationResult, Dkm return; } - completionRoutine(GetChildren(inspectionContext, evaluationResult, dataItem, initialRequestSize)); + var stackFrame = evaluationResult.StackFrame; + GetChildrenAndContinue(dataItem, workList, stackFrame, initialRequestSize, inspectionContext, completionRoutine); } void IDkmClrResultProvider.GetItems(DkmEvaluationResultEnumContext enumContext, DkmWorkList workList, int startIndex, int count, DkmCompletionRoutine completionRoutine) { - try - { - var dataItem = enumContext.GetDataItem(); - if (dataItem == null) - { - // We don't know about this result. Call next implementation - enumContext.GetItems(workList, startIndex, count, completionRoutine); - return; - } - - completionRoutine(GetItems(enumContext.InspectionContext, dataItem.EvalResultDataItem, startIndex, count)); - } - catch (Exception e) when (ExpressionEvaluatorFatalError.CrashIfFailFastEnabled(e)) + var dataItem = enumContext.GetDataItem(); + if (dataItem == null) { - throw ExceptionUtilities.Unreachable; + // We don't know about this result. Call next implementation + enumContext.GetItems(workList, startIndex, count, completionRoutine); + return; } + + GetItemsAndContinue(dataItem.EvalResultDataItem, workList, startIndex, count, enumContext.InspectionContext, completionRoutine); } string IDkmClrResultProvider.GetUnderlyingString(DkmEvaluationResult result) @@ -116,7 +105,7 @@ string IDkmClrResultProvider.GetUnderlyingString(DkmEvaluationResult result) return result.GetUnderlyingString(); } - return dataItem.Value?.GetUnderlyingString(); + return dataItem.Value?.GetUnderlyingString(result.InspectionContext); } catch (Exception e) when (ExpressionEvaluatorFatalError.CrashIfFailFastEnabled(e)) { @@ -124,18 +113,96 @@ string IDkmClrResultProvider.GetUnderlyingString(DkmEvaluationResult result) } } - internal static DkmEvaluationResult CreateEvaluationResult( + private void CreateEvaluationResultAndContinue(EvalResultDataItem dataItem, DkmWorkList workList, DkmInspectionContext inspectionContext, DkmStackWalkFrame stackFrame, CompletionRoutine completionRoutine) + { + switch (dataItem.Kind) + { + case ExpansionKind.Error: + completionRoutine(DkmFailedEvaluationResult.Create( + inspectionContext, + StackFrame: stackFrame, + Name: dataItem.Name, + FullName: dataItem.FullName, + ErrorMessage: dataItem.DisplayValue, + Flags: DkmEvaluationResultFlags.None, + Type: null, + DataItem: null)); + break; + case ExpansionKind.NonPublicMembers: + case ExpansionKind.StaticMembers: + completionRoutine(CreateEvaluationResult( + inspectionContext, + dataItem.Value, + dataItem.Name, + typeName: string.Empty, + display: null, + dataItem: dataItem)); + break; + case ExpansionKind.RawView: + completionRoutine(CreateEvaluationResult( + inspectionContext, + dataItem.Value, + Resources.RawView, + typeName: string.Empty, + display: null, + dataItem: dataItem)); + break; + case ExpansionKind.ResultsView: + completionRoutine(CreateEvaluationResult( + inspectionContext, + dataItem.Value, + dataItem.Name, + typeName: string.Empty, + display: Resources.ResultsViewValueWarning, + dataItem: dataItem)); + break; + case ExpansionKind.TypeVariables: + var value = dataItem.Value; + completionRoutine(DkmSuccessEvaluationResult.Create( + inspectionContext, + stackFrame, + dataItem.Name, + dataItem.FullName, + dataItem.Flags, + dataItem.DisplayValue, + EditableValue: null, + Type: dataItem.DisplayValue, + Category: dataItem.Category, + Access: value.Access, + StorageType: value.StorageType, + TypeModifierFlags: value.TypeModifierFlags, + Address: value.Address, + CustomUIVisualizers: null, + ExternalModules: null, + DataItem: dataItem)); + break; + default: + Debug.Assert((dataItem.Kind == ExpansionKind.Default) || (dataItem.Kind == ExpansionKind.PointerDereference)); + // This call will evaluate DebuggerDisplayAttributes. + GetResultAndContinue( + dataItem, + workList, + declaredType: DkmClrType.Create(dataItem.Value.Type.AppDomain, dataItem.DeclaredType), + inspectionContext: inspectionContext, + parent: dataItem.Parent, + completionRoutine: completionRoutine); + break; + } + } + + private static DkmEvaluationResult CreateEvaluationResult( + DkmInspectionContext inspectionContext, DkmClrValue value, - string name, // Reflects DebuggerDisplayAttribute - string typeName, // Reflects DebuggerDisplayAttribute - string display, // Reflects DebuggerDisplayAttribute + string name, + string typeName, + string display, EvalResultDataItem dataItem) { if (value.IsError()) { // Evaluation failed return DkmFailedEvaluationResult.Create( - InspectionContext: value.InspectionContext, + InspectionContext: inspectionContext, StackFrame: value.StackFrame, Name: name, FullName: dataItem.FullName, @@ -163,7 +230,7 @@ string IDkmClrResultProvider.GetUnderlyingString(DkmEvaluationResult result) // Valid value return DkmSuccessEvaluationResult.Create( - InspectionContext: value.InspectionContext, + InspectionContext: inspectionContext, StackFrame: value.StackFrame, Name: name, FullName: dataItem.FullName, @@ -182,17 +249,24 @@ string IDkmClrResultProvider.GetUnderlyingString(DkmEvaluationResult result) } } - /// The qualified name (i.e. including containing types and namespaces) of a named, - /// pointer, or array type followed by the qualified name of the actual runtime type, if it - /// differs from the declared type. - private static string GetTypeName(DkmInspectionContext inspectionContext, DkmClrType declaredType, DkmClrType runtimeType) + /// + /// The qualified name (i.e. including containing types and namespaces) of a named, pointer, + /// or array type followed by the qualified name of the actual runtime type, if provided. + /// + private static string GetTypeName(DkmInspectionContext inspectionContext, DkmClrValue value, DkmClrType declaredType, ExpansionKind kind) { - var declaredTypeName = inspectionContext.GetTypeName(declaredType); var declaredLmrType = declaredType.GetLmrType(); + var runtimeType = value.Type; var runtimeLmrType = runtimeType.GetLmrType(); - return declaredLmrType.Equals(runtimeLmrType) || declaredLmrType.IsPointer - ? declaredTypeName - : string.Format("{0} {{{1}}}", declaredTypeName, inspectionContext.GetTypeName(runtimeType)); + var includeRuntimeTypeName = + !declaredLmrType.Equals(runtimeLmrType) && + !declaredLmrType.IsPointer && + (kind != ExpansionKind.PointerDereference) && + (!declaredLmrType.IsNullable() || value.EvalFlags.Includes(DkmEvaluationResultFlags.ExceptionThrown)); + var declaredTypeName = inspectionContext.GetTypeName(declaredType, Formatter.NoFormatSpecifiers); + return includeRuntimeTypeName ? + string.Format("{0} {{{1}}}", declaredTypeName, inspectionContext.GetTypeName(runtimeType, Formatter.NoFormatSpecifiers)) : + declaredTypeName; } internal EvalResultDataItem CreateDataItem( @@ -255,7 +329,7 @@ private static string GetTypeName(DkmInspectionContext inspectionContext, DkmClr flags.Includes(DkmEvaluationResultFlags.ExceptionThrown) ? null : fullName, formatSpecifiers, flags, - this.Formatter.GetEditableValue(value)); + this.Formatter.GetEditableValue(value, inspectionContext)); if (expansion == null) { var expansionType = value.HasExceptionThrown(parent) ? value.Type.GetLmrType() : declaredType; @@ -264,31 +338,38 @@ private static string GetTypeName(DkmInspectionContext inspectionContext, DkmClr } return new EvalResultDataItem( + ExpansionKind.Default, name, typeDeclaringMember, declaredType, - value, - expansion, - childShouldParenthesize, - fullName, - flags.Includes(DkmEvaluationResultFlags.ExceptionThrown) ? null : fullName, - formatSpecifiers, - category, - flags, - this.Formatter.GetEditableValue(value)); + parent: parent, + value: value, + displayValue: null, + expansion: expansion, + childShouldParenthesize: childShouldParenthesize, + fullName: fullName, + childFullNamePrefixOpt: flags.Includes(DkmEvaluationResultFlags.ExceptionThrown) ? null : fullName, + formatSpecifiers: formatSpecifiers, + category: category, + flags: flags, + editableValue: this.Formatter.GetEditableValue(value, inspectionContext), + inspectionContext: inspectionContext); } - private DkmEvaluationResult GetRootResult(DkmClrValue value, DkmClrType declaredType, string resultName) + private void GetRootResultAndContinue(DkmClrValue value, DkmWorkList workList, DkmClrType declaredType, DkmInspectionContext inspectionContext, string resultName, CompletionRoutine completionRoutine) { var type = value.Type.GetLmrType(); if (type.IsTypeVariables()) { var expansion = new TypeVariablesExpansion(type); var dataItem = new EvalResultDataItem( + ExpansionKind.Default, resultName, typeDeclaringMember: null, declaredType: type, + parent: null, value: value, + displayValue: null, expansion: expansion, childShouldParenthesize: false, fullName: null, @@ -296,14 +377,15 @@ private DkmEvaluationResult GetRootResult(DkmClrValue value, DkmClrType declared formatSpecifiers: Formatter.NoFormatSpecifiers, category: DkmEvaluationResultCategory.Data, flags: DkmEvaluationResultFlags.ReadOnly, - editableValue: null); + editableValue: null, + inspectionContext: inspectionContext); Debug.Assert(dataItem.Flags == (DkmEvaluationResultFlags.ReadOnly | DkmEvaluationResultFlags.Expandable)); // Note: We're not including value.EvalFlags in Flags parameter // below (there shouldn't be a reason to do so). - return DkmSuccessEvaluationResult.Create( - InspectionContext: value.InspectionContext, + completionRoutine(DkmSuccessEvaluationResult.Create( + InspectionContext: inspectionContext, StackFrame: value.StackFrame, Name: Resources.TypeVariablesName, FullName: dataItem.FullName, @@ -318,46 +400,73 @@ private DkmEvaluationResult GetRootResult(DkmClrValue value, DkmClrType declared Address: value.Address, CustomUIVisualizers: null, ExternalModules: null, - DataItem: dataItem); + DataItem: dataItem)); } else { - var inspectionContext = value.InspectionContext; if ((inspectionContext.EvaluationFlags & DkmEvaluationFlags.ResultsOnly) != 0) { - return ResultsViewExpansion.CreateResultsOnly(resultName, declaredType, value, null, this.Formatter); + CreateEvaluationResultAndContinue( + ResultsViewExpansion.CreateResultsOnlyRow(inspectionContext, resultName, declaredType, value, null, this.Formatter), + workList, + inspectionContext, + value.StackFrame, + completionRoutine); + } + else + { + ReadOnlyCollection formatSpecifiers; + var fullName = this.Formatter.TrimAndGetFormatSpecifiers(resultName, out formatSpecifiers); + var dataItem = CreateDataItem( + inspectionContext, + resultName, + typeDeclaringMember: null, + declaredType: declaredType.GetLmrType(), + value: value, + parent: null, + expansionFlags: ExpansionFlags.All, + childShouldParenthesize: this.Formatter.NeedsParentheses(fullName), + fullName: fullName, + formatSpecifiers: formatSpecifiers, + category: DkmEvaluationResultCategory.Other, + flags: value.EvalFlags, + evalFlags: inspectionContext.EvaluationFlags); + GetResultAndContinue(dataItem, workList, declaredType, inspectionContext, parent: null, completionRoutine: completionRoutine); } - - ReadOnlyCollection formatSpecifiers; - var fullName = this.Formatter.TrimAndGetFormatSpecifiers(resultName, out formatSpecifiers); - var dataItem = CreateDataItem( - inspectionContext, - resultName, - typeDeclaringMember: null, - declaredType: declaredType.GetLmrType(), - value: value, - parent: null, - expansionFlags: ExpansionFlags.All, - childShouldParenthesize: this.Formatter.NeedsParentheses(fullName), - fullName: fullName, - formatSpecifiers: formatSpecifiers, - category: DkmEvaluationResultCategory.Other, - flags: value.EvalFlags, - evalFlags: inspectionContext.EvaluationFlags); - return GetResult(dataItem, value.Type, declaredType, parent: null); } } - internal DkmEvaluationResult GetResult(EvalResultDataItem dataItem, DkmClrType runtimeType, DkmClrType declaredType, EvalResultDataItem parent) + internal void GetResultAndContinue(EvalResultDataItem dataItem, DkmWorkList workList, DkmClrType declaredType, DkmInspectionContext inspectionContext, EvalResultDataItem parent, CompletionRoutine completionRoutine) { - var value = dataItem.Value; // Value may have replaced (specifically, for Nullable). - - string debuggerDisplayName; - string debuggerDisplayValue; - string debuggerDisplayType; - value.GetDebuggerDisplayStrings(out debuggerDisplayName, out debuggerDisplayValue, out debuggerDisplayType); + var value = dataItem.Value; // Value may have been replaced (specifically, for Nullable). + DebuggerDisplayInfo displayInfo; + if (value.TryGetDebuggerDisplayInfo(out displayInfo)) + { + var targetType = displayInfo.TargetType; + var attribute = displayInfo.Attribute; + CompletionRoutine onException = + e => completionRoutine(CreateEvaluationResultFromException(e, dataItem, inspectionContext)); + + value.EvaluateDebuggerDisplayStringAndContinue(workList, inspectionContext, targetType, attribute.Name, + displayName => ContinueWithExceptionHandling( + () => value.EvaluateDebuggerDisplayStringAndContinue(workList, inspectionContext, targetType, attribute.Value, + displayValue => ContinueWithExceptionHandling( + () => value.EvaluateDebuggerDisplayStringAndContinue(workList, inspectionContext, targetType, attribute.TypeName, + displayType => ContinueWithExceptionHandling( + () => completionRoutine(GetResult(inspectionContext, dataItem, declaredType, displayName.Result, displayValue.Result, displayType.Result, parent)), + onException)), + onException)), + onException)); + } + else + { + completionRoutine(GetResult(inspectionContext, dataItem, declaredType, displayName: null, displayValue: null, displayType: null, parent: parent)); + } + } - var name = dataItem.NameOpt; + private DkmEvaluationResult GetResult(DkmInspectionContext inspectionContext, EvalResultDataItem dataItem, DkmClrType declaredType, string displayName, string displayValue, string displayType, EvalResultDataItem parent) + { + var name = dataItem.Name; Debug.Assert(name != null); var typeDeclaringMember = dataItem.TypeDeclaringMember; @@ -367,9 +476,9 @@ internal DkmEvaluationResult GetResult(EvalResultDataItem dataItem, DkmClrType r // Note: Dev12 respects the debugger display name in the Locals window, // but not in the Watch window, but we can't distinguish and this // behavior seems reasonable. - if (debuggerDisplayName != null && parent != null) + if (displayName != null && parent != null) { - name = debuggerDisplayName; + name = displayName; } else if (typeDeclaringMember != null) { @@ -390,52 +499,109 @@ internal DkmEvaluationResult GetResult(EvalResultDataItem dataItem, DkmClrType r } } + var value = dataItem.Value; string display; if (value.HasExceptionThrown(parent)) { - display = value.GetExceptionMessage(dataItem.FullNameWithoutFormatSpecifiers, this.Formatter); + display = dataItem.DisplayValue ?? value.GetExceptionMessage(dataItem.FullNameWithoutFormatSpecifiers, this.Formatter); } - else if (debuggerDisplayValue != null) + else if (displayValue != null) { - display = value.IncludeObjectId(debuggerDisplayValue); + display = value.IncludeObjectId(displayValue); } else { - display = value.GetValueString(); + display = value.GetValueString(inspectionContext, Formatter.NoFormatSpecifiers); } - var typeName = debuggerDisplayType ?? GetTypeName(value.InspectionContext, declaredType, runtimeType); - return CreateEvaluationResult(value, name, typeName, display, dataItem); + var typeName = displayType ?? GetTypeName(inspectionContext, value, declaredType, dataItem.Kind); + + return CreateEvaluationResult(inspectionContext, value, name, typeName, display, dataItem); } - private DkmGetChildrenAsyncResult GetChildren(DkmInspectionContext inspectionContext, DkmEvaluationResult evaluationResult, EvalResultDataItem dataItem, int initialRequestSize) + private void GetChildrenAndContinue(EvalResultDataItem dataItem, DkmWorkList workList, DkmStackWalkFrame stackFrame, int initialRequestSize, DkmInspectionContext inspectionContext, DkmCompletionRoutine completionRoutine) { var expansion = dataItem.Expansion; - var builder = ArrayBuilder.GetInstance(); + var rows = ArrayBuilder.GetInstance(); int index = 0; if (expansion != null) { - expansion.GetRows(this, builder, inspectionContext, dataItem, dataItem.Value, 0, initialRequestSize, visitAll: true, index: ref index); + expansion.GetRows(this, rows, inspectionContext, dataItem, dataItem.Value, 0, initialRequestSize, visitAll: true, index: ref index); } - var rows = builder.ToArrayAndFree(); - Debug.Assert(index >= rows.Length); - Debug.Assert(initialRequestSize >= rows.Length); - var enumContext = DkmEvaluationResultEnumContext.Create(index, evaluationResult.StackFrame, evaluationResult.InspectionContext, new EnumContextDataItem(dataItem)); - return new DkmGetChildrenAsyncResult(rows, enumContext); + var numRows = rows.Count; + Debug.Assert(index >= numRows); + Debug.Assert(initialRequestSize >= numRows); + var initialChildren = new DkmEvaluationResult[numRows]; + GetEvaluationResultsAndContinue(rows, initialChildren, 0, numRows, workList, inspectionContext, stackFrame, + () => ContinueWithExceptionHandling( + () => + { + var enumContext = DkmEvaluationResultEnumContext.Create(index, stackFrame, inspectionContext, new EnumContextDataItem(dataItem)); + completionRoutine(new DkmGetChildrenAsyncResult(initialChildren, enumContext)); + rows.Free(); + }, + e => completionRoutine(DkmGetChildrenAsyncResult.CreateErrorResult(e)))); } - private DkmEvaluationEnumAsyncResult GetItems(DkmInspectionContext inspectionContext, EvalResultDataItem dataItem, int startIndex, int count) + private void GetItemsAndContinue(EvalResultDataItem dataItem, DkmWorkList workList, int startIndex, int count, DkmInspectionContext inspectionContext, DkmCompletionRoutine completionRoutine) { var expansion = dataItem.Expansion; - var builder = ArrayBuilder.GetInstance(); + var value = dataItem.Value; + var rows = ArrayBuilder.GetInstance(); if (expansion != null) { int index = 0; - expansion.GetRows(this, builder, inspectionContext, dataItem, dataItem.Value, startIndex, count, visitAll: false, index: ref index); + expansion.GetRows(this, rows, inspectionContext, dataItem, value, startIndex, count, visitAll: false, index: ref index); + } + var numRows = rows.Count; + Debug.Assert(count >= numRows); + var results = new DkmEvaluationResult[numRows]; + GetEvaluationResultsAndContinue(rows, results, 0, numRows, workList, inspectionContext, value.StackFrame, + () => ContinueWithExceptionHandling( + () => + { + completionRoutine(new DkmEvaluationEnumAsyncResult(results)); + rows.Free(); + }, + e => completionRoutine(DkmEvaluationEnumAsyncResult.CreateErrorResult(e)))); + } + + private void StoreResultAndContinue(DkmEvaluationResult result, ArrayBuilder rows, DkmEvaluationResult[] results, int index, int numRows, DkmWorkList workList, DkmInspectionContext inspectionContext, DkmStackWalkFrame stackFrame, CompletionRoutine completionRoutine) + { + results[index] = result; + index++; + if (index < numRows) + { + GetEvaluationResultsAndContinue(rows, results, index, numRows, workList, inspectionContext, stackFrame, completionRoutine); + } + else + { + completionRoutine(); + } + } + + private void GetEvaluationResultsAndContinue(ArrayBuilder rows, DkmEvaluationResult[] results, int index, int numRows, DkmWorkList workList, DkmInspectionContext inspectionContext, DkmStackWalkFrame stackFrame, CompletionRoutine completionRoutine) + { + if (index >= numRows) + { + completionRoutine(); + } + else + { + CreateEvaluationResultAndContinue(rows[index], workList, inspectionContext, stackFrame, + result => ContinueWithExceptionHandling( + () => StoreResultAndContinue(result, rows, results, index, numRows, workList, inspectionContext, stackFrame, completionRoutine), + e => + { + // If we fail to store a result, just stop enumerating rows (rather than attempting to store + // an error message in the current row, etc). This is because it may have been the act of + // indexing into the results store that threw (so it would just throw again here). The user + // experience is less than ideal (there's no real indication that something went wrong), + // however, it seems like it's better to enumerate/display some rows than none. We will + // receive a non-fatal Watson report in this case, so the problem won't go unnoticed. + completionRoutine(); + })); } - var rows = builder.ToArrayAndFree(); - Debug.Assert(count >= rows.Length); - return new DkmEvaluationEnumAsyncResult(rows); } internal Expansion GetTypeExpansion(DkmInspectionContext inspectionContext, Type declaredType, DkmClrValue value, ExpansionFlags flags) @@ -482,7 +648,32 @@ internal Expansion GetTypeExpansion(DkmInspectionContext inspectionContext, Type flags &= ~ExpansionFlags.IncludeBaseMembers; } - return MemberExpansion.CreateExpansion(declaredType, value, flags, TypeHelpers.IsVisibleMember, this.Formatter); + return MemberExpansion.CreateExpansion(inspectionContext, declaredType, value, flags, TypeHelpers.IsVisibleMember, this.Formatter); + } + + private static DkmEvaluationResult CreateEvaluationResultFromException(Exception e, EvalResultDataItem dataItem, DkmInspectionContext inspectionContext) + { + return DkmFailedEvaluationResult.Create( + inspectionContext, + dataItem.Value.StackFrame, + Name: dataItem.Name, + FullName: null, + ErrorMessage: e.Message, + Flags: DkmEvaluationResultFlags.None, + Type: null, + DataItem: null); + } + + internal static void ContinueWithExceptionHandling(CompletionRoutine onCompleted, CompletionRoutine onException) + { + try + { + onCompleted(); + } + catch (Exception e) when (ExpressionEvaluatorFatalError.ReportNonFatalException(e, DkmComponentManager.ReportCurrentNonFatalException)) + { + onException(e); + } } } } diff --git a/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.csproj b/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.csproj index 1d5069c7afb..63951347c47 100644 --- a/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.csproj +++ b/src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.csproj @@ -92,6 +92,7 @@ + diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrValue.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrValue.cs index fef4a7556bc..464aff5b9e1 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrValue.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrValue.cs @@ -1,8 +1,9 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + #region Assembly Microsoft.VisualStudio.Debugger.Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a // References\Debugger\v2.0\Microsoft.VisualStudio.Debugger.Engine.dll - #endregion + using System; using System.Collections.ObjectModel; using System.Diagnostics; @@ -29,8 +30,7 @@ public class DkmClrValue : DkmDataContainer string alias, IDkmClrFormatter formatter, DkmEvaluationResultFlags evalFlags, - DkmClrValueFlags valueFlags, - DkmInspectionContext inspectionContext) + DkmClrValueFlags valueFlags) { Debug.Assert(!type.GetLmrType().IsTypeVariables() || (valueFlags == DkmClrValueFlags.Synthetic)); Debug.Assert((alias == null) || evalFlags.Includes(DkmEvaluationResultFlags.HasObjectId)); @@ -44,14 +44,12 @@ public class DkmClrValue : DkmDataContainer this.Alias = alias; this.EvalFlags = evalFlags; this.ValueFlags = valueFlags; - this.InspectionContext = inspectionContext ?? new DkmInspectionContext(formatter, DkmEvaluationFlags.None, 10); } public readonly DkmEvaluationResultFlags EvalFlags; public readonly DkmClrValueFlags ValueFlags; public readonly DkmClrType Type; public DkmClrType DeclaredType { get { throw new NotImplementedException(); } } - public readonly DkmInspectionContext InspectionContext; public readonly DkmStackWalkFrame StackFrame; public readonly DkmEvaluationResultCategory Category; public readonly DkmEvaluationResultAccessType Access; @@ -64,21 +62,13 @@ public class DkmClrValue : DkmDataContainer private readonly IDkmClrFormatter _formatter; private readonly object _rawValue; - internal DkmClrValue WithInspectionContext(DkmInspectionContext inspectionContext) + public DkmClrValue Dereference(DkmInspectionContext inspectionContext) { - return new DkmClrValue( - _rawValue, - this.HostObjectValue, - this.Type, - this.Alias, - _formatter, - this.EvalFlags, - this.ValueFlags, - inspectionContext); - } + if (inspectionContext == null) + { + throw new ArgumentNullException("inspectionContext"); + } - public DkmClrValue Dereference() - { if (_rawValue == null) { throw new InvalidOperationException("Cannot dereference invalid value"); @@ -105,8 +95,7 @@ public DkmClrValue Dereference() alias: null, formatter: _formatter, evalFlags: evalFlags, - valueFlags: valueFlags, - inspectionContext: this.InspectionContext); + valueFlags: valueFlags); } public bool IsNull @@ -135,24 +124,44 @@ internal static object GetHostObjectValue(Type lmrType, object rawValue) : null; } - public string GetValueString() + public string GetValueString(DkmInspectionContext inspectionContext, ReadOnlyCollection formatSpecifiers) { + if (inspectionContext == null) + { + throw new ArgumentNullException("inspectionContext"); + } + // The real version does some sort of dynamic dispatch that ultimately calls this method. - return _formatter.GetValueString(this); + return _formatter.GetValueString(this, inspectionContext, formatSpecifiers); } - public bool HasUnderlyingString() + public bool HasUnderlyingString(DkmInspectionContext inspectionContext) { - return _formatter.HasUnderlyingString(this); + if (inspectionContext == null) + { + throw new ArgumentNullException("inspectionContext"); + } + + return _formatter.HasUnderlyingString(this, inspectionContext); } - public string GetUnderlyingString() + public string GetUnderlyingString(DkmInspectionContext inspectionContext) { - return _formatter.GetUnderlyingString(this); + if (inspectionContext == null) + { + throw new ArgumentNullException("inspectionContext"); + } + + return _formatter.GetUnderlyingString(this, inspectionContext); } - public string EvaluateToString() + public string EvaluateToString(DkmInspectionContext inspectionContext) { + if (inspectionContext == null) + { + throw new ArgumentNullException("inspectionContext"); + } + // This is a rough approximation of the real functionality. Basically, // if object.ToString is not overridden, we return null and it is the // caller's responsibility to compute a string. @@ -183,10 +192,15 @@ public string EvaluateToString() /// /// Very simple expression evaluation (may not support all syntax supported by Concord). /// - public string EvaluateDebuggerDisplayString(string formatString) + public void EvaluateDebuggerDisplayString(DkmWorkList workList, DkmInspectionContext inspectionContext, DkmClrType targetType, string formatString, DkmCompletionRoutine completionRoutine) { Debug.Assert(!this.IsNull, "Not supported by VIL"); + if (inspectionContext == null) + { + throw new ArgumentNullException("inspectionContext"); + } + var pooled = PooledStringBuilder.GetInstance(); var builder = pooled.Builder; @@ -237,8 +251,7 @@ public string EvaluateDebuggerDisplayString(string formatString) alias: null, formatter: _formatter, evalFlags: GetEvaluationResultFlags(fieldValue), - valueFlags: DkmClrValueFlags.None, - inspectionContext: this.InspectionContext); + valueFlags: DkmClrValueFlags.None); } else { @@ -253,8 +266,7 @@ public string EvaluateDebuggerDisplayString(string formatString) alias: null, formatter: _formatter, evalFlags: GetEvaluationResultFlags(propertyValue), - valueFlags: DkmClrValueFlags.None, - inspectionContext: this.InspectionContext); + valueFlags: DkmClrValueFlags.None); } else { @@ -277,8 +289,7 @@ public string EvaluateDebuggerDisplayString(string formatString) alias: null, formatter: _formatter, evalFlags: GetEvaluationResultFlags(methodValue), - valueFlags: DkmClrValueFlags.None, - inspectionContext: this.InspectionContext); + valueFlags: DkmClrValueFlags.None); } else { @@ -291,13 +302,12 @@ public string EvaluateDebuggerDisplayString(string formatString) alias: null, formatter: _formatter, evalFlags: DkmEvaluationResultFlags.None, - valueFlags: DkmClrValueFlags.Error, - inspectionContext: this.InspectionContext); + valueFlags: DkmClrValueFlags.Error); } } } - builder.Append(exprValue.GetValueString()); // Re-enter the formatter. + builder.Append(exprValue.GetValueString(inspectionContext, Formatter.NoFormatSpecifiers)); // Re-enter the formatter. } else if (openPos < 0) { @@ -309,8 +319,8 @@ public string EvaluateDebuggerDisplayString(string formatString) { throw new ArgumentException(string.Format("Unmatched open brace in '{0}'", formatString)); } - - return pooled.ToStringAndFree(); + + workList.AddWork(() => completionRoutine(new DkmEvaluateDebuggerDisplayStringAsyncResult(pooled.ToStringAndFree()))); } public DkmClrValue GetMemberValue(string MemberName, int MemberType, string ParentTypeName) @@ -346,8 +356,7 @@ public DkmClrValue GetMemberValue(string MemberName, int MemberType, string Pare alias: null, formatter: _formatter, evalFlags: DkmEvaluationResultFlags.None, - valueFlags: DkmClrValueFlags.None, - inspectionContext: this.InspectionContext); + valueFlags: DkmClrValueFlags.None); } else if (MemberName == InternalWellKnownMemberNames.NullableValue) { @@ -362,8 +371,7 @@ public DkmClrValue GetMemberValue(string MemberName, int MemberType, string Pare alias: null, formatter: _formatter, evalFlags: DkmEvaluationResultFlags.None, - valueFlags: DkmClrValueFlags.None, - inspectionContext: this.InspectionContext); + valueFlags: DkmClrValueFlags.None); } } @@ -401,8 +409,7 @@ public DkmClrValue GetMemberValue(string MemberName, int MemberType, string Pare alias: null, formatter: _formatter, evalFlags: evalFlags | DkmEvaluationResultFlags.ExceptionThrown, - valueFlags: DkmClrValueFlags.None, - inspectionContext: this.InspectionContext); + valueFlags: DkmClrValueFlags.None); } break; case MemberTypes.Property: @@ -426,8 +433,7 @@ public DkmClrValue GetMemberValue(string MemberName, int MemberType, string Pare alias: null, formatter: _formatter, evalFlags: evalFlags | DkmEvaluationResultFlags.ExceptionThrown, - valueFlags: DkmClrValueFlags.None, - inspectionContext: this.InspectionContext); + valueFlags: DkmClrValueFlags.None); } break; default: @@ -466,12 +472,16 @@ public DkmClrValue GetMemberValue(string MemberName, int MemberType, string Pare alias: null, formatter: _formatter, evalFlags: evalFlags, - valueFlags: DkmClrValueFlags.None, - inspectionContext: this.InspectionContext); + valueFlags: DkmClrValueFlags.None); } - public DkmClrValue GetArrayElement(int[] indices) + public DkmClrValue GetArrayElement(int[] indices, DkmInspectionContext inspectionContext) { + if (inspectionContext == null) + { + throw new ArgumentNullException("inspectionContext"); + } + var array = (System.Array)_rawValue; var element = array.GetValue(indices); var type = DkmClrType.Create(this.Type.AppDomain, (TypeImpl)((element == null) ? array.GetType().GetElementType() : element.GetType())); @@ -482,8 +492,7 @@ public DkmClrValue GetArrayElement(int[] indices) alias: null, formatter: _formatter, evalFlags: DkmEvaluationResultFlags.None, - valueFlags: DkmClrValueFlags.None, - inspectionContext: this.InspectionContext); + valueFlags: DkmClrValueFlags.None); } public ReadOnlyCollection ArrayDimensions @@ -526,8 +535,13 @@ public ReadOnlyCollection ArrayLowerBounds } } - public DkmClrValue InstantiateProxyType(DkmClrType proxyType) + public DkmClrValue InstantiateProxyType(DkmInspectionContext inspectionContext, DkmClrType proxyType) { + if (inspectionContext == null) + { + throw new ArgumentNullException("inspectionContext"); + } + var lmrType = proxyType.GetLmrType(); Debug.Assert(!lmrType.IsGenericTypeDefinition); const BindingFlags bindingFlags = @@ -544,12 +558,16 @@ public DkmClrValue InstantiateProxyType(DkmClrType proxyType) alias: null, formatter: _formatter, evalFlags: DkmEvaluationResultFlags.None, - valueFlags: DkmClrValueFlags.None, - inspectionContext: this.InspectionContext); + valueFlags: DkmClrValueFlags.None); } - public DkmClrValue InstantiateResultsViewProxy(DkmClrType enumerableType) + public DkmClrValue InstantiateResultsViewProxy(DkmInspectionContext inspectionContext, DkmClrType enumerableType) { + if (inspectionContext == null) + { + throw new ArgumentNullException("inspectionContext"); + } + var appDomain = enumerableType.AppDomain; var module = GetModule(appDomain, "System.Core.dll"); if (module == null) @@ -573,7 +591,7 @@ public DkmClrValue InstantiateResultsViewProxy(DkmClrType enumerableType) return null; } - return this.InstantiateProxyType(proxyType); + return this.InstantiateProxyType(inspectionContext, proxyType); } private static DkmClrModuleInstance GetModule(DkmClrAppDomain appDomain, string moduleName) diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluateDebuggerDisplayStringAsyncResult.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluateDebuggerDisplayStringAsyncResult.cs new file mode 100644 index 00000000000..0b4617087d8 --- /dev/null +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluateDebuggerDisplayStringAsyncResult.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +#region Assembly Microsoft.VisualStudio.Debugger.Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a +// D:\Roslyn\Main\Open\Binaries\Debug\Microsoft.VisualStudio.Debugger.Engine.dll +#endregion + +using System; + +namespace Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation +{ + public struct DkmEvaluateDebuggerDisplayStringAsyncResult + { + private readonly string _result; + + public DkmEvaluateDebuggerDisplayStringAsyncResult(string result) + { + if (result == null) + { + throw new ArgumentNullException("result"); + } + + _result = result; + } + + public string Result { get { return _result; } } + } +} \ No newline at end of file diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationAsyncResult.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationAsyncResult.cs new file mode 100644 index 00000000000..9e24b6e501c --- /dev/null +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationAsyncResult.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +#region Assembly Microsoft.VisualStudio.Debugger.Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a +// D:\Roslyn\Main\Open\Binaries\Debug\Microsoft.VisualStudio.Debugger.Engine.dll +#endregion + +using System; +using System.Diagnostics; + +namespace Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation +{ + public struct DkmEvaluationAsyncResult + { + private readonly DkmEvaluationResult _result; + + public DkmEvaluationAsyncResult(DkmEvaluationResult Result) + { + if (Result == null) + { + throw new ArgumentNullException("Result"); + } + + _result = Result; + } + + public int ErrorCode { get { throw new NotImplementedException(); } } + + public DkmEvaluationResult Result { get { return _result; } } + + public static DkmEvaluationAsyncResult CreateErrorResult(Exception exception) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmInspectionContext.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmInspectionContext.cs index 8d3b43ff5e7..31bff8281f3 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmInspectionContext.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmInspectionContext.cs @@ -1,9 +1,11 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + #region Assembly Microsoft.VisualStudio.Debugger.Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a // References\Debugger\v2.0\Microsoft.VisualStudio.Debugger.Engine.dll - #endregion + using System; +using System.Collections.ObjectModel; using System.Runtime.InteropServices; using Microsoft.VisualStudio.Debugger.Clr; using Microsoft.VisualStudio.Debugger.ComponentInterfaces; @@ -33,10 +35,10 @@ internal DkmInspectionContext(IDkmClrFormatter formatter, DkmEvaluationFlags eva // '16' and '10'. public readonly uint Radix; - public string GetTypeName(DkmClrType clrType) + public string GetTypeName(DkmClrType clrType, ReadOnlyCollection formatSpecifiers) { // The real version does some sort of dynamic dispatch that ultimately calls this method. - return _formatter.GetTypeName(this, clrType); + return _formatter.GetTypeName(this, clrType, formatSpecifiers); } } } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmMisc.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmMisc.cs index 9c58db3fb61..77e7ab7db9e 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmMisc.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmMisc.cs @@ -1,13 +1,22 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + #region Assembly Microsoft.VisualStudio.Debugger.Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a // References\Debugger\v2.0\Microsoft.VisualStudio.Debugger.Engine.dll - #endregion + +using System; + namespace Microsoft.VisualStudio.Debugger { public delegate void DkmCompletionRoutine(TResult result); - public class DkmWorkList { } + public static class DkmComponentManager + { + public static bool ReportCurrentNonFatalException(Exception currentException, string implementationName) + { + return true; + } + } public enum DkmDataCreationDisposition { diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmWorkList.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmWorkList.cs new file mode 100644 index 00000000000..915df83aa93 --- /dev/null +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmWorkList.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +#region Assembly Microsoft.VisualStudio.Debugger.Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a +// D:\Roslyn\Main\Open\Binaries\Debug\Microsoft.VisualStudio.Debugger.Engine.dll +#endregion + +using System; +using System.Collections.Generic; +using System.Diagnostics; + +namespace Microsoft.VisualStudio.Debugger +{ + /// + /// This mock of DkmWorkList doesn't really reflect the details of the *real* implementation. + /// It simply serves as a useful mechanism for testing async calls (in a way that resembles + /// the Concord dispatcher). + /// + public sealed class DkmWorkList + { + private readonly Queue _workList; + + /// + /// internal helper for testing only (not available on *real* DkmWorkList)... + /// + internal DkmWorkList() + { + _workList = new Queue(1); + } + + /// + /// internal helper for testing only (not available on *real* DkmWorkList)... + /// + internal void AddWork(Action item) + { + _workList.Enqueue(item); + } + + public void Execute() + { + while (_workList.Count > 0) + { + var item = _workList.Dequeue(); + item.Invoke(); + } + } + } +} \ No newline at end of file diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/IDkmClrFormatter.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/IDkmClrFormatter.cs index ee624796401..14c5380c39b 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/IDkmClrFormatter.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/IDkmClrFormatter.cs @@ -1,8 +1,10 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + #region Assembly Microsoft.VisualStudio.Debugger.Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a // References\Debugger\v2.0\Microsoft.VisualStudio.Debugger.Engine.dll - #endregion + +using System.Collections.ObjectModel; using Microsoft.VisualStudio.Debugger.Clr; using Microsoft.VisualStudio.Debugger.Evaluation; using Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation; @@ -11,9 +13,9 @@ namespace Microsoft.VisualStudio.Debugger.ComponentInterfaces { public interface IDkmClrFormatter { - string GetValueString(DkmClrValue clrValue); - string GetTypeName(DkmInspectionContext inspectionContext, DkmClrType clrType); - bool HasUnderlyingString(DkmClrValue clrValue); - string GetUnderlyingString(DkmClrValue clrValue); + string GetTypeName(DkmInspectionContext inspectionContext, DkmClrType clrType, ReadOnlyCollection formatSpecifiers); + string GetUnderlyingString(DkmClrValue clrValue, DkmInspectionContext inspectionContext); + string GetValueString(DkmClrValue clrValue, DkmInspectionContext inspectionContext, ReadOnlyCollection formatSpecifiers); + bool HasUnderlyingString(DkmClrValue clrValue, DkmInspectionContext inspectionContext); } } diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/IDkmClrResultProvider.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/IDkmClrResultProvider.cs index 7d4882a61f0..aec25b0ee43 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/IDkmClrResultProvider.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/IDkmClrResultProvider.cs @@ -1,9 +1,11 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + #region Assembly Microsoft.VisualStudio.Debugger.Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a // References\Debugger\v2.0\Microsoft.VisualStudio.Debugger.Engine.dll - #endregion + using System.Collections.ObjectModel; +using Microsoft.VisualStudio.Debugger.Clr; using Microsoft.VisualStudio.Debugger.Evaluation; using Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation; @@ -11,7 +13,7 @@ namespace Microsoft.VisualStudio.Debugger.ComponentInterfaces { public interface IDkmClrResultProvider { - DkmEvaluationResult GetResult(DkmClrValue clrValue, ReadOnlyCollection formatSpecifiers, string resultName, string resultFullName); + void GetResult(DkmClrValue clrValue, DkmWorkList workList, DkmClrType declaredType, DkmInspectionContext inspectionContext, ReadOnlyCollection formatSpecifiers, string resultName, string resultFullName, DkmCompletionRoutine completionRoutine); void GetChildren(DkmEvaluationResult evaluationResult, DkmWorkList workList, int initialRequestSize, DkmInspectionContext inspectionContext, DkmCompletionRoutine completionRoutine); void GetItems(DkmEvaluationResultEnumContext enumContext, DkmWorkList workList, int startIndex, int count, DkmCompletionRoutine completionRoutine); string GetUnderlyingString(DkmEvaluationResult result); diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/ResultProviderTestBase.cs b/src/ExpressionEvaluator/Core/Test/ResultProvider/ResultProviderTestBase.cs index b7b4cff04e3..c9b0ba177e8 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/ResultProviderTestBase.cs +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/ResultProviderTestBase.cs @@ -4,8 +4,8 @@ using System.Collections.ObjectModel; using System.Collections.Generic; using System.Linq; -using System.Reflection; using System.Runtime.ExceptionServices; +using Microsoft.VisualStudio.Debugger; using Microsoft.VisualStudio.Debugger.Clr; using Microsoft.VisualStudio.Debugger.ComponentInterfaces; using Microsoft.VisualStudio.Debugger.Evaluation; @@ -33,8 +33,7 @@ internal ResultProviderTestBase(ResultProvider resultProvider, DkmInspectionCont Type type = null, string alias = null, DkmEvaluationResultFlags evalFlags = DkmEvaluationResultFlags.None, - DkmClrValueFlags valueFlags = DkmClrValueFlags.None, - DkmInspectionContext inspectionContext = null) + DkmClrValueFlags valueFlags = DkmClrValueFlags.None) { if (type == null) { @@ -47,8 +46,7 @@ internal ResultProviderTestBase(ResultProvider resultProvider, DkmInspectionCont alias, _formatter, evalFlags, - valueFlags, - inspectionContext); + valueFlags); } internal DkmClrValue CreateDkmClrValue( @@ -56,8 +54,7 @@ internal ResultProviderTestBase(ResultProvider resultProvider, DkmInspectionCont DkmClrType type, string alias = null, DkmEvaluationResultFlags evalFlags = DkmEvaluationResultFlags.None, - DkmClrValueFlags valueFlags = DkmClrValueFlags.None, - DkmInspectionContext inspectionContext = null) + DkmClrValueFlags valueFlags = DkmClrValueFlags.None) { return new DkmClrValue( value, @@ -66,14 +63,12 @@ internal ResultProviderTestBase(ResultProvider resultProvider, DkmInspectionCont alias, _formatter, evalFlags, - valueFlags, - inspectionContext); + valueFlags); } internal DkmClrValue CreateErrorValue( DkmClrType type, - string message, - DkmInspectionContext inspectionContext = null) + string message) { return new DkmClrValue( value: null, @@ -82,8 +77,7 @@ internal ResultProviderTestBase(ResultProvider resultProvider, DkmInspectionCont alias: null, formatter: _formatter, evalFlags: DkmEvaluationResultFlags.None, - valueFlags: DkmClrValueFlags.Error, - inspectionContext: inspectionContext); + valueFlags: DkmClrValueFlags.Error); } #region Formatter Tests @@ -100,11 +94,9 @@ internal string FormatValue(object value, bool useHexadecimal = false) internal string FormatValue(object value, Type type, bool useHexadecimal = false) { - var clrValue = CreateDkmClrValue( - value, - type, - inspectionContext: CreateDkmInspectionContext(_formatter, DkmEvaluationFlags.None, radix: useHexadecimal ? 16u : 10u)); - return clrValue.GetValueString(); + var clrValue = CreateDkmClrValue(value, type); + var inspectionContext = CreateDkmInspectionContext(_formatter, DkmEvaluationFlags.None, radix: useHexadecimal ? 16u : 10u); + return clrValue.GetValueString(inspectionContext, Formatter.NoFormatSpecifiers); } internal bool HasUnderlyingString(object value) @@ -115,13 +107,13 @@ internal bool HasUnderlyingString(object value) internal bool HasUnderlyingString(object value, Type type) { var clrValue = GetValueForUnderlyingString(value, type); - return clrValue.HasUnderlyingString(); + return clrValue.HasUnderlyingString(DefaultInspectionContext); } internal string GetUnderlyingString(object value) { var clrValue = GetValueForUnderlyingString(value, value.GetType()); - return clrValue.GetUnderlyingString(); + return clrValue.GetUnderlyingString(DefaultInspectionContext); } internal DkmClrValue GetValueForUnderlyingString(object value, Type type) @@ -129,8 +121,7 @@ internal DkmClrValue GetValueForUnderlyingString(object value, Type type) return CreateDkmClrValue( value, type, - evalFlags: DkmEvaluationResultFlags.RawString, - inspectionContext: CreateDkmInspectionContext(_formatter, DkmEvaluationFlags.None, radix: 10)); + evalFlags: DkmEvaluationResultFlags.RawString); } #endregion @@ -147,30 +138,48 @@ internal static DkmInspectionContext CreateDkmInspectionContext(IDkmClrFormatter return new DkmInspectionContext(formatter, flags, radix); } - internal DkmEvaluationResult FormatResult(string name, DkmClrValue value, DkmClrType declaredType = null) + internal DkmEvaluationResult FormatResult(string name, DkmClrValue value, DkmClrType declaredType = null, DkmInspectionContext inspectionContext = null) { - return FormatResult(name, name, value, declaredType); + return FormatResult(name, name, value, declaredType, inspectionContext); } - internal DkmEvaluationResult FormatResult(string name, string fullName, DkmClrValue value, DkmClrType declaredType = null) + internal DkmEvaluationResult FormatResult(string name, string fullName, DkmClrValue value, DkmClrType declaredType = null, DkmInspectionContext inspectionContext = null) { - // TODO: IDkmClrResultProvider.GetResult should have - // an explicit declaredType parameter. See #1099981 - return ((ResultProvider)_resultProvider).GetResult(value, declaredType ?? value.Type, formatSpecifiers: null, resultName: name, resultFullName: fullName); + DkmEvaluationResult evaluationResult = null; + var workList = new DkmWorkList(); + _resultProvider.GetResult( + value, + workList, + declaredType: declaredType ?? value.Type, + inspectionContext: inspectionContext ?? DefaultInspectionContext, + formatSpecifiers: Formatter.NoFormatSpecifiers, + resultName: name, + resultFullName: null, + completionRoutine: asyncResult => evaluationResult = asyncResult.Result); + workList.Execute(); + return evaluationResult; } internal DkmEvaluationResult[] GetChildren(DkmEvaluationResult evalResult, DkmInspectionContext inspectionContext = null) { DkmEvaluationResultEnumContext enumContext; - const int size = 1; var builder = ArrayBuilder.GetInstance(); - // Request 0 children. - var items = GetChildren(evalResult, 0, inspectionContext, out enumContext); - Assert.Equal(items.Length, 0); - // Request >0 children. - items = GetChildren(evalResult, size, inspectionContext, out enumContext); + // Request 0-3 children. + int size; + DkmEvaluationResult[] items; + for (size = 0; size < 3; size++) + { + items = GetChildren(evalResult, size, inspectionContext, out enumContext); + var totalChildCount = enumContext.Count; + Assert.InRange(totalChildCount, 0, int.MaxValue); + var expectedSize = (size < totalChildCount) ? size : totalChildCount; + Assert.Equal(expectedSize, items.Length); + } + // Request items (increasing the size of the request with each iteration). + size = 1; + items = GetChildren(evalResult, size, inspectionContext, out enumContext); while (items.Length > 0) { builder.AddRange(items); @@ -181,6 +190,7 @@ internal DkmEvaluationResult[] GetChildren(DkmEvaluationResult evalResult, DkmIn items = GetItems(enumContext, offset, 0); Assert.Equal(items.Length, 0); // Request >0 items. + size++; items = GetItems(enumContext, offset, size); } @@ -191,7 +201,9 @@ internal DkmEvaluationResult[] GetChildren(DkmEvaluationResult evalResult, DkmIn internal DkmEvaluationResult[] GetChildren(DkmEvaluationResult evalResult, int initialRequestSize, DkmInspectionContext inspectionContext, out DkmEvaluationResultEnumContext enumContext) { DkmGetChildrenAsyncResult getChildrenResult = default(DkmGetChildrenAsyncResult); - _resultProvider.GetChildren(evalResult, null, initialRequestSize, inspectionContext ?? DefaultInspectionContext, r => { getChildrenResult = r; }); + var workList = new DkmWorkList(); + _resultProvider.GetChildren(evalResult, workList, initialRequestSize, inspectionContext ?? DefaultInspectionContext, r => { getChildrenResult = r; }); + workList.Execute(); var exception = getChildrenResult.Exception; if (exception != null) { @@ -204,7 +216,9 @@ internal DkmEvaluationResult[] GetChildren(DkmEvaluationResult evalResult, int i internal DkmEvaluationResult[] GetItems(DkmEvaluationResultEnumContext enumContext, int startIndex, int count) { DkmEvaluationEnumAsyncResult getItemsResult = default(DkmEvaluationEnumAsyncResult); - _resultProvider.GetItems(enumContext, null, startIndex, count, r => { getItemsResult = r; }); + var workList = new DkmWorkList(); + _resultProvider.GetItems(enumContext, workList, startIndex, count, r => { getItemsResult = r; }); + workList.Execute(); var exception = getItemsResult.Exception; if (exception != null) { diff --git a/src/ExpressionEvaluator/Core/Test/ResultProvider/ResultProviderTestUtilities.csproj b/src/ExpressionEvaluator/Core/Test/ResultProvider/ResultProviderTestUtilities.csproj index e018101ea1c..5bcd22f68a0 100644 --- a/src/ExpressionEvaluator/Core/Test/ResultProvider/ResultProviderTestUtilities.csproj +++ b/src/ExpressionEvaluator/Core/Test/ResultProvider/ResultProviderTestUtilities.csproj @@ -111,6 +111,9 @@ ResultProvider\Helpers\ArrayBuilder.cs + + ResultProvider\Helpers\DebuggerDisplayInfo.cs + ResultProvider\Helpers\DkmClrValueFlagsExtensions.cs @@ -153,6 +156,8 @@ + + @@ -183,6 +188,7 @@ + @@ -221,5 +227,4 @@ - - + \ No newline at end of file diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ResultProvider/VisualBasicFormatter.vb b/src/ExpressionEvaluator/VisualBasic/Source/ResultProvider/VisualBasicFormatter.vb index ce58d62c562..9cf736f918e 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ResultProvider/VisualBasicFormatter.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ResultProvider/VisualBasicFormatter.vb @@ -26,26 +26,23 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator staticMembersString:=Resources.SharedMembers) End Sub - Private Function IDkmClrFormatter_GetTypeName(inspectionContext As DkmInspectionContext, clrType As DkmClrType) As String Implements IDkmClrFormatter.GetTypeName + Private Function IDkmClrFormatter_GetTypeName(inspectionContext As DkmInspectionContext, clrType As DkmClrType, formatSpecifiers As ReadOnlyCollection(Of String)) As String Implements IDkmClrFormatter.GetTypeName Return GetTypeName(clrType.GetLmrType()) End Function - Private Function IDkmClrFormatter_GetUnderlyingString(clrValue As DkmClrValue) As String Implements IDkmClrFormatter.GetUnderlyingString - Return GetUnderlyingString(clrValue) + Private Function IDkmClrFormatter_GetUnderlyingString(clrValue As DkmClrValue, inspectionContext As DkmInspectionContext) As String Implements IDkmClrFormatter.GetUnderlyingString + Return GetUnderlyingString(clrValue, inspectionContext) End Function - Private Function IDkmClrFormatter_GetValueString(clrValue As DkmClrValue) As String Implements IDkmClrFormatter.GetValueString - ' TODO: IDkmClrFormatter.GetValueString should have - ' an explicit InspectionContext parameter that is not - ' inherited from the containing DkmClrValue. #1099978. - Dim options = If((clrValue.InspectionContext.EvaluationFlags And DkmEvaluationFlags.NoQuotes) = 0, + Private Function IDkmClrFormatter_GetValueString(clrValue As DkmClrValue, inspectionContext As DkmInspectionContext, formatSpecifiers As ReadOnlyCollection(Of String)) As String Implements IDkmClrFormatter.GetValueString + Dim options = If((inspectionContext.EvaluationFlags And DkmEvaluationFlags.NoQuotes) = 0, ObjectDisplayOptions.UseQuotes, ObjectDisplayOptions.None) - Return GetValueString(clrValue, options, GetValueFlags.IncludeObjectId) + Return GetValueString(clrValue, inspectionContext, options, GetValueFlags.IncludeObjectId) End Function - Private Function IDkmClrFormatter_HasUnderlyingString(clrValue As DkmClrValue) As Boolean Implements IDkmClrFormatter.HasUnderlyingString - Return HasUnderlyingString(clrValue) + Private Function IDkmClrFormatter_HasUnderlyingString(clrValue As DkmClrValue, inspectionContext As DkmInspectionContext) As Boolean Implements IDkmClrFormatter.HasUnderlyingString + Return HasUnderlyingString(clrValue, inspectionContext) End Function Friend Overrides Function IsIdentifierPartCharacter(c As Char) As Boolean diff --git a/src/ExpressionEvaluator/VisualBasic/Test/ResultProvider/ExpansionTests.vb b/src/ExpressionEvaluator/VisualBasic/Test/ResultProvider/ExpansionTests.vb index 87e9c18bb97..0273a07677d 100644 --- a/src/ExpressionEvaluator/VisualBasic/Test/ResultProvider/ExpansionTests.vb +++ b/src/ExpressionEvaluator/VisualBasic/Test/ResultProvider/ExpansionTests.vb @@ -280,8 +280,8 @@ End Class ' This Char is not printable, so we expect the EditableValue to be the "ChrW" representation. quotedChar = "ChrW(&H7)" - value = CreateDkmClrValue(ChrW(&H0007), GetType(Char), inspectionContext:=CreateDkmInspectionContext(radix:=16)) - result = FormatResult("c", value) + value = CreateDkmClrValue(ChrW(&H0007), GetType(Char)) + result = FormatResult("c", value, inspectionContext:=CreateDkmInspectionContext(radix:=16)) Verify(result, EvalResult("c", quotedChar, "Char", "c", editableValue:=quotedChar)) End Sub diff --git a/src/ExpressionEvaluator/VisualBasic/Test/ResultProvider/FormatSpecifierTests.vb b/src/ExpressionEvaluator/VisualBasic/Test/ResultProvider/FormatSpecifierTests.vb index 2f1f3f13986..a13c07dc289 100644 --- a/src/ExpressionEvaluator/VisualBasic/Test/ResultProvider/FormatSpecifierTests.vb +++ b/src/ExpressionEvaluator/VisualBasic/Test/ResultProvider/FormatSpecifierTests.vb @@ -17,44 +17,44 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Dim stringType = runtime.GetType(GetType(String)) ' Nothing - Dim value = CreateDkmClrValue(Nothing, type:=stringType, inspectionContext:=inspectionContext) - Dim result = FormatResult("s", value) + Dim value = CreateDkmClrValue(Nothing, type:=stringType) + Dim result = FormatResult("s", value, inspectionContext:=inspectionContext) Verify(result, EvalResult("s", "Nothing", "String", "s", editableValue:=Nothing, flags:=DkmEvaluationResultFlags.None)) ' "" - value = CreateDkmClrValue(String.Empty, type:=stringType, inspectionContext:=inspectionContext) - result = FormatResult("s", value) + value = CreateDkmClrValue(String.Empty, type:=stringType) + result = FormatResult("s", value, inspectionContext:=inspectionContext) Verify(result, EvalResult("s", "", "String", "s", editableValue:="""""", flags:=DkmEvaluationResultFlags.RawString)) ' "'" - value = CreateDkmClrValue("'", type:=stringType, inspectionContext:=inspectionContext) - result = FormatResult("s", value) + value = CreateDkmClrValue("'", type:=stringType) + result = FormatResult("s", value, inspectionContext:=inspectionContext) Verify(result, EvalResult("s", "'", "String", "s", editableValue:="""'""", flags:=DkmEvaluationResultFlags.RawString)) ' """" - value = CreateDkmClrValue("""", type:=stringType, inspectionContext:=inspectionContext) - result = FormatResult("s", value) + value = CreateDkmClrValue("""", type:=stringType) + result = FormatResult("s", value, inspectionContext:=inspectionContext) Verify(result, EvalResult("s", """", "String", "s", editableValue:="""""""""", flags:=DkmEvaluationResultFlags.RawString)) ' " " with alias - value = CreateDkmClrValue(" ", type:=stringType, [alias]:="1", evalFlags:=DkmEvaluationResultFlags.HasObjectId, inspectionContext:=inspectionContext) - result = FormatResult("s", value) + value = CreateDkmClrValue(" ", type:=stringType, [alias]:="1", evalFlags:=DkmEvaluationResultFlags.HasObjectId) + result = FormatResult("s", value, inspectionContext:=inspectionContext) Verify(result, EvalResult("s", " {$1}", "String", "s", editableValue:=""" """, flags:=DkmEvaluationResultFlags.RawString Or DkmEvaluationResultFlags.HasObjectId)) ' array - value = CreateDkmClrValue({"1"}, type:=stringType.MakeArrayType(), inspectionContext:=inspectionContext) - result = FormatResult("a", value) + value = CreateDkmClrValue({"1"}, type:=stringType.MakeArrayType()) + result = FormatResult("a", value, inspectionContext:=inspectionContext) Verify(result, EvalResult("a", "{Length=1}", "String()", "a", editableValue:=Nothing, flags:=DkmEvaluationResultFlags.Expandable)) Dim children = GetChildren(result) - ' TODO: InspectionContext should not be inherited. See IDkmClrFormatter.GetValueString. + ' DkmInspectionContext should not be inherited. Verify(children, - EvalResult("(0)", "1", "String", "a(0)", editableValue:="""1""", flags:=DkmEvaluationResultFlags.RawString)) + EvalResult("(0)", """1""", "String", "a(0)", editableValue:="""1""", flags:=DkmEvaluationResultFlags.RawString)) End Sub @@ -64,32 +64,32 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Dim charType = runtime.GetType(GetType(Char)) ' 0 - Dim value = CreateDkmClrValue(ChrW(0), type:=charType, inspectionContext:=inspectionContext) - Dim result = FormatResult("c", value) + Dim value = CreateDkmClrValue(ChrW(0), type:=charType) + Dim result = FormatResult("c", value, inspectionContext:=inspectionContext) Verify(result, EvalResult("c", "vbNullChar", "Char", "c", editableValue:="vbNullChar", flags:=DkmEvaluationResultFlags.None)) ' "'"c - value = CreateDkmClrValue("'"c, type:=charType, inspectionContext:=inspectionContext) - result = FormatResult("c", value) + value = CreateDkmClrValue("'"c, type:=charType) + result = FormatResult("c", value, inspectionContext:=inspectionContext) Verify(result, EvalResult("c", "'", "Char", "c", editableValue:="""'""c", flags:=DkmEvaluationResultFlags.None)) ' """"c - value = CreateDkmClrValue(""""c, type:=charType, inspectionContext:=inspectionContext) - result = FormatResult("c", value) + value = CreateDkmClrValue(""""c, type:=charType) + result = FormatResult("c", value, inspectionContext:=inspectionContext) Verify(result, EvalResult("c", """"c, "Char", "c", editableValue:="""""""""c", flags:=DkmEvaluationResultFlags.None)) ' array - value = CreateDkmClrValue({"1"c}, type:=charType.MakeArrayType(), inspectionContext:=inspectionContext) - result = FormatResult("a", value) + value = CreateDkmClrValue({"1"c}, type:=charType.MakeArrayType()) + result = FormatResult("a", value, inspectionContext:=inspectionContext) Verify(result, EvalResult("a", "{Length=1}", "Char()", "a", editableValue:=Nothing, flags:=DkmEvaluationResultFlags.Expandable)) Dim children = GetChildren(result) - ' TODO: InspectionContext should not be inherited. See IDkmClrFormatter.GetValueString. + ' DkmInspectionContext should not be inherited. Verify(children, - EvalResult("(0)", "1", "Char", "a(0)", editableValue:="""1""c", flags:=DkmEvaluationResultFlags.None)) + EvalResult("(0)", """1""c", "Char", "a(0)", editableValue:="""1""c", flags:=DkmEvaluationResultFlags.None)) End Sub End Class diff --git a/src/ExpressionEvaluator/VisualBasic/Test/ResultProvider/ObjectIdTests.vb b/src/ExpressionEvaluator/VisualBasic/Test/ResultProvider/ObjectIdTests.vb index f65a0ce1249..27484cb9d82 100644 --- a/src/ExpressionEvaluator/VisualBasic/Test/ResultProvider/ObjectIdTests.vb +++ b/src/ExpressionEvaluator/VisualBasic/Test/ResultProvider/ObjectIdTests.vb @@ -21,9 +21,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator FormatResult("i", value, objectType), EvalResult("i", "1 {$1}", "Object {Integer}", "i", DkmEvaluationResultFlags.HasObjectId)) ' Integer (hex) - value = CreateDkmClrValue(value:=2, type:=GetType(Integer), alias:="2", evalFlags:=DkmEvaluationResultFlags.HasObjectId, inspectionContext:=CreateDkmInspectionContext(radix:=16)) + value = CreateDkmClrValue(value:=2, type:=GetType(Integer), alias:="2", evalFlags:=DkmEvaluationResultFlags.HasObjectId) Verify( - FormatResult("i", value, objectType), + FormatResult("i", value, objectType, inspectionContext:=CreateDkmInspectionContext(radix:=16)), EvalResult("i", "&H00000002 {$2}", "Object {Integer}", "i", DkmEvaluationResultFlags.HasObjectId)) ' Char value = CreateDkmClrValue(value:="c"c, type:=GetType(Char), alias:="3", evalFlags:=DkmEvaluationResultFlags.HasObjectId) -- GitLab