-
Notifications
You must be signed in to change notification settings - Fork 971
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert IFont and IFontDisp to CSWin32 (#8322)
Converts IFont / IFontDisp to CSWin32. IFontDisp wasn't properly defined (wrong DISPIDs). I attemped to run my VB tests against the correct code to see if that fixed the test run problem, but alas, it did not. Including the VB tests (Skipped) to allow manual testing and allow investigating and vetting against further fixes that come as part of the modernization effort here. This adds some tests for the other IFont usages. Additionally: - Adds the interface definition for IDispatch (which CsWin32 omits) and a CCW - Adds DynamicAxHost for testing AxHost with controls direct from assemblies - Adds ComClasses/ComClassFactory for creating COM classes direct from assemblies - Adds explicit converters to VARIANT and CY (currency format) - Adds ToStringAndFree to BSTR - Adds another overload for prop getting from IDispatch - Moves code from ControlPaint to it's only usage in COM2FontConverter
- Loading branch information
1 parent
2a329f0
commit 6277e50
Showing
31 changed files
with
772 additions
and
333 deletions.
There are no files selected for viewing
56 changes: 0 additions & 56 deletions
56
src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.IFont.cs
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.IFontDisp.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.FONTDESC.cs
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.OleCreateFontIndirect.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/CY.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// 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 Windows.Win32.System.Com; | ||
|
||
internal partial struct CY | ||
{ | ||
// https://learn.microsoft.com/openspecs/windows_protocols/ms-oaut/5a2b34c4-d109-438e-9ec8-84816d8de40d | ||
|
||
public static explicit operator decimal(CY value) => decimal.FromOACurrency(value.int64); | ||
public static explicit operator CY(decimal value) => new() { int64 = decimal.ToOACurrency(value) }; | ||
|
||
public static explicit operator float(CY value) => (float)(value.int64 / 10000f); | ||
public static explicit operator CY(float value) => new() { int64 = (long)(value * 10000) }; | ||
} |
82 changes: 82 additions & 0 deletions
82
src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IDispatch.Interface.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// 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. | ||
|
||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using ComWrappers = Interop.WinFormsComWrappers; | ||
|
||
namespace Windows.Win32.System.Com; | ||
|
||
internal unsafe partial struct IDispatch : IVTable<IDispatch, IDispatch.Vtbl> | ||
{ | ||
static void IVTable<IDispatch, Vtbl>.PopulateComInterfaceVTable(Vtbl* vtable) | ||
{ | ||
vtable->GetTypeInfoCount_4 = &GetTypeInfoCount; | ||
vtable->GetTypeInfo_5 = &GetTypeInfo; | ||
vtable->GetIDsOfNames_6 = &GetIDsOfNames; | ||
vtable->Invoke_7 = &Invoke; | ||
} | ||
|
||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] | ||
private static HRESULT GetTypeInfoCount(IDispatch* @this, uint* pctinfo) | ||
=> ComWrappers.UnwrapAndInvoke<IDispatch, Interface>(@this, o => o.GetTypeInfoCount(pctinfo)); | ||
|
||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] | ||
private static HRESULT GetTypeInfo(IDispatch* @this, uint iTInfo, uint lcid, ITypeInfo** ppTInfo) | ||
=> ComWrappers.UnwrapAndInvoke<IDispatch, Interface>(@this, o => o.GetTypeInfo(iTInfo, lcid, ppTInfo)); | ||
|
||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] | ||
private static HRESULT GetIDsOfNames(IDispatch* @this, Guid* riid, PWSTR* rgszNames, uint cNames, uint lcid, int* rgDispId) | ||
=> ComWrappers.UnwrapAndInvoke<IDispatch, Interface>(@this, o => o.GetIDsOfNames(riid, rgszNames, cNames, lcid, rgDispId)); | ||
|
||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] | ||
private static HRESULT Invoke( | ||
IDispatch* @this, | ||
int dispIdMember, | ||
Guid* riid, | ||
uint lcid, | ||
DISPATCH_FLAGS dwFlags, | ||
DISPPARAMS* pDispParams, | ||
VARIANT* pVarResult, | ||
EXCEPINFO* pExcepInfo, | ||
uint* pArgErr) | ||
=> ComWrappers.UnwrapAndInvoke<IDispatch, Interface>( | ||
@this, | ||
o => o.Invoke(dispIdMember, riid, lcid, dwFlags, pDispParams, pVarResult, pExcepInfo, pArgErr)); | ||
|
||
[ComImport] | ||
[Guid("00020400-0000-0000-C000-000000000046")] | ||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | ||
public unsafe interface Interface | ||
{ | ||
[PreserveSig] | ||
HRESULT GetTypeInfoCount( | ||
uint* pctinfo); | ||
|
||
[PreserveSig] | ||
HRESULT GetTypeInfo( | ||
uint iTInfo, | ||
uint lcid, | ||
ITypeInfo** ppTInfo); | ||
|
||
[PreserveSig] | ||
HRESULT GetIDsOfNames( | ||
Guid* riid, | ||
PWSTR* rgszNames, | ||
uint cNames, | ||
uint lcid, | ||
int* rgDispId); | ||
|
||
[PreserveSig] | ||
HRESULT Invoke( | ||
int dispIdMember, | ||
Guid* riid, | ||
uint lcid, | ||
DISPATCH_FLAGS dwFlags, | ||
DISPPARAMS* pDispParams, | ||
VARIANT* pVarResult, | ||
EXCEPINFO* pExcepInfo, | ||
uint* pArgErr); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.