Comments (5)
There is an issue filed on YouTrack for this.
from expressiontreevisualizer.
I've written a small demo application showing how to use the UI controls outside of the VS debugger. I think creating a Rider extension would be a similar process.
from expressiontreevisualizer.
I've never used Rider, so I have no idea what are its' capabilities and extension points. But I guess you have a couple of options.
The ExpressionTreeToString package provides multiple string renderings for an expression tree, and powers the source view of the visualizer. You can get pretty close to the visualizer's information using the C# and textual tree formatters:
// using ExpressionTreeToString;
Expression<Func<int, int, string>> expr1 = (i, j) => (i + j + 5).ToString();
// C# pseudocode
Console.WriteLine(expr1.ToString("C#"));
// prints the following:
/*
(int i, int j) => i + j + 5.ToString()
*/
// prints a string with all the information in the visualizer's treeview
Console.WriteLine(expr1.ToString("Textual tree", "C#"));
/*
Lambda (Func<int, int, string>)
· Parameters[0] - Parameter (int) i
· Parameters[1] - Parameter (int) j
· Body - Call (string) ToString
· Object - Add (int)
· Left - Add (int)
· Left - Parameter (int) i
· Right - Parameter (int) j
· Right - Constant (int) = 5
*/
I imagine Rider has something like the VS Watch window? You could reference the package in your project, and at runtime call the ToString
extension method on the expression with the appropriate formatter.
If Rider allows you to import and use NuGet packages into the IDE environment only while debugging, you wouldn't have to modify your project.
To go further I have to elaborate on the visualizer architecture. For non-serializable types (like System.Linq.Expressions.Expression
) VS requires there to be 2 DLLs:
- The debuggee-side DLL is injected into the debugged process,, and generates serializable objects from the non-serializable debuggee-side objects. The serializable objects are then serialized and passed across to:
- the debugger-side DLL, loaded by VS, which then uses these objects for the visualizer UI.
For this visualizer (and other visualizers I've written), there end up being 4 components:
- Serialization model -- generated from the original expression tree, with all the information the visualizer UI requires (
Serialization
subfolder) - Debuggee-side -- the class that sends the serialization models (
Debuggee
subfolder) - UI components -- views and view-models that display the UI from the serialization models (
UI
subfolder) - Debugger-side -- requests information from the debuggee-side, in this case, the serialization models (
Visualizer
subfolder)
I imagine Rider has a similar architecture for extending the IDE while in a debugging session. We'd need to
- replace the debuggee-side DLL with whatever mechanism Rider uses to get information from the debuggee side, and
- replace the debugger-side DLL with whatever mechanism is used by Rider to display dialogs/views while debugging.
If Rider supports opening a WPF window on the IDE side, then the serialization model and UI components can be reused independent of Visual Studio as is; and they are available as a NuGet package.
If Rider doesn't support opening a WPF window, I imagine quite a bit more work would be involved -- the entire UI would have to be recreated in whatever UI framework Rider does support.
(I apologize for the length; I'm trying to give a comprehensive response.)
Addenda
Image from John M. Wrightly's series on writing debugging visualizers:
How the various components are split between packaged DLLs:
from expressiontreevisualizer.
@maurei Do you have any further thoughts on this?
from expressiontreevisualizer.
Hey @zspitz thanks for the thorough elaboration. I will be getting back at this soon!
from expressiontreevisualizer.
Related Issues (20)
- Please consider of adding a link to released zip files in README HOT 2
- consider creating a REAL extension for VS instead of a crappy installer HOT 2
- Installer
- An unhandled exception of type 'System.Runtime.Serialization.SerializationException' HOT 10
- Consider adding an additional cast for leaf properties
- Toggle source textbox wrapping HOT 1
- Could not load file or assembly 'System.Runtime, Version=4.2.0.0' or one of its dependencies HOT 7
- Label navigation
- "Could not load System.Runtime or one of its dependencies" HOT 5
- Exception in use HOT 4
- "Sequence contains more than one matching element." when switching from DebugView to C# HOT 2
- Handle reducible nodes HOT 1
- Show DLR documentation for a specific expression type / node type
- I've installed it, but how can I use it? HOT 3
- Likely installation error, but visualizer constantly throws exception HOT 3
- Create a LINQPad custom visualizer HOT 1
- Visualizer does not show expression for EF Core 5 on .NET 5 HOT 5
- KeyNotFoundException when opening visualizer HOT 2
- Visualizer does not work in VS 2022
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from expressiontreevisualizer.