Skip to content

Commit

Permalink
Rename main executable project to Kysect.Configuin without .Console
Browse files Browse the repository at this point in the history
  • Loading branch information
FrediKats committed May 19, 2024
1 parent 2f3d99b commit 378bced
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 63 deletions.
8 changes: 4 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Configuin is a tool for working with .NET .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.Console.exe template ".editorconfig" -d "C:\Coding\dotnet-docs"
Kysect.Configuin template ".editorconfig"
```

will generate a file with the following content:
Expand Down Expand Up @@ -45,7 +45,7 @@ The full file can be viewed [here](Docs/.editorconfig).
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:

```bash
Kysect.Configuin.Console.exe generate-styledoc "C:\Project\.editorconfig" -o "output.md" -d "C:\Coding\dotnet-docs"
Kysect.Configuin generate-styledoc "C:\Project\.editorconfig" -o "output.md"
```

For example, the .editorconfig file may contain:
Expand Down Expand Up @@ -85,7 +85,7 @@ class MyClass
### Preview changes after applying `dotnet format` with new .editorconfig

```bash
Kysect.Configuin.Console.exe preview -s "C:\Project\" -t "C:\Project\.editorconfig" -e "C:\.editorconfig"
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.
Expand Down Expand Up @@ -118,7 +118,7 @@ Generated result:
### Format .NET .editorconfig file
```bash
Kysect.Configuin.Console.exe format ".editorconfig" -d "C:\Coding\dotnet-docs"
Kysect.Configuin format ".editorconfig"
```
Configuin formats the .editorconfig file according to the rules described in the documentation. Generated result will be same as [template](Docs/.editorconfig):
Expand Down
1 change: 1 addition & 0 deletions Sources/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<UseArtifactsOutput>true</UseArtifactsOutput>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Kysect.SolutionDefaults">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Kysect.Configuin.CodeStyleDoc;
using Kysect.Configuin.CodeStyleDoc.Markdown;
using Kysect.Configuin.DotnetFormatIntegration;
using Kysect.Configuin.DotnetFormatIntegration.Abstractions;
using Kysect.Configuin.DotnetFormatIntegration.Cli;
using Kysect.Configuin.DotnetFormatIntegration.FileSystem;
using Kysect.Configuin.EditorConfig;
Expand Down Expand Up @@ -31,6 +32,8 @@ public static IServiceCollection InitializeServiceProvider()

serviceCollection.AddSingleton(CreateLogger);

serviceCollection.AddSingleton<IDotnetFormatPreviewGenerator, DotnetFormatPreviewGenerator>();

serviceCollection.AddSingleton<IDotnetConfigSettingsParser, DotnetConfigSettingsParser>();
serviceCollection.AddSingleton<IRoslynRuleDocumentationParser, LearnDocumentationParser>();
serviceCollection.AddSingleton<IMarkdownTextExtractor>(PlainTextExtractor.Create());
Expand Down
26 changes: 26 additions & 0 deletions Sources/Kysect.Configuin.Console/CommandAppInitializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Kysect.Configuin.Console.Commands;
using Microsoft.Extensions.DependencyInjection;
using Spectre.Console.Cli;

namespace Kysect.Configuin.Console;

public static class CommandAppInitializer
{
public static CommandApp Initialize(IServiceCollection services)
{
var registrar = new TypeRegistrar(services);
var app = new CommandApp(registrar);

app.Configure(config =>
{
config.AddCommand<GenerateCodeStyleDocCommand>("generate-styledoc");
config.AddCommand<EditorConfigApplyPreviewCommand>("preview");
config.AddCommand<AnalyzeEditorConfigCommand>("analyze");
config.AddCommand<GenerateEditorConfigTemplateTemplate>("template");
config.AddCommand<FormatEditorconfigCommand>("format");
config.AddCommand<GenerateRoslynRuleDocumentationFile>("generate-roslyn-documentation");
});

return app;
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Kysect.CommonLib.BaseTypes.Extensions;
using Kysect.Configuin.DotnetFormatIntegration;
using Kysect.Configuin.DotnetFormatIntegration.Abstractions;
using Spectre.Console.Cli;
using System.Diagnostics.CodeAnalysis;

namespace Kysect.Configuin.Console.Commands;

internal sealed class EditorConfigApplyPreviewCommand : Command<EditorConfigApplyPreviewCommand.Settings>
internal sealed class EditorConfigApplyPreviewCommand(
IDotnetFormatPreviewGenerator dotnetFormatPreviewGenerator
) : Command<EditorConfigApplyPreviewCommand.Settings>
{
public sealed class Settings : CommandSettings
{
Expand All @@ -18,21 +19,14 @@ public sealed class Settings : CommandSettings
public string NewEditorConfig { get; init; } = null!;
}

private readonly DotnetFormatPreviewGenerator _dotnetFormatPreviewGenerator;

public EditorConfigApplyPreviewCommand(DotnetFormatPreviewGenerator dotnetFormatPreviewGenerator)
{
_dotnetFormatPreviewGenerator = dotnetFormatPreviewGenerator;
}

public override int Execute([NotNull] CommandContext context, [NotNull] Settings settings)
public override int Execute(CommandContext context, Settings settings)
{
settings.SolutionPath.ThrowIfNull();
settings.SourceEditorConfig.ThrowIfNull();
settings.NewEditorConfig.ThrowIfNull();


_dotnetFormatPreviewGenerator.GetEditorConfigWarningUpdates(
dotnetFormatPreviewGenerator.GetEditorConfigWarningUpdates(
settings.SolutionPath,
settings.NewEditorConfig,
settings.SourceEditorConfig);
Expand Down
19 changes: 6 additions & 13 deletions Sources/Kysect.Configuin.Console/Kysect.Configuin.Console.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<NoWarn>$(NoWarn);CS1591;CA1724</NoWarn>
<NoWarn>$(NoWarn);CA1724</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="codeessentials.Extensions.Logging.Demystifier" />
<PackageReference Include="Kysect.CommonLib" />
Expand All @@ -20,14 +17,10 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Kysect.Configuin.CodeStyleDoc\Kysect.Configuin.CodeStyleDoc.csproj" />
<ProjectReference Include="..\Kysect.Configuin.Common\Kysect.Configuin.Common.csproj" />
<ProjectReference Include="..\Kysect.Configuin.ConfigurationRoot\Kysect.Configuin.ConfigurationRoot.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<ProjectReference Include="..\Kysect.Configuin.DotnetFormatIntegration.Abstractions\Kysect.Configuin.DotnetFormatIntegration.Abstractions.csproj" />
<ProjectReference Include="..\Kysect.Configuin.EditorConfig\Kysect.Configuin.EditorConfig.csproj" />
<ProjectReference Include="..\Kysect.Configuin.Learn.Abstraction\Kysect.Configuin.Learn.Abstraction.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Kysect.Configuin.DotnetFormatIntegration.Abstractions;

public interface IDotnetFormatPreviewGenerator
{
void GetEditorConfigWarningUpdates(string solutionPath, string newEditorConfig, string sourceEditorConfig);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<Project Sdk="Microsoft.NET.Sdk">
</Project>
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using Kysect.CommonLib.Collections.Diff;
using Kysect.CommonLib.Logging;
using Kysect.Configuin.DotnetFormatIntegration.Abstractions;
using Kysect.Configuin.DotnetFormatIntegration.Cli;
using Kysect.Configuin.DotnetFormatIntegration.FileSystem;
using Microsoft.Extensions.Logging;

namespace Kysect.Configuin.DotnetFormatIntegration;

public class DotnetFormatPreviewGenerator
public class DotnetFormatPreviewGenerator : IDotnetFormatPreviewGenerator
{
private readonly DotnetFormatWarningGenerator _dotnetFormatWarningGenerator;
private readonly TemporaryFileMover _temporaryFileMover;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Kysect.CommonLib" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Kysect.Configuin.DotnetFormatIntegration.Abstractions\Kysect.Configuin.DotnetFormatIntegration.Abstractions.csproj" />
</ItemGroup>
</Project>
28 changes: 14 additions & 14 deletions Sources/Kysect.Configuin.sln
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,24 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.Packages.props = Directory.Packages.props
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kysect.Configuin.Learn.Abstraction", "Kysect.Configuin.Learn.Abstraction\Kysect.Configuin.Learn.Abstraction.csproj", "{C16DFC44-C11B-4B7D-A1EF-242FAAC55DD6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kysect.Configuin.Learn.Abstraction", "Kysect.Configuin.Learn.Abstraction\Kysect.Configuin.Learn.Abstraction.csproj", "{C16DFC44-C11B-4B7D-A1EF-242FAAC55DD6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kysect.Configuin.Learn", "Kysect.Configuin.Learn\Kysect.Configuin.Learn.csproj", "{4428CEC8-DB24-42BC-9689-BA8DF769F603}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kysect.Configuin.Learn", "Kysect.Configuin.Learn\Kysect.Configuin.Learn.csproj", "{4428CEC8-DB24-42BC-9689-BA8DF769F603}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kysect.Configuin", "Kysect.Configuin\Kysect.Configuin.csproj", "{DC52757E-B97D-433D-BCC7-EB27364D8FC8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kysect.Configuin.DotnetFormatIntegration.Abstractions", "Kysect.Configuin.DotnetFormatIntegration.Abstractions\Kysect.Configuin.DotnetFormatIntegration.Abstractions.csproj", "{38439A63-7A20-40E1-AC7F-0143050CE124}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{38439A63-7A20-40E1-AC7F-0143050CE124}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{38439A63-7A20-40E1-AC7F-0143050CE124}.Debug|Any CPU.Build.0 = Debug|Any CPU
{38439A63-7A20-40E1-AC7F-0143050CE124}.Release|Any CPU.ActiveCfg = Release|Any CPU
{38439A63-7A20-40E1-AC7F-0143050CE124}.Release|Any CPU.Build.0 = Release|Any CPU
{4428CEC8-DB24-42BC-9689-BA8DF769F603}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4428CEC8-DB24-42BC-9689-BA8DF769F603}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4428CEC8-DB24-42BC-9689-BA8DF769F603}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -80,18 +88,10 @@ Global
{372CD01F-754F-4D95-8F59-F08F9BC645A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{372CD01F-754F-4D95-8F59-F08F9BC645A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{372CD01F-754F-4D95-8F59-F08F9BC645A6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {01578FC6-10E0-4D67-A696-986C508E2723}
EndGlobalSection
EndGlobal
fg = Debug|Any CPU
{372CD01F-754F-4D95-8F59-F08F9BC645A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{372CD01F-754F-4D95-8F59-F08F9BC645A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{372CD01F-754F-4D95-8F59-F08F9BC645A6}.Release|Any CPU.Build.0 = Release|Any CPU
{DC52757E-B97D-433D-BCC7-EB27364D8FC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DC52757E-B97D-433D-BCC7-EB27364D8FC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DC52757E-B97D-433D-BCC7-EB27364D8FC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DC52757E-B97D-433D-BCC7-EB27364D8FC8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
10 changes: 10 additions & 0 deletions Sources/Kysect.Configuin/Kysect.Configuin.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Kysect.Configuin.ConfigurationRoot\Kysect.Configuin.ConfigurationRoot.csproj" />
<ProjectReference Include="..\Kysect.Configuin.Console\Kysect.Configuin.Console.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
using Kysect.Configuin.ConfigurationRoot;
using Kysect.Configuin.Console.Commands;
using Kysect.Configuin.Console;
using Microsoft.Extensions.DependencyInjection;
using Spectre.Console.Cli;

namespace Kysect.Configuin.Console;
namespace Kysect.Configuin;

internal class Program
{
public static void Main(string[] args)
private static void Main(string[] args)
{

IServiceCollection registrations = DependencyBuilder.InitializeServiceProvider();

if (args.Length == 0)
args = PrepareTestCommand();

var registrar = new TypeRegistrar(registrations);
var app = new CommandApp(registrar);

app.Configure(config =>
{
config.AddCommand<GenerateCodeStyleDocCommand>("generate-styledoc");
config.AddCommand<EditorConfigApplyPreviewCommand>("preview");
config.AddCommand<AnalyzeEditorConfigCommand>("analyze");
config.AddCommand<GenerateEditorConfigTemplateTemplate>("template");
config.AddCommand<FormatEditorconfigCommand>("format");
config.AddCommand<GenerateRoslynRuleDocumentationFile>("generate-roslyn-documentation");
});

var app = CommandAppInitializer.Initialize(registrations);
app.Run(args);
}

Expand Down

0 comments on commit 378bced

Please sign in to comment.