-
Notifications
You must be signed in to change notification settings - Fork 15
Changed SafeFileDescriptorHandle to SafeHandle #119
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
base: develop
Are you sure you want to change the base?
Changed SafeFileDescriptorHandle to SafeHandle #119
Conversation
Interesting! Leveraging the base class |
There are three reasons to support modification:
By the way, the repo have any discussions or discord? I have some new features want to discuss with you all. |
|
Users should always be using the I am unsure of what a customization use-case might be. Any proposals? |
I've been considering this. Parameter Design Guidelines on Microsoft's site state the following:
I don't anticipate a reason to need any other handle types other than
|
It has just been me working on this project. I have received some excellent ideas and feedback through Issues and Pull Requests on GitHub. I have never used the "Discussions" feature, but I am open to using it! |
Sorry, I may not have made myself clear.
I mean the user can inherit
By the way, i more recommanded to hide the P/Invoke methods: [DllImport("libc", EntryPoint = "write", SetLastError = true)]
internal unsafe static extern nint Write(int fd, void* buf, nuint size);
public static nint Write(int fd, ReadOnlySpan<byte> buf, nuint size)
{
if (size > (nuint)buf.Length)
throw new ArgumentOutOfRangeException(nameof(size), "Count exceeds buffer length.");
unsafe
{
fixed (byte* ptr = buf)
{
return Write(fd, ptr, size);
}
}
}
public static nint Write<T>(int fd, ref T buf, nuint size) where T : struct
{
unsafe
{
fixed (T* ptr = &buf)
{
return Write(fd, ptr, size);
}
}
} |
This is already provided to the library user via
For
|
It is a stated goal in the README that "Using this library you can either use the higher level classes or the lower level libc P/Invoke calls directly." The user can either use the libc P/Invokes directly or they can use the higher level classes that hide those details. Some examples of the aforementioned "hiding" in action:
|
It's true that u hided those wappers in the different positions. But as i mentioned in issues, there are too many More Information: LibraryImport |
Changed SafeFileDescriptorHandle to SafeHandle in the most of NativeMethods