-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Migrate theming from net461 to net50 #9191
Comments
Have you seen https://github.com/Microsoft/Detours? |
Thank you, will look at it the coming weekend |
Thank you, good to know it exists! Gave it a shot, unfortunately it no new information so far. |
detours.net should be able to achieve what we need, not directly though.
is not what we want. The goal would be to achieve hooking "from inside" a .net process by learning from detours.net codebase. Plan
point 1. Should be relatively straightforward |
is there a list of the APIs that are currently hooked for theming? |
8 methods, see Win32ThemeHooks.InstallHooks |
Related WinForms issue dotnet/winforms#5166 |
I had success getting CoreHook to work with .net core as replacement for easyhook. https://github.com/unknownv2/CoreHook |
CoreHook looks interesting but it does appear that WinForms theming is on the roadmap for .NET 8. dotnet/winforms#5166 (comment) If they implement it, that will be November 2023. Unless someone volunteers to build in CoreHook and support it, we can probably count on 2024. I would just wait this one out, it's one year without dark theme in Git Extensions 4.0+. |
I wouldn't count on this in the foreseeable future (if at all). dotnet/winforms#7641 is significantly more likely to occur, though I'd be surprised if it lands in .NET 8 timeframe. |
@macsux Do you have some more information on that? Documentation ? An example repository doing it? Or is it a drop-in replacement for EasyHook? |
It's pretty much a drop in replacement from what I remember. Here's me using it in one of the projects: https://github.com/macsux/cf-buildpack-windows-services/blob/master/src/WindowsServicesBuildpack/ScimControllerInjector.cs |
It looked like a very simple replacement. Just replace LocalHook with CoreHook.LocalHook in Win32ThemeHooks. (after adding the nuget packages and the native dll's) Still, my attempt to replace EasyHook with CoreHook failed with this exception: |
Hello, I'm the author of another app that uses hooking as part of WinForms theming, and I ran into this same ExecutionEngineException issue when trying to move from Framework 4.7.2 to .NET 7. I determined the exception comes from the GetSysColor() hook only, so I created an issue here: dotnet/runtime#78086 As you can see from the reply, it's apparently because GetSysColor() is set up with a [SuppressGCTransition] attribute in the newer .NETs, and that breaks the hook and causes the ExecutionEngineException. Here's the code. It looks like just a normal p/invoke setup that the runtime can call explicitly, so I'm not sure why putting the attribute on just that one definition would affect all calls to the native GetSysColor() function even from native controls, but it seems to. I'm no expert on how this sort of thing works so I dunno. I'm at a loss for any way to get around it, but at least I thought I'd save others the trouble I went through of trying to figure it out. |
It sounds like CoreHook isn't going to work after reading that thread (dotnet/runtime#78086). Seems like the best hope is dotnet/winforms#7641 for this issue, as RussKie originally suggested. |
What if as a temporary solution before .net8 release you were to create a separate build with the dark theme? Something tells me that it shouldnt be too hard to implement |
Closing as it is currently technically not possible, see #9191 (comment). |
Would this work? (Disclaimer: not tested by me)
|
Crossposting some suggestions: #10312 (comment) |
Any news regarding this discussion, with the comment @gerhardol mentioned? |
No workaround for the hooking found. |
The theming support may be coming in .NET 9 it seems: dotnet/winforms#10985 |
@RussKie: If that's all right, I'd ping you once I think, you could "try" it. I would be very much interested in the experience to enable dark mode for whatever custom controls you guys have. For all the normal stuff, it should be easy to migrate. For now, you'd just use... Later I guess we should have an additional project setting, so that also the Designer could pick up that color scheme, and then we generate and inject via So, for styling individual (custom) controls: If it's more than
And, as usual, Igor and I do our usual "Naming and Convention Dance", so, API names might not be cast in stone quite yet. Looking very much forward for feedback, but also keep in mind: The MVP Summit is coming up, so I'll be going dark (pun intended) for next 2 weeks. |
@RussKie Is this ready to be tried for GE? |
¯\_(ツ)_/¯ I'm no longer part of the Windows Forms team, and I have a basic understanding of what the team is working on. |
dotnet/winforms#11857 has been merged, so there is some kind of dark mode expected in .NET9 |
No available Light mode in Git Extensions has always bugged me, so I tried to fix it quickly by trying out this project I didn't spend a lot of time on it but I got this far already, I just lazyily implemented it where it seemed right, I didn't examine the code very much. Some text became invisible and the Colors and Icons look washed out but are fixed when using the high contrast theme but the high contrast theme destroys other things Maybe when I have enough time I can fix all Issues and publish a fork or if we're lucky the devs implement it as this is more of a workaround. |
Coordinate with the changes in .NET9: dotnet/winforms#11857 |
Beginning of discussion: #8522 (comment)
The text was updated successfully, but these errors were encountered: