-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add possibility to execute commands without cloned MS Learn repository
- Loading branch information
Showing
14 changed files
with
90 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
Sources/Kysect.Configuin.Console/Commands/GenerateRoslynRuleDocumentationFile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Kysect.CommonLib.BaseTypes.Extensions; | ||
using Kysect.Configuin.Learn.Abstraction; | ||
using Kysect.Configuin.RoslynModels; | ||
using Spectre.Console.Cli; | ||
using System.ComponentModel; | ||
using System.Text.Json; | ||
|
||
namespace Kysect.Configuin.Console.Commands; | ||
|
||
public class GenerateRoslynRuleDocumentationFile( | ||
IRoslynRuleDocumentationParser roslynRuleDocumentationParser | ||
) : Command<GenerateRoslynRuleDocumentationFile.Settings> | ||
{ | ||
public sealed class Settings : CommandSettings | ||
{ | ||
[Description("Path to cloned MS Learn repository.")] | ||
[CommandArgument(0, "[ms-repo-path]")] | ||
public string? MsLearnRepositoryPath { get; init; } | ||
|
||
[Description("Output path.")] | ||
[CommandArgument(0, "[output-path]")] | ||
public string? OutputPath { get; init; } | ||
} | ||
|
||
public override int Execute(CommandContext context, Settings settings) | ||
{ | ||
settings.ThrowIfNull(); | ||
settings.MsLearnRepositoryPath.ThrowIfNull(); | ||
settings.OutputPath.ThrowIfNull(); | ||
|
||
RoslynRules roslynRules = roslynRuleDocumentationParser.Parse(settings.MsLearnRepositoryPath); | ||
string documentation = JsonSerializer.Serialize(roslynRules); | ||
File.WriteAllText(settings.OutputPath, documentation); | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
Sources/Kysect.Configuin.Console/RoslynRuleDocumentationCache.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Kysect.CommonLib.BaseTypes.Extensions; | ||
using Kysect.Configuin.Common; | ||
using Kysect.Configuin.RoslynModels; | ||
using System.Text.Json; | ||
|
||
namespace Kysect.Configuin.Console; | ||
|
||
public static class RoslynRuleDocumentationCache | ||
{ | ||
public static RoslynRules ReadFromCache() | ||
{ | ||
var fileName = "roslyn-rules.json"; | ||
if (!File.Exists(fileName)) | ||
{ | ||
throw new ConfiguinException($"File with {fileName} was not found"); | ||
} | ||
|
||
string readAllText = File.ReadAllText(fileName); | ||
return JsonSerializer.Deserialize<RoslynRules>(readAllText).ThrowIfNull(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters