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.96k stars 4.03k forks source link

need some more documentation about source generators #55753

Open MithrilMan opened 3 years ago

MithrilMan commented 3 years ago

Source Generators is an easy concept to understand but it relies on Roslyn knowledge to be used properly

There is little documentation about source generators and lot of concepts are given for granted. Cookbook is a nice idea but suffers the same problem (concepts given for granted) and little use cases especially for who's not into roslyn details and wants to learn.

An example of missing (and quite common) topics are

Also would be nice to have a glossary of common terms somewhere, to explain concepts as Symbol, Token, etc.. (or a link to a document that explains that)

Source Generators are really cool, but to be adopted, more specific documentation should be available. Source Generators can attract generic developers without prior roslyn knowledge, and then they hit the wall of "missing knowledge" without a path to fill the gaps.

(I could extend this issue including some topics that would be nice to be shown in cookbook too)

jcouv commented 3 years ago

Here's the documentation we have so far:

FYI for @chsienki in case above topics not covered by existing documentation.

Youssef1313 commented 3 years ago

@jcouv There is also https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview.

I think that's the one we should update as it's intended to be more beginner friendly and more of a "step-by-step tutorial"

@jcouv @mikadumont Do you think this should move to dotnet/docs?

Youssef1313 commented 3 years ago

Also note that some of the questions aren't specific to source generators, but "how to do X using Roslyn APIs" generally, which may be useful in https://github.com/dotnet/docs/tree/main/docs/csharp/roslyn-sdk/tutorials. But it needs some planning regarding what articles should be included and how to organize them to cover different conceptual information.

jcouv commented 3 years ago

Tagging @BillWagner for question on what source generator docs should be on dotnet/docs versus in roslyn repo.

BillWagner commented 3 years ago

Adding @mikadumont and @jmarolf who had been planning the docs for source generators.

MithrilMan commented 3 years ago

Except the link to roslyn specific documentations which I will read soon, I have read other related documents already, unfortunately as said there is not much support for newcomers,

I think would be nice to put links to specific roslyn stuff if that makes sense, maybe at the bottom of https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview

kjkrum commented 2 years ago

The examples in incremental-generators.md use C# 9 features like static anonymous functions. I know there are hacks to use higher language versions in netstandard2.0 projects. If it's assumed that the reader is hacking their language version, perhaps it's worth mentioning and linking to a recommended way of doing it.