Repository navigation
Fix cross-assembly COM projections and shared helpers - #1870
Merged
Merged
Conversation
Resolve interface definitions and COM ancestry with their owning generator and metadata reader. Add reciprocal metadata fixtures covering native pointers, marshaled arrays, and non-COM ancestry. Co-authored-by: Copilot App <[email protected]>
This was referenced Oct 30, 2026
Run the SDK COM source generator on GUID-bearing reciprocal fixtures and compile its output. Fix inherited CCW property inspection to use the method-owning metadata reader. Co-authored-by: Copilot App <[email protected]>
Verify the SDK-generated compilation emits successfully, then normalize only third-party generated trees for the existing cross-platform test formatting assertions. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Register compatible replacement types across inputs, forward local and external dependencies, and replace Apis members individually. Cover complete enum upgrades, architecture variants, nested types and real COM/LibraryImport generation in the three supported modes. Co-authored-by: Copilot App <[email protected]>
Emit common SliceAtNull and GeneratedCode attribute once across metadata inputs while preserving distinct per-array ReadOnlyItemRef overloads. Cover both generation orders with authored array fixtures. Co-authored-by: Copilot App <[email protected]>
…overage Use complete public Windows metadata70.0.11 and a reproducible public Agility1.619.3 fixture. Exercise real DXGI/D3D/DirectML requests in native, marshaled and actual COM-source-generated modes, both request orders, baseline precedence and target architectures. Remove all ExternalCom/Occlusion fixtures added by this work. Co-authored-by: Copilot App <[email protected]>
Use existing inline-array namespace/name cache keys to select one same-root declaration at emission without changing transactional generation. Cover real D3D11 and D3D12 sampler border arrays in all three modes and both request orders, including retained ReadOnlyItemRef calls. Co-authored-by: Copilot App <[email protected]>
Remove type, method and constant winner registration and local-definition forwarding. Keep qualified COM resolution, shared projection roots and helper ownership. Test full public split Windows metadata with one baseline or Agility D3D12 provider, neutral identities, all three projection modes, request/input orders, samplers and failed-generation retry. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Keep cross-assembly regression coverage on the split Windows SDK baseline and defer Agility coverage to the published SDK package. Co-authored-by: Copilot App <[email protected]>
Jevan Saks (jevansaks)
marked this pull request as ready for review
November 4, 2026 08:37
Update to Win32Metadata 71.0.45-preview and remove the checked-in Windows/D3D12 pair. Collect and copy package-selected test metadata after provider selection. Co-authored-by: Copilot App <[email protected]>
Honor AvoidWinmdRootAlias for type definitions as well as references, so inherited IInspectable friendly methods keep Windows HSTRING locals correctly qualified. Co-authored-by: Copilot App <[email protected]>
Jevan Saks (jevansaks)
enabled auto-merge (squash)
November 5, 2026 17:12
Sergio Pedri (Sergio0694)
approved these changes
Nov 5, 2026
Nick Eubanks (nieubank)
pushed a commit
to microsoft/WindowsML
that referenced
this pull request
Nov 17, 2026
…35) * Add C# Windows ML samples over CsWin32 Runtime and Task bindings Rebase the C# image classification sample onto Windows ML 2.8, whose pinned package ships the Runtime Win32 metadata, and add two more C# samples. - Shared C# helpers (Samples/Runtime/shared/csharp): one props file for every C# sample, plus helpers matching the C++ ones for --device cpu|gpu|npu, --ep (Windows ML execution-provider catalog + ONNX Runtime registration), --performance/--efficiency (DXCore adapter ranking), and --verbose (ONNX Runtime logging and IWinMLStageExecutionDiagnostics). - Image classification (C#): now at parity with the C++ sample's options and output, and built by build.ps1 -Sample all. - Hello LanguageModel (C#): ONNX decoder with state pairs or GGUF through llama.cpp, streaming a greedy reply. - Model-backed text generation Task (C#): model provider route and explicit llama.cpp route with optional speculative decoding. - Run scripts take -Language cpp|csharp; GetTopK orders ties by class index. Co-authored-by: Copilot App <[email protected]> * Build C# samples with the .NET SDK and address review feedback build.ps1 in Samples\Runtime and Samples\Tasks builds C++ projects first and C# projects with dotnet build; -Sample all skips the C# samples with a warning when the .NET SDK is missing. Document the .NET 8 prerequisite, skip adapters whose hardware ID can't be read, and guard the IUnknown argument helper. Co-authored-by: Copilot App <[email protected]> * Attribute the IUnknown parameter workaround to CsWin32 Co-authored-by: Copilot App <[email protected]> * Update CsWin32 to 0.3.369 and drop the IUnknown argument workaround CsWin32 0.3.369 (microsoft/CsWin32#1870) generates IUnknown* parameters from the Windows SDK metadata as pointers, so the samples pass the DXCore adapter to CreateExecutionTargetFromAdapter directly. The docs now require 0.3.369 or later. Co-authored-by: Copilot App <[email protected]> * Match the Windows ML 2.9 C++ samples in the C# samples Pin --ep webgpu through IWinMLOrtCompatibility like the other providers, since the Runtime now acquires and registers WebGPU for the pinned target, and add --cache-weights to the C# text generation sample. Co-authored-by: Copilot App <[email protected]> * Exit the C# image classification sample with the failure HRESULT The C++ sample returns the failing HRESULT from wmain. The C# sample now does the same, and the shared C# provider helpers throw the HRESULTs the C++ helpers return (ERROR_NOT_SUPPORTED and ERROR_NOT_FOUND). Co-authored-by: Copilot App <[email protected]> * Format the GetTopK tie-break with clang-format Co-authored-by: Copilot App <[email protected]> * Detect the .NET SDK, not just dotnet.exe, before building C# samples The .NET runtime alone also installs dotnet.exe. The build scripts now look for a .NET 8 or later SDK with dotnet --list-sdks, so -Sample all skips the C# samples with a warning on runtime-only machines. Co-authored-by: Copilot App <[email protected]> * Add an idiomatic C# sample wrapper and port the C# samples to it The C# samples called the Runtime C API through raw CsWin32 bindings, so their code read like interop: factory functions with pointer out parameters, unsafe blocks, and hand-mapped HRESULT checks. Add a source-only wrapper under Samples/Runtime/shared/csharp/Runtime that gives the API an idiomatic C# surface over the same bindings and the published package: - IDisposable objects with deterministic release; objects a property returns stay owned by their parent. - Exceptions that keep the HRESULT; success codes never throw. - .NET names, strings, and spans. - Zero-copy access to CPU tensors through TensorLock<T>, with a read-only span for read locks and Commit for writes to device tensors. - DXCore adapter ranking and execution target helpers. - Text generation as an IAsyncEnumerable with cancellation, run on a dedicated session thread, plus an allocation-free synchronous loop. All unsafe code stays inside the wrapper. It is sample code, not a supported API. Its names follow .NET conventions so the samples could move to a C# projection with few changes if one ships. Port the image classification, Hello LanguageModel, and text generation samples to the wrapper. Their options, output, and exit codes are unchanged. Image decoding uses Windows.Graphics.Imaging. Tested on x64 CPU and on an ARM64 NVIDIA GPU against the C++ samples: image classification on CPU, GPU, and pinned WebGPU; Hello LanguageModel with GGUF and ONNX models; model-provider text generation with a program cache; and llama.cpp with and without a draft model. NPU wasn't tested. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: Copilot App <[email protected]>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix projections when Windows metadata references COM interfaces defined in a separate WinMD, such as a D3D12 provider.
DML_BUFFER_BINDING.Bufferuses the referencedID3D12Resourcewith the correct pointer or managed interface shape.Key changes:
IntPtr.Windows.Win32.PInvokewhen metadata files share a projection root.71.0.45-previewand use its package-selected Windows/D3D12 baseline for native, marshaled, and COM source-generator regression coverage. No checked-in WinMDs or local SDK reproduction tooling are added.Input selection supplies exactly one D3D12 provider. There is no per-type occlusion or name-based replacement logic. Agility coverage will use the published SDK package.