csharpier
csharpier documentation
- Version in MegaLinter: 0.29.2
- Visit Official Web Site
- See How to configure csharpier rules
- See How to ignore files and directories with csharpier
- You can define a
.csharpierignore
file to ignore files and folders
- You can define a
Configuration in MegaLinter
- Enable csharpier by adding
CSHARP_CSHARPIER
in ENABLE_LINTERS variable - Disable csharpier by adding
CSHARP_CSHARPIER
in DISABLE_LINTERS variable
- Enable autofixes by adding
CSHARP_CSHARPIER
in APPLY_FIXES variable
Variable | Description | Default value |
---|---|---|
CSHARP_CSHARPIER_ARGUMENTS | User custom arguments to add in linter CLI call Ex: -s --foo "bar" |
|
CSHARP_CSHARPIER_COMMAND_REMOVE_ARGUMENTS | User custom arguments to remove from command line before calling the linter Ex: -s --foo "bar" |
|
CSHARP_CSHARPIER_FILTER_REGEX_INCLUDE | Custom regex including filter Ex: (src\|lib) |
Include every file |
CSHARP_CSHARPIER_FILTER_REGEX_EXCLUDE | Custom regex excluding filter Ex: (test\|examples) |
Exclude no file |
CSHARP_CSHARPIER_CLI_LINT_MODE | Override default CLI lint mode - file : Calls the linter for each file- list_of_files : Call the linter with the list of files as argument- project : Call the linter from the root of the project |
list_of_files |
CSHARP_CSHARPIER_FILE_EXTENSIONS | Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all filesEx: [".py", ""] |
[".cs"] |
CSHARP_CSHARPIER_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_CSHARPIER_PRE_COMMANDS | List of bash commands to run before the linter | None |
CSHARP_CSHARPIER_POST_COMMANDS | List of bash commands to run after the linter | None |
CSHARP_CSHARPIER_UNSECURED_ENV_VARIABLES | List of env variables explicitly not filtered before calling CSHARP_CSHARPIER and its pre/post commands | None |
CSHARP_CSHARPIER_CONFIG_FILE | csharpier configuration file nameUse LINTER_DEFAULT to let the linter find it |
.csharpierrc |
CSHARP_CSHARPIER_RULES_PATH | Path where to find linter configuration file | Workspace folder, then MegaLinter default rules |
CSHARP_CSHARPIER_DISABLE_ERRORS | Run linter but consider errors as warnings | true |
CSHARP_CSHARPIER_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | 0 |
CSHARP_CSHARPIER_CLI_EXECUTABLE | Override CLI executable | ['dotnet-csharpier'] |
IDE Integration
Use csharpier in your favorite IDE to catch errors before MegaLinter !
IDE | Extension Name | Install | |
---|---|---|---|
rider | csharpier | Visit Web Site | |
visual_studio | CSharpier | Visit Web Site | |
Visual Studio Code | csharpier-vscode |
MegaLinter Flavors
This linter is available in the following flavors
Flavor | Description | Embedded linters | Info | |
---|---|---|---|---|
all | Default MegaLinter Flavor | 124 | ||
dotnet | Optimized for C, C++, C# or VB based projects | 61 | ||
dotnetweb | Optimized for C, C++, C# or VB based projects with JS/TS | 70 | ||
formatters | Contains only formatters | 17 |
Behind the scenes
How are identified applicable files
- File extensions:
.cs
How the linting is performed
- csharpier is called once with the list of files as arguments (
list_of_files
CLI lint mode)
Example calls
dotnet csharpier --check myfile.cs myfile2.cs
dotnet csharpier myfile.cs myfile2.cs
Help content
dotnet-csharpier
Usage:
dotnet-csharpier [options] [<directoryOrFile>...]
Arguments:
<directoryOrFile> One or more paths to a directory containing C# files to format or a C# file to format. It may be ommited when piping data via stdin.
Options:
--check Check that files are formatted. Will not write any changes.
--loglevel <loglevel> Specify the log level - Debug, Information (default), Warning, Error, None [default: Information]
--no-cache Bypass the cache to determine if a file needs to be formatted.
--no-msbuild-check Bypass the check to determine if a csproj files references a different version of CSharpier.MsBuild.
--include-generated Include files generated by the SDK and files that begin with <autogenerated /> comments
--fast Skip comparing syntax tree of formatted file to original file to validate changes.
--skip-write Skip writing changes. Generally used for testing to ensure csharpier doesn't throw any errors or cause syntax tree validation failures.
--write-stdout Write the results of formatting any files to stdout.
--pipe-multiple-files Keep csharpier running so that multiples files can be piped to it via stdin.
--server Run CSharpier as a server so that multiple files may be formatted.
--server-port <server-port> Specify the port that CSharpier should start on. Defaults to a random unused port.
--config-path <config-path> Path to the CSharpier configuration file
--compilation-errors-as-warnings Treat compilation errors from files as warnings instead of errors.
--version Show version information
-?, -h, --help Show help and usage information
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 --global csharpier