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

Issue with consuming DLLs built with .NET7 from .NET6 #14313

Open
vzarytovskii opened this issue Nov 14, 2022 · 4 comments
Open

Issue with consuming DLLs built with .NET7 from .NET6 #14313

vzarytovskii opened this issue Nov 14, 2022 · 4 comments

Comments

@vzarytovskii
Copy link
Member

vzarytovskii commented Nov 14, 2022

  1. Build a library which has langversion=7 and targets net6.0, using net7.0 SDK
    1. Library should involve some sort of SRTP code (with either new or old syntax).
  2. Reference this library in a project which targets net6.0 and uses net6.0 SDK

This will result in Error reading/writing metadata for the F# compiled DLL '%s'. Was the DLL compiled with an earlier version of the F# compiler? (error: 'u_trait_sln')..

This is sort of by design, since we're technically picking some data which is unknown to the old compiler.

The general recommendation is to move to .NET7 SDK on the consumer side, or target .NET7, when langversion 7 is needed to be used.

@github-actions github-actions bot added this to the Backlog milestone Nov 14, 2022
@vzarytovskii vzarytovskii moved this to Not Planned in F# Compiler and Tooling Nov 14, 2022
@vzarytovskii vzarytovskii pinned this issue Nov 14, 2022
@vzarytovskii vzarytovskii changed the title Tracking: Issue with consuming DLLs built with .NET7 from .NET6 Issue with consuming DLLs built with .NET7 from .NET6 Nov 14, 2022
@vzarytovskii vzarytovskii removed this from the Backlog milestone Nov 14, 2022
@dsyme
Copy link
Contributor

dsyme commented Nov 14, 2022

Do we have a repro?

We should adjust /langversion:6.0 so that it never emits the new staticTyOpt.

@vzarytovskii
Copy link
Member Author

vzarytovskii commented Nov 14, 2022

I think /langversion:6 doesn't emit it, only in 7, problem is with consuming the library with langversion=7 from 6.0 sdk

When switching library project to langversion=7, the issue goes away on the consuming side.

@vzarytovskii
Copy link
Member Author

@dsyme one thing we can do is to warn that it can be technically unsupported.
When the language version is 7, and tfm is <7.0

@KevinRansom KevinRansom unpinned this issue Nov 23, 2022
gusty added a commit to fsprojects/FSharpPlus that referenced this issue Nov 30, 2022
@wallymathieu
Copy link
Contributor

I've tried locally to reproduce the issue. Simply by building the project on the branch v1.3
https://github.com/fsprojects/FSharpPlus/tree/v1.3
then copy the resulting net6 dll into a folder with a net6 global json

{
  "sdk": {
    "version": "6.0.100",
    "rollForward": "latestFeature"
  }
}

repro.fsx

#r "FSharpPlus.dll"
open FSharpPlus;;

It seems that even with LangVersion 6 specified I can reproduce the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants