Skip to content

Commit

Permalink
Add discoverty tests to specs for .NET 5, fix TargetFrameworkMoniker …
Browse files Browse the repository at this point in the history
…creation from short name
  • Loading branch information
gasparnagy committed Feb 22, 2021
1 parent 5099c4d commit e0bfeb3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
10 changes: 9 additions & 1 deletion Deveroom.VisualStudio/ProjectSystem/TargetFrameworkMoniker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ public class TargetFrameworkMoniker
public const string NetFrameworkPlatform = ".NETFramework";
private const string NetCoreShortValuePrefix = "netcoreapp";
private const string NetFrameworkShortValuePrefix = "net";
private const string Net5ShortValuePrefix = "net5";

// e.g .NETCoreApp,Version=v2.1 or .NETFramework,Version=v4.5.2
// e.g.
// * .NET 5: .NETCoreApp,Version=v5.0
// * .NET Core: .NETCoreApp,Version=v2.1
// * .NET Fw: .NETFramework,Version=v4.5.2
public string Value { get; }

public string Platform { get; }
Expand Down Expand Up @@ -51,6 +55,10 @@ public static TargetFrameworkMoniker CreateFromShortName(string shortValue)
{
value = $".NETCoreApp,Version=v{shortValue.Substring(NetCoreShortValuePrefix.Length)}";
}
else if (shortValue.StartsWith(Net5ShortValuePrefix))
{
value = $".NETCoreApp,Version=v{shortValue.Substring(Net5ShortValuePrefix.Length-1)}";
}
else if (shortValue.StartsWith(NetFrameworkShortValuePrefix))
{
value = $".NETFramework,Version=v{shortValue[NetFrameworkShortValuePrefix.Length]}.{shortValue[NetFrameworkShortValuePrefix.Length + 1]}.{shortValue[NetFrameworkShortValuePrefix.Length + 2]}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Examples:
| netcoreapp2.2 |
| netcoreapp3.0 |
| netcoreapp3.1 |
| net5.0 |
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ Scenario Outline: Discover binding source location from SpecFlow project with as
Then the discovery succeeds with several step definitions
And the step definitions contain source file and line
Examples:
| label | framework |
| V1 | net452 |
| V2 | netcoreapp2.1 |

| label | framework |
| V1 | net452 |
| V2 | netcoreapp2.1 |
| V3 | netcoreapp3.1 |
| V5 | net5.0 |
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,18 @@ public void GivenTheProjectFormatIs(string projectFormat)
_generatorOptions.NewProjectFormat = true;
}

private bool IsNet5(string targetFramework)
{
return targetFramework.StartsWith("net") && targetFramework.Length >= 6 &&
char.IsDigit(targetFramework[3]) &&
!targetFramework.StartsWith("net3") && !targetFramework.StartsWith("net4");
}

[Given(@"the target framework is (.*)")]
public void GivenTheTargetFrameworkIs(string targetFramework)
{
_generatorOptions.TargetFramework = targetFramework;
if (targetFramework.Contains("netcoreapp"))
if (targetFramework.Contains("netcoreapp") || IsNet5(targetFramework))
{
if (!_generatorOptions.NewProjectFormat)
_generatorOptions.NewProjectFormat = true;
Expand Down

0 comments on commit e0bfeb3

Please sign in to comment.