Ship Roslyn code refactoring as NuGet package

僤鯓⒐⒋嵵緔 提交于 2019-12-12 13:53:33

问题


When installing the .NET Compiler Platform SDK you get Visual Studio templates for creating an "Analyzer with Code Fix (NuGet + VSIX)" and a "Code Refactoring (VSIX)".

Why isn't there a template for shipping a code refactoring with NuGet (like "Code Refactoring (NuGet + VSIX)")?
Is it even possible to add a code refactoring provider from a NuGet package (by creating the NuGet package manually)?
Doesn't it make sense to install a code refactoring provider on a project per project basis?

EDIT: My use case is a code refactoring that generates a C# type out of untyped data (like JSON). This is basically what F# type providers are (although they are much more powerful of course). This means that the user creates a class like the following

[JsonProvider("http://example.com/data.json")]
public class ExampleData
{
}

and the refactoring fills it with properties from the sample data it fetched from the url in the attribute:

[JsonProvider("http://example.com/data.json")]
public class ExampleData
{
    public string Property1 { get; private set; }
    public int Property2 { get; private set; }

    public void Load(Uri uri) { ... }
    public void FromData(string data) { ... }
    ...
}

The reason I don't want to create an analyzer is because the user should be able to decide when to update the C# type. Because I don't really know when the data the URL points to is changing. And I don't want to annoy the user with a squiggly line that she can't get rid of.


回答1:


Distributing refactorings via NuGet is not currently supported, but is something we would like to add in the future.



来源:https://stackoverflow.com/questions/33118238/ship-roslyn-code-refactoring-as-nuget-package

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!