cezarypiatek / MappingGenerator

:arrows_counterclockwise: "AutoMapper" like, Roslyn based, code fix provider that allows to generate mapping code in design time.
https://marketplace.visualstudio.com/items?itemName=54748ff9-45fc-43c2-8ec5-cf7912bc3b84.mappinggenerator
MIT License
1.03k stars 120 forks source link

Use with vs code via nuget package #83

Closed jpeg729 closed 4 years ago

jpeg729 commented 5 years ago

Now that support for roslyn analysers and code fixes has been merged into omnisharp (c.f. https://github.com/OmniSharp/omnisharp-roslyn/pull/1076) I would love to be able to use this with vs code.

Would you consider updating the nuget package?

cezarypiatek commented 5 years ago

MappingGenerator is mainly based on the code refactorings. Is it supported by VSCode?

jpeg729 commented 5 years ago

The pull request I linked to claims to support "roslyn analyzers and code fixes", which suggests that they are supported. However, I only have partial success.

Quick testing with VS Code with dotnet core 2.2 running on linux shows that I can Ctrl+. on a class name and do things like "Generate constructor" and "Generate Equals and GetHashCode...".

More quick testing shows that adding the existing version of the nuget package MappingGenerator does not enable Ctrl+. for things that I regularly do in Visual Studio with the extension. I don't know why.

So basically, maybe refactorings are supported, and if not, but they probably will be soon.

Another approach is suggested by Roslynator that has just released an extension that supports VS Code, c.f. https://marketplace.visualstudio.com/items?itemName=josefpihrt-vscode.roslynator.

cezarypiatek commented 5 years ago

Thanks for the research. The current nuget package of MappingGenerator may not be completed (I tried to make it work a while ago but I didn't finish that). I will take a look an that in the free moment.

cezarypiatek commented 5 years ago

Ok, I've updated the Nuget package. Can you verify how it works on VSCode?

jpeg729 commented 5 years ago

Thank you for your efforts, unfortunately I can't make it work on VS Code on Linux and I can't see why. I'll try on Windows tomorrow.

cezarypiatek commented 4 years ago

@jpeg729 Here's a very good description of how to use refactorings from VSIX with VSCode. Can you try it and let me know if this actually works for MappintGenerator?

https://www.strathweb.com/2017/05/using-roslyn-refactorings-with-omnisharp-and-visual-studio-code/

p3t3rix commented 4 years ago

Does this mean that the package should work as a standalone nuget package analyzer without installing it via vsix ?

cezarypiatek commented 4 years ago

Analyzers and CodeFixes should work using NuGet package. Unfortunately, code refactorings - which are used as underlying mechanisms for most of the MappingGenerator features are not supported by NuGet package (Only Rider is able to load refactorings from NugetPackage, not sure about VS - maybe they change something recently).