Skip to content

Compiler Diagnostics

CaeriusNet's Roslyn source generators emit compile-time diagnostics to catch configuration and mapping errors before runtime. Each diagnostic has a unique ID, severity, and actionable guidance.

Diagnostic reference

IDSeverityTitleDescription
CAERIUS001ErrorType must be sealedA [GenerateDto] or [GenerateTvp] type is missing the sealed modifier
CAERIUS002ErrorType must be partialA [GenerateDto] or [GenerateTvp] type is missing the partial modifier
CAERIUS003ErrorPrimary constructor requiredThe type does not use a primary constructor for its parameters
CAERIUS004ErrorEmpty primary constructorThe primary constructor has no parameters (no columns to map)
CAERIUS005WarningUnmapped CLR type falls back to sql_variantA property type has no native SQL Server mapping
CAERIUS006WarningUnsupported type for SQL Server mappingA property type uses sql_variant fallback with performance implications

Severity levels

SeverityBuild impactAction required
ErrorFails compilationMust fix before building
WarningCompilation succeedsReview and fix or suppress intentionally

How to suppress diagnostics

Per-declaration with #pragma

csharp
#pragma warning disable CAERIUS005
[GenerateDto]
public sealed partial record FlexibleDto(int Id, object DynamicValue);
#pragma warning restore CAERIUS005

Project-wide with .editorconfig

ini
[*.cs]
# Suppress specific diagnostic
dotnet_diagnostic.CAERIUS005.severity = none

# Downgrade to suggestion
dotnet_diagnostic.CAERIUS006.severity = suggestion

Via <NoWarn> in .csproj

xml
<PropertyGroup>
    <NoWarn>$(NoWarn);CAERIUS005;CAERIUS006</NoWarn>
</PropertyGroup>

How to escalate severity

Promote warnings to errors to enforce stricter rules in CI:

Via .editorconfig

ini
[*.cs]
# Treat sql_variant fallback as a build error
dotnet_diagnostic.CAERIUS005.severity = error
dotnet_diagnostic.CAERIUS006.severity = error

Via <WarningsAsErrors> in .csproj

xml
<PropertyGroup>
    <WarningsAsErrors>$(WarningsAsErrors);CAERIUS005;CAERIUS006</WarningsAsErrors>
</PropertyGroup>

CI enforcement

Escalating CAERIUS005 and CAERIUS006 to errors in your CI .editorconfig prevents accidental sql_variant usage from reaching production.

Troubleshooting

SymptomCauseFix
No diagnostics emittedGenerator not runningEnsure CaeriusNet package is referenced and IDE recognizes analyzers
Diagnostics not appearing in IDEIDE cache staleRestart IDE or run dotnet build from CLI
Suppression not workingWrong scopeEnsure #pragma wraps the type declaration, not just the file

See also: Source Generators — full guide to [GenerateDto] and [GenerateTvp] code generation.

Released under the MIT License.