From f07e04185c4f3d986158f59cd441870957172306 Mon Sep 17 00:00:00 2001 From: h3xds1nz Date: Tue, 8 Oct 2024 07:02:22 +0200 Subject: [PATCH] Remove MarshalLocal proxy for IsTypeVisibleFromCom (#9609) --- .../src/PresentationFramework/MarshalLocal.cs | 14 -------------- .../PresentationFramework.csproj | 1 - .../System/Windows/Controls/WebBrowser.cs | 2 +- .../System/Windows/Interop/DynamicScriptObject.cs | 7 +++---- 4 files changed, 4 insertions(+), 20 deletions(-) delete mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/MarshalLocal.cs diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MarshalLocal.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MarshalLocal.cs deleted file mode 100644 index 14ba67f4806..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MarshalLocal.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Runtime.InteropServices -{ - internal static class MarshalLocal - { - public static bool IsTypeVisibleFromCom(Type type) - { - return Marshal.IsTypeVisibleFromCom(type); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj index 50cee26ed8e..28168bbd37b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj @@ -62,7 +62,6 @@ - diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/WebBrowser.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/WebBrowser.cs index 9f9fe44c19b..f15a9689765 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/WebBrowser.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/WebBrowser.cs @@ -436,7 +436,7 @@ public object ObjectForScripting { Type t = value.GetType(); - if (!System.Runtime.InteropServices.MarshalLocal.IsTypeVisibleFromCom(t)) + if (!Marshal.IsTypeVisibleFromCom(t)) { throw new ArgumentException(SR.NeedToBeComVisible); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/DynamicScriptObject.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/DynamicScriptObject.cs index cd240311650..e97f853a82b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/DynamicScriptObject.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/DynamicScriptObject.cs @@ -285,8 +285,7 @@ internal unsafe bool TryFindMemberAndInvokeNonWrapped(string memberName, int fla // model, we rather throw instead. This Try-method allows internal lookups without directly // throwing on non-fatal "member not found" situations, as we might want to have more complex // fallback logic (as in ToString). - int dispid; - if (!TryGetDispIdForMember(memberName, cacheDispId, out dispid)) + if (!TryGetDispIdForMember(memberName, cacheDispId, out int dispId)) { return false; } @@ -358,7 +357,7 @@ internal unsafe bool TryFindMemberAndInvokeNonWrapped(string memberName, int fla // by the CLR. Therefore we also check for the IsCOMObject property. It also seems // COM interop special-cases DateTime as it's not revealed to be visible by any // of the first two checks below. - if (!MarshalLocal.IsTypeVisibleFromCom(argType) && + if (!Marshal.IsTypeVisibleFromCom(argType) && !argType.IsCOMObject && argType != typeof(DateTime)) { throw new ArgumentException(SR.NeedToBeComVisible); @@ -371,7 +370,7 @@ internal unsafe bool TryFindMemberAndInvokeNonWrapped(string memberName, int fla } NativeMethods.EXCEPINFO exInfo = new NativeMethods.EXCEPINFO(); - HRESULT hr = InvokeOnScriptObject(dispid, flags, dp, exInfo, out result); + HRESULT hr = InvokeOnScriptObject(dispId, flags, dp, exInfo, out result); if (hr.Failed) {