Comments (11)
@patrickallensimpson We should ask the .NET Core team I think, can you open a .NET Core bug on this?
from fsharp.
I think this is caused by the following ifdef:
Line 1506 in 6819e1c
FSharp is not emitting actual PInvoke method for this that leads to this error.
The DefinePInvokeMethod method was added back to .NET Core. You should be able to delete this ifdef to fix this.
from fsharp.
@jkotas, Thanks mate.
from fsharp.
It looks like it will not be reintroduced until Dotnet Core 3.0
from fsharp.
Yes, you are right - this was fixed by dotnet/corefx#31096
from fsharp.
I've been going over the usage of the FX_RESHAPED_REFEMIT define in the ilreflect.fs and it looks like we might need a different set of defines or re-think API usage here. Are there specifications on what the absil is expecting as far as behavior regarding method usage from the Emit? I'm looking at some other cases related to the #defines that might be served by moving to other API's that both Core and Framework 4.5+ have in common. This is an area I'm particularly interested in and wouldn't mind helping to fix since I've got a significant amount of PInvoke scripts that I use with the Framework but want to start using Core going forward.
What are the framework expectations regarding F# moving forward do we need to keep supporting 2.0 and such?
To give you some background for why I want to get this fixed:
This whole issue came up when I started up a new Web project that I decided to target to CoreCLR. In the processes I wanted to use the SQLGeography implementation from Microsoft.SqlServer.Types but that doesn't work with CoreCLR. So I just re-implemented the Geography type using PInvoke direct to the underlying native DLL included in that project and in the process simplified the API for using with F#.
Everything was fine until I wanted to execute some code in in the REPL F# Interactive and I noticed that I get the security exception, unless I loaded the PInvoke calls from a DLL. (I hacked Visual Studio 2017 to use the CoreCLR fsi instead of the normal FSI, of course the debug feature doesn't work right since I'm spawning the CoreCLR fsi from another app).
I use the FSI all the time to test my code while writing it, it's better than unit tests honestly. I can write some code execute it right there and check that the results make sense. And if your doing things "Right" were the only dependencies in your function come from arguments its makes this strategy work really well. This is why I'm highly motivated to get this working for CoreCLR 3.0 at least. I'd move all my projects forward a version just for this feature.
Thanks,
-Patrick
from fsharp.
Are we using the System.Reflection.Emit API here because it's convenient or because the dynamic assemblies and modules allow us to keep adding types and functions on the fly with out having to deal with throwing away old versions of the assemblies as you're executing script code? Or is that just a happy coincidence. The reason I ask is would it be better to use Cecil to generate the Assemblies and then just load them on the fly as you go. I suppose that isn't really that much worse that what the FSI has to do now when types change. Though if you ask which assembly a type is coming from during reflection it might look weirder than it currently does.
from fsharp.
Considering that we now have F# 4.6 FSI as a preview dotnet command dotnet fsi
inside the .Net Core 3.0 preview 3 shouldn't we fix that #define now? This is still an issue under 3.0.100-preview3-010431 running Microsoft (R) F# Interactive version 10.4.0 for F# 4.6
Thanks!
from fsharp.
@patrickallensimpson This should be a bug in Microsoft/visualfsharp I think - can you move this bug there and ask for @KevinRansom's input? thanks
from fsharp.
I've created a new issue over in Microsoft/visualfsharp as you requested. I'll contact @KevinRansom next.
from fsharp.
Thanks to the great work by @KevinRansom I'm closing this issue. Kevin, thanks again. This means I can move fully over to .NET Core now for all my scripts thanks again!
-Patrick
from fsharp.
Related Issues (20)
- Compiler and interactive session crash instantly. HOT 2
- StackOverflow calling very large generated function HOT 3
- Does F# type inference works top-down (and left-right) only? HOT 2
- Why is Map.filter 10x slower than using a query to select the keys and remove those individually? HOT 2
- Can't build with mono 5.18 / msbuild 15.3 (also fails without msbuild) HOT 19
- FSI evaluates expressions incorrectly HOT 1
- Result builder throwing null reference exception HOT 5
- Fail to parse(?) decimals with FSharpValue.MakeRecord ONLY in iOS device with Region Spanish/Colombia HOT 8
- fsharpi error on matching union type HOT 1
- Missing code for version 4.5.4 and 4.6.0+ HOT 3
- Publish F# 4.6 FSharp.Compiler.Tools package HOT 16
- fsharpi crash when applying attribute to type parameter HOT 2
- IEvent.Publish "forgets" that it's an IObservable when used with an anonymous record argument HOT 2
- Publish F-Sharp 4.6 on Github HOT 4
- F#: [<StructuredFormatDisplay>] in composed records just print dots. (...) HOT 2
- is there any uwp or wpf template for f# in visual studio? HOT 1
- can't run fsi HOT 4
- The property of `Struct Record` should add [<IsReadOnly>] for the read operation HOT 2
- This repo can be retired HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fsharp.