Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

AV0009: Invalid API version format specifier

Value
Rule IDAV0009
CategoryUsage
Fix isBreaking

Cause

An API version format specifier is invalid.

Rule Description

When an API version is formatted, it must use a valid format specifier.

Consider the following code:

Console.WriteLine(new ApiVersion(2026, 1, 1).ToString("'unterminated"));

The format specifier 'unterminated is not a valid API version format. This would not be detected until runtime.

How to Fix Violations

Update the API version format.

Console.WriteLine(new ApiVersion(2026, 1, 1).ToString("'v'VV"));

When to Suppress Warnings

It is never safe to suppress this rule because a runtime exception will be thrown when the value is formatted.