Dosaic.Hosting.Generator
1.2.9
dotnet add package Dosaic.Hosting.Generator --version 1.2.9
NuGet\Install-Package Dosaic.Hosting.Generator -Version 1.2.9
<PackageReference Include="Dosaic.Hosting.Generator" Version="1.2.9" />
<PackageVersion Include="Dosaic.Hosting.Generator" Version="1.2.9" />
<PackageReference Include="Dosaic.Hosting.Generator" />
paket add Dosaic.Hosting.Generator --version 1.2.9
#r "nuget: Dosaic.Hosting.Generator, 1.2.9"
#:package Dosaic.Hosting.Generator@1.2.9
#addin nuget:?package=Dosaic.Hosting.Generator&version=1.2.9
#tool nuget:?package=Dosaic.Hosting.Generator&version=1.2.9
Dosaic.Hosting.Generator
Dosaic.Hosting.Generator is a Roslyn IIncrementalGenerator that runs at compile time to discover all Dosaic plugin types across the application and its referenced assemblies. It emits a single generated class — Dosaic.Generated.DosaicPluginTypes — containing a Type[] of every discovered plugin. This enables AOT-compatible, reflection-free plugin discovery for Dosaic.Hosting.WebHost.
Installation
Add both packages to your application project:
dotnet add package Dosaic.Hosting.Generator
dotnet add package Dosaic.Hosting.WebHost
Or as PackageReference entries in your .csproj:
<PackageReference Include="Dosaic.Hosting.Generator" Version="" />
<PackageReference Include="Dosaic.Hosting.WebHost" Version="" />
Note: If you omit
Dosaic.Hosting.Generatoryou must pass plugin types to the web host manually.
Usage
Because the generator runs during compilation, no additional configuration is required. Reference DosaicPluginTypes.All directly in your Program.cs:
using Dosaic.Hosting.WebHost;
PluginWebHostBuilder.RunDefault(Dosaic.Generated.DosaicPluginTypes.All);
PluginWebHostBuilder iterates the provided Type[] and activates every service-, application-, and endpoint-configurator plugin at startup.
How it Works
PluginTypesGenerator implements IIncrementalGenerator and executes the following pipeline on every incremental build:
- Syntax filtering — registers a
SyntaxProviderthat selects everyTypeDeclarationSyntaxnode in the compilation. - Type resolution — combines the full
Compilationwith the collected syntax nodes and resolves each candidate to anITypeSymbol. - Discovery — scans both the host assembly and every referenced assembly symbol for types that match the inclusion criteria (see below).
- Code emission — writes
DosaicPluginTypes.g.csinto the compilation with theDosaic.Generatednamespace.
Inclusion criteria
A type is included in DosaicPluginTypes.All when all of the following are true:
- The type is
publicand notabstract. - The root namespace of the type does not match any excluded namespace prefix.
- At least one of:
- The type (directly or via its interface hierarchy) implements
IPluginActivateable, or - The type carries an attribute whose root namespace starts with
Dosaic.
- The type (directly or via its interface hierarchy) implements
Generated output
The generator emits a file named DosaicPluginTypes.g.cs similar to the following example:
using System;
using System.Diagnostics.CodeAnalysis;
using System.CodeDom.Compiler;
namespace Dosaic.Generated;
[ExcludeFromCodeCoverage]
[GeneratedCode("Dosaic.Hosting.Generator", "1.0.0.0")]
public class DosaicPluginTypes
{
public static Type[] All = new Type[]
{
typeof(Dosaic.Api.OpenApi.OpenApiConfiguration),
typeof(Dosaic.Api.OpenApi.OpenApiPlugin),
typeof(Dosaic.Hosting.Abstractions.Middlewares.ExceptionMiddleware),
typeof(Dosaic.Hosting.Abstractions.Middlewares.RequestContentLengthLimitMiddleware),
typeof(Dosaic.Plugins.Authorization.Keycloak.KeycloakPlugin),
typeof(Dosaic.Plugins.Authorization.Keycloak.KeycloakPluginConfiguration),
typeof(Dosaic.Plugins.Endpoints.RestResourceEntity.RestResourceEntityPlugin),
typeof(Dosaic.Plugins.Jobs.Hangfire.HangfireConfiguration),
typeof(Dosaic.Plugins.Jobs.Hangfire.HangFirePlugin),
typeof(Dosaic.Plugins.Persistence.EntityFramework.EntityFrameworkPlugin),
};
}
Types are sorted alphabetically by their fully-qualified name. Generic types are emitted as open generics (e.g. typeof(MyPlugin<>)).
When no plugin types are found the generator still emits the class with an empty array:
public static Type[] All = new Type[0];
Excluded namespaces
The following root-namespace prefixes are ignored during discovery to avoid pulling in framework or third-party types:
| Prefix | Reason |
|---|---|
Microsoft |
ASP.NET Core / runtime types |
System |
BCL types |
FastEndpoints |
Third-party endpoint library |
testhost |
Test runner host |
netstandard |
.NET Standard contract assembly |
Newtonsoft |
JSON.NET |
mscorlib |
Legacy BCL |
NuGet |
NuGet client types |
NSwag |
OpenAPI tooling |
FluentValidation |
Validation library |
YamlDotNet |
YAML parsing |
Accessibility |
Windows UI accessibility |
NJsonSchema |
JSON schema library |
Namotion |
JSON schema / reflection helpers |
This list may be extended in future releases as new dependencies are integrated.
Features
- Zero runtime reflection — all plugin discovery happens at Roslyn compile time; no assembly scanning at startup.
- Incremental generation — uses
IIncrementalGeneratorfor fast, cache-friendly incremental builds; only re-runs when affected syntax changes. - Full-assembly scanning — discovers plugins in both the host application assembly and every transitively referenced assembly.
- Generic type support — correctly emits open generic
typeof(…)expressions for generic plugin types. - AOT compatible — the generated
Type[]is a plain static field; compatible with ahead-of-time compilation and trimming. - Automatic exclusion — well-known framework and third-party namespaces are filtered out automatically.
- Deterministic output — types are sorted alphabetically by fully-qualified name, producing stable diffs across builds.
- Decorated output — generated file is annotated with
[ExcludeFromCodeCoverage]and[GeneratedCode]to keep tooling metrics clean.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.2.9 | 0 | 3/13/2026 |
| 1.2.8 | 81 | 3/9/2026 |
| 1.2.7 | 79 | 3/4/2026 |
| 1.2.6 | 109 | 2/19/2026 |
| 1.2.5 | 95 | 2/17/2026 |
| 1.2.4 | 122 | 2/13/2026 |
| 1.2.3 | 105 | 1/27/2026 |
| 1.2.2 | 291 | 12/16/2025 |
| 1.2.1 | 279 | 12/16/2025 |
| 1.2.0 | 431 | 12/11/2025 |
| 1.1.21 | 453 | 12/10/2025 |
| 1.1.20 | 417 | 11/18/2025 |
| 1.1.19 | 312 | 11/11/2025 |
| 1.1.18 | 211 | 10/14/2025 |
| 1.1.17 | 214 | 10/1/2025 |
| 1.1.16 | 212 | 9/25/2025 |
| 1.1.15 | 208 | 9/24/2025 |
| 1.1.14 | 192 | 9/24/2025 |
| 1.1.13 | 207 | 9/24/2025 |
| 1.1.12 | 328 | 9/16/2025 |