-
Notifications
You must be signed in to change notification settings - Fork 790
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
FSharp.Core 4.4.0.0 always gets referenced when using Type Provider #23
Comments
I have talked this over with Don and we agree that this is an issue with the type provider. the compiler does what it is told and the type provider has told it to use fsharp.core.dll. I considered remapping the references in the compiler, but that sort of magic does not really belong in the compiler. What is needed is providedtypes.fs needs a new set of helpers which will make types, methodinfos, generic types etc only from the set of assemblies passed to the type provider by the compiler. I notice that there is a bunch of code in the TP for handling assembly resolution failure and so loading stuff randomly from the compiling machine. None of that will work well for portable libraries, and will work even worse if we re-host the compiler on coreclr, also when we are doing multi-targeting, I.e. using FSharp 4.0 to compile an F# 3.1 or F# 3.0 application, the only runtime difference is the set of target assemblies. @ovatsus as maintainer of the TypeProviders starter pack, would you like to start a thread on how to solve this. I will help make sure the solution will work for the cross platform scenario. |
This is very tricky business, unfortunately, with assembly mismatches all over. |
I agree it ain't easy. So the type provider must only use types from the reference set for quotations and provided types. If the type can't be loaded from there then it is a missing type error. If you use LoadFrom and then GetType() and MakeGenericType etc. Type Forwarders and binding redirects should not be honored. Remapping is possible but ultimately a hack, and the compiler doesn't really know about profiles, it just knows about the set of assemblies that it gets from the command line and the source code being compiled. If I had the bandwidth I would look at this, since it is an important issue, and one that is only going to get more important. |
What is our guidance to TP authors/consumers, then? If our position is that this is an issue with the TP, how do they fix their issue? If there is no good way to "fix" this, I guess we just advise folks that it's unsupported to down-target when using type providers (i.e. type providers are not forward-compatible). |
It is definitely possible to fix this in type providers, and most likely it is possible to have some very general machinery in ProvidedTypes.fs that fixes this in most cases for most type providers. It feels like we need to iterate towards some additions to ProvidedTypes.fs (in the Type Provider Starter Pack) which get us what we need.... |
Can you elaborate on how this can be fixed in TPs, so that @ctaggart and co. can make appropriate adjustments? If the TP was built entirely using 3.1 toolchain, what mechanism do we offer to prevent vFuture toolchain from adding bogus new references? |
I made an attempt to fix the problem. I realized that I use Also per @KevinRansom suggestion I changed assembly resolution logic from But the problem is not gone. To experiment I added a console app as test projects that targets .NET 4.0 + FSharp.Core 4.3.0.0. Please assist. |
This is a fundamentally very hard problem. TypeProvider authors need to think like compiler writers, and only bind types from the set of types provided to the compiler. The tendency is to think like an app and library author and bind to loadable types. As far as I can tell no type provider has yet done this correctly, I would dearly like to figure out how to solve this, but I am snowed under with other stuff to do. What is required is a binder that will return types from a set of reachable assemblies. Those types are the ones that need to be returned to the compiler. I had suggested and implemented a prototype of a filter between the compiler and the type provider that fixed up the references to only reachable types and it even worked. But Don convinced me that it was an invalid approach that primarily masked bugs in the type provider. |
Hi there.
Can you clarify? Easiest way to repro locally is pull the whole repo |
@dmitry-a-morozov This is a long-shot, but during the last half a year or so I've got the feeling that whenever there's Assembly.LoadFrom, one wants to apply policies as well or things turn up wrong at some point for the end user. More info at Fsharp.Data #821. |
Hi @dmitry-a-morozov - addressing one small part of this puzzle - In #478 I describe how the ReferencedAssemblies property is not populated fully and doesn't include FSharp.Core and mscorlib in the references. This is simply a bug but an annoying one as it would be very useful information to help with multi-targeting. |
Hi @dsyme. Thanks for the update. Keep me posted. Eventually I will need somebody's help or guidelines to fix the issue. Unless F# team will find a way to magically resolve it. |
…tection Better indexer detection
Originally opened by @ctaggart on Codeplex. Seems like a weird/severe enough problem that we should get eyes on it asap.
I've been troubleshooting this issue with Visual Studio 2015 Preview the last couple of nights and created a very simple FSharp.Data.SqlClient project to reproduce the issue. The project that uses the type provider ends up referencing both 4.4.0.0 and 4.3.1.0 of FSharp.Core. I was expecting it to only reference
4.3.1.0
that the project is set to. We figured out that we can still get it to run on 4.3.1.0 by doing a binding redirect down.Please have a look at this issue:
fsprojects/FSharp.Data.SqlClient#79
It is super easy to reproduce:
cheers,
Cameron
KevinRansom wrote Nov 19, 2014 at 9:16 AM [x]
Thanks for this report we will take a look to try to figure out what makes sense to do here.
Kevin
latkin wrote Nov 26, 2014 at 4:58 PM [x]
At the project level, everything is working as expected, and 4.3.1.0 is the only FSharp.Core referenced in the compiler command line.
At some point when the provided types are generated during compilation, various F#-specific types are required (unit, async...) and the compiler assumes those come from the same FSharp.Core version that it is using (4.4.0.0 in this case). A reference is somehow injected to 4.4.0.0 due to this, as best as I can tell. Reproing with the OSS compiler results in unintentional reference to 4.4.0.9055, which follows the same pattern.
The text was updated successfully, but these errors were encountered: