Can I write a resharper plugin to reorganize a custom DSL that generates C # code

Say for example I have a yaml file

immutable_class: Foo
  A: int
  B: string

which according to the alleged rule MSBUILD will generate

partial class Foo {

    public int A { set ; private get; }
    public string B { set; private get; }

    private Foo(){}

    public static Foo Default = new Foo(); 

    public Foo SetA(int value){
        var r = (Foo) this.Clone();
        r.A = value;    
        return r;
    }  

    public Foo SetB(string value){
        var r = (Foo) this.Clone();
        r.B = value; 
        return r;   
    }                  
}

now somewhere in my source code I will have

Foo foo = Foo.Default;
foo = foo
    .SetA(1)
    .SetB("Hello");

var tmp = foo.B;

Now I say resharper, I want the refactoring to rename B , and the plugin will recognize that the source of this property is DSL, which generates a class and refactors this DSL accordingly. Suppose I have tools for actually refactoring DSL when I was called with the correct information.

Is the Resharper API open enough to do such things?

+4
1

API ReSharper , .

yaml. , B node # B node yaml. ReSharper "B" .

( ​​ , , . , Foo.B, B yaml, Foo.SetB? , , yaml B Foo.SetB, B SetB. , Foo.SetB? , . , yaml #)

ReSharper - , (, , , ..). devguide, :

+2

Source: https://habr.com/ru/post/1540121/


All Articles