简体   繁体   中英

Ship Roslyn code refactoring as NuGet package

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.

目前不支持通过NuGet分发重构,但我们希望将来添加。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM