diff --git a/Sources/Kysect.Configuin.Common/Kysect.Configuin.Common.csproj b/Sources/Kysect.Configuin.Common/Kysect.Configuin.Common.csproj index d7ed19c..b97c167 100644 --- a/Sources/Kysect.Configuin.Common/Kysect.Configuin.Common.csproj +++ b/Sources/Kysect.Configuin.Common/Kysect.Configuin.Common.csproj @@ -5,7 +5,7 @@ - + diff --git a/Sources/Kysect.Configuin.Console/Kysect.Configuin.Console.csproj b/Sources/Kysect.Configuin.Console/Kysect.Configuin.Console.csproj index a36fe2e..f295740 100644 --- a/Sources/Kysect.Configuin.Console/Kysect.Configuin.Console.csproj +++ b/Sources/Kysect.Configuin.Console/Kysect.Configuin.Console.csproj @@ -8,7 +8,7 @@ - + diff --git a/Sources/Kysect.Configuin.Core/CodeStyleGeneration/Markdown/MarkdownCodeStyleFormatter.cs b/Sources/Kysect.Configuin.Core/CodeStyleGeneration/Markdown/MarkdownCodeStyleFormatter.cs index 48fde57..a64a137 100644 --- a/Sources/Kysect.Configuin.Core/CodeStyleGeneration/Markdown/MarkdownCodeStyleFormatter.cs +++ b/Sources/Kysect.Configuin.Core/CodeStyleGeneration/Markdown/MarkdownCodeStyleFormatter.cs @@ -50,7 +50,7 @@ public string FormatQualityRule(CodeStyleRoslynQualityRuleConfiguration rule) { var builder = new MarkdownStringBuilder(); - builder.AddH2(rule.Rule.RuleId.ToString()); + builder.AddH2($"{rule.Rule.Title} ({rule.Rule.RuleId})"); builder.AddEmptyLine(); builder.AddText($"Severity: {rule.Severity}"); diff --git a/Sources/Kysect.Configuin.Core/Kysect.Configuin.Core.csproj b/Sources/Kysect.Configuin.Core/Kysect.Configuin.Core.csproj index 232bd49..4958704 100644 --- a/Sources/Kysect.Configuin.Core/Kysect.Configuin.Core.csproj +++ b/Sources/Kysect.Configuin.Core/Kysect.Configuin.Core.csproj @@ -8,7 +8,7 @@ - + diff --git a/Sources/Kysect.Configuin.Core/MsLearnDocumentation/MsLearnDocumentationParser.cs b/Sources/Kysect.Configuin.Core/MsLearnDocumentation/MsLearnDocumentationParser.cs index 08efa31..8dec8c7 100644 --- a/Sources/Kysect.Configuin.Core/MsLearnDocumentation/MsLearnDocumentationParser.cs +++ b/Sources/Kysect.Configuin.Core/MsLearnDocumentation/MsLearnDocumentationParser.cs @@ -124,6 +124,7 @@ public IReadOnlyCollection ParseQualityRules(string info) MsLearnPropertyValueDescriptionTable table = _msLearnTableParser.Parse(markdownTableContent); MsLearnPropertyValueDescriptionTableRow ruleId = table.GetSingleValue("Rule ID"); + MsLearnPropertyValueDescriptionTableRow title = table.GetSingleValue("Title"); MsLearnPropertyValueDescriptionTableRow category = table.GetSingleValue("Category"); // TODO: add this fields to model MsLearnPropertyValueDescriptionTableRow breakingChanges = table.GetSingleValue("Fix is breaking or non-breaking"); @@ -136,8 +137,7 @@ public IReadOnlyCollection ParseQualityRules(string info) return ruleIds .Select(id => new RoslynQualityRule( id, - // TODO: #40 parse rule name - ruleName: string.Empty, + title.Value, category.Value, // TODO: #41 parse description description: string.Empty)) diff --git a/Sources/Kysect.Configuin.Core/MsLearnDocumentation/Tables/MsLearnTableParser.cs b/Sources/Kysect.Configuin.Core/MsLearnDocumentation/Tables/MsLearnTableParser.cs index f74d0c4..491f0bd 100644 --- a/Sources/Kysect.Configuin.Core/MsLearnDocumentation/Tables/MsLearnTableParser.cs +++ b/Sources/Kysect.Configuin.Core/MsLearnDocumentation/Tables/MsLearnTableParser.cs @@ -57,13 +57,11 @@ private static void ValidateTableHeader(MarkdownTableContent simpleTable) if (simpleTable.Headers.Count != 2 && simpleTable.Headers.Count != 3) throw new ArgumentException($"Unexpected column count in property-value table. Expected 2 or 3, but was {simpleTable.Headers.Count}"); - // TODO: This validation sometimes throw error. In some cases table has "Item" column instead of "Property". - // Maybe we need to drop it. - //string[] expectedHeaders = { "Property", "Value", "Description" }; - //for (int i = 0; i < simpleTable.Headers.Count; i++) - //{ - // if (!string.IsNullOrEmpty(simpleTable.Headers[i]) && simpleTable.Headers[i] != expectedHeaders[i]) - // throw new ArgumentException($"Table header on index {i} must be equal to {expectedHeaders[i]} but was {simpleTable.Headers[i]}"); - //} + string[] expectedHeaders = { "Property", "Value", "Description" }; + for (int i = 0; i < simpleTable.Headers.Count; i++) + { + 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]}"); + } } } \ No newline at end of file diff --git a/Sources/Kysect.Configuin.Core/RoslynRuleModels/RoslynQualityRule.cs b/Sources/Kysect.Configuin.Core/RoslynRuleModels/RoslynQualityRule.cs index 4bc14a3..e3de4fa 100644 --- a/Sources/Kysect.Configuin.Core/RoslynRuleModels/RoslynQualityRule.cs +++ b/Sources/Kysect.Configuin.Core/RoslynRuleModels/RoslynQualityRule.cs @@ -3,14 +3,14 @@ public class RoslynQualityRule { public RoslynRuleId RuleId { get; } - public string RuleName { get; } + public string Title { get; } public string Category { get; } public string Description { get; } - public RoslynQualityRule(RoslynRuleId ruleId, string ruleName, string category, string description) + public RoslynQualityRule(RoslynRuleId ruleId, string title, string category, string description) { RuleId = ruleId; - RuleName = ruleName; + Title = title; Category = category; Description = description; } diff --git a/Sources/Kysect.Configuin.Tests/CodeStyleGeneration/MarkdownCodeStyleFormatterTests.cs b/Sources/Kysect.Configuin.Tests/CodeStyleGeneration/MarkdownCodeStyleFormatterTests.cs index 157481b..f727e36 100644 --- a/Sources/Kysect.Configuin.Tests/CodeStyleGeneration/MarkdownCodeStyleFormatterTests.cs +++ b/Sources/Kysect.Configuin.Tests/CodeStyleGeneration/MarkdownCodeStyleFormatterTests.cs @@ -56,10 +56,9 @@ class MyClass [Test] public void FormatQualityRule_ForCA1064_ReturnExpected() { - // TODO: change CA1064 -> Exceptions should be public (CA1064) // TODO: add description const string expected = """ - ## CA1064 + ## Exceptions should be public (CA1064) Severity: Warning diff --git a/Sources/Kysect.Configuin.Tests/MsLearnDocumentation/MsLearnDocumentationParserTests.cs b/Sources/Kysect.Configuin.Tests/MsLearnDocumentation/MsLearnDocumentationParserTests.cs index 014d951..4fe6a48 100644 --- a/Sources/Kysect.Configuin.Tests/MsLearnDocumentation/MsLearnDocumentationParserTests.cs +++ b/Sources/Kysect.Configuin.Tests/MsLearnDocumentation/MsLearnDocumentationParserTests.cs @@ -149,8 +149,7 @@ public void ParseQualityRule_CA1865_CA1867_ReturnExpectedResult() // TODO: parse description var expected = new RoslynQualityRule( RoslynRuleId.Parse("CA1865"), - // TODO: parse name? - ruleName: string.Empty, + "Use 'string.Method(char)' instead of 'string.Method(string)' for string with single char", category: "Performance", // TODO: parse description? description: string.Empty); diff --git a/Sources/Kysect.Configuin.Tests/MsLearnDocumentation/MsLearnTableParserTests.cs b/Sources/Kysect.Configuin.Tests/MsLearnDocumentation/MsLearnTableParserTests.cs index 1248546..2a6b94b 100644 --- a/Sources/Kysect.Configuin.Tests/MsLearnDocumentation/MsLearnTableParserTests.cs +++ b/Sources/Kysect.Configuin.Tests/MsLearnDocumentation/MsLearnTableParserTests.cs @@ -21,7 +21,7 @@ public class MsLearnTableParserTests public void Parse_KeyValueTable_ReturnExpectedResult() { string input = """ - | | Value | + | Property | Value | |-------------------------------------|------------------------------| | **Rule ID** | CA1000 | | **Category** | [Design](design-warnings.md) | diff --git a/Sources/Kysect.Configuin.Tests/Resources/WellKnownRoslynRuleDefinitions.cs b/Sources/Kysect.Configuin.Tests/Resources/WellKnownRoslynRuleDefinitions.cs index 1234816..f02185a 100644 --- a/Sources/Kysect.Configuin.Tests/Resources/WellKnownRoslynRuleDefinitions.cs +++ b/Sources/Kysect.Configuin.Tests/Resources/WellKnownRoslynRuleDefinitions.cs @@ -46,11 +46,11 @@ class MyClass public static RoslynQualityRule CA1064() { - // TODO: parse description return new RoslynQualityRule( RoslynRuleId.Parse("CA1064"), - string.Empty, + "Exceptions should be public", "Design", + // TODO: parse description string.Empty); } } \ No newline at end of file diff --git a/ms-learn b/ms-learn index 4db1bae..d11c0f1 160000 --- a/ms-learn +++ b/ms-learn @@ -1 +1 @@ -Subproject commit 4db1baedec260460a8bc8fbccb5fcd753374c494 +Subproject commit d11c0f18c81a4099ed3078f715cc8a1f5966f936