You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by GitBox <gi...@apache.org> on 2020/10/09 05:26:33 UTC
[GitHub] [lucenenet] NightOwl888 commented on issue #256: Port ConditionalWeakTable from .NET Core 3.x to .NET Standard 2.0
NightOwl888 commented on issue #256:
URL: https://github.com/apache/lucenenet/issues/256#issuecomment-705975452
@shadowcaptain
Thanks. [An attempt](https://github.com/NightOwl888/J2N/tree/feature/conditional-weak-table/src/J2N/Runtime/CompilerServices) has already been made on this. The blocker is the fact that it depends on [DependentHandle](https://github.com/NightOwl888/J2N/blob/feature/conditional-weak-table/src/J2N/Runtime/CompilerServices/DependentHandle.cs) which has native resources.
`DependentHandle` calls native methods using `[MethodImpl(MethodImplOptions.InternalCall)]`.
```c#
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern IntPtr nInitialize(object primary, object? secondary);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern object? nGetPrimary(IntPtr dependentHandle);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern object? nGetPrimaryAndSecondary(IntPtr dependentHandle, out object? secondary);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void nSetPrimary(IntPtr dependentHandle, object? primary);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void nSetSecondary(IntPtr dependentHandle, object? secondary);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void nFree(IntPtr dependentHandle);
```
It is not currently known how to translate that into a call that can be done from a 3rd party library such as J2N. Some important questions to answer:
- Can we assume the native method exists for the current platform, since .NET Standard should "just work"?
- Do we need to bundle the native resources in J2N to call them?
- If we need to bundle native resources, do they work on all platforms or do we need separate builds for specific platforms?
Note that `[MethodImpl(MethodImplOptions.InternalCall)]` doesn't exist on .NET Standard 1.x, but it is probably time to drop support for that target, anyway.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org