Split WindowsRuntimeObject into a partial implementation file#2446
Merged
Sergio0694 merged 1 commit intoJun 17, 2026
Conversation
Extract the bulk of WindowsRuntimeObject's implementation into a new partial file (WindowsRuntimeObject.Impl.cs) and update WindowsRuntimeObject.cs to be a partial declaration. The change relocates constructors, caching fields, dynamic cast/QueryInterface logic, virtual method table helpers, and exception stubs into the new file while removing now-unneeded usings from the original file. This refactor preserves existing behavior but improves code organization and maintainability by separating surface declaration from detailed implementation.
manodasanW
approved these changes
Jun 17, 2026
85ce997
into
staging/winrt-runtime-ref-assembly
11 checks passed
Sergio0694
added a commit
that referenced
this pull request
Jun 17, 2026
…2448) * Bring back WindowsRuntimeConstants for the WindowsRuntimeObject constructor Re-add the type removed in #2434, now holding the dedicated obsolete message, diagnostic id (CSWINRT3001) and URL format used to flag the reference-assembly-only WindowsRuntimeObject constructor. Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com> * Add a reference-assembly-only constructor for WindowsRuntimeObject After #2446 all WindowsRuntimeObject constructors live in the implementation-only WindowsRuntimeObject.Impl.cs and are stripped from the reference assembly, so the compiler would synthesize a protected parameterless constructor. That constructor is absent from the implementation assembly and would throw MissingMethodException at runtime if a user type derived from WindowsRuntimeObject. Explicitly define it for the reference assembly only, marked obsolete (CSWINRT3001) and hidden, so deriving from WindowsRuntimeObject produces a build diagnostic instead. Only generated projections may derive from it. Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com> * Add back the CSWINRT3001 diagnostics doc Re-add the diagnostics doc removed in #2434, updated for the new scenario (deriving from WindowsRuntimeObject is not supported), and rename it to match the diagnostic id (updating the solution reference, which was previously dangling). Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
Splits the
WindowsRuntimeObjectbase type into two partial files:WindowsRuntimeObject.cskeeps the type declaration and the public explicit interface implementations, while the newWindowsRuntimeObject.Impl.csholds all of the implementation detail (backing fields, constructors, and methods). This is a pure code move with no behavior changes.Motivation
This refactoring is a prerequisite for #2444 (
Set up dual reference assembly build for WinRT.Runtime). Pulling it into its own PR keeps the diff for #2444 small and much easier to review: the move alone adds a large number of lines to the diff even though it only relocates existing code. #2444 will be rebased on top of this once it merges.Changes
WindowsRuntimeObject.cs: reduced to the type declaration (nowpartial) and the explicit interface implementations forIDynamicInterfaceCastable,IUnmanagedVirtualMethodTableProvider, andICustomQueryInterface, which forward to the implementation methods.WindowsRuntimeObject.Impl.cs: new partial file containing the relocated implementation (backing fields, constructors, and all members).