Open Logerfo opened 7 years ago
It's a good idea -- something I looked at before, but it turned out to be quite hard to do properly. I'll give it another try, but can't promise any specific timeline at the moment.
I think you should be able to use the code from RoslynQuoter to do this:
https://github.com/KirillOsenkov/RoslynQuoter/blob/master/src/Quoter/Quoter.cs
This would be a big time-saver! Even better if I can select a subnode to generate since I'll almost never want to see the generation code for the whole class.
Sorry for bumping, but has there been any progress on this?
No problem -- I haven't worked on it for a while, but don't mind taking another look. Though I haven't done any SharpLab work for a month or so, so there are no specific time guarantees for this.
I think for both issues you've faced previously we can have solutions now. The perf issue has been fixed because we now no longer call into C# scripting at all, but instead interpret the syntax tree. And it was used for validation only, so the part that used to run scripting (or now runs interpretation) could be turned off entirely.
Also support for new language features could be approximated by periodically bumping the RoslynQuoter NuGet package (as I am periodically updating to latest Roslyn). I think if a language feature is not supported you could just catch the exception and display a message that the feature is not supported.
I think it would be valuable to be able to show quoter in most cases even though we can't support all language features. 95% supported cases is still better than 0%.
Of course I could help if you run into any difficulties, just reach out to me.
Disclaimer: in no way you should view this as request for more work. I know you're busy so this is just to say that if you do decide to work on this anyway it'll be easier because I can help.
Thanks!
I've just published the latest version here: https://www.nuget.org/packages/RoslynQuoter/1.0.1
@KirillOsenkov Thanks! I am keen to try it out, but I am currently wrapping up some large/interesting improvement around containers, I'll try to look after that. I think we can live without support for latest language features in the initial version, as long as performance is OK.
As SharpLab already has Syntax Tree result viewing, I presume it would not be hard to implement an option to show the API calls to construct the Syntax Tree, just like RoslynQuoter does. That would make even easier to write analyzers code fixes.