From 0bfb9e2ef9626990f1bb3beb77d4132dae16d1fb Mon Sep 17 00:00:00 2001 From: Michael Hauer Date: Wed, 7 Oct 2015 19:20:51 +0200 Subject: [PATCH] code cleanup in XUnitConverter - using statements - static methods when possible - ... --- .../AssertArgumentOrderTest.cs | 8 ++------ src/XUnitConverter.Tests/ConverterTestBase.cs | 14 +++++--------- .../MSTestToXUnitConverterTests.cs | 12 ++---------- .../TestAssertTrueOrFalseConverterTests.cs | 9 ++------- src/XUnitConverter/AssertArgumentOrderConverter.cs | 4 ++-- src/XUnitConverter/ConverterBase.cs | 6 +----- src/XUnitConverter/MSTestToXUnitConverter.cs | 10 +++------- src/XUnitConverter/Program.cs | 5 +---- .../TestAssertTrueOrFalseConverter.cs | 5 ----- 9 files changed, 18 insertions(+), 55 deletions(-) diff --git a/src/XUnitConverter.Tests/AssertArgumentOrderTest.cs b/src/XUnitConverter.Tests/AssertArgumentOrderTest.cs index 4ec8f69b..c571ade2 100644 --- a/src/XUnitConverter.Tests/AssertArgumentOrderTest.cs +++ b/src/XUnitConverter.Tests/AssertArgumentOrderTest.cs @@ -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] diff --git a/src/XUnitConverter.Tests/ConverterTestBase.cs b/src/XUnitConverter.Tests/ConverterTestBase.cs index d6c066ae..c3754acb 100644 --- a/src/XUnitConverter.Tests/ConverterTestBase.cs +++ b/src/XUnitConverter.Tests/ConverterTestBase.cs @@ -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 { @@ -39,10 +35,10 @@ private async Task 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); diff --git a/src/XUnitConverter.Tests/MSTestToXUnitConverterTests.cs b/src/XUnitConverter.Tests/MSTestToXUnitConverterTests.cs index 140ca071..4a929de4 100644 --- a/src/XUnitConverter.Tests/MSTestToXUnitConverterTests.cs +++ b/src/XUnitConverter.Tests/MSTestToXUnitConverterTests.cs @@ -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] diff --git a/src/XUnitConverter.Tests/TestAssertTrueOrFalseConverterTests.cs b/src/XUnitConverter.Tests/TestAssertTrueOrFalseConverterTests.cs index e8ea2bab..38ca7fc0 100644 --- a/src/XUnitConverter.Tests/TestAssertTrueOrFalseConverterTests.cs +++ b/src/XUnitConverter.Tests/TestAssertTrueOrFalseConverterTests.cs @@ -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] diff --git a/src/XUnitConverter/AssertArgumentOrderConverter.cs b/src/XUnitConverter/AssertArgumentOrderConverter.cs index 8ecbda11..daec79db 100644 --- a/src/XUnitConverter/AssertArgumentOrderConverter.cs +++ b/src/XUnitConverter/AssertArgumentOrderConverter.cs @@ -128,11 +128,11 @@ private int IndexOfParameterWithName(IMethodSymbol symbol, HashSet names protected override async Task 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); } diff --git a/src/XUnitConverter/ConverterBase.cs b/src/XUnitConverter/ConverterBase.cs index e5c83ef8..a0276899 100644 --- a/src/XUnitConverter/ConverterBase.cs +++ b/src/XUnitConverter/ConverterBase.cs @@ -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 { diff --git a/src/XUnitConverter/MSTestToXUnitConverter.cs b/src/XUnitConverter/MSTestToXUnitConverter.cs index ad8945a9..57910324 100644 --- a/src/XUnitConverter/MSTestToXUnitConverter.cs +++ b/src/XUnitConverter/MSTestToXUnitConverter.cs @@ -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 s_mstestNamespaces; private static UsingDirectiveSyntax RemoveLeadingAndTrailingCompilerDirectives(UsingDirectiveSyntax usingSyntax) diff --git a/src/XUnitConverter/Program.cs b/src/XUnitConverter/Program.cs index 93797bee..db6d7d93 100644 --- a/src/XUnitConverter/Program.cs +++ b/src/XUnitConverter/Program.cs @@ -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 { diff --git a/src/XUnitConverter/TestAssertTrueOrFalseConverter.cs b/src/XUnitConverter/TestAssertTrueOrFalseConverter.cs index a74edf12..b5573897 100644 --- a/src/XUnitConverter/TestAssertTrueOrFalseConverter.cs +++ b/src/XUnitConverter/TestAssertTrueOrFalseConverter.cs @@ -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;