Skip to content
Merged
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
31 changes: 23 additions & 8 deletions src/Paket.Core/Versioning/FrameworkHandling.fs
Original file line number Diff line number Diff line change
Expand Up @@ -843,19 +843,34 @@ module FrameworkDetection =
Some (v.ToString() |> simplify)
else None

let (|MatchTfmString|_|) (tfmStart: string) tryParseSecondPart (s:string) =
if s.StartsWith tfmStart then
let secondPart = s.Substring (tfmStart.Length)
tryParseSecondPart secondPart
else
None
let (|MatchTfm|_|) (tfmStart: string) tryParseVersion (s:string) =
if s.StartsWith tfmStart then
let versionPart = s.Substring (tfmStart.Length)
tryNormalizeVersion versionPart
|> Option.bind tryParseVersion
else
None
let (|MatchNet5DashOs|_|) tryParseSecondPart (s:string) =
let parts = s.Split('-')
if parts.Length = 2 && s.StartsWith "net" then
let versionPart = parts.[0].Substring (3)
tryNormalizeVersion versionPart
|> function
| Some "5" -> tryParseSecondPart parts.[1]
| _ -> None
else
None
let (|MatchNet5DashWindows|_|) tryParseVersion (s:string) =
let parts = s.Split('-')
if parts.Length = 2 && s.StartsWith "net" && parts.[1].StartsWith "win" then
let netVersionPart = parts.[0].Substring (3)
let winVersionPart = parts.[1].Substring (3)
tryNormalizeVersion netVersionPart
|> function
| Some "5" -> tryParseVersion winVersionPart
| _ -> None
else
None
let (|MatchTfms|_|) (tfmStarts: string seq) tryParseVersion (s:string) =
tfmStarts
|> Seq.tryPick (fun tfmStart ->
Expand Down Expand Up @@ -897,8 +912,8 @@ module FrameworkDetection =
| "net35-Unity Micro v3.5" -> Some (DotNetUnity DotNetUnityVersion.V3_5_Micro)
| "net35-Unity Subset v3.5" -> Some (DotNetUnity DotNetUnityVersion.V3_5_Subset)
| "net35-Unity Full v3.5" -> Some (DotNetUnity DotNetUnityVersion.V3_5_Full)
| MatchTfm "net5.0-win" Net5WindowsVersion.TryParse fm -> Some (DotNet5Windows fm)
| MatchTfmString "net5.0-" Net5Os.TryParse fm -> Some (DotNet5WithOs fm)
| MatchNet5DashWindows Net5WindowsVersion.TryParse fm -> Some (DotNet5Windows fm)
| MatchNet5DashOs Net5Os.TryParse fm -> Some (DotNet5WithOs fm)
| ModifyMatchTfm skipFullAndClient "net" FrameworkVersion.TryParse fm -> Some (DotNetFramework fm)
// Backwards compat quirk (2017-08-20).
| "uap101" -> Some (UAP UAPVersion.V10_1)
Expand Down
30 changes: 30 additions & 0 deletions tests/Paket.Tests/Versioning/PlatformMatchingSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,31 @@ let ``Can detect net5.0``() =
let p = PlatformMatching.forceExtractPlatforms "net5.0"
p.ToTargetProfile false |> shouldEqual (Some (TargetProfile.SinglePlatform (FrameworkIdentifier.DotNetFramework FrameworkVersion.V5)))

[<Test>]
let ``Can detect net5``() =
let p = PlatformMatching.forceExtractPlatforms "net5"
p.ToTargetProfile false |> shouldEqual (Some (TargetProfile.SinglePlatform (FrameworkIdentifier.DotNetFramework FrameworkVersion.V5)))

[<Test>]
let ``Can detect net5000``() =
let p = PlatformMatching.forceExtractPlatforms "net5000"
p.ToTargetProfile false |> shouldEqual (Some (TargetProfile.SinglePlatform (FrameworkIdentifier.DotNetFramework FrameworkVersion.V5)))

[<Test>]
let ``Can detect net5.0-windows``() =
let p = PlatformMatching.forceExtractPlatforms "net5.0-windows"
p.ToTargetProfile false |> shouldEqual (Some (TargetProfile.SinglePlatform (FrameworkIdentifier.DotNet5Windows Net5WindowsVersion.V7_0)))

[<Test>]
let ``Can detect net5-windows``() =
let p = PlatformMatching.forceExtractPlatforms "net5-windows"
p.ToTargetProfile false |> shouldEqual (Some (TargetProfile.SinglePlatform (FrameworkIdentifier.DotNet5Windows Net5WindowsVersion.V7_0)))

[<Test>]
let ``Can detect net5000-windows``() =
let p = PlatformMatching.forceExtractPlatforms "net5000-windows"
p.ToTargetProfile false |> shouldEqual (Some (TargetProfile.SinglePlatform (FrameworkIdentifier.DotNet5Windows Net5WindowsVersion.V7_0)))

[<Test>]
let ``Can detect net5.0-windows10.0.19041.0``() =
let p = PlatformMatching.forceExtractPlatforms "net5.0-windows10.0.19041.0"
Expand All @@ -176,6 +196,16 @@ let ``Can detect net5.0-windows10.0.19041``() =
let p = PlatformMatching.forceExtractPlatforms "net5.0-windows10.0.19041"
p.ToTargetProfile false |> shouldEqual (Some (TargetProfile.SinglePlatform (FrameworkIdentifier.DotNet5Windows Net5WindowsVersion.V10_0_19041_0)))

[<Test>]
let ``Can detect net5-windows10.0.19041``() =
let p = PlatformMatching.forceExtractPlatforms "net5-windows10.0.19041"
p.ToTargetProfile false |> shouldEqual (Some (TargetProfile.SinglePlatform (FrameworkIdentifier.DotNet5Windows Net5WindowsVersion.V10_0_19041_0)))

[<Test>]
let ``Can detect net5000-windows10.0.19041``() =
let p = PlatformMatching.forceExtractPlatforms "net5000-windows10.0.19041"
p.ToTargetProfile false |> shouldEqual (Some (TargetProfile.SinglePlatform (FrameworkIdentifier.DotNet5Windows Net5WindowsVersion.V10_0_19041_0)))

[<Test>]
let ``Can detect netstandard1.6``() =
let p = PlatformMatching.forceExtractPlatforms "netstandard1.6"
Expand Down