diff --git a/Sources/Kysect.Configuin.CodeStyleDoc/CodeStyleGenerator.cs b/Sources/Kysect.Configuin.CodeStyleDoc/CodeStyleGenerator.cs index 560d5ed..f97eabe 100644 --- a/Sources/Kysect.Configuin.CodeStyleDoc/CodeStyleGenerator.cs +++ b/Sources/Kysect.Configuin.CodeStyleDoc/CodeStyleGenerator.cs @@ -108,7 +108,8 @@ private ICodeStyleElement ParseRuleSettings( RoslynStyleRule rule = ruleGroup.Rules.Single(r => r.RuleId.Equals(severityEditorConfigSetting.RuleId)); var options = ruleGroup .Options - .Select(o => GetOptionConfiguration(optionConfigurations, o.Name)) + .Select(o => FindOptionConfiguration(optionConfigurations, o.Name)) + .WhereNotNull() .ToList(); return new CodeStyleRoslynStyleRuleConfiguration(rule, severityEditorConfigSetting.Severity, options, ruleGroup.Overview, ruleGroup.Example); @@ -123,14 +124,10 @@ private ICodeStyleElement ParseRuleSettings( throw new ConfiguinException($"Rule with id {severityEditorConfigSetting.RuleId} was not found"); } - private CodeStyleRoslynOptionConfiguration GetOptionConfiguration( + private CodeStyleRoslynOptionConfiguration? FindOptionConfiguration( IReadOnlyCollection optionConfigurations, string name) { - CodeStyleRoslynOptionConfiguration? option = optionConfigurations.FirstOrDefault(o => o.Option.Name == name); - if (option is null) - throw new ConfiguinException($"Option with name {name} was not found"); - - return option; + return optionConfigurations.FirstOrDefault(o => o.Option.Name == name); } } \ No newline at end of file diff --git a/Sources/Kysect.Configuin.MsLearn/MsLearnDocumentationParser.cs b/Sources/Kysect.Configuin.MsLearn/MsLearnDocumentationParser.cs index e264d78..59a5a2f 100644 --- a/Sources/Kysect.Configuin.MsLearn/MsLearnDocumentationParser.cs +++ b/Sources/Kysect.Configuin.MsLearn/MsLearnDocumentationParser.cs @@ -1,3 +1,4 @@ +using Kysect.CommonLib.BaseTypes.Extensions; using Kysect.Configuin.Common; using Kysect.Configuin.Markdown.Documents; using Kysect.Configuin.Markdown.Tables; @@ -81,6 +82,10 @@ private List ParseIde0055FormatOptions( public RoslynStyleRuleGroup ParseStyleRules(string info) { + info.ThrowIfNull(); + + info = _documentationPreprocessor.Process(info); + MarkdownDocument markdownDocument = MarkdownDocumentExtensions.CreateFromString(info); IReadOnlyCollection markdownHeadedBlocks = markdownDocument.SplitByHeaders(_textExtractor); diff --git a/Sources/Kysect.Configuin.MsLearn/MsLearnDocumentationPreprocessor.cs b/Sources/Kysect.Configuin.MsLearn/MsLearnDocumentationPreprocessor.cs index a2acf3c..885157e 100644 --- a/Sources/Kysect.Configuin.MsLearn/MsLearnDocumentationPreprocessor.cs +++ b/Sources/Kysect.Configuin.MsLearn/MsLearnDocumentationPreprocessor.cs @@ -7,6 +7,8 @@ public class MsLearnDocumentationPreprocessor { public MsLearnDocumentationRawInfo Process(MsLearnDocumentationRawInfo info) { + info.ThrowIfNull(); + return new MsLearnDocumentationRawInfo( info.QualityRuleFileContents.Select(Process).ToList(), info.StyleRuleFileContents.Select(Process).ToList(), @@ -27,6 +29,8 @@ public string Process(string input) lines = RemoveZones(lines); + lines = lines.Where(l => !l.StartsWith("[!INCLUDE")).ToList(); + return string.Join(Environment.NewLine, lines); } @@ -41,14 +45,18 @@ private List RemoveZones(List lines) if (startIndex == -1 || endIndex == -1 || startIndex >= endIndex) throw new ArgumentException("Cannot find zones for removing"); - if (lines[startIndex].StartsWith(":::zone pivot=\"lang-csharp-vb\"")) + bool actualZone = lines[startIndex].StartsWith(":::zone pivot=\"lang-csharp-vb\"") + || lines[startIndex].StartsWith(":::zone pivot=\"dotnet-8-0\""); + if (actualZone) { lines.RemoveAt(endIndex); lines.RemoveAt(startIndex); continue; } - if (lines[startIndex].StartsWith(":::zone pivot=\"lang-fsharp\"")) + bool notActualZone = lines[startIndex].StartsWith(":::zone pivot=\"lang-fsharp\"") + || lines[startIndex].StartsWith(":::zone pivot=\"dotnet-7-0,dotnet-6-0\""); + if (notActualZone) { lines.RemoveRange(startIndex, endIndex - startIndex + 1); continue; diff --git a/Sources/Kysect.Configuin.MsLearn/Tables/MsLearnTableParser.cs b/Sources/Kysect.Configuin.MsLearn/Tables/MsLearnTableParser.cs index 2b9da5b..acb18c3 100644 --- a/Sources/Kysect.Configuin.MsLearn/Tables/MsLearnTableParser.cs +++ b/Sources/Kysect.Configuin.MsLearn/Tables/MsLearnTableParser.cs @@ -65,6 +65,9 @@ private static void ValidateTableHeader(MarkdownTableContent simpleTable) string[] expectedHeaders = { "Property", "Value", "Description" }; for (int i = 0; i < simpleTable.Headers.Count; i++) { + if (string.IsNullOrEmpty(simpleTable.Headers[i])) + continue; + if (simpleTable.Headers[i] != expectedHeaders[i]) throw new ArgumentException($"Table header on index {i} must be equal to {expectedHeaders[i]} but was {simpleTable.Headers[i]}"); } diff --git a/ms-learn b/ms-learn index 580d9e0..c24f784 160000 --- a/ms-learn +++ b/ms-learn @@ -1 +1 @@ -Subproject commit 580d9e096eefc6933545d8bf2c214f69c7e623ea +Subproject commit c24f78455608122bad39f73001bc14365f03f683