This project is read-only.

Roslyn Code-Fix Patterns Tool

Topics: General
Apr 4, 2014 at 4:03 PM
Edited Apr 4, 2014 at 4:07 PM

Roslyn Code-Fix Patterns Tool

Engineering a compiler of programming language is rather complex.
But recognising "Code Smell" is relatively simple.

There should be a mechanism to match a pattern of code, at the text of the code level (not semantic level).

Original (Code Smell of VB6)
Dim myVarible As Integer
myVarible = 123
Dim myVariable As Integer = 123

Roslyn Code-Fix Pattern

There two parts to this the pattern and the patch.

This is the pattern of code to look for.
Dim %{0 : Identifier} As %{1 : TypeDeclaration}
%{0 : Identifier} = %{2}
This is the transformed should look like.
Dim ${0} As %{1} = %{2}
These two parts get compiled into Roslyn code suggestion code. Another option would be to produce a code suggestion project with the code generated that match this pattern, so further analysis can be done on it.

Writing a code fix is very similar to the code you already write. Almost like "Macros" in Nemerle.
Apr 4, 2014 at 7:23 PM
you can achieve similar effect using our user diagnostic API and code fixer API.
Marked as answer by Pilchie on 4/5/2014 at 7:32 AM
Apr 6, 2014 at 4:10 AM
Yes I know but it's a bit convoluted when we could exploit the complier (tweaked) itself to help us.
Like I you saying "Why use an IDE when you've got Notepad and the Command Line?"