Skip to content

Conversation

@mjmckp
Copy link
Contributor

@mjmckp mjmckp commented Oct 4, 2017

The toByref method fills a gap in the NativePtr module - converting typed native pointers to byref pointers. This is necessary, e.g., to call methods such as Thread.VolatileRead or Thread.VolatileWrite. This method was originally proposed here #409 but wasn't incorporated into the NativePtr module.

RFC https://github.com/fsharp/fslang-design/blob/master/RFCs/FS-1044-add-nativeptr-tobyref.md

@msftclas
Copy link

msftclas commented Oct 4, 2017

CLA assistant check
All CLA requirements met.

@abelbraaksma
Copy link
Contributor

abelbraaksma commented Oct 4, 2017

I think it is a good addition 👍, but I'd suggest to name it toByRef in stead. If I look at the code base, that seems to be the common nomenclature (i.e., compare System.MarshalByRefObject or member __.IsByRef in Symbols.fs).

I don't know whether the compiled name should include the suffix Inlined?

@mjmckp
Copy link
Contributor Author

mjmckp commented Oct 4, 2017

@abelbraaksma I have changed the name as suggested. I included the suffix Inlined for the compiled name to be consistent with the compiled name for all the other inline methods in the module.

@abelbraaksma
Copy link
Contributor

Before @dsyme or @KevinRansom can merge this, you should probably fix the tests. I didn't check, but perhaps the surface area changed (there's a test that deliberately fails each time a public method is added, changed, removed)? I am not 100% sure what is required to add public methods to the core in terms of procedure.

@mjmckp
Copy link
Contributor Author

mjmckp commented Oct 10, 2017

Thanks @abelbraaksma, I had a look through the tests and there doesn't appear to be a single place in which the NativePtr module is tested, would you mind suggesting a location? I was thinking of just a basic read/write test on the resulting byref for a few core types, would that be sufficient?

@dsyme
Copy link
Contributor

dsyme commented Oct 10, 2017

@mjmckp
Copy link
Contributor Author

mjmckp commented Oct 11, 2017

I've updated the tests, thanks. No idea why the CI builds are failing, tho.

@mjmckp
Copy link
Contributor Author

mjmckp commented Oct 12, 2017

There is a similar method in System.Runtime.CompilerServices.Unsafe here, which has a nontrivial implementation for non .NET core (does a round-trip via a local). Is there any chance the same thing applies here?

@realvictorprm
Copy link
Contributor

@dotnet-bot test this please

@realvictorprm
Copy link
Contributor

Triggering test because details ain't available.

@realvictorprm
Copy link
Contributor

@mjmckp please rename the PR name to respect the changed naming.

@mjmckp mjmckp changed the title Add NativePtr.toByref Add NativePtr.toByRef Dec 5, 2017
@realvictorprm
Copy link
Contributor

@dsyme all Checks have passed. Is this ready to merge now?

@mjmckp thanks!

@realvictorprm
Copy link
Contributor

@KevinRansom F# 4.3 ?

@dsyme
Copy link
Contributor

dsyme commented Dec 8, 2017

Approved. But this should have a tracking RFC too

@KevinRansom F# SDK 4.3 ?

@realvictorprm "F# SDK 4.3" means F# 4.1 with FSharp.Core 4.4.3.0 and updated compiler

@dsyme dsyme changed the title Add NativePtr.toByRef [RFC Needed] Add NativePtr.toByRef Dec 8, 2017
@dsyme
Copy link
Contributor

dsyme commented Dec 8, 2017

@dsyme dsyme changed the title [RFC Needed] Add NativePtr.toByRef [FS-1044] Add NativePtr.toByRef Dec 8, 2017
Copy link
Contributor

@KevinRansom KevinRansom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution

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

Successfully merging this pull request may close these issues.

6 participants