Skip to content

Removes unused/unreachable WinRT ContentType plumbing from assembly binding#127629

Open
Copilot wants to merge 4 commits intomainfrom
copilot/cleanup-set-getcontenttype
Open

Removes unused/unreachable WinRT ContentType plumbing from assembly binding#127629
Copilot wants to merge 4 commits intomainfrom
copilot/cleanup-set-getcontenttype

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 30, 2026

Removes unused/unreachable WinRT ContentType plumbing from the CoreCLR native assembly binder and AssemblySpec. The cleanup is split into three commits, each one removing what becomes dead after the previous step.

Commit 1 — Remove unused SetContentType from AssemblySpec / AssemblyName

  • BaseAssemblySpec::SetContentType had no callers — removed.
  • The only caller of BINDER_SPACE::AssemblyName::SetContentType passed AssemblyContentType_Default, which is the value m_kContentType is already initialized to in the AssemblyIdentity constructor. The setter is removed and the redundant call site is replaced with a flag-validation check (IsAfContentType_Default) that returns FUSION_E_INVALID_NAME for non-default content types.
  • Files: src/coreclr/binder/assemblyname.cpp, src/coreclr/binder/inc/assemblyname.hpp, src/coreclr/binder/inc/assemblyname.inl, src/coreclr/vm/assemblyspec.hpp.

Commit 2 — Remove dead WinRT ContentType plumbing in assembly binder

With SetContentType gone, nothing ever sets afContentType_WindowsRuntime on BaseAssemblySpec::m_dwFlags or marks IDENTITY_FLAG_CONTENT_TYPE. The corresponding branches were therefore unreachable and have been removed:

  • BaseAssemblySpec::InitializeWithAssemblyIdentity and PopulateAssemblyNameData — the WindowsRuntime propagation paths.
  • BaseAssemblySpec::GetTextualIdentity — the WinRT-aware display-name path.
  • BINDER_SPACE::AssemblyName::Equals / Hash — the WinRT-aware comparison/hash branches (data.ContentType can no longer be WindowsRuntime).
  • BINDER_SPACE::AssemblyName::GetContentType accessor — no remaining callers.

Commit 3 — Remove unused m_kContentType and surrounding plumbing

After commits 1 and 2, the m_kContentType field is only ever written from a zero-initialized AssemblyNameData and read from a textual-identity branch that is never taken. Removed:

  • AssemblyIdentity::m_kContentType field + ctor init, and AssemblyIdentity::IDENTITY_FLAG_CONTENT_TYPE.
  • AssemblyNameData::ContentType and the corresponding write in AssemblyName::Init.
  • AssemblyName::INCLUDE_FLAGS::INCLUDE_CONTENT_TYPE (and its contribution to INCLUDE_ALL), plus the two &= ~IDENTITY_FLAG_CONTENT_TYPE clears in Hash / GetDisplayName.
  • TextualIdentityParser::ToString's unreachable ContentType= emission, and the now-orphaned ContentTypeToString helper.
  • The __AssemblyContentType typedef in bindertypes.hpp — the binder no longer uses it.

Out of scope

  • Managed System.Reflection.AssemblyContentType (consumed by CoreLib).
  • corhdr.h's afContentType_* flags (still consumed by ilasm/ildasm and the AOT toolchain).

Validation

./build.sh clr+libs succeeds with 0 warnings, 0 errors at the tip of the branch.

Note

This PR was authored with assistance from GitHub Copilot.


Plan checklist

  • Commit 1 — remove unused BaseAssemblySpec::SetContentType and BINDER_SPACE::AssemblyName::SetContentType
  • Commit 2 — remove dead WinRT branches in InitializeWithAssemblyIdentity / PopulateAssemblyNameData / GetTextualIdentity / Equals / Hash / GetContentType
  • Commit 3 — remove now-unreachable m_kContentType field, IDENTITY_FLAG_CONTENT_TYPE, INCLUDE_CONTENT_TYPE, AssemblyNameData::ContentType, ContentTypeToString helper, and __AssemblyContentType typedef
  • Build clr+libs — succeeded with 0 warnings / 0 errors
  • Update PR title and description to describe all commits

Copilot AI and others added 3 commits April 30, 2026 07:41
`BaseAssemblySpec::SetContentType` had no callers, and the only call to
`AssemblyName::SetContentType` passed `AssemblyContentType_Default`,
which is the value `m_kContentType` is already initialized to in the
`AssemblyIdentity` constructor. Remove both `SetContentType` methods and
replace the redundant call site with a flag-validation check.

Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/7568770f-93f6-4aab-8674-88bae7a8e6f2

Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
Now that `SetContentType` is gone, nothing sets `afContentType_WindowsRuntime`
on `BaseAssemblySpec::m_dwFlags`. As a result, the WinRT propagation in
`InitializeWithAssemblyIdentity`, `PopulateAssemblyNameData`, and the
display-name output path are all dead, as are the WinRT-aware branches in
`AssemblyName::Hash`/`Equals` (since `data.ContentType` can no longer be
WinRT). Remove that dead plumbing along with the now-unused
`AssemblyName::GetContentType` accessor.

Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/7568770f-93f6-4aab-8674-88bae7a8e6f2

Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/d08178be-33e1-4d96-9ea8-baf44b37a666

Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 30, 2026 23:11
Copilot AI review requested due to automatic review settings April 30, 2026 23:11
@github-actions github-actions Bot added the area-AssemblyLoader-coreclr only use for closed issues label Apr 30, 2026
Copilot AI requested a review from elinor-fung April 30, 2026 23:20
@elinor-fung elinor-fung changed the title Remove unused m_kContentType plumbing in CoreCLR assembly binder Removes unused/unreachable WinRT ContentType plumbing from assembly binding Apr 30, 2026
@elinor-fung elinor-fung added area-AssemblyLoading and removed area-AssemblyLoader-coreclr only use for closed issues labels Apr 30, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @elinor-fung
See info in area-owners.md if you want to be subscribed.

@jkotas jkotas marked this pull request as ready for review May 1, 2026 01:18
Copilot AI review requested due to automatic review settings May 1, 2026 01:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes unused/unreachable WinRT ContentType plumbing from the CoreCLR native assembly binding pipeline (VM BaseAssemblySpec ↔ binder AssemblyName/AssemblyIdentity), simplifying identity propagation, display-name formatting, and hashing/equality now that non-default content types are rejected/unsupported.

Changes:

  • Removes ContentType propagation from BaseAssemblySpec into binder identities / AssemblyNameData, and drops WinRT-aware display-name logic.
  • Removes ContentType state and flags from binder identity/types (AssemblyIdentity::IDENTITY_FLAG_CONTENT_TYPE, m_kContentType, AssemblyNameData::ContentType, and related helpers).
  • Removes binder AssemblyName content-type accessor/mutator and simplifies Equals/Hash by dropping the WinRT content-type branches; validates non-default content types as invalid.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/coreclr/vm/coreassemblyspec.cpp Removes content-type propagation/display logic from BaseAssemblySpec paths.
src/coreclr/vm/assemblyspec.hpp Removes unused AssemblySpec::SetContentType API.
src/coreclr/binder/textualidentityparser.cpp Removes unreachable ContentType= emission and the ContentTypeToString helper.
src/coreclr/binder/inc/bindertypes.hpp Removes binder-local AssemblyContentType typedef and drops AssemblyNameData::ContentType.
src/coreclr/binder/inc/assemblyname.inl Removes AssemblyName::GetContentType / SetContentType.
src/coreclr/binder/inc/assemblyname.hpp Removes INCLUDE_CONTENT_TYPE and content-type accessors from AssemblyName API surface.
src/coreclr/binder/inc/assemblyidentity.hpp Removes IDENTITY_FLAG_CONTENT_TYPE and m_kContentType from AssemblyIdentity.
src/coreclr/binder/assemblyname.cpp Validates non-default content type as invalid; removes content-type state usage from init/hash/equals/display-name.

Comment on lines 394 to 399
assemblyIdentity.SetHave(BINDER_SPACE::AssemblyIdentity::IDENTITY_FLAG_RETARGETABLE);
}

if ((flags & ASM_DISPLAYF_CONTENT_TYPE) && (m_dwFlags & afContentType_Mask) == afContentType_WindowsRuntime)
{
assemblyIdentity.SetHave(BINDER_SPACE::AssemblyIdentity::IDENTITY_FLAG_CONTENT_TYPE);
assemblyIdentity.m_kContentType = AssemblyContentType_WindowsRuntime;
}

IfFailThrow(BINDER_SPACE::TextualIdentityParser::ToString(&assemblyIdentity,
assemblyIdentity.m_dwIdentityFlags,
result));
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASM_DISPLAYF_CONTENT_TYPE handling was removed from GetDisplayName, but ASM_DISPLAYF_FULL (in bindertypes.hpp) still includes ASM_DISPLAYF_CONTENT_TYPE. That makes the flag effectively dead and ASM_DISPLAYF_FULL a bit misleading; consider removing ASM_DISPLAYF_CONTENT_TYPE (and dropping it from ASM_DISPLAYF_FULL) as part of this cleanup.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed ASM_DISPLAYF_CONTENT_TYPE and dropped it from ASM_DISPLAYF_FULL in eee266c.

Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/a037f39b-26d8-4ca8-a39b-bb606dce3d93

Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants