Skip to content

Commit 894d076

Browse files
committed
Simplify implementation of SA1600 code fix following review
1 parent 825805f commit 894d076

5 files changed

Lines changed: 14 additions & 41 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1600CodeFixProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private static Task<Document> GetMethodDocumentationTransformedDocumentAsync(Doc
145145

146146
var documentationNodes = new List<XmlNodeSyntax>();
147147

148-
documentationNodes.Add(XmlSyntaxFactory.EmptySummaryElement(newLineText));
148+
documentationNodes.Add(XmlSyntaxFactory.SummaryElement(newLineText));
149149

150150
if (methodDeclaration.TypeParameterList != null)
151151
{
@@ -185,7 +185,7 @@ private static Task<Document> GetMethodDocumentationTransformedDocumentAsync(Doc
185185
};
186186

187187
documentationNodes.Add(XmlSyntaxFactory.NewLine(newLineText));
188-
documentationNodes.Add(XmlSyntaxFactory.CompactReturnsElement(returnContent));
188+
documentationNodes.Add(XmlSyntaxFactory.ReturnsElement(returnContent));
189189

190190
var documentationComment =
191191
XmlSyntaxFactory.DocumentationComment(

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1600UnitTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ public Task<T> TestMethod6<T>(T param1, int param2)
726726
public {typeKeyword} Test
727727
{{
728728
/// <summary>
729+
///
729730
/// </summary>
730731
/// <returns>A <see cref=""Task""/> representing the result of the asynchronous operation.</returns>
731732
public Task TestMethod1()
@@ -734,6 +735,7 @@ public Task TestMethod1()
734735
}}
735736
736737
/// <summary>
738+
///
737739
/// </summary>
738740
/// <returns>A <see cref=""Task{{TResult}}""/> representing the result of the asynchronous operation.</returns>
739741
public Task<int> TestMethod2()
@@ -742,6 +744,7 @@ public Task<int> TestMethod2()
742744
}}
743745
744746
/// <summary>
747+
///
745748
/// </summary>
746749
/// <typeparam name=""T""></typeparam>
747750
/// <returns>A <see cref=""Task{{TResult}}""/> representing the result of the asynchronous operation.</returns>
@@ -751,6 +754,7 @@ public Task<T> TestMethod3<T>()
751754
}}
752755
753756
/// <summary>
757+
///
754758
/// </summary>
755759
/// <param name=""param1""></param>
756760
/// <param name=""param2""></param>
@@ -761,6 +765,7 @@ public Task TestMethod4(int param1, int param2)
761765
}}
762766
763767
/// <summary>
768+
///
764769
/// </summary>
765770
/// <param name=""param1""></param>
766771
/// <param name=""param2""></param>
@@ -771,6 +776,7 @@ public Task<int> TestMethod5(int param1, int param2)
771776
}}
772777
773778
/// <summary>
779+
///
774780
/// </summary>
775781
/// <typeparam name=""T""></typeparam>
776782
/// <param name=""param1""></param>

StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/XmlSyntaxFactoryTests.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,8 @@ public void TestRemarksElement()
7070
[Fact]
7171
public void TestReturnsElement()
7272
{
73-
string expected =
74-
"<returns>\r\n"
75-
+ "/// Returns.\r\n"
76-
+ "/// </returns>";
77-
Assert.Equal(expected, XmlSyntaxFactory.ReturnsElement("\r\n", XmlSyntaxFactory.Text("Returns.")).ToFullString());
73+
string expected = "<returns>Returns.</returns>";
74+
Assert.Equal(expected, XmlSyntaxFactory.ReturnsElement(XmlSyntaxFactory.Text("Returns.")).ToFullString());
7875
}
7976

8077
[Fact]

StyleCop.Analyzers/StyleCop.Analyzers/Helpers/XmlSyntaxFactory.cs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,6 @@ public static XmlElementSyntax SummaryElement(string newLineText, SyntaxList<Xml
171171
return MultiLineElement(XmlCommentHelper.SummaryXmlTag, newLineText, content);
172172
}
173173

174-
public static XmlElementSyntax EmptySummaryElement(string newLineText)
175-
{
176-
return Element(XmlCommentHelper.SummaryXmlTag, SyntaxFactory.List(new XmlNodeSyntax[] { NewLine(newLineText) }));
177-
}
178-
179174
public static XmlElementSyntax RemarksElement(string newLineText, params XmlNodeSyntax[] content)
180175
{
181176
return RemarksElement(newLineText, List(content));
@@ -186,22 +181,12 @@ public static XmlElementSyntax RemarksElement(string newLineText, SyntaxList<Xml
186181
return MultiLineElement("remarks", newLineText, content);
187182
}
188183

189-
public static XmlElementSyntax ReturnsElement(string newLineText, params XmlNodeSyntax[] content)
190-
{
191-
return ReturnsElement(newLineText, List(content));
192-
}
193-
194-
public static XmlElementSyntax ReturnsElement(string newLineText, SyntaxList<XmlNodeSyntax> content)
195-
{
196-
return MultiLineElement(XmlCommentHelper.ReturnsXmlTag, newLineText, content);
197-
}
198-
199-
public static XmlElementSyntax CompactReturnsElement(params XmlNodeSyntax[] content)
184+
public static XmlElementSyntax ReturnsElement(params XmlNodeSyntax[] content)
200185
{
201-
return CompactReturnsElement(List(content));
186+
return ReturnsElement(List(content));
202187
}
203188

204-
public static XmlElementSyntax CompactReturnsElement(SyntaxList<XmlNodeSyntax> content)
189+
public static XmlElementSyntax ReturnsElement(SyntaxList<XmlNodeSyntax> content)
205190
{
206191
return Element(XmlCommentHelper.ReturnsXmlTag, content);
207192
}
@@ -255,7 +240,7 @@ public static XmlElementSyntax TypeParamElement(string parameterName, params Xml
255240

256241
public static XmlElementSyntax TypeParamElement(string parameterName, SyntaxList<XmlNodeSyntax> content)
257242
{
258-
XmlElementSyntax element = Element("typeparam", content);
243+
XmlElementSyntax element = Element(XmlCommentHelper.TypeParamXmlTag, content);
259244
return element.WithStartTag(element.StartTag.AddAttributes(NameAttribute(parameterName)));
260245
}
261246

StyleCop.Analyzers/StyleCop.Analyzers/StyleCop.Analyzers.csproj

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,4 @@
3737
<None Include="**\*.json" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
3838
</ItemGroup>
3939

40-
<ItemGroup>
41-
<Compile Update="DocumentationRules\DocumentationResources.Designer.cs">
42-
<DesignTime>True</DesignTime>
43-
<AutoGen>True</AutoGen>
44-
<DependentUpon>DocumentationResources.resx</DependentUpon>
45-
</Compile>
46-
</ItemGroup>
47-
48-
<ItemGroup>
49-
<EmbeddedResource Update="DocumentationRules\DocumentationResources.resx">
50-
<Generator>ResXFileCodeGenerator</Generator>
51-
<LastGenOutput>DocumentationResources.Designer.cs</LastGenOutput>
52-
</EmbeddedResource>
53-
</ItemGroup>
54-
5540
</Project>

0 commit comments

Comments
 (0)