Skip to content

roslynator

GitHub stars formatter GitHub release (latest SemVer) GitHub last commit GitHub commit activity GitHub contributors

roslynator documentation

Roslynator - GitHub

Configuration in MegaLinter

Variable Description Default value
CSHARP_ROSLYNATOR_ARGUMENTS User custom arguments to add in linter CLI call
Ex: -s --foo "bar"
CSHARP_ROSLYNATOR_COMMAND_REMOVE_ARGUMENTS User custom arguments to remove from command line before calling the linter
Ex: -s --foo "bar"
CSHARP_ROSLYNATOR_FILTER_REGEX_INCLUDE Custom regex including filter
Ex: (src\|lib)
Include every file
CSHARP_ROSLYNATOR_FILTER_REGEX_EXCLUDE Custom regex excluding filter
Ex: (test\|examples)
Exclude no file
CSHARP_ROSLYNATOR_CLI_LINT_MODE Override default CLI lint mode
- file: Calls the linter for each file
- project: Call the linter from the root of the project
file
CSHARP_ROSLYNATOR_FILE_EXTENSIONS Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all files
Ex: [".py", ""]
[".csproj"]
CSHARP_ROSLYNATOR_FILE_NAMES_REGEX File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files
Ex: ["Dockerfile(-.+)?", "Jenkinsfile"]
Include every file
CSHARP_ROSLYNATOR_PRE_COMMANDS List of bash commands to run before the linter None
CSHARP_ROSLYNATOR_POST_COMMANDS List of bash commands to run after the linter None
CSHARP_ROSLYNATOR_UNSECURED_ENV_VARIABLES List of env variables explicitly not filtered before calling CSHARP_ROSLYNATOR and its pre/post commands None
CSHARP_ROSLYNATOR_DISABLE_ERRORS Run linter but consider errors as warnings true
CSHARP_ROSLYNATOR_DISABLE_ERRORS_IF_LESS_THAN Maximum number of errors allowed 0
CSHARP_ROSLYNATOR_CLI_EXECUTABLE Override CLI executable ['roslynator']

IDE Integration

Use roslynator in your favorite IDE to catch errors before MegaLinter !

IDE Extension Name Install
visual_studio Roslynator 2022 Visit Web Site
Visual Studio Code Roslynator Install in VSCode

MegaLinter Flavors

This linter is available in the following flavors

Flavor Description Embedded linters Info
all Default MegaLinter Flavor 122 Docker Image Size (tag) Docker Pulls
dotnet Optimized for C, C++, C# or VB based projects 61 Docker Image Size (tag) Docker Pulls
dotnetweb Optimized for C, C++, C# or VB based projects with JS/TS 70 Docker Image Size (tag) Docker Pulls
formatters Contains only formatters 17 Docker Image Size (tag) Docker Pulls

Behind the scenes

How are identified applicable files

  • File extensions: .csproj

How the linting is performed

  • roslynator is called one time by identified file (file CLI lint mode)

Example calls

roslynator analyze myproject.csproj
roslynator fix myproject.csproj

Help content

Roslynator Command Line Tool version 0.8.9.0 (Roslyn version 4.9.0.0)
Usage: roslynator [command] [arguments]

Commands:
  analyze            Analyzes specified project or solution and reports diagnostics.
  find-symbol        Finds symbols in the specified project or solution.
  fix                Fixes diagnostics in the specified project or solution.
  format             Formats whitespace in the specified project or solution.
  generate-doc       Generates reference documentation from specified project/solution.
  generate-doc-root  [deprecated] Generates root documentation file from specified project/solution.
  list-symbols       Lists symbols from the specified project or solution.
  lloc               Counts logical lines of code in the specified project or solution.
  loc                Counts physical lines of code in the specified project or solution.
  migrate            Migrates analyzers to a new version.
  rename-symbol      Rename symbols in the specified project or solution.
  spellcheck         Searches the specified project or solution for possible misspellings or typos.

Run 'roslynator help [command]' for more information on a command.

Installation on mega-linter Docker image

  • Dockerfile commands :
# Parent descriptor install
RUN apk add --no-cache dotnet8-sdk
ENV PATH="${PATH}:/root/.dotnet/tools"
# Linter install
RUN dotnet tool install -g roslynator.dotnet.cli