Cerbi.GovernanceAnalyzer 1.0.0

dotnet add package Cerbi.GovernanceAnalyzer --version 1.0.0
                    
NuGet\Install-Package Cerbi.GovernanceAnalyzer -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cerbi.GovernanceAnalyzer" Version="1.0.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cerbi.GovernanceAnalyzer" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Cerbi.GovernanceAnalyzer">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Cerbi.GovernanceAnalyzer --version 1.0.0
                    
#r "nuget: Cerbi.GovernanceAnalyzer, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Cerbi.GovernanceAnalyzer@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Cerbi.GovernanceAnalyzer&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Cerbi.GovernanceAnalyzer&version=1.0.0
                    
Install as a Cake Tool

Cerbi.GovernanceAnalyzer

Universal Roslyn analyzer for compile-time log governance. Validates {Placeholder} message template fields against governance profiles for all major .NET logging frameworks:

  • ✅ Microsoft.Extensions.Logging (ILogger)
  • ✅ Serilog (ILogger, static Log)
  • ✅ NLog (ILogger, Logger)

Why?

CerbiShield enforces log governance at runtime. This analyzer catches violations at compile time — before code even ships. Missing required fields, forbidden PII fields, type mismatches, and invalid enum values are flagged as build warnings/errors.

Installation

dotnet add package Cerbi.GovernanceAnalyzer

Setup

  1. Add the NuGet package to your project
  2. Create a cerbi_governance.json file in your project root
  3. Reference it as an AdditionalFile in your .csproj:
<ItemGroup>
  <AdditionalFiles Include="cerbi_governance.json" />
</ItemGroup>

Governance Profile Example

{
  "name": "PII-Protection",
  "appName": "payment-service",
  "requiredFields": ["userId", "correlationId"],
  "disallowedFields": ["ssn", "creditCardNumber"],
  "fieldSeverities": {
    "userId": "Error",
    "ssn": "Forbidden",
    "debugInfo": "Warn"
  },
  "fieldTypes": {
    "userId": "String",
    "correlationId": "Guid",
    "retryCount": "Int"
  },
  "enums": {
    "environment": ["dev", "test", "staging", "production"]
  },
  "allowRelax": false
}

Diagnostics

ID Title Severity Description
CERBI000 No profile loaded Info No cerbi_governance.json found in AdditionalFiles
CERBI001 Missing required field Error A required field is not in the message template
CERBI002 Forbidden field Error A disallowed field appears in the message template
CERBI003 Advisory field Warning A field has advisory-level severity
CERBI004 Invalid field type Warning Argument type doesn't match expected type
CERBI005 Invalid enum value Warning String value not in allowed enum list

How It Works

The analyzer runs inside the C# compiler (Roslyn). It:

  1. Loads cerbi_governance.json from AdditionalFiles at compilation start
  2. Intercepts every logging method invocation (LogInformation, Warning, Info, etc.)
  3. Detects the logging framework via semantic model type checking
  4. Extracts {Placeholder} field names from message templates
  5. Validates fields against the governance profile rules
  6. Reports diagnostics as compiler warnings/errors

Zero runtime overhead — all analysis happens at build time only.

License

MIT

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has 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.0.0 227 3/17/2026