|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System; |
|
|
|
using System.Diagnostics.CodeAnalysis; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
|
|
|
|
namespace Avalonia.Win32.Interop.Automation |
|
|
|
@ -21,11 +22,15 @@ namespace Avalonia.Win32.Interop.Automation |
|
|
|
internal const int UIA_E_NOCLICKABLEPOINT = unchecked((int)0x80040202); |
|
|
|
internal const int UIA_E_PROXYASSEMBLYNOTLOADED = unchecked((int)0x80040203); |
|
|
|
|
|
|
|
private static bool? s_isNetComInteropAvailable; |
|
|
|
internal static bool IsNetComInteropAvailable => s_isNetComInteropAvailable ??= GetIsNetComInteropAvailable(); |
|
|
|
|
|
|
|
internal static int UiaLookupId(AutomationIdType type, ref Guid guid) |
|
|
|
{ |
|
|
|
return RawUiaLookupId( type, ref guid ); |
|
|
|
} |
|
|
|
|
|
|
|
[RequiresUnreferencedCode("Requires .NET COM interop")] |
|
|
|
internal static object UiaGetReservedNotSupportedValue() |
|
|
|
{ |
|
|
|
object notSupportedValue; |
|
|
|
@ -33,6 +38,7 @@ namespace Avalonia.Win32.Interop.Automation |
|
|
|
return notSupportedValue; |
|
|
|
} |
|
|
|
|
|
|
|
[RequiresUnreferencedCode("Requires .NET COM interop")] |
|
|
|
internal static object UiaGetReservedMixedAttributeValue() |
|
|
|
{ |
|
|
|
object mixedAttributeValue; |
|
|
|
@ -49,6 +55,19 @@ namespace Avalonia.Win32.Interop.Automation |
|
|
|
|
|
|
|
Marshal.ThrowExceptionForHR(hr, (IntPtr)(-1)); |
|
|
|
} |
|
|
|
|
|
|
|
private static bool GetIsNetComInteropAvailable() |
|
|
|
{ |
|
|
|
#if NET6_0_OR_GREATER
|
|
|
|
if (!System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
#endif
|
|
|
|
|
|
|
|
var comConfig = AppContext.GetData("System.Runtime.InteropServices.BuiltInComInterop.IsSupported"); |
|
|
|
return comConfig == null || bool.Parse(comConfig.ToString()); |
|
|
|
} |
|
|
|
|
|
|
|
[DllImport("UIAutomationCore.dll", EntryPoint = "UiaLookupId", CharSet = CharSet.Unicode)] |
|
|
|
private static extern int RawUiaLookupId(AutomationIdType type, ref Guid guid); |
|
|
|
|