csharpier
csharpier documentation
- Version in MegaLinter: 1.0.1
- 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", ""] |
[".config", ".cs", ".csproj", ".props", ".targets"] |
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 | ['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 | 127 | |
dotnet | Optimized for C, C++, C# or VB based projects | 64 | ||
dotnetweb | Optimized for C, C++, C# or VB based projects with JS/TS | 73 | ||
formatters | Contains only formatters | 18 |
Behind the scenes
How are identified applicable files
- File extensions:
.config
,.cs
,.csproj
,.props
,.targets
How the linting is performed
- csharpier is called once with the list of files as arguments (
list_of_files
CLI lint mode)
Example calls
csharpier check myfile.cs myfile2.cs
csharpier format myfile.cs myfile2.cs
Help content
Description:
Usage:
CSharpier [command] [options]
Options:
--version Show version information
-?, -h, --help Show help and usage information
Commands:
format <directoryOrFile> Format files.
check <directoryOrFile> Check that files are formatted. Will not write any changes.
pipe-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.
Installation on mega-linter Docker image
- Dockerfile commands :
# Parent descriptor install
RUN apk add --no-cache dotnet9-sdk
ENV PATH="${PATH}:/root/.dotnet/tools"
# Linter install
# renovate: datasource=nuget depName=csharpier
ARG CSHARP_CSHARPIER_VERSION=1.0.1
RUN dotnet tool install --allow-roll-forward --global csharpier --version "${CSHARP_CSHARPIER_VERSION}"