Skip to content
This repository was archived by the owner on Jul 12, 2022. It is now read-only.

Commit c833fdc

Browse files
committed
Merge pull request #169 from rainersigwald/keep-class-comments-in-xunit
Preserve leading trivia when deleting TestClassAttribute
2 parents a35a6cd + 0458032 commit c833fdc

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/XUnitConverter.Tests/MSTestToXUnitConverterTests.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,42 @@ public class MyTestClass
103103
await Verify(text, expected);
104104
}
105105

106+
[Fact]
107+
public async Task TestPreserveClassDocComments()
108+
{
109+
string text = @"
110+
using System;
111+
using Microsoft.VisualStudio.TestTools.UnitTesting;
112+
113+
namespace System.Composition.UnitTests
114+
{
115+
/// <summary>
116+
/// Some sort of doc comment.
117+
/// </summary>
118+
[TestClass]
119+
public class MyTestClass
120+
{
121+
}
122+
}
123+
";
124+
var expected = @"
125+
using System;
126+
using Xunit;
127+
128+
namespace System.Composition.UnitTests
129+
{
130+
/// <summary>
131+
/// Some sort of doc comment.
132+
/// </summary>
133+
public class MyTestClass
134+
{
135+
}
136+
}
137+
";
138+
await Verify(text, expected);
139+
}
140+
141+
106142
[Fact]
107143
public async Task TestUpdatesTestMethodAttributes()
108144
{

src/XUnitConverter/MSTestToXUnitConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ private void RemoveTestAttributes(CompilationUnitSyntax root, SemanticModel sema
163163
}
164164
else
165165
{
166-
transformationRoot = transformationRoot.RemoveNode(attributeListSyntax, SyntaxRemoveOptions.KeepNoTrivia);
166+
transformationRoot = transformationRoot.RemoveNode(attributeListSyntax, SyntaxRemoveOptions.KeepLeadingTrivia);
167167
}
168168
}
169169
return transformationRoot;

0 commit comments

Comments
 (0)