Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .NET Standard 2.1 support #3530

Merged
merged 29 commits into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion src/Paket.Core/Dependencies/NuGetV2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ let private handleODataEntry nugetURL packageName version entry =
let restriction = a.[2]
match PlatformMatching.extractPlatforms false restriction with
| Some p ->
Some { p with Platforms = p.Platforms |> List.filter KnownTargetProfiles.isSupportedProfile }
Some { p with Platforms = p.Platforms }
| None ->
if not (restriction.StartsWith "_") then
Logging.traceWarnIfNotBefore ("Package", restriction, packageName, version) "Could not detect any platforms from '%s' in package %O %O, please tell the package authors" restriction packageName version
Expand Down
1 change: 0 additions & 1 deletion src/Paket.Core/PublicAPI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,6 @@ module PublicAPI =
profile.Frameworks
|> List.filter (function
| MonoTouch
| DNXCore _
| UAP _
| MonoAndroid _
| XamariniOS
Expand Down
43 changes: 17 additions & 26 deletions src/Paket.Core/Versioning/FrameworkHandling.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type DotNetStandardVersion =
| V1_5
| V1_6
| V2_0
| V2_1
override this.ToString() =
match this with
| V1_0 -> "v1.0"
Expand All @@ -28,6 +29,7 @@ type DotNetStandardVersion =
| V1_5 -> "v1.5"
| V1_6 -> "v1.6"
| V2_0 -> "v2.0"
| V2_1 -> "v2.1"
member this.ShortString() =
match this with
| DotNetStandardVersion.V1_0 -> "1.0"
Expand All @@ -38,17 +40,21 @@ type DotNetStandardVersion =
| DotNetStandardVersion.V1_5 -> "1.5"
| DotNetStandardVersion.V1_6 -> "1.6"
| DotNetStandardVersion.V2_0 -> "2.0"
| DotNetStandardVersion.V2_1 -> "2.1"
static member TryParse s =
match s with
| "" | "1" -> Some(DotNetStandardVersion.V1_0)
| ""
| "1" -> Some(DotNetStandardVersion.V1_0)
| "1.1" -> Some(DotNetStandardVersion.V1_1)
| "1.2" -> Some(DotNetStandardVersion.V1_2)
| "1.3" -> Some(DotNetStandardVersion.V1_3)
| "1.4" -> Some(DotNetStandardVersion.V1_4)
| "1.5" -> Some(DotNetStandardVersion.V1_5)
| "1.6" -> Some(DotNetStandardVersion.V1_6)
| "2" -> Some(DotNetStandardVersion.V2_0)
| "2" -> Some(DotNetStandardVersion.V2_0)
| "2.1" -> Some(DotNetStandardVersion.V2_1)
| _ -> None

[<RequireQualifiedAccess>]
/// The Framework version.
// Each time a new version is added NuGetPackageCache.CurrentCacheVersion should be bumped.
Expand All @@ -71,7 +77,7 @@ type FrameworkVersion =
| V4_7
| V4_7_1
| V4_7_2
| V5_0
| V4_8
override this.ToString() =
match this with
| V1 -> "v1.0"
Expand All @@ -92,7 +98,7 @@ type FrameworkVersion =
| V4_7 -> "v4.7"
| V4_7_1 -> "v4.7.1"
| V4_7_2 -> "v4.7.2"
| V5_0 -> "v5.0"
| V4_8 -> "v4.8"

member this.ShortString() =
match this with
Expand All @@ -114,7 +120,7 @@ type FrameworkVersion =
| FrameworkVersion.V4_7 -> "47"
| FrameworkVersion.V4_7_1 -> "471"
| FrameworkVersion.V4_7_2 -> "472"
| FrameworkVersion.V5_0 -> "50"
| FrameworkVersion.V4_8 -> "48"

static member TryParse s =
match s with
Expand All @@ -136,7 +142,7 @@ type FrameworkVersion =
| "4.7" -> Some FrameworkVersion.V4_7
| "4.7.1" -> Some FrameworkVersion.V4_7_1
| "4.7.2" -> Some FrameworkVersion.V4_7_2
| "5" -> Some FrameworkVersion.V5_0
| "4.8" -> Some FrameworkVersion.V4_8
| _ -> None

[<RequireQualifiedAccess>]
Expand Down Expand Up @@ -509,8 +515,6 @@ type TizenVersion =
type FrameworkIdentifier =
| DotNetFramework of FrameworkVersion
| UAP of UAPVersion
| DNX of FrameworkVersion
| DNXCore of FrameworkVersion
| DotNetStandard of DotNetStandardVersion
| DotNetCoreApp of DotNetCoreAppVersion
| DotNetUnity of DotNetUnityVersion
Expand All @@ -531,8 +535,6 @@ type FrameworkIdentifier =
override x.ToString() =
match x with
| DotNetFramework v -> "net" + v.ShortString()
| DNX v -> "dnx" + v.ShortString()
| DNXCore v -> "dnxcore" + v.ShortString()
| DotNetStandard v -> "netstandard" + v.ShortString()
| DotNetCoreApp v -> "netcoreapp" + v.ShortString()
| DotNetUnity v -> "net" + v.ShortString()
Expand Down Expand Up @@ -623,9 +625,7 @@ type FrameworkIdentifier =
| DotNetFramework FrameworkVersion.V4_7 -> [ DotNetFramework FrameworkVersion.V4_6_3]
| DotNetFramework FrameworkVersion.V4_7_1 -> [ DotNetFramework FrameworkVersion.V4_7; DotNetStandard DotNetStandardVersion.V2_0 ]
| DotNetFramework FrameworkVersion.V4_7_2 -> [ DotNetFramework FrameworkVersion.V4_7_1 ]
| DotNetFramework FrameworkVersion.V5_0 -> [ DotNetFramework FrameworkVersion.V4_7_2 ]
| DNX _ -> [ ]
| DNXCore _ -> [ ]
| DotNetFramework FrameworkVersion.V4_8 -> [ DotNetFramework FrameworkVersion.V4_7_2 ]
| DotNetStandard DotNetStandardVersion.V1_0 -> [ ]
| DotNetStandard DotNetStandardVersion.V1_1 -> [ DotNetStandard DotNetStandardVersion.V1_0 ]
| DotNetStandard DotNetStandardVersion.V1_2 -> [ DotNetStandard DotNetStandardVersion.V1_1 ]
Expand All @@ -634,12 +634,13 @@ type FrameworkIdentifier =
| DotNetStandard DotNetStandardVersion.V1_5 -> [ DotNetStandard DotNetStandardVersion.V1_4 ]
| DotNetStandard DotNetStandardVersion.V1_6 -> [ DotNetStandard DotNetStandardVersion.V1_5 ]
| DotNetStandard DotNetStandardVersion.V2_0 -> [ DotNetStandard DotNetStandardVersion.V1_6 ]
| DotNetStandard DotNetStandardVersion.V2_1 -> [ DotNetStandard DotNetStandardVersion.V2_0 ]
| DotNetCoreApp DotNetCoreAppVersion.V1_0 -> [ DotNetStandard DotNetStandardVersion.V1_6 ]
| DotNetCoreApp DotNetCoreAppVersion.V1_1 -> [ DotNetCoreApp DotNetCoreAppVersion.V1_0 ]
| DotNetCoreApp DotNetCoreAppVersion.V2_0 -> [ DotNetCoreApp DotNetCoreAppVersion.V1_1; DotNetStandard DotNetStandardVersion.V2_0 ]
| DotNetCoreApp DotNetCoreAppVersion.V2_1 -> [ DotNetCoreApp DotNetCoreAppVersion.V2_0 ]
| DotNetCoreApp DotNetCoreAppVersion.V2_2 -> [ DotNetCoreApp DotNetCoreAppVersion.V2_1 ]
| DotNetCoreApp DotNetCoreAppVersion.V3_0 -> [ DotNetCoreApp DotNetCoreAppVersion.V2_2 ]
| DotNetCoreApp DotNetCoreAppVersion.V3_0 -> [ DotNetCoreApp DotNetCoreAppVersion.V2_2; DotNetStandard DotNetStandardVersion.V2_1 ]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cartermp @terrajobst is this correct?
.NET Core 3.0 is compatible to .NET Standard 2.1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and what about ..NET 4.8? Is that supposed to be compatible with .NET Standard 2.1?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from what I read .NET will not be compatible with the 2.1 "standard"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok so I will remove that .NET 4.8 -> .NET Standard 2.1 arrow for now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.NET Standard 2.1 is only compatible with .NET Core 3.0 at the moment; no plans for compat with .NWT Framework. It will also eventually be supported by Mono.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will also eventually be supported by Mono.

This will be funny when that happens

| DotNetUnity DotNetUnityVersion.V3_5_Full -> [ ]
| DotNetUnity DotNetUnityVersion.V3_5_Subset -> [ ]
| DotNetUnity DotNetUnityVersion.V3_5_Micro -> [ ]
Expand Down Expand Up @@ -793,10 +794,6 @@ module FrameworkDetection =
| "sl4-wp75" | "sl4-wp7.5" -> Some (WindowsPhone WindowsPhoneVersion.V7_5)
| MatchTfms ["wp";"wpv"] (Bind WindowsPhoneVersion.TryParse) fm -> Some (WindowsPhone fm)
| MatchTfms ["wpa";"wpav";"wpapp"] (Bind WindowsPhoneAppVersion.TryParse) fm -> Some (WindowsPhoneApp fm)
| MatchTfm "dnx" (allowVersions ["";"4.5.1"]) () -> Some(DNX FrameworkVersion.V4_5_1)
| MatchTfms ["dnxcore";"netplatform";"netcore";"aspnetcore";"aspnet";"dotnet"] (Bind (allowVersions ["";"5"]))
() -> Some(DNXCore FrameworkVersion.V5_0)
| v when v.StartsWith "dotnet" -> Some(DNXCore FrameworkVersion.V5_0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we drop support for those monikers and hope no-one uses them? (fine by me just asking)
Do we tell those people to stay on previous paket versions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those things do not exist. they are completely abandoned. I wanted to drop them long time ago.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NuGet apparently still parses them: http://nugettoolsdev.azurewebsites.net/4.5.0/parse-framework?framework=dnxcore
Yes, we can remove them and see what happens but I wouldn't be surprised if this at least produces warnings for some packages still having those things. I just wanted to check if we have a strategy if this is indeed the case or if we need one? For example we could tell them to update their packages and tell the package author to fix its package or revert the change.

| MatchTfm "netstandard" DotNetStandardVersion.TryParse fm -> Some (DotNetStandard fm)
// "netcore" is for backwards compat (2017-08-20), we wrote this incorrectly into the lockfile.
| MatchTfms ["netcoreapp";"netcore"] (Bind DotNetCoreAppVersion.TryParse) fm -> Some (DotNetCoreApp fm)
Expand Down Expand Up @@ -1126,6 +1123,7 @@ module KnownTargetProfiles =
FrameworkVersion.V4_7
FrameworkVersion.V4_7_1
FrameworkVersion.V4_7_2
FrameworkVersion.V4_8
]

let DotNetFrameworkIdentifiers =
Expand All @@ -1145,6 +1143,7 @@ module KnownTargetProfiles =
DotNetStandardVersion.V1_5
DotNetStandardVersion.V1_6
DotNetStandardVersion.V2_0
DotNetStandardVersion.V2_1
]

let DotNetStandardProfiles =
Expand Down Expand Up @@ -1339,13 +1338,6 @@ module KnownTargetProfiles =
AllDotNetProfiles
|> Set.ofList

let isSupportedProfile profile =
match profile with
| FrameworkIdentifier.DNX _
| FrameworkIdentifier.DNXCore _
| FrameworkIdentifier.DotNetFramework (FrameworkVersion.V5_0) -> false
| _ -> true

let TryFindPortableProfile (name:string) =
let lowerName = name.ToLowerInvariant()
AllProfiles
Expand Down Expand Up @@ -1466,7 +1458,6 @@ module SupportCalculation =
fws
|> List.filter (function
| MonoTouch
| DNXCore _
| UAP _
| MonoAndroid _
| XamariniOS
Expand Down
2 changes: 0 additions & 2 deletions src/Paket.Core/Versioning/PlatformMatching.fs
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ let getTargetCondition (target:TargetProfile) =
| TargetProfile.SinglePlatform(platform) ->
match platform with
| DotNetFramework(version) ->"$(TargetFrameworkIdentifier) == '.NETFramework'", sprintf "$(TargetFrameworkVersion) == '%O'" version
| DNX(version) ->"$(TargetFrameworkIdentifier) == 'DNX'", sprintf "$(TargetFrameworkVersion) == '%O'" version
| DNXCore(version) ->"$(TargetFrameworkIdentifier) == 'DNXCore'", sprintf "$(TargetFrameworkVersion) == '%O'" version
| DotNetStandard(version) ->"$(TargetFrameworkIdentifier) == '.NETStandard'", sprintf "$(TargetFrameworkVersion) == '%O'" version
| DotNetCoreApp(version) ->"$(TargetFrameworkIdentifier) == '.NETCoreApp'", sprintf "$(TargetFrameworkVersion) == '%O'" version
| DotNetUnity(DotNetUnityVersion.V3_5_Full as version) ->
Expand Down
4 changes: 0 additions & 4 deletions src/Paket.Core/Versioning/Requirements.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1248,10 +1248,6 @@ let addFrameworkRestrictionsToDependencies rawDependencies (frameworkGroups:Pars
handleProblem (UnknownPortableProfile v)
| _ -> ()
prof)
|> Seq.filter (fun frameworkGroup ->
match frameworkGroup with
| TargetProfile.SinglePlatform sp -> KnownTargetProfiles.isSupportedProfile sp
| _ -> true)
// TODO: Check if this is needed (I think the logic below is a general version of this subset logic)
|> Seq.filter (fun frameworkGroup ->
// filter all restrictions which would render this group to nothing (ie smaller restrictions)
Expand Down
4 changes: 0 additions & 4 deletions tests/Paket.Tests/InstallModel/FrameworkIdentifierSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ let ``should serialize basic framework versions net20, net40, net45 ...``() =
let ``should serialize silverlight framework identifier correctly``() =
(Silverlight SilverlightVersion.V5).ToString() |> shouldEqual "sl5"

[<Test>]
let ``should understand basic dnx``() =
FrameworkDetection.Extract("dnxcore50").Value |> shouldEqual (DNXCore(FrameworkVersion.V5_0))

[<Test>]
let ``should understand xamarinios``() =
FrameworkDetection.Extract("xamarinios10").Value |> shouldEqual (XamariniOS)
Expand Down
21 changes: 2 additions & 19 deletions tests/Paket.Tests/Nuspec/NuspecSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -273,27 +273,10 @@ let ``can detect framework assemblies for Microsoft.Framework.Logging``() =
nuspec.FrameworkAssemblyReferences.[0].FrameworkRestrictions
|> shouldEqual
(makeOrList
[FrameworkRestriction.Exactly(DotNetFramework(FrameworkVersion.V4_5))
FrameworkRestriction.Exactly(DNX(FrameworkVersion.V4_5_1))])
[FrameworkRestriction.Exactly(DotNetFramework(FrameworkVersion.V4_5))])

let name,_,restrictions = nuspec.Dependencies.Value.[0]
let name,_,_restrictions = nuspec.Dependencies.Value.[0]
name |> shouldEqual (PackageName "Microsoft.Framework.DependencyInjection.Interfaces")

let name,_,restrictions = nuspec.Dependencies.Value.[2]
name |> shouldEqual (PackageName "System.Collections.Concurrent")
restrictions |> shouldEqual (makeOrList [FrameworkRestriction.AtLeast(DNXCore(FrameworkVersion.V5_0))])

[<Test>]
let ``can detect explicit dependencies for FluentAssertions 4``() =
//ensureDir()
let deps = Nuspec.Load(Path.Combine(__SOURCE_DIRECTORY__,"FluentAssertions4.nuspec")).Dependencies.Value |> List.toArray

deps.[0]
|> shouldEqual
(PackageName "System.Collections",
DependenciesFileParser.parseVersionRequirement(">= 4.0.10"),
makeOrList [FrameworkRestriction.AtLeast(DNXCore(FrameworkVersion.V5_0))])



[<Test>]
Expand Down
8 changes: 1 addition & 7 deletions tests/Paket.Tests/Versioning/PlatformMatchingSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let ``Check that lists are updated``() =
let cases = FSharp.Reflection.FSharpType.GetUnionCases(typeof<'t>)
checkListEx tagReader cases l

checkList (FrameworkVersion.V5_0 :: KnownTargetProfiles.DotNetFrameworkVersions) // v5 was unlisted
checkList KnownTargetProfiles.DotNetFrameworkVersions
checkList KnownTargetProfiles.DotNetCoreAppVersions
checkList KnownTargetProfiles.DotNetStandardVersions
checkList KnownTargetProfiles.DotNetUnityVersions
Expand Down Expand Up @@ -103,11 +103,6 @@ let ``Can detect uap101``() =
let p = PlatformMatching.forceExtractPlatforms "uap101"
p.ToTargetProfile false |> shouldEqual (Some (TargetProfile.SinglePlatform (UAP UAPVersion.V10_1)))

[<Test>]
let ``Can detect .NETPlatform5.4``() =
let p = PlatformMatching.forceExtractPlatforms ".NETPlatform5.4"
p.ToTargetProfile false |> shouldEqual (Some (TargetProfile.SinglePlatform (DNXCore FrameworkVersion.V5_0)))


[<Test>]
let ``Can detect MonoTouch0.00``() =
Expand Down Expand Up @@ -144,7 +139,6 @@ let ``Can detect net3.5``() =
let p = PlatformMatching.forceExtractPlatforms "net3.5"
p.ToTargetProfile false |> shouldEqual (Some (TargetProfile.SinglePlatform (FrameworkIdentifier.DotNetFramework FrameworkVersion.V3_5)))


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