SourceGenerator.Foundations
0.1.0
See the version list below for details.
dotnet add package SourceGenerator.Foundations --version 0.1.0
NuGet\Install-Package SourceGenerator.Foundations -Version 0.1.0
<PackageReference Include="SourceGenerator.Foundations" Version="0.1.0" />
paket add SourceGenerator.Foundations --version 0.1.0
#r "nuget: SourceGenerator.Foundations, 0.1.0"
// Install SourceGenerator.Foundations as a Cake Addin #addin nuget:?package=SourceGenerator.Foundations&version=0.1.0 // Install SourceGenerator.Foundations as a Cake Tool #tool nuget:?package=SourceGenerator.Foundations&version=0.1.0
SourceGenerator.Foudations
Source Generators are awesome but working with them can be a bit painful. This library is designed to try to smooth out some of the following bumps.
Nuget Nightmares
Source generators run in a unique place and their references don't act the same. If you have a source generator that attempts to reference a NuGet package it will fail to be found at runtime. The reason is the source generators need to have their dll's alongside the running process but that also means that the project the generator is running aginst will to. If you look online the best option is to do this:
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" GeneratePathProperty="true" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="$(PKGNewtonsoft_Json)\lib\netstandard2.0\Newtonsoft.Json.dll" Visible="false" />
</ItemGroup>
This MSBuild logic adds a reference to Newtonsoft.Json
version 13.0.1
and sets a few attributes. Using GeneratePathProperty="true"
will emit the variable PKGNewtonsoft_Json
which points at the root of the NuGet package on dis. Using EmbeddedResource
we then give the full path to the dll. When the project is compiled the dlls will be embeded as a resource.
This works well but requires a lot of boilerplate. Even worse is this is just for one package. You would need to repeat this for every dependency and any transitive ones as well. This gets out of hand very fast.
Source.Generator foundations automates this all for you. Just add your NuGet references and nothing else
Logging
Source generator run in the background and it can be very hard to debug. If you want to make a log you have to write the files to disk and open to read them.
With this library we leverage the existing Output window and create an entry for each source generator. This is all done by using some Visaul Studio api.
Debugging
To be able to debug a source generators one of the suggested methods is to add the following.
static CustomSourceGenerator()
{
Debugger.Launch();
}
This will popup the following window and you have to select your visual studio instance. Instaed with foundations you can just call a single method and break points work from that point on.
How it works
SourceGenerator.Foundations is a source generator for source generators. It embed addtional code to provide all the features above.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SourceGenerator.Foundations:
Package | Downloads |
---|---|
ResourceIndex.Generator
Package Description |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on SourceGenerator.Foundations:
Repository | Stars |
---|---|
AssetRipper/AssetRipper
GUI Application to work with engine assets, asset bundles, and serialized files
|
Version | Downloads | Last updated |
---|---|---|
2.0.13 | 2,048 | 1/5/2025 |
2.0.12 | 115 | 1/3/2025 |
2.0.11 | 152 | 12/31/2024 |
2.0.10 | 136 | 12/30/2024 |
2.0.9 | 642 | 12/23/2024 |
2.0.8 | 362 | 12/9/2024 |
2.0.7 | 98 | 12/9/2024 |
2.0.6 | 315 | 7/28/2024 |
2.0.5 | 93 | 7/27/2024 |
2.0.4 | 349 | 6/21/2024 |
2.0.3 | 309 | 5/13/2024 |
2.0.3-PullRequest0018.5 | 71 | 5/13/2024 |
2.0.3-PullRequest0018.4 | 56 | 5/13/2024 |
2.0.3-multi-nuget.4 | 73 | 3/14/2024 |
2.0.3-multi-nuget.1 | 59 | 3/14/2024 |
2.0.3-ci.1 | 61 | 4/28/2024 |
2.0.2 | 182 | 3/10/2024 |
2.0.2-PullRequest0015.4 | 60 | 3/10/2024 |
2.0.2-GeneratorDiagnosticAn... | 57 | 3/10/2024 |
2.0.2-GeneratorDiagnosticAn... | 59 | 3/10/2024 |
2.0.2-GeneratorDiagnosticAn... | 64 | 3/10/2024 |
2.0.2-GeneratorDiagnosticAn... | 62 | 3/10/2024 |
2.0.2-ci.5 | 63 | 3/10/2024 |
2.0.1 | 547 | 2/21/2024 |
2.0.0 | 151 | 2/17/2024 |
1.5.4-PullRequest0014.4 | 62 | 2/17/2024 |
1.5.4-hoist-pattern.7 | 68 | 2/21/2024 |
1.5.4-hoist-pattern.6 | 66 | 2/20/2024 |
1.5.4-hoist-pattern.5 | 73 | 2/19/2024 |
1.5.4-hoist-pattern.4 | 68 | 2/17/2024 |
1.5.4-hoist-pattern.3 | 69 | 2/17/2024 |
1.5.4-ci.5 | 69 | 2/17/2024 |
1.5.3 | 138 | 2/13/2024 |
1.5.3-ci.1 | 71 | 2/13/2024 |
1.5.2 | 132 | 1/31/2024 |
1.5.2-polyfills.4 | 140 | 1/27/2024 |
1.5.2-polyfills.1 | 66 | 1/24/2024 |
1.5.2-ci.5 | 65 | 1/31/2024 |
1.5.1 | 117 | 1/21/2024 |
1.5.1-rc.1 | 62 | 1/21/2024 |
1.4.1 | 212 | 11/17/2023 |
1.4.0 | 143 | 11/17/2023 |
1.3.1 | 135 | 11/16/2023 |
1.2.5 | 161 | 11/13/2023 |
1.2.4 | 198 | 11/12/2023 |
1.2.3 | 315 | 11/2/2023 |
1.2.1 | 168 | 10/29/2023 |
1.2.0 | 140 | 11/12/2023 |
1.1.3 | 194 | 11/6/2023 |
1.1.1 | 91 | 3/7/2023 |
1.0.0 | 266 | 2/17/2023 |
0.1.0 | 92 | 10/26/2022 |