Configuin is a tool for working with .NET .editorconfig.
- Generate .NET .editorconfig template
- Generate documentation for .NET .editorconfig
- Preview changes after applying
dotnet format
with new .editorconfig - Format .NET .editorconfig file
- [in progress] .editorconfig analyzer
- [in progress] Compare two .editorconfig
Configuin parses all rules described in the documentation and generates a .editorconfig where they are all described to simplify the process of filling out the .editorconfig. For example, the command
Kysect.Configuin template ".editorconfig"
will generate a file with the following content:
## Simplify name (IDE0001)
## This rule concerns the use of simplified type names in declarations and executable code, when possible. You can remove unnecessary name qualification to simplify code and improve readability.
## using System.IO;
## class C
## {
## // IDE0001: 'System.IO.FileInfo' can be simplified to 'FileInfo'
## System.IO.FileInfo file;
##
## // Fixed code
## FileInfo file;
## }
# dotnet_diagnostic.IDE0001.severity =
# ...
The full file can be viewed here.
Configuin parses the Roslyn description, which is available on the MS Learn website, parses the .editorconfig file provided by the user, and generates a document with a detailed description of the lines. Example of use:
Kysect.Configuin generate-styledoc "C:\Project\.editorconfig" -o "output.md"
For example, the .editorconfig file may contain:
dotnet_diagnostic.IDE0040.severity = warning
dotnet_style_require_accessibility_modifiers = always:warning
When generating the code style, a description will be found for these lines and such an output will be generated:
## Add accessibility modifiers (IDE0040)
Severity: Warning
This style rule concerns requiring accessibility modifiers in declarations.
### dotnet_style_require_accessibility_modifiers = always
\```csharp
// dotnet_style_require_accessibility_modifiers = always
// dotnet_style_require_accessibility_modifiers = for_non_interface_members
class MyClass
{
private const string thisFieldIsConst = "constant";
}
// dotnet_style_require_accessibility_modifiers = never
class MyClass
{
const string thisFieldIsConst = "constant";
}
\```
Kysect.Configuin preview -s "C:\Project\" -t "C:\Project\.editorconfig" -e "C:\.editorconfig"
Configuin generates a list of changes that will be received if the .editorconfig is applied to the project.
Algorithm:
dotnet format
is launched for the project and the list of messages is saved- .editorconfig is replaced with the one specified by the user
dotnet format
is launched and the second result is saved- A diff is generated between the results
- .editorconfig change is rolled back
Example of use:
- Take a project with .editorconfig
- Copy .editorconfig and modify it, for example, include CA1032
- Run Configuin, specify the path to the solution and the modified .editorconfig
Generated result:
[18:25:16 INF] Comparing dotnet format report
[18:25:16 INF] Same: 0, added: 2, removed: 0
[18:25:16 INF] New warnings count: 2
[18:25:16 INF] C:\Coding\Kysect.CommonLib\Sources\Kysect.CommonLib\Reflection\ReflectionException.cs
[18:25:16 INF] error CA1032: Add the following constructor to ReflectionException: public ReflectionException()
[18:25:16 INF] C:\Coding\Kysect.CommonLib\Sources\Kysect.CommonLib\Reflection\ReflectionException.cs
[18:25:16 INF] error CA1032: Add the following constructor to ReflectionException: public ReflectionException(string message)
Kysect.Configuin format ".editorconfig"
Configuin formats the .editorconfig file according to the rules described in the documentation. Generated result will be same as template:
# Autogenerated values
[*.cs]
### IDE ###
dotnet_diagnostic.IDE0001.severity = warning
dotnet_diagnostic.IDE0002.severity = warning
# IDE0003 and IDE0009
dotnet_diagnostic.IDE0003.severity = warning
dotnet_diagnostic.IDE0009.severity = warning
dotnet_style_qualification_for_field = false:warning
dotnet_style_qualification_for_property = false:warning
dotnet_style_qualification_for_method = false:warning
dotnet_style_qualification_for_event = false:warning
...
### CA ###
dotnet_diagnostic.CA1000.severity = none
dotnet_diagnostic.CA1001.severity = warning
dotnet_diagnostic.CA1002.severity = warning
Some features:
- Same rules are grouped
- Options saved near the rule
- Not parsed rules don't change
- Comments are saved and moved with the rule
Command 'format' support flag --group-ca
that allows to group rules by category. For example:
# with --group-ca false
# Autogenerated values
[*.cs]
### CA ###
dotnet_diagnostic.CA1016.severity = none
dotnet_diagnostic.CA1027.severity = none
dotnet_diagnostic.CA1501.severity = none
dotnet_diagnostic.CA1835.severity = none
# with --group-ca true
# Autogenerated values
[*.cs]
### CA Design ###
dotnet_diagnostic.CA1016.severity = none
dotnet_diagnostic.CA1027.severity = none
### CA Maintainability ###
dotnet_diagnostic.CA1501.severity = none
### CA Performance ###
dotnet_diagnostic.CA1835.severity = none