mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-08 03:27:04 +09:00
Add nullable reference type annotations to System.Text.Json source gen (#79613)
* Add nullability annotaitons to sourcegen components. * Move sourcegen testing from Roslyn4.0 to Roslyn4.4. * Fix accessibility modifiers * Allow source generators to multi-target * Binplace only netstandard2.0 compiled source generators * Use live NetCoreAppCurrent tfm * Update Directory.Build.targets * Pick correct analyzer asset for consumption * Fix build * Revert "Move sourcegen testing from Roslyn4.0 to Roslyn4.4." This reverts commit fe7857066040ddf0ef632c135e83e49b097c28f7. * Make analyzer P2Ps choose the right asset * PR feedback * Update src/libraries/System.Text.Json/gen/JsonSourceGenerator.Parser.cs * Make source generator target an LKG * Update project-guidelines.md Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
This commit is contained in:
parent
a53c6adf16
commit
97a51ccdb1
32 changed files with 278 additions and 225 deletions
|
@ -190,6 +190,8 @@ All test outputs should be under
|
|||
In the gen directory any source generator related to the assembly should exist. This does not mean the source generator is only used for that assembly only that it is conceptually apart of that assembly. For example, the assembly may provide attributes or low-level types the source generator uses.
|
||||
To consume a source generator, simply add a `<ProjectReference Include="..." ReferenceOutputAssembly="false" OutputItemType="Analyzer" />` item to the project, usually next to the `Reference` and `ProjectReference` items.
|
||||
|
||||
A source generator must target `netstandard2.0` as such assemblies are loaded into the compiler's process which might run on either .NET Framework or modern .NET depending on the tooling being used (CLI vs Visual Studio). While that's true, a source project can still multi-target and include `$(NetCoreAppToolCurrent)` (which is the latest non live-built .NETCoreApp tfm that is supported by the SDK) to benefit from the ehancanced nullable reference type warnings emitted by the compiler. For an example see [System.Text.Json's roslyn4.4 source generator](/src/libraries/System.Text.Json/gen/System.Text.Json.SourceGeneration.Roslyn4.4.csproj). While the repository's infrastructure makes sure that only the source generator's `netstandard2.0` build output is included in packages, to consume such a multi-targeting source generator via a `ProjectReference` (as described above), you need to add the `ReferringTargetFramework=netstandard2.0` metadata to the ProjectReference item to guarantee that the netstandard2.0 asset is chosen.
|
||||
|
||||
## Facades
|
||||
Facade are unique in that they don't have any code and instead are generated by finding a contract reference assembly with the matching identity and generating type forwards for all the types to where they live in the implementation assemblies (aka facade seeds). There are also partial facades which contain some type forwards as well as some code definitions. All the various build configurations should be contained in the one csproj file per library.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue