Skip to content

Compiler diagnostics

CaeriusNet's Roslyn analyzer emits compile-time diagnostics for [GenerateDto], [GenerateTvp], and AutoContracts manifest issues. The analyzer ships inside the CaeriusNet NuGet package; no extra reference is required.

Use this page to decide whether a diagnostic must be fixed, can be suppressed, or should be escalated in CI.

Diagnostic reference

IDSeverityTitleTriggered when
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 declare a primary constructor (or the constructor has no parameters)
CAERIUS004Error[GenerateTvp] requires a non-empty TvpNameThe attribute sets TvpName to an empty or whitespace-only string
CAERIUS005WarningUnmapped CLR type falls back to sql_variantA constructor parameter has a type with no native SQL Server mapping
CAERIUS006ErrorGenerator target shape is not supportedA generator target cannot be represented safely
CAERIUS200ErrorAutoContracts manifest is missingAutoContracts is enabled, but caerius.contracts.json has not been generated or restored
CAERIUS201ErrorStored procedure could not be foundThe manifest references a procedure that is missing from the inspected SQL Server database
CAERIUS202ErrorReferenced TVP type is missingA procedure parameter references a TVP type that is missing from SQL Server metadata
CAERIUS203ErrorTVP SQL type is not supportedA referenced TVP column uses a SQL Server type AutoContracts cannot generate safely
CAERIUS204ErrorFirst projection cannot be determinedSQL Server cannot expose a stable first result set for the procedure
CAERIUS205WarningStored procedure has no result setThe procedure is included for read-contract generation but SQL Server reports no result set
CAERIUS206ErrorOUTPUT parameters are not supportedA procedure declares one or more OUTPUT parameters
CAERIUS207ErrorSQL type cannot be mappedA procedure parameter or projected column uses an unmappable SQL Server type
CAERIUS208Policy-dependentNullable column violates policySQL Server metadata marks a projected column nullable and the active policy rejects it
CAERIUS209ErrorContract hash differs during VerifyVerify found drift between SQL Server metadata and caerius.contracts.json
CAERIUS210WarningStored procedure is probably incompatibleMetadata discovery found an incompatible shape without enough detail for a narrower diagnostic

Severity levels

SeverityBuild impactAction required
ErrorFails compilationMust be fixed before the project builds
WarningCompilation succeedsReview and fix, or suppress intentionally

Full rule pages

For examples and rule-specific guidance, open the individual pages under Diagnostic rules.

Suppressing 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 entirely
dotnet_diagnostic.CAERIUS005.severity = none

# Or downgrade to a suggestion
# dotnet_diagnostic.CAERIUS005.severity = suggestion

Via <NoWarn> in .csproj

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

Escalating 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

Via <WarningsAsErrors> in .csproj

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

CI enforcement

Escalating CAERIUS005 and AutoContracts warnings such as CAERIUS205, CAERIUS208, or CAERIUS210 in your CI .editorconfig prevents accidental contract drift or ambiguous metadata from reaching production.

Troubleshooting

SymptomCauseFix
No diagnostics emittedAnalyzer not loadedEnsure the CaeriusNet package is referenced (the analyzer ships in the same package)
Diagnostics not visible in IDEIDE cache staleRestart the IDE or run dotnet build from the CLI
#pragma suppression has no effectWrong scopeWrap the type declaration, not the file or a member

See also: source generators - the full guide to [GenerateDto] and [GenerateTvp].

Released under the MIT License.