Skip to main content

Pledge diagnostics

One page per rule. Each diagnostic links here from the IDE and the build log. Severities are the defaults; .editorconfig can change them (dotnet_diagnostic.PLEDGE004.severity = error).

IDSeverityRuleFix
PLEDGE001ErrorContract call is not at the top of the methodMove it to the top
PLEDGE002ErrorResult<T>() used incorrectlyUse the method's result type
PLEDGE003ErrorOld(...) used outside a postcondition
PLEDGE004WarningImpure expression in a contractMark the callee [Pure]
PLEDGE005WarningPledge generator is not active
PLEDGE006InfoContracts are not checked here: no call sites, a delegate, or a call through an interface or base methodCall the contracted method directly
PLEDGE007WarningOld(...) of a mutable referenceCopy with .ToArray() or with { }
PLEDGE008WarningConstant argument violates a precondition
PLEDGE009WarningContract on an unsupported member

PLEDGE005, PLEDGE009 and PLEDGE006's no-call-sites form come from the source generator, the rest from analyzers in the same assembly. All ship in the Pledge package.