diff --git a/.gitignore b/.gitignore index 5fb1efe..8076852 100644 --- a/.gitignore +++ b/.gitignore @@ -266,3 +266,4 @@ _* # neither should the solution that references them /ExpressionTreeVisualizer.Dev.sln +/PostBuild diff --git a/Debuggee/Debuggee.csproj b/Debuggee/Debuggee.csproj index 1c86f40..4412a7e 100644 --- a/Debuggee/Debuggee.csproj +++ b/Debuggee/Debuggee.csproj @@ -2,7 +2,7 @@ net472;netstandard2.0;netcoreapp2.0 - ExpressionTreeVisualizer.Serialization + ExpressionTreeVisualizer.Debuggee ExpressionTreeVisualizer.Debuggee 8.0 enable @@ -28,8 +28,8 @@ - - + + ..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.DebuggerVisualizers.dll false @@ -40,9 +40,7 @@ - + diff --git a/Package/Package.csproj b/Package/Package.csproj index 46fd1c6..5d11ed6 100644 --- a/Package/Package.csproj +++ b/Package/Package.csproj @@ -27,10 +27,10 @@ - + - - + + diff --git a/PostBuild/PostBuild.csproj b/PostBuild/PostBuild.csproj deleted file mode 100644 index b3bb340..0000000 --- a/PostBuild/PostBuild.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - netstandard2.0 - OnBuildSuccess - - - - - - - - - - diff --git a/Serialization/ExpressionNodeData.cs b/Serialization/ExpressionNodeData.cs index 45ff250..e01be65 100644 --- a/Serialization/ExpressionNodeData.cs +++ b/Serialization/ExpressionNodeData.cs @@ -13,6 +13,7 @@ using System.Collections; using ZSpitz.Util; using static ZSpitz.Util.Functions; +using ExpressionTreeToString; namespace ExpressionTreeVisualizer.Serialization { [Serializable] @@ -64,16 +65,18 @@ public class ExpressionNodeData { public string[] FactoryMethodNames => _factoryMethodNames; - internal ExpressionNodeData(object o, (string aggregatePath, string pathFromParent) path, VisualizerData visualizerData, Dictionary pathSpans, bool isParameterDeclaration = false, PropertyInfo? pi = null, string? parentWatchExpression = null) : + internal ExpressionNodeData(object o, (string aggregatePath, string pathFromParent) path, VisualizerData visualizerData, ValueExtractor valueExtractor, Dictionary pathSpans, bool isParameterDeclaration = false, PropertyInfo? pi = null, string? parentWatchExpression = null) : this( o, path, visualizerData.Config.Language, + valueExtractor, pathSpans, isParameterDeclaration, pi, parentWatchExpression ) { } private ExpressionNodeData( object o, (string aggregatePath, string pathFromParent) path, string language, + ValueExtractor valueExtractor, Dictionary pathSpans, bool isParameterDeclaration = false, PropertyInfo? pi = null, string? parentWatchExpression = null ) { var (aggregatePath, pathFromParent) = path; @@ -107,32 +110,28 @@ private ExpressionNodeData( Closure = expressionType.Name; } - object? value = null; + var (evaluated, value) = valueExtractor.GetValue(expr); + if (evaluated) { + StringValue = StringValue(value!, language); // TODO value is allowed to be null + EnableValueInNewWindow = value is { } && value.GetType().InheritsFromOrImplementsAny(NodeTypes); + } // fill StringValue and EndNodeType properties, for expressions switch (expr) { case ConstantExpression cexpr when !cexpr.Type.IsClosureClass(): - value = cexpr.Value; EndNodeType = Constant; break; case ParameterExpression pexpr1: EndNodeType = Parameter; break; case Expression e1 when expr.IsClosedVariable(): - value = expr.ExtractValue(); EndNodeType = ClosedVar; break; case DefaultExpression defexpr: - value = defexpr.ExtractValue(); EndNodeType = Default; break; } - if (value != null) { - StringValue = StringValue(value, language); - EnableValueInNewWindow = value.GetType().InheritsFromOrImplementsAny(NodeTypes); - } - break; case MemberBinding mbind: NodeType = mbind.BindingType.ToString(); @@ -197,7 +196,7 @@ private ExpressionNodeData( .Where(x => x.x != null) .SelectT((relativePath, o1, prp) => new ExpressionNodeData( o1, (FullPath ?? "", relativePath), - language, pathSpans, + language, valueExtractor, pathSpans, false, prp, WatchExpressionFormatString)) .ToList(); diff --git a/Serialization/VisualizerData.cs b/Serialization/VisualizerData.cs index 539c9fc..6cb9a6b 100644 --- a/Serialization/VisualizerData.cs +++ b/Serialization/VisualizerData.cs @@ -18,7 +18,9 @@ public VisualizerData(object o, Config? config = null) { o = ((Expression)ResolvePath(o, Config.Path)).ExtractValue(); } Source = WriterBase.Create(o, Config.Formatter, Config.Language, out var pathSpans).ToString(); - Root = new ExpressionNodeData(o, ("", ""), this, pathSpans, false); + + var valueExtractor = new ValueExtractor(); + Root = new ExpressionNodeData(o, ("", ""), this, valueExtractor, pathSpans, false); } } } diff --git a/Tests.Visualizer/Tests.csproj b/Tests.Visualizer/Tests.csproj index ecdde9a..7c365e2 100644 --- a/Tests.Visualizer/Tests.csproj +++ b/Tests.Visualizer/Tests.csproj @@ -9,14 +9,14 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Visualizer/Visualizer.csproj b/Visualizer/Visualizer.csproj index 60c74eb..d0e654c 100644 --- a/Visualizer/Visualizer.csproj +++ b/Visualizer/Visualizer.csproj @@ -16,12 +16,12 @@ ..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.DebuggerVisualizers.dll false - + - - + + diff --git a/appveyor.yml b/appveyor.yml index 31ef1aa..c5436c3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,7 +14,6 @@ only_commits: - Serialization/ - UI/ - Visualizer/ - - Visualizer.Xaml/ - appveyor.yml dotnet_csproj: