SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
https://www.specflow.org/
Other
2.25k stars 754 forks source link

MSTest.AssemblyHooks.cs violates SA1210 rule #1864

Closed zplan closed 4 years ago

zplan commented 4 years ago

SpecFlow Version:

Used Test Runner

Version number: 3.1.80

Project Format of the SpecFlow project

.feature.cs files are generated using

Visual Studio Version

Enable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings

Are the latest Visual Studio updates installed?

.NET Framework:

Test Execution Method:

Issue Description

Follow-up issue to https://github.com/SpecFlowOSS/SpecFlow/issues/1848

Our projects have installed the "Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8". This includes the analyzer StyleCop.Analyzers with the default rule SA1210 "The using directives within a C# code file are not sorted alphabetically by namespace.". For our release builds we have the flag TreatWarningsAsErrors = true, so we are not able to compile without errors anymore because of this specflow issue.

By fixing the issue https://github.com/SpecFlowOSS/SpecFlow/issues/1848 the wrong using order was introduced.

MSTest.AssemblyHooks.cs(1,1): error SA1210: Using directives should be ordered alphabetically by the namespaces.

MSTest.AssemblyHooks.cs:

using System.Diagnostics;
using System.CodeDom.Compiler;
using global::Microsoft.VisualStudio.TestTools.UnitTesting;
using global::TechTalk.SpecFlow;

[GeneratedCode("SpecFlow", "3.1.80")]
[TestClass]
public class ...
...

Steps to Reproduce

Create a test project (netcoreapp2.1 or net472) Set true in csproj add nuget packages: SpecFlow, SpecFlow.MsTest, SpecFlow.Tools.MsBuild.Generation version 3.1.80 add nuget package: Microsoft.CodeAnalysis.FxCopAnalyzers version 2.9.8 compile you should see an error like this: obj\Release\net472\MSTest.AssemblyHooks.cs(1,1): error SA1210: Using directives should be ordered alphabetically by the namespaces.[C:\MyProject\MyProject.csproj]

SabotageAndi commented 4 years ago

The files are located here:

https://github.com/SpecFlowOSS/SpecFlow/tree/master/Plugins/TechTalk.SpecFlow.MSTest.Generator.SpecFlowPlugin/build https://github.com/SpecFlowOSS/SpecFlow/tree/master/Plugins/TechTalk.SpecFlow.NUnit.Generator.SpecFlowPlugin/build https://github.com/SpecFlowOSS/SpecFlow/tree/master/Plugins/TechTalk.SpecFlow.xUnit.Generator.SpecFlowPlugin/build

If you send us a PR with the correct order, we can release a fixed version probably tomorrow.

zplan commented 4 years ago

If you send us a PR with the correct order, we can release a fixed version probably tomorrow.

PR https://github.com/SpecFlowOSS/SpecFlow/pull/1865 created.

SabotageAndi commented 4 years ago

Sorry for the delay. NuGet packages are uploading now to NuGet.org

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.