AV0009: Invalid API version format specifier
| Value | |
|---|---|
| Rule ID | AV0009 |
| Category | Usage |
| Fix is | Breaking |
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.