Epsitec.Tool.Format 1.16.0.2647

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global Epsitec.Tool.Format --version 1.16.0.2647
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local Epsitec.Tool.Format --version 1.16.0.2647
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=Epsitec.Tool.Format&version=1.16.0.2647
                    
nuke :add-package Epsitec.Tool.Format --version 1.16.0.2647
                    

Epsitec Source Format Tool

epsitec-format is a dotnet tool that checks and fixes source text files according to line-based rules: C# comment reflow, indentation and object-initializer layout, encoding and layout driven by .editorconfig, Razor @code blocks, misplaced warning suppressions, the C# file header, the C# comment style, the C# XML doc comments and the line length. It can write its findings as JUnit and GitLab Code Quality reports, and states its exit policy with --fail-on and --tolerate.

The tool is purely line and text based (regular expressions and greedy word wrapping). It uses no Roslyn syntax tree, no semantic analysis and no MSBuild, so it starts fast and has a minimal dependency surface.

Installation

dotnet tool install --global Epsitec.Tool.Format
dotnet tool update --global Epsitec.Tool.Format
dotnet tool uninstall --global Epsitec.Tool.Format

The commands name the package id, Epsitec.Tool.Format; the tool's command is epsitec-format.

Usage

epsitec-format [<targets>... | --changed <file>|-]
               [--fix]
               [--rules comments,indent,initializers,encoding,razor,suppressions,header,comment-style,xmldoc,layout]
               [--ids|--include-ids FMT0001,...]
               [--exclude-ids FMT0001,...]
               [--update-year [--year <N>]]
               [--extensions <list>]
               [--max-columns <N>]
               [--json | --msbuild | --summary]
               [--fail-on none|unfixable|any]
               [--tolerate none|suggestion|warning|error]
               [--junit <file>]
               [--codequality <file>]
  • <targets> → files, directories or glob patterns (*, **), the current directory by default. Directories are scanned recursively; a path with a bin, obj, .git, .vs, node_modules, TestResults, artifacts or .nupkg segment is skipped.
  • --changed <file> or --changed - → check only the files listed one per line in <file>, or on stdin, as git diff --name-only writes them. It replaces the targets, and enables the diff reach (see Diagnostics).
  • --fix → apply the fixable rules in place. Without it, the tool only checks and writes nothing.
  • --rules → a subset of the ten rules; all of them by default.
  • --ids (or --include-ids) and --exclude-ids → select or leave out FMT identifiers. Only the selected issues are reported and, with --fix, applied.
  • --update-year, with --changed → check the copyright year of the changed files against the current year, and bring it up to date with --fix (FMT0019); --year <N> gives the year instead of the local clock.
  • --extensions → the file extensions the encoding and layout rules check, replacing their default list.
  • --max-columns → the wrap width of comment prose for every file of the run, over the .editorconfig setting.
  • --json, --msbuild, --summary → the stdout report: a JSON object, one build-tool diagnostic line per issue ({path}({line},1): {category} {id}: {title}, which editors and build tools read), or the count of issues per identifier. Without any, one human-readable line per issue, then a summary line.
  • --junit <file>, --codequality <file> → also write a JUnit XML report or a GitLab Code Quality report, whatever the stdout report. A GitLab job publishes them with artifacts:reports:junit and artifacts:reports:codequality.

Examples

# Check the current directory.
epsitec-format

# Fix the comment reflow and the indentation of a folder.
epsitec-format src --rules comments,indent --fix

# Check the files of a change, the diff-reach kinds included.
git diff --name-only main | epsitec-format --changed -

# Count the issues per identifier, failing on warnings and errors.
epsitec-format src --summary --tolerate suggestion

# Write the reports of a CI job.
epsitec-format --summary --junit artifacts/epsitec-format.xml --codequality artifacts/epsitec-format.codequality.json

Rules

  • comments → reflows // and /// comment prose to the configured width, and normalizes /*****/ separator lines to 79 columns. Copyright blocks, code snippets, tables, drawings, XML doc element lines and URLs are preserved.
  • indent → replaces tab-based leading indentation with spaces, with a tab width of 4.
  • initializers → reports object-initializer braces indented deeper than their var … = new … line. Report-only.
  • encoding → checks the byte-order mark, the line endings, the final newline, the trailing blank lines and the trailing whitespace against charset, end_of_line, insert_final_newline and trim_trailing_whitespace in .editorconfig. Every kind is fixable.
  • razor → reports the @code and @functions blocks of .razor files: members belong in a .razor.cs code-behind. Report-only.
  • suppressions → reports an .editorconfig file outside the root of the git working tree, a #pragma warning disable without a matching restore, and one that names no warning. Report-only.
  • header → checks the two header lines of .cs files, the Epsitec copyright line and the author line, reports attribution lines, and, with --update-year, the copyright year.
  • comment-style → checks the line comments of .cs files: two spaces after //, no en dash or em dash, a blank line around the Arrange, Act and Assert markers, and no spec reference.
  • xmldoc → reports an XML doc comment on a test method, and a type summary that does not open with The <c>TypeName</c> <kind>. Report-only.
  • layout → reports the lines wider than the max_line_length of .editorconfig. Report-only.

The encoding and layout rules accept by default .cs, .csproj, .props, .targets, .slnx, .razor, .json, .md, .txt, .xml, .xsl, .csv, .yml, .ps1, .sh, .js, .ts, .css and .html files. A generated file (a first line containing <auto-generated, or generated_code = true in .editorconfig) is exempt from every kind except FMT0005 and FMT0011.

Diagnostics

Every issue kind has a stable FMT identifier, never renumbered nor reused. Each has a reach: a tree kind is reported by every run, a diff kind only by the runs with --changed, or whose --ids names it, since these kinds are too numerous in an existing tree to be reported by every full scan.

Id Rule Reach Title
FMT0001 comments tree Comment prose is not wrapped to the target width
FMT0002 comments tree Separator comment is not exactly 79 columns wide
FMT0003 indent tree Leading indentation uses tabs
FMT0004 initializers tree Object-initializer brace is indented deeper than its declaration
FMT0005 encoding tree File byte-order mark does not match the charset
FMT0006 encoding tree Line endings do not match end_of_line
FMT0007 encoding tree File does not end with a newline
FMT0008 encoding tree File ends with blank lines
FMT0009 encoding tree Line ends with whitespace
FMT0010 razor tree Razor component declares an @code or @functions block
FMT0011 suppressions tree .editorconfig file outside the module root
FMT0012 suppressions tree #pragma warning disable without a matching restore
FMT0013 suppressions tree #pragma warning disable without an identifier
FMT0014 header diff File does not start with the copyright and author header
FMT0015 header diff Header author line does not follow the Author/Maintainer grammar
FMT0016 header diff File header has more than two lines
FMT0017 header tree Attribution line in the file header
FMT0018 header tree Attribution line in a comment
FMT0019 header diff Copyright year is not up to date
FMT0020 comment-style diff Line comment is not followed by two spaces
FMT0021 comment-style diff Comment contains an en dash or an em dash
FMT0022 comment-style diff Arrange, Act or Assert marker is not set off by blank lines
FMT0023 comment-style tree Source file cites a spec
FMT0024 xmldoc diff Test method carries an XML doc comment
FMT0025 xmldoc diff Type summary does not open with the type name and kind
FMT0026 layout diff Line is longer than max_line_length

Configuration

The tool reads .editorconfig, every file from the directory of a source file up to the first root = true.

[*.cs]
max_line_length = 90
epsitec_comment_line_length = 79
# Turn an identifier off, or change its severity.
dotnet_diagnostic.FMT0025.severity = none
dotnet_diagnostic.FMT0017.severity = error
  • epsitec_comment_line_length → the wrap width of comment prose, 79 by default; --max-columns wins over it.
  • max_line_length → the longest line that layout accepts; without a positive value, layout checks nothing.
  • dotnet_diagnostic.<id>.severity → the Roslyn key, shared with the compiler: none, silent or hidden turn the identifier off for the files of the section, suggestion, warning and error set its severity, and default restores the default severity, warning for every identifier. Turning an identifier off wins over --ids.
  • A file named .fmtignore excludes its directory and all its subdirectories from every run, up to the root of the git working tree.

A few lines of a .cs file can stand verbatim between #pragma warning disable format and #pragma warning restore format, as Roslyn's formatting analyzer lets them stand; #pragma warning disable FMT0026 withdraws only the identifiers it names. The identifiers of the suppressions rule keep checking the directives themselves.

Exit codes

Exit code Meaning
0 No issue left that the --fail-on policy selects with a severity above the --tolerate level.
1 At least one such issue.
2 Bad usage: an unknown rule or identifier, conflicting options, a missing target.
3 A fix-time safety check failed (a file changed under the tool), a read or write error occurred, or a report could not be written.
  • --fail-on none|unfixable|any → which issues left in the source can fail the run: none, the report-only ones, or any. The default is any in check mode and none in fix mode.
  • --tolerate none|suggestion|warning|error → the highest severity a successful run tolerates. The default is warning: since every identifier has the default severity warning, a check run without options and without severities in .editorconfig exits 0 whatever it finds. --tolerate suggestion fails on warnings and errors.

File handling

Files are read as strict UTF-8; a file that is not valid UTF-8, or that holds a NUL byte, is reported as ignored and never written. A fix preserves the byte-order mark, the line endings, the final newline and the trailing empty lines of the file, unless an encoding issue changes them; a rewritten file with mixed line endings takes its dominant ending throughout. A file with no applied fix is left byte-identical.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.16.6.2648 0 11/23/2026
1.16.5.2647 60 11/21/2026
1.16.4.2647 52 11/21/2026
1.16.3.2647 61 11/21/2026
1.16.2.2647 61 11/20/2026
1.16.0.2647 93 11/17/2026
1.15.0.2647 90 11/16/2026
1.14.14.2646 110 11/10/2026
1.14.11.2646 101 11/9/2026
1.13.4.2642 130 10/18/2026
1.13.2.2642 114 10/12/2026
1.11.3.2641 120 10/6/2026
1.9.2.2640 109 9/30/2026
1.9.0.2640 107 9/28/2026
1.8.0.2639 113 9/26/2026
1.7.0.2639 107 9/26/2026
1.6.1.2639 106 9/24/2026
0.9.3.2624 253 6/21/2026