dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.74k stars 3.99k forks source link

[Feature] Distribute code snippets with nuget package #33146

Open nkolev92 opened 5 years ago

nkolev92 commented 5 years ago

From @CodeTherapist on February 1, 2019 15:56

Similar how we can today distribute a msbuild task per nuget package, We could distribute code snippet(s) with a nuget package. When a nuget package is referenced in a project that contains snippets, they become available for the specific project.

This feature would enable library authors to provide useful code fragments that are common with the usage of the library. For example:

image

The internal structure of the nuget package

image

I'm not sure if my suggestion is feasible and in the correct repository here. Some aspects of the feature are related to Roslyn and Visual Studio.

Copied from original issue: NuGet/Home#7758

nkolev92 commented 5 years ago

From @dfkeenan on February 2, 2019 15:45

I think this is a great idea. I would also like to be able to distribute item templates this way.

nkolev92 commented 5 years ago

From @CodeTherapist on February 4, 2019 8:10

@dfkeenan Item templates can be distributed as a nuget packages, see the docs.

nkolev92 commented 5 years ago

@CodeTherapist Thanks for creating this issue.

The snippets are not usually project or solution specific. They are user specific, and the IDE team already has a recommended way of distributing them through VSIXs. See https://docs.microsoft.com/en-us/visualstudio/ide/how-to-distribute-code-snippets?view=vs-2017.

I'd suggest that the discussion starts on that end, and then involve NuGet. I'm not sure the IDE would be able to handle project specific snippets at all (it might be a large architectural change on their end).

I'd recommend starting with dotnet/roslyn.

@CodeTherapist If you want, I can move this issue for you there.

nkolev92 commented 5 years ago

From @dfkeenan on February 5, 2019 8:12

I thought those templates were for projects/solutions not items. Besides I don't want to use the command line to add a new file to a project. Ideally from Visual Studio I could add a NuGet package then using the Add New Item dialog choose a file I wan to add.

nkolev92 commented 5 years ago

From @CodeTherapist on February 5, 2019 11:1

@nkolev92 Thanks for reviewing my issue - yes please, you can move it.

theresia-tobii commented 1 year ago

This would be very nice!

HowardvanRooijen commented 1 year ago

We've absolutely love this feature too. We have lots of OSS projects which layer up architectural patterns, but would love to also be able to include snippets as the "instruction manual" to easily deliver that pit of quality experience for consumers.

dameng324 commented 6 months ago

any progress on it?

CyrusNajmabadi commented 6 months ago

I'm not really sure why this is on Roslyn. We don't own anything in the packaging/project space. If you wanted to include snippets in a package as the "instruction manual", we wouldn't really have anything to do with that.