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

Cleanup and Fix Framework restrictions #2317

Closed
matthid opened this issue May 7, 2017 · 3 comments
Closed

Cleanup and Fix Framework restrictions #2317

matthid opened this issue May 7, 2017 · 3 comments

Comments

@matthid
Copy link
Member

matthid commented May 7, 2017

Intro

Framework restrictions are a feature to handle NuGet dependency groups. That is their primary responsibility. Sadly we leak that implementation detail in the paket.dependency and paket.references files with confusing effects for the user.

Description

There is no user definition on what >= netstandard1.3 or <= net45 means. But both are allowed in all paket files, with a wide range of unexpected effects.

Paket internally uses >= and <= to define special operations which are not easily explained and have nothing to do with "compatible with" (as one might assume).
For example ">= netstandard13" currently means "a NetStandard framework with a higher version than 1.3" and NOT "any target framework compatible with netstandard 1.3", because that would include some net-frameworks, see

let isTargetMatchingRestrictions =
memoize <| fun (restrictions:FrameworkRestriction list, target) ->
if List.isEmpty restrictions then true else
match target with
| SinglePlatform pf ->
restrictions
|> List.exists (fun restriction ->
match restriction with
| FrameworkRestriction.Exactly (Native(NoBuildMode,NoPlatform)) ->
match pf with
| Native(_) -> true
| _ -> false
| FrameworkRestriction.Exactly fw ->
match fw, pf with
| DotNetFramework _, DotNetStandard _ -> false
| DotNetStandard _, DotNetFramework _ -> false
| _ -> pf.IsCompatible(fw)
| FrameworkRestriction.Portable _ -> false
| FrameworkRestriction.AtLeast fw ->
match fw, pf with
| DotNetFramework _, DotNetStandard _ -> false
| DotNetStandard _, DotNetFramework _ -> false
| _ -> pf.IsAtLeast(fw)
| FrameworkRestriction.Between(min,max) ->
match min, pf with
| DotNetFramework _, DotNetStandard _ -> false
| DotNetStandard _, DotNetFramework _ -> false
| _ -> pf.IsBetween(min,max))
| _ ->
restrictions
|> List.exists (fun restriction ->
match restriction with
| FrameworkRestriction.Portable r -> true
| _ -> false)

Possible actions

  1. We need to define >= and <= or mark them invalid
  2. We need to define > and < or mark them invalid
  3. We need to change the implementation to handle the definition accordingly
  4. In that process we might need to cleanup some internal data structures in paket to make this part more understandable.
  5. We need to ensure that we do not strongly couple any definition with the original goal of framework restrictions (of the definitions are slightly different). So we might need different operators in the lock-file or have multiple meanings of >=...

Disclaimer

I really think stuff is working quite well. So any change in this needs to be really carefully reviewed. As we don't have any documentation on >= and <= I don't think breaking stuff there is quite as important. I know that since the early netstandard hacks some people use >= net45 to get rid of netstandard dependencies.

@matthid
Copy link
Member Author

matthid commented May 7, 2017

About the last statement: I don't think it matters if we break anything. They probably won't notice because a lot of libraries provide only a netstandard target and then netstandard packages are pulled anyway..
And breaking changes there won't/shouldn't even affect compilation. So I think redefining >= and <= is quite safe.

Here is my suggestion:

  • We leave the definition of framework restrictions itself untouched (they are for the TARGET framework you are compiling for). Everything else is way more confusing as it is already. You tell paket what you compile for to improve the resolution process. This is an easy definition. If you set = netstandard13 in the deps file and compile for net46 its a user error.
  • >= in user files means compatible with (> is the same but without the actual given framework). So this defines a set of frameworks. So >= is equivalent to listing all those frameworks.
  • <= in itself is not defined. It is only an addition to a >= set, to reduce it
    • <= net45 <- syntax error.
    • >= netstandard13 <= net45 the set >= netstandard13 without the set of >= net45 (but including net45)

@matthid
Copy link
Member Author

matthid commented May 7, 2017

Suggestion 2:

Get rid of the >= and <= notations and make them syntax errors. They are much harder to understand than a simple framework list we target.

@matthid
Copy link
Member Author

matthid commented May 26, 2017

This is now kind of implemented, we only have ==, >= and <, see #2336

@matthid matthid closed this as completed May 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant