nmbl Documentation
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage
Edit page

color - Colorize C# Code by Concern

Overview

The color command generates syntax-highlighted HTML output that colorizes C# source lines according to their code concern category. Two analysis modes are available:

  • Cross-cutting concerns (default) — classifies lines by concern type such as logging, caching, or security using rule-based classification.
  • Structural/Syntactic (--structural) — classifies lines by syntactic role such as methods, properties, and fields.

The command operates in two modes based on the input path:

  • Single-file mode — input is a .cs file; output defaults to <input>.html next to the source file.
  • Multi-file mode — input is a .csproj, .slnx, or directory; an output directory must be supplied.

Syntax

Single-file mode

nmbl color <InputFile.cs> [OutputFile.html] [--no-summary] [--structural]

Multi-file mode

nmbl color <Project.csproj|Solution.slnx|Directory> <OutputDirectory> [--no-summary] [--structural]

Arguments

  • InputPath - Required. A .cs file (single-file mode) or a .csproj, .slnx, or directory (multi-file mode).
  • OutputPath - Output HTML file (single-file mode) or output directory (multi-file mode). Required in multi-file mode; defaults to <InputPath>.html in single-file mode.

Options

  • --no-summary - Suppress the per-run concern summary printed after generation.
  • --structural - Use structural/syntactic analysis instead of cross-cutting concern classification.

Output

Single-file output

Writes one HTML file. After generation, prints the output path and (unless --no-summary is set) a summary of the top 5 concern categories by line count.

Multi-file output

Writes one HTML file per discovered C# source file into the output directory, using the original filename with .html appended (e.g., MyService.cs becomes MyService.cs.html). After generation, prints a count of successfully processed files and the output directory path.

Exit Codes

  • 0 - Success (including when no C# files are found).
  • 1 - Missing required arguments, unsupported input type, or an error during analysis.

Examples

Colorize a single file

nmbl color src/Services/OrderService.cs

Creates src/Services/OrderService.cs.html next to the source file.

Specify a custom output path

nmbl color src/Services/OrderService.cs output/OrderService.html

Writes the HTML to the specified path.

Colorize a single file without the summary

nmbl color src/Services/OrderService.cs --no-summary

Generates the HTML but skips printing the concern breakdown.

Use structural analysis on a single file

nmbl color src/Services/OrderService.cs --structural

Colors lines by syntactic role (methods, properties, fields, etc.) instead of cross-cutting concerns.

Colorize all files in a project

nmbl color MyProject.csproj ./output

Generates one HTML file per .cs file discovered in the project, written to ./output/.

Colorize an entire solution

nmbl color MySolution.slnx ./colorized

Discovers all C# files across all projects in the solution and writes HTML files to ./colorized/.

Colorize a directory tree

nmbl color src/ ./colorized --no-summary

Processes all C# files found under src/ and suppresses the summary.

Multi-file mode with structural analysis

nmbl color MyProject.csproj ./output --structural

Uses structural analysis for all files in the project.

Concern Modes

Cross-cutting concerns (default)

The default mode classifies each line by its concern type using a rule engine. Examples of concern categories include logging, caching, security, data access, and exception handling. Lines not matching any concern rule are left uncolored.

Structural/Syntactic (--structural)

Classifies lines by their syntactic role within the C# code structure. Examples include methods, properties, fields, constructors, and type declarations.

  • cc - Analyze cyclomatic complexity
  • cogc - Analyze cognitive complexity
  • todos - Find TODO comments