 csharpier
csharpier
csharpier documentation
- Version in MegaLinter: 0.24.2
- Visit Official Web Site
- See How to configure csharpier rules
- See How to ignore files and directories with csharpier- You can define a .csharpierignorefile to ignore files and folders
 
- You can define a 
Configuration in MegaLinter
- Enable csharpier by adding CSHARP_CSHARPIERin ENABLE_LINTERS variable
- Disable csharpier by adding CSHARP_CSHARPIERin DISABLE_LINTERS variable
- Enable autofixes by adding CSHARP_CSHARPIERin 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_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_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 Flavours
This linter is available in the following flavours
| Flavor | Description | Embedded linters | Info | |
|---|---|---|---|---|
|  | all | Default MegaLinter Flavor | 113 | |
| dotnet | Optimized for C, C++, C# or VB based projects | 59 | 
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_filesCLI 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. If a path is not specified the current directory is used
Options:
  --check                      Check that files are formatted. Will not write any changes.
  --no-cache                   Bypass the cache to determine if a file needs to be formatted.
  --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
  --config-path <config-path>  Path to the CSharpier configuration file
  --version                    Show version information
  -?, -h, --help               Show help and usage information
Installation on mega-linter Docker image
- Dockerfile commands :
# Parent descriptor install
RUN wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \
    && chmod +x dotnet-install.sh \
    && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest
ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet"
# Linter install
RUN /usr/share/dotnet/dotnet tool install -g csharpier