Skip to content
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

Add extensibility option to most static functions #518

Open
uom42 opened this issue Feb 24, 2025 · 4 comments
Open

Add extensibility option to most static functions #518

uom42 opened this issue Feb 24, 2025 · 4 comments
Assignees

Comments

@uom42
Copy link

uom42 commented Feb 24, 2025

Describe the additions or enhancements you'd like
Since most functions are declared in static classes,
in order to expand the capabilities of Vanara, and greater compliance with the Net extensibility ideology,
there is a proposal to add "this" modifer before the first argument for most static functions turning them into extensions.
This can be done even with extern WinAPI functions.

Thus, these functions can be used in two ways:


var wndActive = User32.GetActiveWindow ();

//Classic WinAPI mode:
User32.MoveWindow (wndActive, 0, 100, 100, 100, true);

//Modern .Net way:
wndActive.MoveWindow (0, 100, 100, 100, true);

I think this can be done for 85-90% of Vanara lib.

@uom42
Copy link
Author

uom42 commented Feb 24, 2025

This is a huge amount of work, I’m ready to help on my part!

@dahall
Copy link
Owner

dahall commented Feb 24, 2025

I did this with a few of the functions and found that it breaks IntelliSense when trying to use the method as a non-extended method. Have you seen the same?

@dahall dahall self-assigned this Feb 24, 2025
@uom42
Copy link
Author

uom42 commented Feb 25, 2025

I've never noticed IntelliSense breaking.

There are some problems with IntelliSense with inheritance and inplicit/explicit operators, for example if you make an Extension for HDC that has a direct conversion to IntPtr, then IntelliSense does not show the extended function in the list of IntPtr.

I’m ready to check if you indicate where you encountered errors!

@uom42
Copy link
Author

uom42 commented Feb 25, 2025

Perhaps, as a starting point, we could try extend the functions for specialized Vanara-types like an HWND / HINSTANCE / SafeHandle, etc., without affecting the standard unmanaged int / string / bool and test the stability of the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants