-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Code Quality: Replaced Vanara with CsWin32 in ContextMenu class #17136
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: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ContextMenu will retire in favor of my new group of helper tho.
{ | ||
fixed (byte* p = global::System.Text.Encoding.UTF8.GetBytes(value)) | ||
{ | ||
return new PCSTR(p); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea what you doing. Once getting out of fixed
, the p
won't be guaranteed to be fixed any longer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do I then construct the struct from a string/int value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to pin the address until the method you want to call is returned.
fixed (char* pName = name)
{
// PInvoke.Method(..., pName, ...);
}
So, this case you can't create a helper like that.
|
||
public static unsafe PCSTR FromInt(int value) | ||
{ | ||
return new PCSTR((byte*)&value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too, taking pointer of an int value? For what.
Will it not reuse the code here? |
I don't think so, I'll create a static ContextMenuManager along with JumpListManager, TrayIconManager, etc, all of which are AoT-safe. That said, I don't think I'd be against this PR as far as this works and because I don't think mine will be implemented any time soon. |
Resolved / Related Issues
Steps used to test these changes
WIP