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

code cleanup in XUnitConverter #186

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/XUnitConverter.Tests/AssertArgumentOrderTest.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Collections.Generic;
using System.Threading.Tasks;

using Microsoft.CodeAnalysis;

using Xunit;

namespace XUnitConverter.Tests
{
public class AssertArgumentOrderTest : ConverterTestBase
{
protected override XUnitConverter.ConverterBase CreateConverter()
protected override ConverterBase CreateConverter()
{
return new XUnitConverter.AssertArgumentOrderConverter();
return new AssertArgumentOrderConverter();
}

[Fact]
Expand Down
14 changes: 5 additions & 9 deletions src/XUnitConverter.Tests/ConverterTestBase.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Text;
using Xunit;
using XUnitConverter;

namespace XUnitConverter.Tests
{
Expand Down Expand Up @@ -39,10 +35,10 @@ private async Task<Project> RunConverter(Project project, bool runFormatter)
}
}

return solution.GetProject(project.Id); ;
return solution.GetProject(project.Id);
}

private Project CreateSolution(string source)
private static Project CreateSolution(string source)
{
var testProjectName = "Test";
var projectId = ProjectId.CreateNewId(testProjectName);
Expand Down
12 changes: 2 additions & 10 deletions src/XUnitConverter.Tests/MSTestToXUnitConverterTests.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Xunit;
using System.Threading;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Text;

namespace XUnitConverter.Tests
{
public class MSTestToXUnitConverterTests : ConverterTestBase
{
protected override XUnitConverter.ConverterBase CreateConverter()
protected override ConverterBase CreateConverter()
{
return new XUnitConverter.MSTestToXUnitConverter();
return new MSTestToXUnitConverter();
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Xunit;

namespace XUnitConverter.Tests
{
public class TestAssertTrueOrFalseConverterTests : ConverterTestBase
{
protected override XUnitConverter.ConverterBase CreateConverter()
protected override ConverterBase CreateConverter()
{
return new XUnitConverter.TestAssertTrueOrFalseConverter();
return new TestAssertTrueOrFalseConverter();
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions src/XUnitConverter/AssertArgumentOrderConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ private int IndexOfParameterWithName(IMethodSymbol symbol, HashSet<string> names

protected override async Task<Solution> ProcessAsync(
Document document,
SyntaxNode syntaxRoot,
SyntaxNode syntaxNode,
CancellationToken cancellationToken)
{
var rewriter = new Rewriter(await document.GetSemanticModelAsync(cancellationToken));
var newNode = rewriter.Visit(syntaxRoot);
var newNode = rewriter.Visit(syntaxNode);

return document.Project.Solution.WithDocumentSyntaxRoot(document.Id, newNode);
}
Expand Down
6 changes: 1 addition & 5 deletions src/XUnitConverter/ConverterBase.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.CodeAnalysis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;

namespace XUnitConverter
{
Expand Down
10 changes: 3 additions & 7 deletions src/XUnitConverter/MSTestToXUnitConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CodeGeneration;
using System.Runtime.Serialization;
using System.IO;
using Microsoft.CodeAnalysis.CSharp.Syntax;

namespace XUnitConverter
{
public sealed class MSTestToXUnitConverter : ConverterBase
{
private static object s_lockObject = new object();
private static readonly object s_lockObject = new object();
private static HashSet<string> s_mstestNamespaces;

private static UsingDirectiveSyntax RemoveLeadingAndTrailingCompilerDirectives(UsingDirectiveSyntax usingSyntax)
Expand Down
5 changes: 1 addition & 4 deletions src/XUnitConverter/Program.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.CodeAnalysis.MSBuild;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.MSBuild;

namespace XUnitConverter
{
Expand Down
5 changes: 0 additions & 5 deletions src/XUnitConverter/TestAssertTrueOrFalseConverter.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
Expand Down