Treat Compiler Warnings as Error

Quality Gate Quality Gates

Ignored compiler warnings can lead to runtime errors, unpredictable behavior or security vulnerabilities; fixing them early prevents production problems and fosters best practices.

Requires Roslyn or R# Analyzers issues to be imported: https://www.ndepend.com/docs/roslyn-analyzer-issue-import https://www.ndepend.com/docs/resharper-code-inspection-issue-import

Compiler warnings are Roslyn issues whose rule id starts with "CS" or "VB". Warns on any warning, fails on 10 or more. C# compiler warnings list: https://learn.microsoft.com/en-us/dotnet/csharp/misc/cs0183

CQLinq source

This quality gate is written in CQLinq, C# LINQ over the NDepend code model. It ships with every new NDepend project: you can read it, adapt it, or use it as a starting point for your own custom rules.

// <QualityGate Name="Treat Compiler Warnings as Error" Unit="issues" />
failif count > 10
warnif count > 0
from issue in context.IssuesSet.AllIssues.Where(
  i => (i.Rule.Provider == RuleProvider.Roslyn &&
        i.Rule.Id.StartsWithAny("CS","VB")) ||
       (i.Rule.Provider == RuleProvider.Resharper &&
        i.Rule.Category.EndsWith("CompilerWarnings")))
select new { issue, Explanation =issue.GetExplanation() }

//<Desc>
// Ignored compiler warnings can lead to runtime errors, unpredictable
// behavior or security vulnerabilities; fixing them early prevents production
// problems and fosters best practices.
//
// Requires Roslyn or R# Analyzers issues to be imported:
// https://www.ndepend.com/docs/roslyn-analyzer-issue-import
// https://www.ndepend.com/docs/resharper-code-inspection-issue-import
//
// Compiler warnings are Roslyn issues whose rule id starts with "CS" or "VB".
// Warns on any warning, fails on 10 or more. C# compiler warnings list:
// https://learn.microsoft.com/en-us/dotnet/csharp/misc/cs0183
//</Desc>

Quality Gates: all 19 items