diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IExpandCollapseProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IExpandCollapseProvider.cs deleted file mode 100644 index 5c3636e4465..00000000000 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IExpandCollapseProvider.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; -using Windows.Win32.UI.Accessibility; - -internal static partial class Interop -{ - internal static partial class UiaCore - { - [ComImport] - [Guid("d847d3a5-cab0-4a98-8c32-ecb45c59ad24")] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - public interface IExpandCollapseProvider - { - /// - /// Blocking method that returns after the element has been expanded. - /// - void Expand(); - - /// - /// Blocking method that returns after the element has been collapsed. - /// - void Collapse(); - - /// - /// Indicates an element's current Collapsed or Expanded state - /// - ExpandCollapseState ExpandCollapseState { get; } - } - } -} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IGridItemProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IGridItemProvider.cs deleted file mode 100644 index 5946ef959bb..00000000000 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IGridItemProvider.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class UiaCore - { - [ComImport] - [Guid("d02541f1-fb81-4d64-ae32-f520f8a6dbd1")] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - public interface IGridItemProvider - { - int Row { get; } - - int Column { get; } - - int RowSpan { get; } - - int ColumnSpan { get; } - - Windows.Win32.UI.Accessibility.IRawElementProviderSimple.Interface? ContainingGrid { get; } - } - } -} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IGridProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IGridProvider.cs deleted file mode 100644 index e08db3e30be..00000000000 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IGridProvider.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class UiaCore - { - [ComImport] - [Guid("b17d6187-0907-464b-a168-0ef17a1572b1")] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - public interface IGridProvider - { - [return: MarshalAs(UnmanagedType.IUnknown)] - object? /*IRawElementProviderSimple*/ GetItem(int row, int column); - - int RowCount { get; } - - int ColumnCount { get; } - } - } -} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IInvokeProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IInvokeProvider.cs deleted file mode 100644 index 3d2a559efd9..00000000000 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IInvokeProvider.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class UiaCore - { - /// - /// Implemented by objects that have a single, unambiguous, action associated with them. - /// These objects are usually stateless, and invoking them does not change their own state, - /// but causes something to happen in the larger context of the app the control is in. - /// - /// Examples of UI that implements this includes: - /// Push buttons - /// Hyperlinks - /// Menu items - /// - [ComImport] - [Guid("54fcb24b-e18e-47a2-b4d3-eccbe77599a2")] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - public interface IInvokeProvider - { - /// - /// Request that the control initiate its action. - /// Should return immediately without blocking. - /// There is no way to determine what happened, when it happened, or whether - /// anything happened at all. - /// - void Invoke(); - } - } -} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IMultipleViewProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IMultipleViewProvider.cs deleted file mode 100644 index 75e95f7d64d..00000000000 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IMultipleViewProvider.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class UiaCore - { - [ComImport] - [Guid("6278cab1-b556-4a1a-b4e0-418acc523201")] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - public interface IMultipleViewProvider - { - string? GetViewName(int viewId); - - void SetCurrentView(int viewId); - - int CurrentView { get; } - - int[]? GetSupportedViews(); - } - } -} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRangeValueProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRangeValueProvider.cs deleted file mode 100644 index 290af1b4338..00000000000 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRangeValueProvider.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class UiaCore - { - [ComImport] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [Guid("36dc7aef-33e6-4691-afe1-2be7274b3d33")] - public interface IRangeValueProvider - { - void SetValue(double value); - - double Value { get; } - - BOOL IsReadOnly { get; } - - double Maximum { get; } - - double Minimum { get; } - - double LargeChange { get; } - - double SmallChange { get; } - } - } -} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IScrollItemProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IScrollItemProvider.cs deleted file mode 100644 index 3f9710720b1..00000000000 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IScrollItemProvider.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class UiaCore - { - /// - /// Implemented by objects in a known Scrollable context, such as ListItems, ListViewItems, TreeViewItems, and Tabs. - /// This allows them to be scrolled into view using known API's based on the control in question. - /// - [ComImport] - [Guid("2360c714-4bf1-4b26-ba65-9b21316127eb")] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - public interface IScrollItemProvider - { - /// - /// Scrolls the windows containing this automation element to make this element visible. - /// InvalidOperationException should be thrown if item becomes unable to be scrolled. Makes - /// no guarantees about where the item will be in the scrolled window. - /// - void ScrollIntoView(); - } - } -} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ISelectionItemProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ISelectionItemProvider.cs deleted file mode 100644 index aa00ed6907b..00000000000 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ISelectionItemProvider.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class UiaCore - { - /// - /// Define a Selectable Item (only supported on logical elements that are a - /// child of an Element that supports SelectionPattern and is itself selectable). - /// This allows for manipulation of Selection from the element itself. - /// - [ComImport] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [Guid("2acad808-b2d4-452d-a407-91ff1ad167b2")] - public interface ISelectionItemProvider - { - /// - /// Sets the current element as the selection - /// This clears the selection from other elements in the container. - /// - void Select(); - - /// - /// Adds current element to selection. - /// - void AddToSelection(); - - /// - /// Removes current element from selection. - /// - void RemoveFromSelection(); - - /// - /// Check whether an element is selected. - /// - /// Returns true if the element is selected. - BOOL IsSelected { get; } - - /// - /// The logical element that supports the SelectionPattern for this Item. - /// - /// Returns a IRawElementProviderSimple. - Windows.Win32.UI.Accessibility.IRawElementProviderSimple.Interface? SelectionContainer { get; } - } - } -} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ISelectionProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ISelectionProvider.cs deleted file mode 100644 index b514e0e5307..00000000000 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ISelectionProvider.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class UiaCore - { - /// - /// The interface representing containers that manage selection. - /// - /// - /// Client code uses this public interface; server implementers implement the - /// ISelectionProvider public interface instead. - /// - [ComImport] - [Guid("fb8b03af-3bdf-48d4-bd36-1a65793be168")] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - public interface ISelectionProvider - { - /// - /// Get the currently selected elements - /// - /// An AutomationElement array containing the currently selected elements - [return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_UNKNOWN)] - object[]? /* IRawElementProviderSimple */ GetSelection(); - - /// - /// Indicates whether the control allows more than one element to be selected - /// - /// Boolean indicating whether the control allows more than one element to be selected - /// If this is false, then the control is a single-select control - BOOL CanSelectMultiple { get; } - - /// - /// Indicates whether the control requires at least one element to be selected - /// - /// Boolean indicating whether the control requires at least one element to be selected - /// If this is false, then the control allows all elements to be unselected - BOOL IsSelectionRequired { get; } - } - } -} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITableItemProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITableItemProvider.cs deleted file mode 100644 index ac562e11395..00000000000 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITableItemProvider.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class UiaCore - { - [ComImport] - [Guid("b9734fa6-771f-4d78-9c90-2517999349cd")] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - public interface ITableItemProvider - { - [return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_UNKNOWN)] - object[]? /*IRawElementProviderSimple[]*/ GetRowHeaderItems(); - - [return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_UNKNOWN)] - object[]? /*IRawElementProviderSimple[]*/ GetColumnHeaderItems(); - } - } -} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITableProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITableProvider.cs deleted file mode 100644 index 6064b6220a8..00000000000 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITableProvider.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; -using Windows.Win32.UI.Accessibility; - -internal static partial class Interop -{ - internal static partial class UiaCore - { - [ComImport] - [Guid("9c860395-97b3-490a-b52a-858cc22af166")] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - public interface ITableProvider - { - [return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_UNKNOWN)] - object[]? /*IRawElementProviderSimple[]*/ GetRowHeaders(); - - [return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_UNKNOWN)] - object[]? /*IRawElementProviderSimple[]*/ GetColumnHeaders(); - - RowOrColumnMajor RowOrColumnMajor { get; } - } - } -} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IToggleProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IToggleProvider.cs deleted file mode 100644 index ec089d62590..00000000000 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IToggleProvider.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; -using UIA = Windows.Win32.UI.Accessibility; - -internal static partial class Interop -{ - internal static partial class UiaCore - { - [ComImport] - [Guid("56D00BD0-C4F4-433C-A836-1A52A57E0892")] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - public interface IToggleProvider - { - void Toggle(); - - /// - /// Indicates an element's current on or off state - /// - UIA.ToggleState ToggleState { get; } - } - } -} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IValueProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IValueProvider.cs deleted file mode 100644 index e16f705dacc..00000000000 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IValueProvider.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class UiaCore - { - [ComImport] - [Guid("c7935180-6fb3-4201-b174-7df73adbf64a")] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - public interface IValueProvider - { - /// - /// Request to set the value that this UI element is representing - /// - /// Value to set the UI to - void SetValue([MarshalAs(UnmanagedType.LPWStr)] string? value); - - /// Value of a value control, as a a string. - string? Value { get; } - - /// Indicates that the value can only be read, not modified. - ///returns True if the control is read-only - BOOL IsReadOnly { get; } - } - } -} diff --git a/src/System.Windows.Forms.Primitives/src/NativeMethods.json b/src/System.Windows.Forms.Primitives/src/NativeMethods.json index b1ae5cd3fea..37546183bd6 100644 --- a/src/System.Windows.Forms.Primitives/src/NativeMethods.json +++ b/src/System.Windows.Forms.Primitives/src/NativeMethods.json @@ -62,6 +62,7 @@ "IEnumVARIANT.Reset", "IEnumVARIANT.Clone", "IErrorInfo.GetDescription", + "IExpandCollapseProvider.get_ExpandCollapseState", "IFileDialog.Show", "IFileDialog.GetResult", "IFileOpenDialog.GetResults", @@ -71,6 +72,13 @@ "IGlobalInterfaceTable.GetInterfaceFromGlobal", "IGlobalInterfaceTable.RegisterInterfaceInGlobal", "IGlobalInterfaceTable.RevokeInterfaceFromGlobal", + "IGridItemProvider.get_Column", + "IGridItemProvider.get_ColumnSpan", + "IGridItemProvider.get_ContainingGrid", + "IGridItemProvider.get_Row", + "IGridItemProvider.get_RowSpan", + "IGridProvider.get_ColumnCount", + "IGridProvider.get_RowCount", "IHTMLElement.get_all", "IHTMLElement.get_children", "IHTMLElement.get_document", @@ -200,33 +208,7 @@ "IHTMLWindow3.get_screenLeft", "IHTMLWindow3.get_screenTop", "IHTMLWindow4.get_frameElement", - "IWebBrowser.get_Busy", - "IWebBrowser.get_Document", - "IWebBrowser.get_LocationName", - "IWebBrowser.get_LocationURL", - "IWebBrowser2.ExecWB", - "IWebBrowser2.get_Busy", - "IWebBrowser2.get_Document", - "IWebBrowser2.get_LocationName", - "IWebBrowser2.get_LocationURL", - "IWebBrowser2.get_Offline", - "IWebBrowser2.get_ReadyState", - "IWebBrowser2.get_RegisterAsDropTarget", - "IWebBrowser2.get_Silent", - "IWebBrowser2.Navigate2", - "IWebBrowser2.GoBack", - "IWebBrowser2.GoForward", - "IWebBrowser2.GoHome", - "IWebBrowser2.GoSearch", - "IWebBrowser2.put_RegisterAsDropTarget", - "IWebBrowser2.put_Silent", - "IWebBrowser2.Refresh", - "IWebBrowser2.Refresh2", - "IWebBrowser2.Stop", - "IWebBrowserApp.get_Busy", - "IWebBrowserApp.get_Document", - "IWebBrowserApp.get_LocationName", - "IWebBrowserApp.get_LocationURL", + "IMultipleViewProvider.get_CurrentView", "IOleAdviseHolder.Advise", "IOleAdviseHolder.SendOnClose", "IOleAdviseHolser.SendOnRename", @@ -315,6 +297,12 @@ "IQuickActivate.GetContentExtent", "IQuickActivate.QuickActivate", "IQuickActivate.SetContentExtent", + "IRangeValueProvider.get_IsReadOnly", + "IRangeValueProvider.get_LargeChange", + "IRangeValueProvider.get_Maximum", + "IRangeValueProvider.get_Minimum", + "IRangeValueProvider.get_SmallChange", + "IRangeValueProvider.get_Value", "IRawElementProviderFragment.get_BoundingRectangle", "IRawElementProviderFragment.get_FragmentRoot", "IRawElementProviderFragment.GetEmbeddedFragmentRoots", @@ -338,16 +326,22 @@ "IRichEditOleCallback.QueryAcceptData", "IRichEditOleCallback.QueryInsertObject", "IRichEditOleCallback.ShowContainerUI", + "ISelectionItemProvider.get_IsSelected", + "ISelectionItemProvider.get_SelectionContainer", + "ISelectionProvider.get_CanSelectMultiple", + "ISelectionProvider.get_IsSelectionRequired", "IServiceProvider.QueryService", "ISpecifyPropertyPages.GetPages", "IStorage.CreateStream", "IStorage.OpenStream", "ISupportErrorInfo.InterfaceSupportsErrorInfo", + "ITableProvider.get_RowOrColumnMajor", "ITextDocument.Range", "ITextRange.EndOf", "ITextRange.GetText", "ITextRange.ScrollIntoView", "ITextRange.StartOf", + "IToggleProvider.get_ToggleState", "ITypeInfo.GetDocumentation", "ITypeInfo.GetFuncDesc", "ITypeInfo.GetIDsOfNames", @@ -361,7 +355,36 @@ "ITypeInfo.ReleaseTypeAttr", "ITypeLib.GetLibAttr", "ITypeLib.GetTypeInfoOfGuid", - "IUnknown.QueryInterface" + "IUnknown.QueryInterface", + "IValueProvider.get_IsReadOnly", + "IValueProvider.get_Value", + "IWebBrowser.get_Busy", + "IWebBrowser.get_Document", + "IWebBrowser.get_LocationName", + "IWebBrowser.get_LocationURL", + "IWebBrowser2.ExecWB", + "IWebBrowser2.get_Busy", + "IWebBrowser2.get_Document", + "IWebBrowser2.get_LocationName", + "IWebBrowser2.get_LocationURL", + "IWebBrowser2.get_Offline", + "IWebBrowser2.get_ReadyState", + "IWebBrowser2.get_RegisterAsDropTarget", + "IWebBrowser2.get_Silent", + "IWebBrowser2.Navigate2", + "IWebBrowser2.GoBack", + "IWebBrowser2.GoForward", + "IWebBrowser2.GoHome", + "IWebBrowser2.GoSearch", + "IWebBrowser2.put_RegisterAsDropTarget", + "IWebBrowser2.put_Silent", + "IWebBrowser2.Refresh", + "IWebBrowser2.Refresh2", + "IWebBrowser2.Stop", + "IWebBrowserApp.get_Busy", + "IWebBrowserApp.get_Document", + "IWebBrowserApp.get_LocationName", + "IWebBrowserApp.get_LocationURL" ] } } \ No newline at end of file diff --git a/src/System.Windows.Forms.Primitives/src/NativeMethods.txt b/src/System.Windows.Forms.Primitives/src/NativeMethods.txt index c1f6e129a2a..9e427f0091f 100644 --- a/src/System.Windows.Forms.Primitives/src/NativeMethods.txt +++ b/src/System.Windows.Forms.Primitives/src/NativeMethods.txt @@ -371,6 +371,7 @@ IEnumFORMATETC IEnumOLEVERB IEnumVARIANT IErrorInfo +IExpandCollapseProvider IFileDialog IFileDialogCustomize IFileDialogEvents @@ -381,6 +382,8 @@ IFontDisp IGetOleObject IGetVBAObject IGlobalInterfaceTable +IGridItemProvider +IGridProvider IHTMLDocument IHTMLDocument2 IHTMLDocument3 @@ -390,6 +393,7 @@ IHTMLElement3 IHTMLElementCollection IHTMLWindow3 IHTMLWindow4 +IInvokeProvider IMAGE_LIST_WRITE_STREAM_FLAGS ImageList_Add ImageList_Create @@ -418,6 +422,7 @@ ImmSetConversionStatus ImmSetOpenStatus IMN_* IMPLTYPEFLAGS +IMultipleViewProvider InitCommonControls InitCommonControlsEx INITCOMMONCONTROLSEX_ICC @@ -445,6 +450,7 @@ IPictureDisp IPropertyNotifySink IProvideMultipleClassInfo IQuickActivate +IRangeValueProvider IRawElementProviderFragment IRawElementProviderFragmentRoot IRawElementProviderHwndOverride @@ -455,7 +461,10 @@ IsAccelerator IsAppThemed IsChild IsDialogMessage +IScrollItemProvider IScrollProvider +ISelectionItemProvider +ISelectionProvider IServiceProvider IShellItem ISimpleFrameSite @@ -471,10 +480,14 @@ IsWindowEnabled IsWindowUnicode IsWindowVisible IsZoomed +ITableItemProvider +ITableProvider ITextDocument ITextProvider ITextProvider2 ITextRangeProvider +IToggleProvider +IValueProvider IVBFormat IVBGetControl IViewObject diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/IComInterface.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/IComInterface.cs new file mode 100644 index 00000000000..f2a55794aca --- /dev/null +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/IComInterface.cs @@ -0,0 +1,12 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Windows.Win32; + +/// +/// This should be placed on a COM struct when it needs to be bounded to +/// its corresponding COM interface. +/// +internal interface IComInterface +{ +} diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/ComSafeArrayScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/ComSafeArrayScope.cs index cf051618dac..113f3e5ad4c 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/ComSafeArrayScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/ComSafeArrayScope.cs @@ -16,7 +16,7 @@ namespace Windows.Win32.System.Com; /// Use in a statement to ensure the gets disposed. /// /// -internal readonly unsafe ref struct ComSafeArrayScope where T: unmanaged, IComIID +internal readonly unsafe ref struct ComSafeArrayScope where T : unmanaged, IComIID { private readonly SafeArrayScope _value; @@ -41,6 +41,32 @@ public ComSafeArrayScope(uint size) _value = new(PInvoke.SafeArrayCreate(VARENUM.VT_UNKNOWN, 1, &saBound)); } + /// + /// Creates a from an array of COM interfaces. + /// + /// + /// + /// must implement where T is . + /// Otherwise an will be thrown. + /// + /// + public static ComSafeArrayScope CreateFromInterfaceArray(TComInterface[] array) + { + if (!typeof(T).IsAssignableTo(typeof(IComInterface))) + { + throw new ArgumentException($"{typeof(T).Name} must implement {nameof(IComInterface)}<{typeof(TComInterface).Name}>"); + } + + uint length = (uint)array.Length; + ComSafeArrayScope scope = new(length); + for (int i = 0; i < length; i++) + { + scope[i] = ComHelpers.GetComPointer(array[i]); + } + + return scope; + } + /// /// /// The will ref count the COM pointer on get/put. diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/Accessibility/IRawElementProviderSimple.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/Accessibility/IRawElementProviderSimple.cs new file mode 100644 index 00000000000..e17493908de --- /dev/null +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/Accessibility/IRawElementProviderSimple.cs @@ -0,0 +1,8 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Windows.Win32.UI.Accessibility; + +internal partial struct IRawElementProviderSimple : IComInterface +{ +} diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/System/Com/ComSafeArrayScopeTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/System/Com/ComSafeArrayScopeTests.cs index bfe5778ebe8..4322cc7e15c 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/System/Com/ComSafeArrayScopeTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/System/Com/ComSafeArrayScopeTests.cs @@ -1,6 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Runtime.InteropServices; +using Windows.Win32.System.Variant; +using Windows.Win32.UI.Accessibility; + namespace Windows.Win32.System.Com.Tests; public unsafe class ComSafeArrayScopeTests @@ -18,4 +22,52 @@ public void ComSafeArrayScope_Construct_NonCOM_ThrowArgumentException() PInvoke.SafeArrayDestroy(array); } } + + [Fact] + public void ComSafeArrayScope_CreateFromInterfaceArray_DoesNot_ThrowArgumentException() + { + IRawElementProviderSimple.Interface[] providers = [new MyRawElementProviderSimple()]; + Action action = () => + { + using var scope = ComSafeArrayScope.CreateFromInterfaceArray(providers); + }; + + action.Should().NotThrow(); + } + + [Fact] + public void ComSafeArrayScope_CreateFromInterfaceArray_ThrowsArgumentException() + { + IStream.Interface[] streams = [new MyStream()]; + Action action = () => + { + using var scope = ComSafeArrayScope.CreateFromInterfaceArray(streams); + }; + + // Note that this test may fail later on when IStream implements IComInterface. + action.Should().Throw(); + } + + private class MyRawElementProviderSimple : IRawElementProviderSimple.Interface, IManagedWrapper + { + public HRESULT get_ProviderOptions(ProviderOptions* pRetVal) => throw new NotImplementedException(); + public HRESULT GetPatternProvider(UIA_PATTERN_ID patternId, IUnknown** pRetVal) => throw new NotImplementedException(); + public HRESULT GetPropertyValue(UIA_PROPERTY_ID propertyId, VARIANT* pRetVal) => throw new NotImplementedException(); + public HRESULT get_HostRawElementProvider(IRawElementProviderSimple** pRetVal) => throw new NotImplementedException(); + } + + private class MyStream : IStream.Interface, IManagedWrapper + { + public unsafe HRESULT Read(void* pv, uint cb, [Optional] uint* pcbRead) => throw new NotImplementedException(); + public unsafe HRESULT Write(void* pv, uint cb, [Optional] uint* pcbWritten) => throw new NotImplementedException(); + public unsafe HRESULT Seek(long dlibMove, SeekOrigin dwOrigin, [Optional] ulong* plibNewPosition) => throw new NotImplementedException(); + public HRESULT SetSize(ulong libNewSize) => throw new NotImplementedException(); + public unsafe HRESULT CopyTo(IStream* pstm, ulong cb, [Optional] ulong* pcbRead, [Optional] ulong* pcbWritten) => throw new NotImplementedException(); + public HRESULT Commit(uint grfCommitFlags) => throw new NotImplementedException(); + public HRESULT Revert() => throw new NotImplementedException(); + public HRESULT LockRegion(ulong libOffset, ulong cb, uint dwLockType) => throw new NotImplementedException(); + public HRESULT UnlockRegion(ulong libOffset, ulong cb, uint dwLockType) => throw new NotImplementedException(); + public unsafe HRESULT Stat(STATSTG* pstatstg, uint grfStatFlag) => throw new NotImplementedException(); + public unsafe HRESULT Clone(IStream** ppstm) => throw new NotImplementedException(); + } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Accessibility/AccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Accessibility/AccessibleObject.cs index 2049320f837..746fd67541c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Accessibility/AccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Accessibility/AccessibleObject.cs @@ -30,23 +30,23 @@ public unsafe partial class AccessibleObject : IRawElementProviderSimple.Interface, IRawElementProviderFragment.Interface, IRawElementProviderFragmentRoot.Interface, - UiaCore.IInvokeProvider, - UiaCore.IValueProvider, - UiaCore.IRangeValueProvider, - UiaCore.IExpandCollapseProvider, - UiaCore.IToggleProvider, - UiaCore.ITableProvider, - UiaCore.ITableItemProvider, - UiaCore.IGridProvider, - UiaCore.IGridItemProvider, + IInvokeProvider.Interface, + IValueProvider.Interface, + IRangeValueProvider.Interface, + IExpandCollapseProvider.Interface, + IToggleProvider.Interface, + ITableProvider.Interface, + ITableItemProvider.Interface, + IGridProvider.Interface, + IGridItemProvider.Interface, IEnumVARIANT.Interface, IOleWindow.Interface, UiaCore.ILegacyIAccessibleProvider, - UiaCore.ISelectionProvider, - UiaCore.ISelectionItemProvider, + ISelectionProvider.Interface, + ISelectionItemProvider.Interface, IRawElementProviderHwndOverride.Interface, - UiaCore.IScrollItemProvider, - UiaCore.IMultipleViewProvider, + IScrollItemProvider.Interface, + IMultipleViewProvider.Interface, ITextProvider.Interface, ITextProvider2.Interface, // This IAccessible needs moved first once IManagedWrapper is implemented so it gets chosen by built-in COM interop. @@ -874,19 +874,10 @@ HRESULT IRawElementProviderFragment.Interface.GetEmbeddedFragmentRoots(SAFEARRAY } IRawElementProviderSimple.Interface[]? fragmentRoots = GetEmbeddedFragmentRoots(); - if (fragmentRoots is null) - { - *pRetVal = default; - return HRESULT.S_OK; - } - - ComSafeArrayScope scope = new((uint)fragmentRoots.Length); - for (int i = 0; i < fragmentRoots.Length; i++) - { - scope[i] = ComHelpers.GetComPointer(fragmentRoots[i]); - } + *pRetVal = fragmentRoots is null + ? default + : ComSafeArrayScope.CreateFromInterfaceArray(fragmentRoots); - *pRetVal = scope; return HRESULT.S_OK; } @@ -991,13 +982,34 @@ IRawElementProviderSimple.Interface[] UiaCore.ILegacyIAccessibleProvider.GetSele void UiaCore.ILegacyIAccessibleProvider.SetValue(string szValue) => SetValue(szValue); - void UiaCore.IExpandCollapseProvider.Expand() => Expand(); + HRESULT IExpandCollapseProvider.Interface.Expand() + { + Expand(); + return HRESULT.S_OK; + } - void UiaCore.IExpandCollapseProvider.Collapse() => Collapse(); + HRESULT IExpandCollapseProvider.Interface.Collapse() + { + Collapse(); + return HRESULT.S_OK; + } - UIA.ExpandCollapseState UiaCore.IExpandCollapseProvider.ExpandCollapseState => ExpandCollapseState; + HRESULT IExpandCollapseProvider.Interface.get_ExpandCollapseState(ExpandCollapseState* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } - void UiaCore.IInvokeProvider.Invoke() => Invoke(); + *pRetVal = ExpandCollapseState; + return HRESULT.S_OK; + } + + HRESULT IInvokeProvider.Interface.Invoke() + { + Invoke(); + return HRESULT.S_OK; + } ITextRangeProvider* ITextProvider.Interface.DocumentRange => DocumentRangeInternal; @@ -1032,41 +1044,209 @@ HRESULT ITextProvider2.Interface.RangeFromPoint(UiaPoint point, ITextRangeProvid HRESULT ITextProvider2.Interface.RangeFromAnnotation(IRawElementProviderSimple* annotationElement, ITextRangeProvider** pRetVal) => GetRangeFromAnnotation(annotationElement, pRetVal); - BOOL UiaCore.IValueProvider.IsReadOnly => IsReadOnly ? true : false; + HRESULT IValueProvider.Interface.SetValue(PCWSTR val) + { + SetValue(val.ToString()); + return HRESULT.S_OK; + } - string? UiaCore.IValueProvider.Value => Value; + HRESULT IValueProvider.Interface.get_Value(BSTR* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } - void UiaCore.IValueProvider.SetValue(string? newValue) => SetValue(newValue); + *pRetVal = Value is null ? default : new(Value); + return HRESULT.S_OK; + } - void UiaCore.IToggleProvider.Toggle() => Toggle(); + HRESULT IValueProvider.Interface.get_IsReadOnly(BOOL* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } - ToggleState UiaCore.IToggleProvider.ToggleState => ToggleState; + *pRetVal = IsReadOnly; + return HRESULT.S_OK; + } - object[]? UiaCore.ITableProvider.GetRowHeaders() => GetRowHeaders(); + HRESULT IToggleProvider.Interface.Toggle() + { + Toggle(); + return HRESULT.S_OK; + } - object[]? UiaCore.ITableProvider.GetColumnHeaders() => GetColumnHeaders(); + HRESULT IToggleProvider.Interface.get_ToggleState(ToggleState* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } - RowOrColumnMajor UiaCore.ITableProvider.RowOrColumnMajor => RowOrColumnMajor; + *pRetVal = ToggleState; + return HRESULT.S_OK; + } - object[]? UiaCore.ITableItemProvider.GetRowHeaderItems() => GetRowHeaderItems(); + HRESULT ITableProvider.Interface.GetRowHeaders(SAFEARRAY** pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } - object[]? UiaCore.ITableItemProvider.GetColumnHeaderItems() => GetColumnHeaderItems(); + IRawElementProviderSimple.Interface[]? rowHeaders = GetRowHeaders(); + *pRetVal = rowHeaders is null + ? default + : ComSafeArrayScope.CreateFromInterfaceArray(rowHeaders); - object? UiaCore.IGridProvider.GetItem(int row, int column) => GetItem(row, column); + return HRESULT.S_OK; + } - int UiaCore.IGridProvider.RowCount => RowCount; + HRESULT ITableProvider.Interface.GetColumnHeaders(SAFEARRAY** pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } - int UiaCore.IGridProvider.ColumnCount => ColumnCount; + IRawElementProviderSimple.Interface[]? columnHeaders = GetColumnHeaders(); + *pRetVal = columnHeaders is null + ? default + : ComSafeArrayScope.CreateFromInterfaceArray(columnHeaders); - int UiaCore.IGridItemProvider.Row => Row; + return HRESULT.S_OK; + } - int UiaCore.IGridItemProvider.Column => Column; + HRESULT ITableProvider.Interface.get_RowOrColumnMajor(RowOrColumnMajor* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } - int UiaCore.IGridItemProvider.RowSpan => RowSpan; + *pRetVal = RowOrColumnMajor; + return HRESULT.S_OK; + } - int UiaCore.IGridItemProvider.ColumnSpan => ColumnSpan; + HRESULT ITableItemProvider.Interface.GetRowHeaderItems(SAFEARRAY** pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } + + IRawElementProviderSimple.Interface[]? rowHeaderItems = GetRowHeaderItems(); + *pRetVal = rowHeaderItems is null + ? default + : ComSafeArrayScope.CreateFromInterfaceArray(rowHeaderItems); + + return HRESULT.S_OK; + } - IRawElementProviderSimple.Interface? UiaCore.IGridItemProvider.ContainingGrid => ContainingGrid; + HRESULT ITableItemProvider.Interface.GetColumnHeaderItems(SAFEARRAY** pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } + + IRawElementProviderSimple.Interface[]? columnHeaderItems = GetColumnHeaderItems(); + *pRetVal = columnHeaderItems is null + ? default + : ComSafeArrayScope.CreateFromInterfaceArray(columnHeaderItems); + + return HRESULT.S_OK; + } + + HRESULT IGridProvider.Interface.GetItem(int row, int column, IRawElementProviderSimple** pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } + + *pRetVal = ComHelpers.TryGetComPointer(GetItem(row, column)); + return HRESULT.S_OK; + } + + HRESULT IGridProvider.Interface.get_RowCount(int* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } + + *pRetVal = RowCount; + return HRESULT.S_OK; + } + + HRESULT IGridProvider.Interface.get_ColumnCount(int* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } + + *pRetVal = ColumnCount; + return HRESULT.S_OK; + } + + HRESULT IGridItemProvider.Interface.get_Row(int* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } + + *pRetVal = Row; + return HRESULT.S_OK; + } + + HRESULT IGridItemProvider.Interface.get_Column(int* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } + + *pRetVal = Column; + return HRESULT.S_OK; + } + + HRESULT IGridItemProvider.Interface.get_RowSpan(int* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } + + *pRetVal = RowSpan; + return HRESULT.S_OK; + } + + HRESULT IGridItemProvider.Interface.get_ColumnSpan(int* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } + + *pRetVal = ColumnSpan; + return HRESULT.S_OK; + } + + HRESULT IGridItemProvider.Interface.get_ContainingGrid(IRawElementProviderSimple** pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } + + *pRetVal = ComHelpers.TryGetComPointer(ContainingGrid); + return HRESULT.S_OK; + } void IAccessible.accDoDefaultAction(object childID) { @@ -2255,43 +2435,196 @@ HRESULT IRawElementProviderHwndOverride.Interface.GetOverrideProviderForHwnd(HWN return HRESULT.S_OK; } - int UiaCore.IMultipleViewProvider.CurrentView => GetMultiViewProviderCurrentView(); + HRESULT IMultipleViewProvider.Interface.get_CurrentView(int* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } + + *pRetVal = GetMultiViewProviderCurrentView(); + return HRESULT.S_OK; + } + + HRESULT IMultipleViewProvider.Interface.GetSupportedViews(SAFEARRAY** pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } + + int[]? result = GetMultiViewProviderSupportedViews(); + + *pRetVal = result is null ? SAFEARRAY.CreateEmpty(VARENUM.VT_I4) : new SafeArrayScope(result); + + return HRESULT.S_OK; + } + + HRESULT IMultipleViewProvider.Interface.GetViewName(int viewId, BSTR* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } + + *pRetVal = new BSTR(GetMultiViewProviderViewName(viewId)); + return HRESULT.S_OK; + } + + HRESULT IMultipleViewProvider.Interface.SetCurrentView(int viewId) + { + SetMultiViewProviderCurrentView(viewId); + return HRESULT.S_OK; + } + + HRESULT IRangeValueProvider.Interface.SetValue(double val) + { + SetValue(val); + return HRESULT.S_OK; + } + + HRESULT IRangeValueProvider.Interface.get_Value(double* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } + + *pRetVal = RangeValue; + return HRESULT.S_OK; + } + + HRESULT IRangeValueProvider.Interface.get_IsReadOnly(BOOL* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } + + *pRetVal = IsReadOnly; + return HRESULT.S_OK; + } + + HRESULT IRangeValueProvider.Interface.get_Maximum(double* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } + + *pRetVal = Maximum; + return HRESULT.S_OK; + } + + HRESULT IRangeValueProvider.Interface.get_Minimum(double* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } - int[]? UiaCore.IMultipleViewProvider.GetSupportedViews() => GetMultiViewProviderSupportedViews(); + *pRetVal = Minimum; + return HRESULT.S_OK; + } - string? UiaCore.IMultipleViewProvider.GetViewName(int viewId) => GetMultiViewProviderViewName(viewId); + HRESULT IRangeValueProvider.Interface.get_LargeChange(double* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } - void UiaCore.IMultipleViewProvider.SetCurrentView(int viewId) => SetMultiViewProviderCurrentView(viewId); + *pRetVal = LargeChange; + return HRESULT.S_OK; + } - BOOL UiaCore.IRangeValueProvider.IsReadOnly => IsReadOnly ? true : false; + HRESULT IRangeValueProvider.Interface.get_SmallChange(double* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } - double UiaCore.IRangeValueProvider.LargeChange => LargeChange; + *pRetVal = SmallChange; + return HRESULT.S_OK; + } - double UiaCore.IRangeValueProvider.Maximum => Maximum; + HRESULT ISelectionProvider.Interface.GetSelection(SAFEARRAY** pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } - double UiaCore.IRangeValueProvider.Minimum => Minimum; + IRawElementProviderSimple.Interface[]? selection = GetSelection(); + *pRetVal = selection is null + ? default + : ComSafeArrayScope.CreateFromInterfaceArray(selection); - double UiaCore.IRangeValueProvider.SmallChange => SmallChange; + return HRESULT.S_OK; + } - double UiaCore.IRangeValueProvider.Value => RangeValue; + HRESULT ISelectionProvider.Interface.get_CanSelectMultiple(BOOL* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } - void UiaCore.IRangeValueProvider.SetValue(double value) => SetValue(value); + *pRetVal = CanSelectMultiple ? BOOL.TRUE : BOOL.FALSE; + return HRESULT.S_OK; + } - object[]? UiaCore.ISelectionProvider.GetSelection() => GetSelection(); + HRESULT ISelectionProvider.Interface.get_IsSelectionRequired(BOOL* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } + + *pRetVal = IsSelectionRequired ? BOOL.TRUE : BOOL.FALSE; + return HRESULT.S_OK; + } - BOOL UiaCore.ISelectionProvider.CanSelectMultiple => CanSelectMultiple ? true : false; + HRESULT ISelectionItemProvider.Interface.Select() + { + SelectItem(); + return HRESULT.S_OK; + } - BOOL UiaCore.ISelectionProvider.IsSelectionRequired => IsSelectionRequired ? true : false; + HRESULT ISelectionItemProvider.Interface.AddToSelection() + { + AddToSelection(); + return HRESULT.S_OK; + } - void UiaCore.ISelectionItemProvider.Select() => SelectItem(); + HRESULT ISelectionItemProvider.Interface.RemoveFromSelection() + { + RemoveFromSelection(); + return HRESULT.S_OK; + } - void UiaCore.ISelectionItemProvider.AddToSelection() => AddToSelection(); + HRESULT ISelectionItemProvider.Interface.get_IsSelected(BOOL* pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } - void UiaCore.ISelectionItemProvider.RemoveFromSelection() => RemoveFromSelection(); + *pRetVal = IsItemSelected ? BOOL.TRUE : BOOL.FALSE; + return HRESULT.S_OK; + } - BOOL UiaCore.ISelectionItemProvider.IsSelected => IsItemSelected ? true : false; + HRESULT ISelectionItemProvider.Interface.get_SelectionContainer(IRawElementProviderSimple** pRetVal) + { + if (pRetVal is null) + { + return HRESULT.E_POINTER; + } - IRawElementProviderSimple.Interface? UiaCore.ISelectionItemProvider.SelectionContainer => ItemSelectionContainer; + *pRetVal = ComHelpers.TryGetComPointer(ItemSelectionContainer); + return HRESULT.S_OK; + } /// /// Raises the UIA Notification event. @@ -2383,7 +2716,11 @@ internal bool RaiseStructureChangedEvent(StructureChangeType structureChangeType return false; } - void UiaCore.IScrollItemProvider.ScrollIntoView() => ScrollIntoView(); + HRESULT IScrollItemProvider.Interface.ScrollIntoView() + { + ScrollIntoView(); + return HRESULT.S_OK; + } internal virtual void ScrollIntoView() => Debug.Fail($"{nameof(ScrollIntoView)}() is not overriden"); @@ -2427,7 +2764,7 @@ HRESULT IDispatch.Interface.GetTypeInfo(uint iTInfo, uint lcid, ITypeInfo** ppTI => ((IDispatch.Interface)_dispatchAdapter).GetTypeInfo(iTInfo, lcid, ppTInfo); HRESULT IDispatch.Interface.GetIDsOfNames(Guid* riid, PWSTR* rgszNames, uint cNames, uint lcid, int* rgDispId) - => ((IDispatch.Interface) _dispatchAdapter).GetIDsOfNames(riid, rgszNames, cNames, lcid, rgDispId); + => ((IDispatch.Interface)_dispatchAdapter).GetIDsOfNames(riid, rgszNames, cNames, lcid, rgDispId); HRESULT IDispatch.Interface.Invoke( int dispIdMember, diff --git a/src/System.Windows.Forms/tests/InteropTests/NativeTests/AccessibleObjectTests.cpp b/src/System.Windows.Forms/tests/InteropTests/NativeTests/AccessibleObjectTests.cpp index a414af53b9f..e7880fb3797 100644 --- a/src/System.Windows.Forms/tests/InteropTests/NativeTests/AccessibleObjectTests.cpp +++ b/src/System.Windows.Forms/tests/InteropTests/NativeTests/AccessibleObjectTests.cpp @@ -487,7 +487,7 @@ TEST const WCHAR* WINAPI Test_IValueProviderGetIsReadOnly(IUnknown* pUnknown, BO // Negative tests. hr = pRangeValueProvider->get_IsReadOnly(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -511,7 +511,7 @@ TEST const WCHAR* WINAPI Test_IValueProviderGetValue(IUnknown* pUnknown, LPCWSTR // Negative tests. hr = pRangeValueProvider->get_Value(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -560,7 +560,7 @@ TEST const WCHAR* WINAPI Test_IRangeValueProviderGetIsReadOnly(IUnknown* pUnknow // Negative tests. hr = pRangeValueProvider->get_IsReadOnly(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -583,7 +583,7 @@ TEST const WCHAR* WINAPI Test_IRangeValueProviderGetLargeChange(IUnknown* pUnkno // Negative tests. hr = pRangeValueProvider->get_LargeChange(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -606,7 +606,7 @@ TEST const WCHAR* WINAPI Test_IRangeValueProviderGetMaximum(IUnknown* pUnknown, // Negative tests. hr = pRangeValueProvider->get_Maximum(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -629,7 +629,7 @@ TEST const WCHAR* WINAPI Test_IRangeValueProviderGetMinimum(IUnknown* pUnknown, // Negative tests. hr = pRangeValueProvider->get_Minimum(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -652,7 +652,7 @@ TEST const WCHAR* WINAPI Test_IRangeValueProviderGetSmallChange(IUnknown* pUnkno // Negative tests. hr = pRangeValueProvider->get_SmallChange(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -675,7 +675,7 @@ TEST const WCHAR* WINAPI Test_IRangeValueProviderGetValue(IUnknown* pUnknown, do // Negative tests. hr = pRangeValueProvider->get_Value(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -720,7 +720,7 @@ TEST const WCHAR* WINAPI Test_IExpandCollapseProviderGetExpandCollapseState(IUnk // Negative tests. hr = pExpandCollapseProvider->get_ExpandCollapseState(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -803,7 +803,7 @@ TEST const WCHAR* WINAPI Test_IToggleProviderGetToggleState(IUnknown* pUnknown, // Negative tests. hr = pToggleProvider->get_ToggleState(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -856,7 +856,7 @@ TEST const WCHAR* WINAPI Test_ITableProviderGetRowOrColumnMajor(IUnknown* pUnkno // Negative tests. hr = pTableProvider->get_RowOrColumnMajor(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -872,15 +872,14 @@ TEST const WCHAR* WINAPI Test_ITableProviderGetColumnHeaders(IUnknown* pUnknown) hr = pUnknown->QueryInterface(IID_ITableProvider, (void**)&pTableProvider); assertEqualHr(S_OK, hr); - SAFEARRAY *result = (SAFEARRAY*)(long)0xdeadbeef; + SAFEARRAY *result; hr = pTableProvider->GetColumnHeaders(&result); assertEqualHr(S_OK, hr); assertNull(result); - SafeArrayDestroy(result); // Negative tests. hr = pTableProvider->GetColumnHeaders(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -896,15 +895,14 @@ TEST const WCHAR* WINAPI Test_ITableProviderGetRowHeaders(IUnknown* pUnknown) hr = pUnknown->QueryInterface(IID_ITableProvider, (void**)&pTableProvider); assertEqualHr(S_OK, hr); - SAFEARRAY *result = (SAFEARRAY*)(long)0xdeadbeef; + SAFEARRAY *result; hr = pTableProvider->GetRowHeaders(&result); assertEqualHr(S_OK, hr); assertNull(result); - SafeArrayDestroy(result); // Negative tests. hr = pTableProvider->GetRowHeaders(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -920,15 +918,14 @@ TEST const WCHAR* WINAPI Test_ITableItemProviderGetColumnHeaderItems(IUnknown* p hr = pUnknown->QueryInterface(IID_ITableItemProvider, (void**)&pTableItemProvider); assertEqualHr(S_OK, hr); - SAFEARRAY *result = (SAFEARRAY*)(long)0xdeadbeef; + SAFEARRAY *result; hr = pTableItemProvider->GetColumnHeaderItems(&result); assertEqualHr(S_OK, hr); assertNull(result); - SafeArrayDestroy(result); // Negative tests. hr = pTableItemProvider->GetColumnHeaderItems(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -944,15 +941,14 @@ TEST const WCHAR* WINAPI Test_ITableItemProviderGetRowHeaderItems(IUnknown* pUnk hr = pUnknown->QueryInterface(IID_ITableItemProvider, (void**)&pTableItemProvider); assertEqualHr(S_OK, hr); - SAFEARRAY *result = (SAFEARRAY*)(long)0xdeadbeef; + SAFEARRAY *result; hr = pTableItemProvider->GetRowHeaderItems(&result); assertEqualHr(S_OK, hr); assertNull(result); - SafeArrayDestroy(result); // Negative tests. hr = pTableItemProvider->GetRowHeaderItems(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -975,7 +971,7 @@ TEST const WCHAR* WINAPI Test_IGridProviderGetColumnCount(IUnknown* pUnknown, in // Negative tests. hr = pGridProvider->get_ColumnCount(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -998,7 +994,7 @@ TEST const WCHAR* WINAPI Test_IGridProviderGetRowCount(IUnknown* pUnknown, int e // Negative tests. hr = pGridProvider->get_RowCount(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -1021,7 +1017,7 @@ TEST const WCHAR* WINAPI Test_IGridProviderGetItem(IUnknown* pUnknown, int row, // Negative tests. hr = pIGridProvider->GetItem(row, column, NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -1044,7 +1040,7 @@ TEST const WCHAR* WINAPI Test_IGridItemProviderGetContainingGrid(IUnknown* pUnkn // Negative tests. hr = pGridItemProvider->get_ContainingGrid(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -1067,7 +1063,7 @@ TEST const WCHAR* WINAPI Test_IGridItemProviderGetColumn(IUnknown* pUnknown, int // Negative tests. hr = pGridItemProvider->get_Column(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -1090,7 +1086,7 @@ TEST const WCHAR* WINAPI Test_IGridItemProviderGetColumnSpan(IUnknown* pUnknown, // Negative tests. hr = pGridItemProvider->get_ColumnSpan(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -1113,7 +1109,7 @@ TEST const WCHAR* WINAPI Test_IGridItemProviderGetRow(IUnknown* pUnknown, int ex // Negative tests. hr = pGridItemProvider->get_Row(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -1136,7 +1132,7 @@ TEST const WCHAR* WINAPI Test_IGridItemProviderGetRowSpan(IUnknown* pUnknown, in // Negative tests. hr = pGridItemProvider->get_RowSpan(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -1690,7 +1686,7 @@ TEST const WCHAR* WINAPI Test_ISelectionProviderGetSelection(IUnknown* pUnknown, // Negative tests hr = pSelectionProvider->GetSelection(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -1713,7 +1709,7 @@ TEST const WCHAR* WINAPI Test_ISelectionProviderGetCanSelectMultiple(IUnknown* p // Negative tests. hr = pRangeSelectionProvider->get_CanSelectMultiple(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); @@ -1736,7 +1732,7 @@ TEST const WCHAR* WINAPI Test_ISelectionProviderGetIsSelectionRequired(IUnknown* // Negative tests. hr = pRangeSelectionProvider->get_IsSelectionRequired(NULL); - assertEqualHr(S_OK, hr); + assertEqualHr(E_POINTER, hr); return S_OK; }); diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListBoxAccessibleObjectTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListBoxAccessibleObjectTests.cs index f75beff3c60..8610af75924 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListBoxAccessibleObjectTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListBoxAccessibleObjectTests.cs @@ -160,7 +160,7 @@ public void ListBoxItemAccessibleObject_GetPropertyValue_HasKeyboardFocusPropert [InlineData(SelectionMode.None, false)] [InlineData(SelectionMode.MultiSimple, true)] [InlineData(SelectionMode.MultiExtended, true)] - public void ListBoxItemAccessibleObject_GetPropertyValue_IsSelectionRequired(SelectionMode mode, bool expected) + public unsafe void ListBoxItemAccessibleObject_GetPropertyValue_IsSelectionRequired(SelectionMode mode, bool expected) { using ListBox listBox = InitializeListBoxWithItems(); listBox.SelectionMode = mode; @@ -171,8 +171,9 @@ public void ListBoxItemAccessibleObject_GetPropertyValue_IsSelectionRequired(Sel Assert.Equal(expected, (bool)actual); - Interop.UiaCore.ISelectionProvider provider = listBoxAccessibleObject; - Assert.Equal(expected, (bool)provider.IsSelectionRequired); + ISelectionProvider.Interface provider = listBoxAccessibleObject; + Assert.True(provider.get_IsSelectionRequired(out BOOL result).Succeeded); + Assert.Equal(expected, (bool)result); } [WinFormsTheory] @@ -180,7 +181,7 @@ public void ListBoxItemAccessibleObject_GetPropertyValue_IsSelectionRequired(Sel [InlineData(SelectionMode.None, false)] [InlineData(SelectionMode.MultiSimple, true)] [InlineData(SelectionMode.MultiExtended, true)] - public void ListBoxItemAccessibleObject_GetPropertyValue_CanSelectMultiple(SelectionMode mode, bool expected) + public unsafe void ListBoxItemAccessibleObject_GetPropertyValue_CanSelectMultiple(SelectionMode mode, bool expected) { using ListBox listBox = InitializeListBoxWithItems(); listBox.SelectionMode = mode; @@ -191,8 +192,9 @@ public void ListBoxItemAccessibleObject_GetPropertyValue_CanSelectMultiple(Selec Assert.Equal(expected, (bool)actual); - Interop.UiaCore.ISelectionProvider provider = listBoxAccessibleObject; - Assert.Equal(expected, (bool)provider.CanSelectMultiple); + ISelectionProvider.Interface provider = listBoxAccessibleObject; + Assert.True(provider.get_CanSelectMultiple(out BOOL result).Succeeded); + Assert.Equal(expected, (bool)result); } [WinFormsFact] @@ -205,7 +207,7 @@ public void ListBoxItemAccessibleObject_RemoveFromSelection() listBox.SetSelected(2, value: true); var listBoxAccessibleObject = listBox.AccessibilityObject; - Interop.UiaCore.ISelectionItemProvider provider = listBoxAccessibleObject.GetChild(0); + ISelectionItemProvider.Interface provider = listBoxAccessibleObject.GetChild(0); provider.RemoveFromSelection(); var indices = listBox.SelectedIndices; diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListVIew.ListViewAccessibleObjectTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListVIew.ListViewAccessibleObjectTests.cs index e746fe95eeb..8e3a67c5aca 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListVIew.ListViewAccessibleObjectTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AccessibleObjects/ListVIew.ListViewAccessibleObjectTests.cs @@ -1769,8 +1769,9 @@ public void ListViewItemAccessibleObject_GetPropertyValue_CanSelectMultiple() var actual = listViewAccessibleObject.GetPropertyValue(UIA_PROPERTY_ID.UIA_SelectionCanSelectMultiplePropertyId); Assert.True((bool)actual); - Interop.UiaCore.ISelectionProvider provider = listViewAccessibleObject; - Assert.True((bool)provider.CanSelectMultiple); + ISelectionProvider.Interface provider = listViewAccessibleObject; + Assert.True(provider.get_CanSelectMultiple(out BOOL result).Succeeded); + Assert.True(result); } }