Roslyn: C# Syntax Explainer Tool

Created on 19 Apr 2020  路  4Comments  路  Source: dotnet/roslyn

C# has become very complex and it can be difficult to keep up with all of the new features and syntax changes.
Examples

  • The question mark is used in many different ways and is part of a number of different operators.
  • There are multiple ways to accomplish the same task using different syntax which can make it difficult to read code that uses a different coding style than you do.

When reading code sometimes I have to stop and look up the syntax of the code I am reading in order to understand what it is doing.

Looking up syntax via a web search can be challenging, particularly if you don't know the name of the operator or feature you are trying to understand, which you probably don't or you wouldn't be looking it up.

It would be helpful to have a tool that I could copy and paste code into that would analyze the code and provide an explanation of the syntax being used along with links to the full documentation for each syntactical element or language feature.

This tool could be incorporated into Visual Studio
Example: Select some code and select a popup option to explain the code syntax.

Need to have an option outside of Visual Studio too for folks using other editors and also for reading code on github or in an article.

Area-IDE Feature Request Need Design Review

Most helpful comment

There's this explainer that is used in https://sharplab.io

All 4 comments

This really isn't the right repository for this proposal as it doesn't involve making changes to the language itself. Such a tool could be built using the Roslyn compiler and examining the syntax trees, so that repository is probably a better match, although it doesn't sound like it'd be a part of Roslyn either.

There's this explainer that is used in https://sharplab.io

I'm going to start by moving this to roslyn and seeing if the IDE team has any ideas.

Thank you @orthoxerox! The Explainer output option in the SharpLab tool you linked is exactly what I am looking for. Having something like this built into Visual Studio would be beneficial as well.

Was this page helpful?
0 / 5 - 0 ratings