ashmind / SharpLab

.NET language playground
https://sharplab.io
BSD 2-Clause "Simplified" License
2.72k stars 199 forks source link

SharpLab IO Plugin for jetbrains rider or visual studio #796

Open rollsch opened 3 years ago

rollsch commented 3 years ago

Has anyone ever developed a plugin like the "IL Viewer" for jetbrains Rider which utilises sharplab?

I constantly paste code back and forth when optimising code and I think a plugin would be extremely useful. I also use dnspy on my built DLLs when the code is not trivial to paste into sharplab.

It might not even be that difficult to develop. Id consider contributing if someone here has jetbrains plugin development experience.

Here is how the IL Viewer looks currently.

image

ashmind commented 3 years ago

Thanks for the suggestion! This can be done, but my previous experience with VS extensions wasn't very positive (always large effort for initial investigation work and then large effort for maintenance work between versions). Not sure if Rider experience is better, hopefully so.

It is more likely that I look into integrating into something like GitHub Codespaces, which is already online -- but I haven't had a chance to do any investigation for that yet.

madskristensen commented 2 years ago

I would love to help and build this extension for Visual Studio. The only thing I need is SharpLab in a consumable form such as a .dll I can call to retrieve the disassembly from any c# string I pass to it.

ashmind commented 2 years ago

@madskristensen That would be great!

To clarify the approach: I can do string-to-string, but in VS context you might have the Compilation object already with the correct references and options -- would it be better to pass in some parts of Roslyn object model instead of a string? E.g. a Compilation and a root SyntaxNode for the segment you want to decompile?

Btw your editorconfig extension was one of the most essential extensions I used to rely on everyday (until VS integrated some of the support). Also used to rely on the web essentials ones very actively. Thanks for those!

madskristensen commented 2 years ago

@ashmind I must admit that I don't know how your websites works and how Roslyn is involved. What I was thinking about from a user scenario perspective is that they can see the disassembly in realtime'ish updating as they type in the .cs file in VS.

@sharwell, is there a way a (MEF) extension can access the Compilation object and a root SyntaxNode from any open .cs file?

sharwell commented 2 years ago

Something like this works:

https://github.com/tunnelvisionlabs/InheritanceMargin/blob/7c3ebf3d71d0185d8b6f74a4b4c1c99f3f9217e6/Tvl.VisualStudio.InheritanceMargin.CSharp/CSharpInheritanceAnalyzer.cs#L460-L472

ashmind commented 2 years ago

Thanks! What's the current target framework requirement for VS extensions?

madskristensen commented 2 years ago

It can do up to .NET Framework 4.8

ashmind commented 2 years ago

Hmm, SharpLab does have a .NET Framework version but that's in maintenance mode rather than being actively updated. Though feature set is still close enough, and it's not like there is an alternative anyways, so I'll use that.

ShreyasJejurkar commented 2 years ago

Tagging @EgorBo here, because his extension does the same thing, but needs a runtime repo source code built!

Hookyns commented 1 year ago

I'm using JetBrains Rider everyday, I know about the integrated IL Viewer, I use it, but I just found out there is a control to select "level"; this option must be new IMO.

image