Creating AST "Source" and "View" Files via ReSharper

Hello Community,

With the advent of Roslyn, it is now possible to think in ASTs and capturing them into source files.  The advantage of this is that the AST files (or .ast file) would be the "source" file, and the developer would then load a "view" of this file based on their formatting preferences.

This would solve the problem of each team member constantly reformatting files to their preferred method of formatting files.  In addition, this would remove all (frustrating and conflicting) discussions (or arguments) over the "best" style for code.

I have created a Visual Studio vote for this idea here:

However, I am very aware that ReSharper doesn't support Roslyn, nor does it plan to for the foreseeable future.  My thought is that maybe JetBrains could also introduce this idea (and probably better and faster than the Visual Studio team, based on history :)), so I wanted to open a discussion here with the community to guage viablity and/or interest.

Any feedback/discussion would be greatly appreciated.

Thank you,

Comment actions Permalink

Since posting this idea, there has been some good feedback around it, and it turns out that there really isn't the need for a dedicated .ast files, but really just the idea of a "source" file and a "view file" (as the title suggests).

The "source" file could be a .cs file that is formatted to be 100% StyleCop-compliant (strict, by default).  This is what is checked into source control.  The formatting settings of this could of course be customized by a team/organization.

Upon loading the "source" file, ReSharper would then build an AST from it, and then create a "view" file that is the formatted AST based on the developer's formatting preferences and rules.  This file would then be stored locally in the user's cache (or better yet their OneDrive/GDrive, based on configuration -- so it could conceivably be used across multiple machines) and would represent the view of the source file as seen by the developer.

Whenever the developer saves the "view" file, ReSharper would then attempt to build an AST from it and then save it back to the "source" file.

That's pretty much the idea here.  It would be even better to provide an API to allow developers to create their own formatting concepts/rules and add them to their formatting preferences.  An example of something like this would be a private-field tuck rule (which is sadly still not possible with ReSharper, but this would make it a snap):

Of course, developers also get their preferred way of naming symbols, such as "_" and even "m_" if they wanted to (or heck, even hungarian notation!).  Since it's based off an AST with a given base-symbol name, anything is possible. :)

Thank you for any consideration/feedback/discussion!

Comment actions Permalink

*please delete*          

Comment actions Permalink

This would be a great way to prove (yet again) that JetBrains has a better handle on .NET AST's than Visual Studio does...  #justsayin B-)

Comment actions Permalink

The kind folks at ReSharper have created an issue for this in awesome issue tracker.  Please vote!!!


Please sign in to leave a comment.