Skip to content

Upgrade winmd generation to ClangSharp 21 - #2287

Draft
Jevan Saks (jevansaks) wants to merge 5 commits into
mainfrom
user/jevansa/clangsharp-21.1.8.4
Draft

Upgrade winmd generation to ClangSharp 21#2287
Jevan Saks (jevansaks) wants to merge 5 commits into
mainfrom
user/jevansa/clangsharp-21.1.8.4

Conversation

@jevansaks

@jevansaks Jevan Saks (jevansaks) commented Aug 14, 2026

Copy link
Copy Markdown
Member

Summary

  • upgrade the embedded scraper to ClangSharp 21.1.8.4 and baseline the entire WinmdGenerator SDK and repository toolchain on .NET 10
  • support VS 2026/MSVC 14.51 headers and normalize ClangSharp 21 output without changing existing callback signatures, inheritance, anonymous-record identities, or metadata names
  • restore ClangSharp response-file compatibility broken by the hosted-generator migration, including OSClient's -std c++20, short aliases, multiline values, and inline --option=value forms
  • package one explicit tools/net10.0 toolset plus the net10 Windows scraper/LLVM runtime; consumers no longer need both .NET 8 and .NET 10

Parser and compatibility decisions

  • language and standard options now reach both libclang and PInvokeGeneratorConfiguration; C++17 remains the default only when the consumer does not select a standard
  • unsupported long response-file options fail explicitly instead of being silently discarded
  • Media.DShow and Mf select C++20 locally because Clang 21 rejects a DXVA signed-shift integral constant expression under C++17; dxva.h and dxva9typ.h remain exactly as supplied by the SDK
  • secondary COM bases represented by ClangSharp 21 as base-subobject fields participate in native-inheritance matching, preserving the existing projected hierarchy
  • compatibility controls preserve cross-partition function-pointer levels, the correct LIBID_SystemMonitor, existing anonymous-record names, and an acyclic UMS projection

WinMD comparison

A controlled Clang 17 and Clang 21 generation used the same source tree and VS 2026/MSVC headers. Both outputs contain 35,145 types. The only semantic changes are 19 LIBID_* constants recovered by ClangSharp 21; the apparent removal/addition of LIBID_SystemMonitor in the textual diff is ordering-only and retains its correct value.

The final single-.NET-10 build has a byte-for-byte identical 35,145-type declaration dump to the previously validated Clang 21 candidate. Candidate WinMD SHA-256: 32328C5DBBC450C03A4DEBF31D493895AE86D6E6B80E1048BF93E5CE0FD8F6C0.

.NET and packaging

ClangSharp 21 targets .NET 10, so WinmdGenerator now requires .NET 10 consistently rather than splitting its scraper and supporting tools across two runtimes. global.json selects SDK 10.0.303, all generator tools/tasks/tests target net10.0, SDK paths resolve under tools/net10.0, and CI installs only the SDK selected by global.json.

The generated package has 69 entries: zero net8.0 entries, 38 explicit net10.0 tool/runtime entries, and zero test artifacts.

Validation

  • clean DoAll.ps1 -Clean -ExcludePackages -ExcludeSamples
  • MetadataUtils.Tests: 17 passed
  • Win32MetadataScraperTests: 50 passed
  • Windows.Win32.Tests: 13 passed
  • packaged WinmdGenerator generated the DiaSdk sample successfully using only the .NET 10 tool layout
  • final WinMD declaration dump is byte-for-byte identical to the validated Clang 21 candidate

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 19e5498a-dfe7-4601-8955-98f33a92582b
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 19e5498a-dfe7-4601-8955-98f33a92582b
Restore SDK-derived DXVA headers and select C++20 only for affected partitions. Install both required SDK generations in CI and explicitly package only runtime tool dependencies.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 19e5498a-dfe7-4601-8955-98f33a92582b
Use SDK 8.0.424 so SDK 10.0.303 can resolve its required .NET 8.0.30 framework and app-host packs without accessing public NuGet feeds.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 19e5498a-dfe7-4601-8955-98f33a92582b
@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown

📋 API Surface Diff

+46 additions / -2 deletions vs main branch (full build log)

Click to expand API diff
diff --git "a/bin\\baseline.apidump.cs" "b/bin\\current.apidump.cs"
index 2c227b36..0c18a07c 100644
--- "a/bin\\baseline.apidump.cs"
+++ "b/bin\\current.apidump.cs"
@@ -51559,6 +51559,9 @@ public static class Apis
 	public const HRESULT E_FDPAIRING_IPBUSDISABLED = -1882193913;
 
 	public const HRESULT E_FDPAIRING_NOPROFILES = -1882193912;
+
+	[Windows.Win32.Foundation.Metadata.Guid (3471363273u, 20331, 17513, 162, 53, 90, 34, 134, 158, 239, 3)]
+	public static Guid LIBID_PNPXAssociation;
 }
 
 using Windows.Win32.Foundation.Metadata;
@@ -69138,6 +69141,9 @@ public static class Apis
 	public const uint WIA_WSD_SCAN_AVAILABLE_ITEM = 38922u;
 
 	public const string WIA_WSD_SCAN_AVAILABLE_ITEM_STR = "Scan Available Item";
+
+	[Windows.Win32.Foundation.Metadata.Guid (2717181734u, 36081, 4561, 191, 146, 0, 96, 8, 30, 216, 17)]
+	public static Guid LIBID_WiaDevMgr;
 }
 
 using Windows.Win32.Foundation;
@@ -264586,6 +264592,9 @@ public static class Apis
 	public const int STREAMBUFFER_EC_RATE_CHANGING_FOR_SETPOSITIONS = 815;
 
 	public const int STREAMBUFFER_EC_SETPOSITIONS_EVENTS_DONE = 816;
+
+	[Windows.Win32.Foundation.Metadata.Guid (3685706779u, 46756, 18584, 174, 101, 32, 79, 13, 149, 9, 161)]
+	public static Guid LIBID_Mpeg2DataLib;
 }
 
 using Windows.Win32.Foundation.Metadata;
@@ -331050,6 +331059,9 @@ public static class Apis
 
 	[Windows.Win32.Foundation.Metadata.Guid (75774394u, 12444, 17422, 156, 180, 61, 204, 163, 117, 100, 35)]
 	public static Guid WMProfile_V80_BESTVBRVideo;
+
+	[Windows.Win32.Foundation.Metadata.Guid (1811229264u, 14666, 4563, 177, 83, 0, 192, 79, 121, 250, 166)]
+	public static Guid LIBID_WMPLib;
 }
 
 namespace Windows.Win32.Media.MediaPlayer;
@@ -444209,7 +444221,9 @@ public struct WinNTSystemInfo
 // Namespace: Windows.Win32.Networking.BackgroundIntelligentTransferService
 // ═══════════════════════════════════════════════════════════════
 
+using System;
 using System.Runtime.InteropServices;
+using Windows.Win32.Foundation.Metadata;
 
 namespace Windows.Win32.Networking.BackgroundIntelligentTransferService;
 
@@ -444633,6 +444647,39 @@ public static class Apis
 	public const int BITS_MC_PEERCACHING_PORT = -2145828854;
 
 	public const int BITS_MC_WSD_PORT = -2145828853;
+
+	[Windows.Win32.Foundation.Metadata.Guid (1234293579u, 32929, 17041, 131, 182, 51, 40, 54, 107, 144, 151)]
+	public static Guid LIBID_BackgroundCopyManager;
+
+	[Windows.Win32.Foundation.Metadata.Guid (4035409695u, 55119, 19482, 187, 138, 225, 106, 202, 145, 36, 234)]
+	public static Guid LIBID_BackgroundCopyManager1_5;
+
+	[Windows.Win32.Foundation.Metadata.Guid (1830333714u, 48611, 17299, 179, 17, 9, 156, 52, 110, 109, 249)]
+	public static Guid LIBID_BackgroundCopyManager2_0;
+
+	[Windows.Win32.Foundation.Metadata.Guid (63609046u, 65373, 18872, 171, 198, 3, 221, 132, 18, 112, 32)]
+	public static Guid LIBID_BackgroundCopyManager2_5;
+
+	[Windows.Win32.Foundation.Metadata.Guid (1704779431u, 18590, 4569, 169, 205, 0, 13, 86, 150, 82, 81)]
+	public static Guid LIBID_BackgroundCopyManager3_0;
+
+	[Windows.Win32.Foundation.Metadata.Guid (3144545643u, 51918, 4572, 153, 146, 0, 25, 185, 58, 58, 132)]
+	public static Guid LIBID_BackgroundCopyManager4_0;
+
+	[Windows.Win32.Foundation.Metadata.Guid (516727628u, 59530, 17635, 141, 106, 137, 33, 189, 233, 228, 82)]
+	public static Guid LIBID_BackgroundCopyManager5_0;
+
+	[Windows.Win32.Foundation.Metadata.Guid (1272177889u, 31700, 18987, 153, 100, 73, 100, 0, 222, 81, 147)]
+	public static Guid LIBID_BackgroundCopyManager10_1;
+
+	[Windows.Win32.Foundation.Metadata.Guid (1165312911u, 42696, 18806, 176, 254, 47, 38, 184, 13, 149, 158)]
+	public static Guid LIBID_BackgroundCopyManager10_2;
+
+	[Windows.Win32.Foundation.Metadata.Guid (1607740117u, 49230, 19766, 173, 199, 224, 143, 241, 87, 55, 173)]
+	public static Guid LIBID_BackgroundCopyManager10_3;
+
+	[Windows.Win32.Foundation.Metadata.Guid (1772964590u, 20926, 17307, 169, 44, 134, 174, 73, 14, 139, 48)]
+	public static Guid LIBID_BackgroundCopyQMgr;
 }
 
 using System.Runtime.InteropServices;
@@ -459515,7 +459562,9 @@ public struct WitnessTagUpdateHelper
 // Namespace: Windows.Win32.Networking.DeliveryOptimization
 // ═══════════════════════════════════════════════════════════════
 
+using System;
 using System.Runtime.InteropServices;
+using Windows.Win32.Foundation.Metadata;
 
 namespace Windows.Win32.Networking.DeliveryOptimization;
 
@@ -459537,6 +459586,9 @@ public static class Apis
 	public const string IntegrityCheckInfo_PiecesHashFileDigestAlgorithm = "PiecesHashFileDigestAlgorithm";
 
 	public const string IntegrityCheckInfo_HashOfHashes = "HashOfHashes";
+
+	[Windows.Win32.Foundation.Metadata.Guid (1536817782u, 29212, 16956, 173, 172, 86, 208, 60, 138, 128, 7)]
+	public static Guid LIBID_DeliveryOptimization;
 }
 
 using Windows.Win32.Foundation.Metadata;
@@ -562787,7 +562839,9 @@ public unsafe delegate void PFN_COMPRESS_FREE ([In] void* UserContext, [In] void
 // Namespace: Windows.Win32.Storage.DataDeduplication
 // ═══════════════════════════════════════════════════════════════
 
+using System;
 using System.Runtime.InteropServices;
+using Windows.Win32.Foundation.Metadata;
 
 namespace Windows.Win32.Storage.DataDeduplication;
 
@@ -562795,6 +562849,9 @@ namespace Windows.Win32.Storage.DataDeduplication;
 public static class Apis
 {
 	public const uint DEDUP_CHUNKLIB_MAX_CHUNKS_ENUM = 1024u;
+
+	[Windows.Win32.Foundation.Metadata.Guid (2400219655u, 6185, 18610, 166, 75, 230, 31, 142, 13, 154, 203)]
+	public static Guid LIBID_DedupDataPort;
 }
 
 using Windows.Win32.Foundation.Metadata;
@@ -745597,9 +745654,6 @@ public static class Apis
 
 	public const uint WINPERF_LOG_VERBOSE = 3u;
 
-	[Windows.Win32.Foundation.Metadata.Guid (460799554u, 9481, 4559, 148, 47, 0, 128, 41, 0, 67, 71)]
-	public static Guid LIBID_SystemMonitor;
-
 	[Windows.Win32.Foundation.Metadata.Guid (3230420978u, 3630, 4559, 148, 44, 0, 128, 41, 0, 67, 71)]
 	public static Guid DIID_DICounterItem;
 
@@ -745820,6 +745874,9 @@ public static class Apis
 	[Windows.Win32.Foundation.Metadata.Guid (81159000u, 50337, 16795, 128, 35, 35, 183, 57, 2, 222, 44)]
 	public static Guid S_PDH;
 
+	[Windows.Win32.Foundation.Metadata.Guid (460799554u, 9481, 4559, 148, 47, 0, 128, 41, 0, 67, 71)]
+	public static Guid LIBID_SystemMonitor;
+
 	[DllImport ("KERNEL32.dll", ExactSpelling = true, PreserveSig = false, SetLastError = true)]
 	[SupportedOSPlatform ("windows5.0")]
 	[Documentation ("https://learn.microsoft.com/windows/win32/api/profileapi/nf-profileapi-queryperformancecounter")]
@@ -783478,6 +783535,9 @@ public static class Apis
 	[Windows.Win32.Foundation.Metadata.Guid (2675556467u, 35437, 19402, 168, 168, 201, 183, 154, 155, 150, 45)]
 	public static Guid DBPROPSET_SQLSERVERSTREAM;
 
+	[Windows.Win32.Foundation.Metadata.Guid (2881368528u, 28078, 4560, 190, 202, 0, 192, 79, 217, 64, 190)]
+	public static Guid LIBID_SubscriptionMgr;
+
 	[DllImport ("ODBC32.dll", ExactSpelling = true, PreserveSig = false)]
 	[Documentation ("https://learn.microsoft.com/sql/odbc/reference/syntax/sqlbindcol-function")]
 	[SupportedArchitecture (Windows.Win32.Foundation.Metadata.Architecture.X64 | Windows.Win32.Foundation.Metadata.Architecture.Arm64)]
@@ -807242,6 +807302,9 @@ public static class Apis
 
 	[Windows.Win32.Foundation.Metadata.Guid (344708394u, 41643, 4558, 177, 31, 0, 170, 0, 83, 5, 3)]
 	public static Guid CLSID_CTaskScheduler;
+
+	[Windows.Win32.Foundation.Metadata.Guid (260519583u, 42213, 19708, 189, 62, 115, 230, 21, 69, 114, 221)]
+	public static Guid LIBID_TaskScheduler;
 }
 
 using Windows.Win32.Foundation.Metadata;

This comment is automatically updated on each push.

Unify the generator SDK, build tools, tests, package layout, and CI on .NET 10 so consumers no longer need parallel .NET 8 and .NET 10 installations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 19e5498a-dfe7-4601-8955-98f33a92582b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant