Albatross.CommandLine.CodeAnalysis 8.0.10

Prefix Reserved
This package has a SemVer 2.0.0 package version: 8.0.10+cc668c1.
dotnet add package Albatross.CommandLine.CodeAnalysis --version 8.0.10
                    
NuGet\Install-Package Albatross.CommandLine.CodeAnalysis -Version 8.0.10
                    
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="Albatross.CommandLine.CodeAnalysis" Version="8.0.10">
  <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="Albatross.CommandLine.CodeAnalysis" Version="8.0.10" />
                    
Directory.Packages.props
<PackageReference Include="Albatross.CommandLine.CodeAnalysis">
  <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 Albatross.CommandLine.CodeAnalysis --version 8.0.10
                    
#r "nuget: Albatross.CommandLine.CodeAnalysis, 8.0.10"
                    
#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 Albatross.CommandLine.CodeAnalysis@8.0.10
                    
#: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=Albatross.CommandLine.CodeAnalysis&version=8.0.10
                    
Install as a Cake Addin
#tool nuget:?package=Albatross.CommandLine.CodeAnalysis&version=8.0.10
                    
Install as a Cake Tool

Albatross.CommandLine.CodeAnalysis

Roslyn analyzer companion for Albatross.CommandLine. It catches common misuse of the [Verb], [Option], [Argument], and [OptionHandler] attributes at compile time, before they manifest as runtime errors or confusing generated-code compiler errors.

Diagnostics

ID Severity Title
ACL0001 Warning Duplicate option name (case-insensitive)
ACL0002 Warning Params class does not derive from VerbAttribute.BaseParamsClass
ACL0003 Error OptionHandlerAttribute TOption is not assignable from the attributed class
ACL0004 Warning Property has both [Option] and [Argument]

ACL0001

Severity: Warning

Title: Duplicate option name (case-insensitive)

Two or more public properties on a [Verb] params class have names that are identical when compared case-insensitively. Because option names are derived from property names via kebab-case conversion (e.g. MyValue--my-value), properties like Name and name both produce --name, creating a duplicate CLI option.

// ❌ ACL0001 — 'Name' and 'name' both produce --name
[Verb<MyHandler>("greet")]
public class GreetParams {
    [Option] public string? Name { get; set; }
    [Option] public string? name { get; set; }  // warning here
}

// ✅ correct
[Verb<MyHandler>("greet")]
public class GreetParams {
    [Option] public string? Name { get; set; }
    [Option] public string? Alias { get; set; }
}

ACL0002

Severity: Warning

Title: Params class does not derive from VerbAttribute.BaseParamsClass

When VerbAttribute.BaseParamsClass is set, the params class must derive from the specified type. This applies to both class-targeted ([Verb<THandler>]) and assembly-targeted ([Verb<TParams, THandler>]) usages. The code generator uses BaseParamsClass to group related commands under a shared DI registration — if the params class does not derive from it, the generated switch expression will be missing entries.

public class BaseParams { }
public class UnrelatedParams { }

// ❌ ACL0002 — GreetParams does not derive from BaseParams
[Verb<MyHandler>("greet", BaseParamsClass = typeof(BaseParams))]
public class GreetParams { }

// ✅ correct
[Verb<MyHandler>("greet", BaseParamsClass = typeof(BaseParams))]
public class GreetParams : BaseParams { }

ACL0003

Severity: Error

Title: OptionHandlerAttribute TOption is not assignable from the attributed class

OptionHandlerAttribute<TOption, THandler> and OptionHandlerAttribute<TOption, THandler, TContextValue> must be applied to a class that is TOption itself or a subclass of it. The code generator uses TOption to wire up the option handler — if the attributed class is not assignable to TOption, the generated code will not compile.

// ❌ ACL0003 — MyOption is not assignable to Option<int>
[OptionHandler<Option<int>, MyHandler>]
public class MyOption : Option<string> { ... }

// ✅ correct — MyOption is assignable to Option<string>
[OptionHandler<Option<string>, MyHandler>]
public class MyOption : Option<string> { ... }

// ✅ also correct — attributed class IS the TOption
[OptionHandler<MyOption, MyHandler>]
public class MyOption : Option<string> { ... }

ACL0004

Severity: Warning

Title: Property has both [Option] and [Argument]

A property cannot be both a named option and a positional argument. The code generator only processes one attribute per property, so having both is always a mistake.

// ❌ ACL0004
[Option]
[Argument]
public string? Value { get; set; }

// ✅ use one or the other
[Option]
public string? Value { get; set; }

Installation

Reference the package as a development-only analyzer — it does not add any runtime dependency:

<PackageReference Include="Albatross.CommandLine.CodeAnalysis" Version="*">
  <PrivateAssets>all</PrivateAssets>
</PackageReference>
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Albatross.CommandLine.CodeAnalysis:

Package Downloads
Albatross.CommandLine

A streamlined integration layer for System.CommandLine with dependency injection, hosting, configuration, logging, and source-generated command wiring for .NET CLI apps.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.0.10 50 3/21/2026
8.0.9 38 3/6/2026