OmniSharp / omnisharp-server

HTTP wrapper around NRefactory allowing C# editor plugins to be written in any language.
http://www.omnisharp.net
MIT License
380 stars 97 forks source link

Refactor create property #223

Open jamlen opened 7 years ago

jamlen commented 7 years ago

I'm on day one of using OmniSharp but once I got it running in Spacemacs (via omnisharp-emacs), the result of a refactor (omnisharp-run-code-action-refactoring) was not what I was expecting.

Given this:

public class MyType
{
  public string Name { get; set; }
}

var a = new MyType
  {
    Name = "Talula",
    NewField = 1234  // <- Refactor create property
  };

I was expecting:

public class MyType
{
  public string Name { get; set; }
  int NewField { get; set; }
}

var a = new MyType
  {
    Name = "Talula",
    NewField = 1234
  };

But what I got was:

public class MyType
{
  public string Name { get; set; }
}

int NewField
{
  get; 
  set;
}

var a = new MyType
  {
    Name = "Talula",
    NewField = 1234
  };
nosami commented 7 years ago

Think you are using omnisharp-server backend here based on NRefactory. There is a newer backend (omnisharp-roslyn) but I don't think omnisharp-emacs supports it. Most of the omnisharp-roslyn backend will work with master omnisharp-emacs (with the exception of refactorings!! - the API changed)

There is a branch here https://github.com/OmniSharp/omnisharp-emacs/tree/feature-omnisharp-roslyn-support but I don't think it was ever finished. Not sure what state this branch is in.

If that doesn't work for you, you're probably SOL unless you want to get your hands dirty. The omnisharp-emacs author (@sp3ctum) doesn't work on the project any more.

mikavilpas commented 7 years ago

Hi, I can confirm what @nosami said. I've been putting off laying the project off my shoulders for way too long now. I'll add something to the readme files to make it official.