Update CsWin32 to 0.3.287 and remove .NET Framework IComIID workarounds#14639
Update CsWin32 to 0.3.287 and remove .NET Framework IComIID workarounds#14639JeremyKuhne wants to merge 2 commits into
Conversation
CsWin32 0.3.287 now emits the IComIID interface for net472/netstandard2.0 (microsoft/CsWin32#1704), so the manual definitions and per-struct implementations we maintained for .NET Framework are no longer needed. - Bump MicrosoftWindowsCsWin32PackageVersion 0.3.151 -> 0.3.287 - Delete the manual IComIID interface and the 12 COM struct partials under System.Private.Windows.Core/src/Framework that appended : IComIID Adapt to generated-signature changes from the version bump: - Optional out-pointer params are now 'out' (WideCharToMultiByte, SHParseDisplayName, get_accHelpTopic, DrawThemeEdge, GetThemeBackgroundRegion) - DocumentProperties now takes PRINTER_HANDLE - Buffer methods lost string-friendly overloads; pin strings for PCWSTR - Re-request DFC_TYPE/DFCS_STATE in NativeMethods.txt (DrawFrameControl now takes uint) so public ButtonState/ScrollButton enum values are preserved - Suppress new CLS warnings on generated COM structs (CS3021/CS3019) - Update XML doc crefs to match new signatures
| { | ||
| // Get Win32 dc with Graphics properties applied to it. | ||
| PInvoke.DrawFrameControl(hdc, ref rcFrame, kind, state); | ||
| PInvoke.DrawFrameControl(hdc, ref rcFrame, (uint)kind, (uint)state); |
There was a problem hiding this comment.
FYI if DrawFrameControl only takes DFC_TYPE / DFC_STATE for these parameters, that type improvement (uint => DFC_TYPE) can be done in win32metadata. Feel free to file an issue on win32metadata to recommend that.
| <NoWarn>$(NoWarn);CS8981;CS3016</NoWarn> | ||
| <!-- | ||
| We don't care about CLS compliance since everything here is internal and we want to match native types. | ||
| CS3019: CsWin32-generated COM structs carry [CLSCompliant] attributes on internal (non-visible) types. |
There was a problem hiding this comment.
Wait, did that CLSCompliant change now cause us to trigger a CS3019 on callers? Or is this only going to happen when you make the projection public ?
There was a problem hiding this comment.
This happens when internal, not public. I could suppress this error as well in the generated code if you like.
There was a problem hiding this comment.
Yes, please do that. I approved it because I assumed the attribute wouldn't matter to folks who don't care about CLSCompliant. I don't want noise for people. None of my code cares about CLS.
There was a problem hiding this comment.
I'll create a PR that hits all of the corners of this.
Shyam-Gupta
left a comment
There was a problem hiding this comment.
Looks good. Thanks Jeremy.
KlausLoeffelmann
left a comment
There was a problem hiding this comment.
I would like to know more first about the motivation behind this, and why we need to do this now.
|
This is not a good point in time to take this PR, as I am really busy to introduce a series of APIs for .NET 11. @JeremyKuhne, next time you plan a change like that, I'd like you to check with me first. Can this PR wait until after we merged for .NET 11? Is this a PR that is immediately needed for an initiative I would not know about which this cannot wait? Let me see, if I can find the time, to quickly rebase to PRs I got on this and see, if they are in any way affected by this. @merriemcgaw , @mcastro-x FYI. |
…overloads - WideCharToMultiByte/SHParseDisplayName: omit the optional out param instead of passing 'out _' so the call truly passes null (out _ is not equivalent to null). - GetShortPathName (Help.cs): use the friendly Span<char> overload, removing manual pinning. RegLoadMUIString is intentionally left on the raw overload: its friendly Span overload passes the char count as cbOutBuf, which the API documents as a byte count, so it would misreport the buffer size.
|
@KlausLoeffelmann you do not need to review if you're too busy, @Shyam-Gupta has signed up for this. This is a low impact change that applies follow up changes upstream to changes in this and other repos. |
Summary
Updates
Microsoft.Windows.CsWin32from0.3.151to0.3.287and removes the manualIComIIDworkarounds we maintained for .NET Framework.CsWin32 0.3.287 now emits the
IComIIDinterface fornet472/netstandard2.0(see microsoft/CsWin32#1704). Previously it only generatedIComIIDfor modern .NET, which is why we hand-authored the interface and appended: IComIIDto each COM struct under theFrameworkfolder. Those workarounds are now redundant.Changes
Core request
MicrosoftWindowsCsWin32PackageVersion0.3.151→0.3.287.IComIIDinterface definition and the 12 COM struct partials underSystem.Private.Windows.Core/src/Framework/Windows/Win32/that implemented it. The sharedIID.csalready handles the static-vs-instance difference via#if NET, so it needs no change.Fallout from the version bump (required to keep the solution building)
out(WideCharToMultiByte,SHParseDisplayName,get_accHelpTopic,DrawThemeEdge,GetThemeBackgroundRegion).DocumentPropertiesnow takesPRINTER_HANDLEinstead ofHANDLE.string-friendly overloads; pin strings and passPCWSTR(GetThemeDocumentationProperty,RegLoadMUIString,GetShortPathName,GetLocaleInfoEx).DrawFrameControldropped itsDFC_TYPE/DFCS_STATEenums (nowuint). Re-requested both enums inNativeMethods.txtso the publicButtonState/ScrollButtonenum values are preserved, and added(uint)casts at call sites.CS3021in the Core projects,CS3019in Primitives), grouped with the existingCS3016suppression.crefs that referenced changed signatures.Validation
Clean rebuild of the full solution (
dotnet build Winforms.sln -t:Rebuild -p:TreatWarningsAsErrors=true) succeeds with 0 errors and 0 warnings across all src, facade, analyzer, source-generator, and test projects.Microsoft Reviewers: Open in CodeFlow