Skip to content

Commit

Permalink
Inconsistent framework exclusion in paket.dependencies - fixes #1093
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Sep 28, 2015
1 parent c4f949c commit 8a24998
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 30 deletions.
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#### 2.4.2 - 28.09.2015
#### 2.4.3 - 28.09.2015
* BUGFIX: Inconsistent framework exclusion in paket.dependencies - https://github.com/fsprojects/Paket/issues/1093

#### 2.4.1 - 28.09.2015
Expand Down
40 changes: 22 additions & 18 deletions src/Paket.Core/Requirements.fs
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,29 @@ let optimizeRestrictions packages =
let localMaxDotNetRestriction = findMaxDotNetRestriction plain

let restrictions =
plain
|> List.map (fun restriction ->
match restriction with
| FrameworkRestriction.Exactly r ->
if r = localMaxDotNetRestriction then
let globalMax =
invertedRestrictions
|> List.skipWhile (fun (r,l) -> r <= localMaxDotNetRestriction && l |> List.exists (fun (n,vr) -> n = name && vr = versionRequirement))
|> List.map fst

if globalMax = [] || r >= globalMax.Head then
FrameworkRestriction.AtLeast r
match plain with
| [] -> plain
| [x] -> plain
| _ ->
plain
|> List.map (fun restriction ->
match restriction with
| FrameworkRestriction.Exactly r ->
if r = localMaxDotNetRestriction then
let globalMax =
invertedRestrictions
|> List.skipWhile (fun (r,l) -> r <= localMaxDotNetRestriction && l |> List.exists (fun (n,vr) -> n = name && vr = versionRequirement))
|> List.map fst

if globalMax = [] || r >= globalMax.Head then
FrameworkRestriction.AtLeast r
else
FrameworkRestriction.Between(r,globalMax.Head)
else
FrameworkRestriction.Between(r,globalMax.Head)
else
restriction
| _ -> restriction)
|> List.distinct
|> List.sort
restriction
| _ -> restriction)
|> List.distinct
|> List.sort

yield name,versionRequirement,restrictions]

Expand Down
2 changes: 1 addition & 1 deletion src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<StartWorkingDirectory>c:\code\Paket09x</StartWorkingDirectory>
<StartWorkingDirectory>D:\code\Pakettest</StartWorkingDirectory>
<StartWorkingDirectory>D:\code\Paketkopie</StartWorkingDirectory>
<StartArguments>update</StartArguments>
<StartArguments>update -f</StartArguments>
<StartAction>Project</StartAction>
<StartProgram>paket.exe</StartProgram>
<StartWorkingDirectory>c:\code\Paketkopie</StartWorkingDirectory>
Expand Down
27 changes: 25 additions & 2 deletions tests/Paket.Tests/DependencySetSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let ``should optimize 2 restriction set with only exactly``() =
[FrameworkRestriction.Exactly (DotNetFramework(FrameworkVersion.V3_5))
FrameworkRestriction.Exactly (DotNetFramework(FrameworkVersion.V4))
FrameworkRestriction.AtLeast (DotNetFramework(FrameworkVersion.V4_5))]
PackageName("P2"), VersionRequirement.AllReleases, [FrameworkRestriction.Between (DotNetFramework(FrameworkVersion.V3_5),DotNetFramework(FrameworkVersion.V4))]]
PackageName("P2"), VersionRequirement.AllReleases, [FrameworkRestriction.Exactly (DotNetFramework(FrameworkVersion.V3_5))]]

original
|> optimizeRestrictions
Expand All @@ -41,7 +41,7 @@ let ``should optimize 2 restriction set with only exactly and client framework``
[FrameworkRestriction.Exactly (DotNetFramework(FrameworkVersion.V3_5))
FrameworkRestriction.Exactly (DotNetFramework(FrameworkVersion.V4_Client))
FrameworkRestriction.AtLeast (DotNetFramework(FrameworkVersion.V4_5))]
PackageName("P2"), VersionRequirement.AllReleases, [FrameworkRestriction.Between (DotNetFramework(FrameworkVersion.V3_5),DotNetFramework(FrameworkVersion.V4_Client))]]
PackageName("P2"), VersionRequirement.AllReleases, [FrameworkRestriction.Exactly (DotNetFramework(FrameworkVersion.V3_5))]]

original
|> optimizeRestrictions
Expand Down Expand Up @@ -132,4 +132,27 @@ let ``filtered with AtLeast restriction should filter non-matching``() =

original
|> DependencySetFilter.filterByRestrictions [FrameworkRestriction.AtLeast (DotNetFramework(FrameworkVersion.V4))]
|> shouldEqual expected

[<Test>]
let ``should optimize ZendeskApi_v2 ``() =
let original =
[PackageName("Newtonsoft.Json"), VersionRequirement.AllReleases, [FrameworkRestriction.Exactly (DotNetFramework(FrameworkVersion.V3_5))]
PackageName("Newtonsoft.Json"), VersionRequirement.AllReleases, [FrameworkRestriction.Exactly (DotNetFramework(FrameworkVersion.V4))]
PackageName("AsyncCTP"), VersionRequirement.AllReleases, [FrameworkRestriction.Exactly (DotNetFramework(FrameworkVersion.V4))]
PackageName("Newtonsoft.Json"), VersionRequirement.AllReleases, [FrameworkRestriction.Exactly (DotNetFramework(FrameworkVersion.V4_5))]
PackageName("Newtonsoft.Json"), VersionRequirement.AllReleases, [FrameworkRestriction.Portable "portable-net45+sl40+wp71+win80"]
PackageName("Microsoft.Bcl.Async"), VersionRequirement.AllReleases, [FrameworkRestriction.Portable "portable-net45+sl40+wp71+win80"]]

let expected =
[PackageName("Newtonsoft.Json"), VersionRequirement.AllReleases,
[FrameworkRestriction.Exactly (DotNetFramework(FrameworkVersion.V3_5))
FrameworkRestriction.Exactly (DotNetFramework(FrameworkVersion.V4))
FrameworkRestriction.Portable "portable-net45+sl40+wp71+win80"
FrameworkRestriction.AtLeast (DotNetFramework(FrameworkVersion.V4_5))]
PackageName("AsyncCTP"), VersionRequirement.AllReleases, [FrameworkRestriction.Exactly (DotNetFramework(FrameworkVersion.V4))]
PackageName("Microsoft.Bcl.Async"), VersionRequirement.AllReleases, [FrameworkRestriction.Portable "portable-net45+sl40+wp71+win80"]]

original
|> optimizeRestrictions
|> shouldEqual expected
6 changes: 2 additions & 4 deletions tests/Paket.Tests/NuGetOData/ODataSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ let ``can detect explicit dependencies for ReadOnlyCollectionExtensions``() =
CacheVersion = NugetPackageCache.CurrentCacheVersion
LicenseUrl = "https://github.com/mausch/ReadOnlyCollections/blob/master/license.txt"
Dependencies =
[PackageName "LinqBridge",DependenciesFileParser.parseVersionRequirement(">= 1.3.0"),
[FrameworkRestriction.Between(DotNetFramework(FrameworkVersion.V2),DotNetFramework(FrameworkVersion.V3_5))]
[PackageName "LinqBridge",DependenciesFileParser.parseVersionRequirement(">= 1.3.0"), [FrameworkRestriction.Exactly (DotNetFramework(FrameworkVersion.V2))]
PackageName "ReadOnlyCollectionInterfaces",DependenciesFileParser.parseVersionRequirement("1.0.0"),
[FrameworkRestriction.Exactly(DotNetFramework(FrameworkVersion.V2))
FrameworkRestriction.Exactly(DotNetFramework(FrameworkVersion.V3_5))
Expand All @@ -98,8 +97,7 @@ let ``can detect explicit dependencies for Math.Numerics``() =
LicenseUrl = "http://numerics.mathdotnet.com/docs/License.html"
CacheVersion = NugetPackageCache.CurrentCacheVersion
Dependencies =
[PackageName "TaskParallelLibrary",DependenciesFileParser.parseVersionRequirement(">= 1.0.2856"),
[FrameworkRestriction.Between(DotNetFramework(FrameworkVersion.V3_5),DotNetFramework(FrameworkVersion.V4_Client))]]
[PackageName "TaskParallelLibrary",DependenciesFileParser.parseVersionRequirement(">= 1.0.2856"), [FrameworkRestriction.Exactly (DotNetFramework(FrameworkVersion.V3_5))]]
SourceUrl = fakeUrl }

[<Test>]
Expand Down
6 changes: 2 additions & 4 deletions tests/Paket.Tests/Nuspec/NuspecSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ let ``can detect explicit dependencies for ReadOnlyCollectionExtensions``() =
Nuspec.Load("Nuspec/ReadOnlyCollectionExtensions.nuspec").Dependencies
|> shouldEqual
[PackageName "LinqBridge",DependenciesFileParser.parseVersionRequirement(">= 1.3.0"),
[FrameworkRestriction.Between(DotNetFramework(FrameworkVersion.V2),DotNetFramework(FrameworkVersion.V3_5))]
[FrameworkRestriction.Exactly (DotNetFramework(FrameworkVersion.V2))]
PackageName "ReadOnlyCollectionInterfaces",DependenciesFileParser.parseVersionRequirement("1.0.0"),
[FrameworkRestriction.Exactly(DotNetFramework(FrameworkVersion.V2))
FrameworkRestriction.Exactly(DotNetFramework(FrameworkVersion.V3_5))
Expand All @@ -170,9 +170,7 @@ let ``can detect dependencies for MathNet.Numerics``() =
|> shouldEqual
[ PackageName "TaskParallelLibrary",
DependenciesFileParser.parseVersionRequirement(">= 1.0.2856.0"),
[FrameworkRestriction.Between(
DotNetFramework(FrameworkVersion.V3_5),
DotNetFramework(FrameworkVersion.V4_Client))] ]
[FrameworkRestriction.Exactly (DotNetFramework(FrameworkVersion.V3_5))] ]

[<Test>]
let ``can detect dependencies for MathNet.Numerics.FSharp``() =
Expand Down

0 comments on commit 8a24998

Please sign in to comment.