Comments (12)
CC: @vbfox
from pinvoke.
Yes we need a list of all the pro/cons.
On the list of languages :
- ✅ C# (
unsafe
/T* foo
) - ✅ C++ (
T* foo
) - ✅ F# (
let foo : nativeptr<'T>
) - ✅ Boo (
unsafe foo as T
) didn't test myself but they had a unit test about unsafe (Language is now considered dead) - 🔵 VB.Net
- 🔵 PowerShell
- 🎱 Nemerle (?)
- 🎱 IronSheme (?)
- 🎱 IronPython (?)
✅: Can call pointer exposing method
🔵: Can call IntPtr
overload even if pointer version exists
IntPtr
overload if the pointer version is present
🎱: Didn't find anythging / not searched
Also for the two overloads solutions it's pretty easy to codegen the IntPtr
overloads if we write the pointer ones.
from pinvoke.
Can you add a legend for these icons above?
from pinvoke.
Ok I differentiated between VB that doesn't allow unsafe but can call the IntPtr
version if also present with the same name and languages that support it natively.
Turn out that powershell is able to call an IntPtr
version too if it exists (Just tested) with the same name so no problem here either.
Everything seem to point that the dual pointer/IntPtr
is the good way to go, but we need to codegen it or it will be problematic pretty fast.
from pinvoke.
Also if we decide to go the "dual" way it's not really needed for a 0.x release, as we will only add overloads that aren't compatible and don't risk being picked by previously existing code.
But It would be nice to have that in 1.0 along with some variant of #70.
from pinvoke.
Thanks, @vbfox. I agree: let's go for dual mode. Until we have the code gen going, we should at least offer IntPtr versions so we don't block out use by VB.
Presumably when we start code gen that converts IntPtr to pointers, we can remove any manually created pointer overloads.
from pinvoke.
I just found out that unsafe code isn't allowed in C# iterator methods. That means that pointers aren't allowed in them, making it less convenient to call these methods even in a language that would otherwise allow it.
from pinvoke.
An open question on resolving some of these is what to do about struct fields that are pointers. Should they be IntPtr or a native pointer type? Can we perhaps use native pointers, but offer properties that expose them as IntPtrs for the VB folks?
from pinvoke.
Progress on fixing kernel32 is blocked on AArnott/CodeGeneration.Roslyn#1
from pinvoke.
Well, if we want to be consistent, struct fields should be native pointer types and the codegen should inject property wrappers of those fields.
So I am leaning toward native pointer type and properties that expose them as IntPtrs.
from pinvoke.
Agreed.
from pinvoke.
#130 tracks the struct fields now.
from pinvoke.
Related Issues (20)
- Request: Better exception handling or documentation for CreateFile HOT 3
- Refresh packages on NuGet HOT 1
- Change NTSTATUS/HResult FACILITY_CODE to match CsWin32 definitions HOT 3
- No release / release notes for 0.7.124 HOT 1
- User32.InvalidateRect missing
- Refactor FacilityCode bitshift op to Facility properties
- MCG0037 error release build with Kernel32 HOT 3
- Support for .NET 6 to include in Maui? HOT 2
- User32+MOUSEINPUT.cs has the wrong type for mouseData
- `User32.EnumChildWindows` has wrong typed argument HOT 1
- Dwmapi DwmIsCompositionEnabled is missing HOT 1
- Init script exception calling "DownloadFile" 404 Not Found HOT 5
- Kernel32.QueryFullProcessImageName broken on Windows 7 HOT 2
- Type of DLGTEMPLATE HOT 1
- User32.SetLayeredWindowAttributes missing HOT 2
- DirectX Video Acceleration HOT 1
- Missing user32 DeleteMenu HOT 5
- Missing user32 RegisterHotKey HOT 2
- Add mpr.dll HOT 1
- Add support for mssign32.dll HOT 1
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 pinvoke.