-
Notifications
You must be signed in to change notification settings - Fork 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
Implement StandardAccessble RCW and AccessibleObject CCW #7145
Conversation
Could you please elaborate on what led to the realisation, and what "internal things of Win32" scenarios led to this change? It would be great to capture all of these details, and may be add tests too. |
"internal things of Win32" => ComObject which returned from https://docs.microsoft.com/en-us/windows/win32/api/oleacc/nf-oleacc-createstdaccessibleobject#parameters . here declared that parameters can be one of 4 interfaces. Then when I probe for supported interfaces in |
Okay. I remove duplicate calls to Only was to access internal IAccessible which I see is for Non-client area accessible objects. If somebody can tell me more about this scenario in accessibility, and how I can test more in that area? Otherwise I think this is good. |
src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildNativeWindow.cs
Show resolved
Hide resolved
src/System.Windows.Forms/tests/InteropTests/AccessibleObjectTests.cs
Outdated
Show resolved
Hide resolved
...System.Windows.Forms.Primitives/src/Interop/WinFormsComWrappers.StandardAccessibleWrapper.cs
Outdated
Show resolved
Hide resolved
...System.Windows.Forms.Primitives/src/Interop/WinFormsComWrappers.StandardAccessibleWrapper.cs
Outdated
Show resolved
Hide resolved
@RussKie I think I address all questions. Am I? |
@RussKie please take a look at this one too. |
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'm getting better at this 😄
Is there some way we can verify we're not leaking objects?
@AaronRobinsonMSFT may I get you to review as well, when you have a chance?
...System.Windows.Forms.Primitives/src/Interop/WinFormsComWrappers.StandardAccessibleWrapper.cs
Outdated
Show resolved
Hide resolved
...System.Windows.Forms.Primitives/src/Interop/WinFormsComWrappers.StandardAccessibleWrapper.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/AccessibleObject.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/AccessibleObject.cs
Outdated
Show resolved
Hide resolved
This is successfully catches bug in the dotnet#7145 implementation
Please do not approve. I found test case #7191 which trigger bug with current implementation, and except much more code to make that happens. Overall I hate this AccessibleObject thing. |
This is successfully catches bug in the dotnet#7145 implementation
On latest commit I fix issue and what's important this PR make WinForms finally working without built-in COM. If this PR pass review, it would be time for celebration. |
@@ -1749,31 +1749,31 @@ protected void UseStdAccessibleObjects(IntPtr handle) | |||
|
|||
protected void UseStdAccessibleObjects(IntPtr handle, int objid) | |||
{ | |||
object? acc = null; | |||
UnsafeNativeMethods.CreateStdAccessibleObject( | |||
Guid IID_IAccessible = IID.IAccessible; |
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.
Name of this local does not follow conventions, You used iAccessibleId
elsewhere. And the same applies to IEnumVariant
DropDownStyle = ComboBoxStyle.DropDown | ||
}; | ||
control.CreateControl(); | ||
ComboBox.ComboBoxAccessibleObject accessibleObject = new ComboBox.ComboBoxAccessibleObject(control); |
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.
Consider new (control)
.
This is successfully catches bug in the #7145 implementation I need just call to `GetFocused`, but if some additional check can be made, I can add them.
f4e1713
to
bfc9519
Compare
@RussKie NativeAOT needs you :) |
Apologies, I've been slammed with other work |
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.
👍
private static extern HRESULT UiaDisconnectProvider(IntPtr provider); | ||
public static HRESULT UiaDisconnectProvider(IRawElementProviderSimple provider) |
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.
[nit] Missing blank line
src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaHostProviderFromHwnd.cs
Outdated
Show resolved
Hide resolved
...System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRaiseStructureChangedEvent.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaReturnRawElementProvider.cs
Outdated
Show resolved
Hide resolved
...dows.Forms.Primitives/src/Interop/WinFormsComWrappers.IRawElementProviderFragmentRootVtbl.cs
Show resolved
Hide resolved
...dows.Forms.Primitives/src/Interop/WinFormsComWrappers.IRawElementProviderFragmentRootVtbl.cs
Outdated
Show resolved
Hide resolved
((delegate* unmanaged<IntPtr, Oleaut32.VARIANT, IntPtr *, HRESULT>)(*(*(void***)_accessibleInstance + 9))) | ||
(_accessibleInstance, childIdVar, &value).ThrowIfFailed(); | ||
return value == IntPtr.Zero ? null : Marshal.GetObjectForIUnknown(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.
Just to confirm I understand this correctly - when the return object will be GC'ed, value
will get released. Is this correct?
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.
Yes. From what I understand Marshal.GetObjectForIUnknown
creates same RCW as built-in COM interop.
src/System.Windows.Forms.Primitives/src/Interop/WinFormsComWrappers.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/tests/InteropTests/AccessibleObjectTests.cs
Outdated
Show resolved
Hide resolved
@AaronRobinsonMSFT if you could spare few minutes for another pass, it'd be great. Mainly to see if we're leaking anything. |
Because I provide AccessibleObject via WM_OBJECT I have to provide 3 interfaces IAccessible, IDispatch and IEnumVariant. But we rely on the IOleWindowVtbl Also I discover incorrect memory definition in ILegacyIAccessibleProvider
32ad267
to
7d42479
Compare
I've just got back from being OOF, and looks like you've wrestled the tests over. I'm a bit swamped atm, but I'll try to get this reviewed by the EOW. |
@Olina-Zhang can you please schedule a test run for this change? |
@kant2002 @RussKie I quickly tested the updated change, still have issue in here:
AccessibilityInsight result in this PR change: |
Thanks! Will take a look and rebase on latest main |
This submission has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 14 days. It will be closed if no further activity occurs within 7 days of this comment. |
prevent bot from closing it. |
This submission has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 14 days. It will be closed if no further activity occurs within 7 days of this comment. |
ping. |
This submission has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 14 days. It will be closed if no further activity occurs within 7 days of this comment. |
Thanks for the effort here @kant2002- it helped get us in gear to make the COM changes we already made for .NET 8. @lonitra is handling |
I love this news :) |
I realize that EnumVariantWrapper RCW is essentially always implement 3 interfaces which is needed
IEnumVariant, IAccessible and IOleWindow
Some internal things of Win32 prevent me using just single call to
CreateStdAccessibleObject
Also add CCW for AccessibleObject
With this change you can run WinForms application with disabled built-in COM except following controls:
That's important step forward #5163
Microsoft Reviewers: Open in CodeFlow