Specflow: Unnecessary generated file changes when switching between platforms

Created on 31 Oct 2018  路  12Comments  路  Source: SpecFlowOSS/SpecFlow

SpecFlow Version:

  • [x] 3.0

Used Test Runner

  • [x] Xunit


Version number: 3.0.132-beta

Visual Studio Version

  • [x] VS for Mac

Are the latest Visual Studio updates installed?

  • [x] Yes

.NET Framework:

  • [x] .NET Core 2.0

Test Execution Method:

  • [x] VS for Mac Unit Tests

<SpecFlow> Section in app.config

{
"bindingCulture": {
"language": "en-us"
},
"language": {
"feature": "en-us"
},

"plugins": [],
"stepAssemblies": [
{
"assembly": "BDD.NetCore.Steps.Adapters"
},
{
"assembly": "BDD.NetCore.Launcher"
}
]
}

Repro Project

None

Issue Description

There's an unnecessary source code change when switching to Mac from Windows and vice versa. It's related to newline
MacOS: In order to try out algorithms\n\t vs Windows:In order to try out algorithms\r\n\t

Suggested workaround: use ${Environment.NewLine} in the generated code

PS: Will be happy to pr

Bug Generator up-for-grabs hard medium

All 12 comments

@SabotageAndi

Perhaps I am overlooking currently something, but won't be the problem still exists when using Environment.NewLine? On Windows it is \r\n, on MacOS it's \n. So there will be always a different in the generated file.
Additionally, the code is generated via CodeDom. We don't write it manually into the file. So I am not sure if we can adjust that.

Is the Line-Ending problem not something, that could be solved with git config?

@SabotageAndi I see if I can find time for a pull-request to show you what I mean

@SabotageAndi It's not a line-ending problem. It's the specific mentioning of \r\n in the generated code. I checked this issue and it looks like SpecFlow really has very little influence over this as this isCodeDom feature.

I guess this issue can be closed for now or at least excluded from 3.0
Thanks.

@godrose Are the \r\nwhen you generate the code-behinds on a Mac? That would meanSystem.CodeDomisn't usingEnvironment.NewLinebut\n\r`.

We could handle this perhaps here: https://github.com/techtalk/SpecFlow/blob/master/SpecFlow.Tools.MsBuild.Generation/FeatureCodeBehindGenerator.cs#L28
We replace there \r\n with Environment.NewLine. On Windows this does nothing and on Mac it is replacing it to the right line ending.

@SabotageAndi To illustrate this
screen shot 2018-11-25 at 8 10 14 am

@godrose Are the \r\nwhen you generate the code-behinds on a Mac? That would meanSystem.CodeDomisn't usingEnvironment.NewLinebut\n\r`.

We could handle this perhaps here: https://github.com/techtalk/SpecFlow/blob/master/SpecFlow.Tools.MsBuild.Generation/FeatureCodeBehindGenerator.cs#L28
We replace there \r\n with Environment.NewLine. On Windows this does nothing and on Mac it is replacing it to the right line ending.

This looks like the perfect place!

@godrose When do we get the PR ;-)

@SabotageAndi Working on it ;)

I'm unable to compile the solution on Mac. Is there any specific configuration I should pick or Debug should be enough?

yeah, I didn't get it to build on Mac, because we compile for full framework.
At the Gherkin parser, the netfx.props (https://github.com/techtalk/SpecFlow/blob/master/netfx.props) was enough to get it to work.
But it looks like not for SpecFlow. After struggling with this for 2 days, I stopped looking at it.

@SabotageAndi Thanks. I will try to find another solution

Was this page helpful?
0 / 5 - 0 ratings