Removes unused/unreachable WinRT ContentType plumbing from assembly binding#127629
Removes unused/unreachable WinRT ContentType plumbing from assembly binding#127629
Conversation
`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>
m_kContentType plumbing in CoreCLR assembly binder|
Tagging subscribers to this area: @agocke, @elinor-fung |
There was a problem hiding this comment.
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
ContentTypepropagation fromBaseAssemblySpecinto binder identities /AssemblyNameData, and drops WinRT-aware display-name logic. - Removes
ContentTypestate and flags from binder identity/types (AssemblyIdentity::IDENTITY_FLAG_CONTENT_TYPE,m_kContentType,AssemblyNameData::ContentType, and related helpers). - Removes binder
AssemblyNamecontent-type accessor/mutator and simplifiesEquals/Hashby 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. |
| 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)); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
Removes unused/unreachable WinRT
ContentTypeplumbing from the CoreCLR native assembly binder andAssemblySpec. The cleanup is split into three commits, each one removing what becomes dead after the previous step.Commit 1 —
Remove unused SetContentType from AssemblySpec / AssemblyNameBaseAssemblySpec::SetContentTypehad no callers — removed.BINDER_SPACE::AssemblyName::SetContentTypepassedAssemblyContentType_Default, which is the valuem_kContentTypeis already initialized to in theAssemblyIdentityconstructor. The setter is removed and the redundant call site is replaced with a flag-validation check (IsAfContentType_Default) that returnsFUSION_E_INVALID_NAMEfor non-default content types.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 binderWith
SetContentTypegone, nothing ever setsafContentType_WindowsRuntimeonBaseAssemblySpec::m_dwFlagsor marksIDENTITY_FLAG_CONTENT_TYPE. The corresponding branches were therefore unreachable and have been removed:BaseAssemblySpec::InitializeWithAssemblyIdentityandPopulateAssemblyNameData— theWindowsRuntimepropagation paths.BaseAssemblySpec::GetTextualIdentity— the WinRT-aware display-name path.BINDER_SPACE::AssemblyName::Equals/Hash— the WinRT-aware comparison/hash branches (data.ContentTypecan no longer beWindowsRuntime).BINDER_SPACE::AssemblyName::GetContentTypeaccessor — no remaining callers.Commit 3 —
Remove unused m_kContentType and surrounding plumbingAfter commits 1 and 2, the
m_kContentTypefield is only ever written from a zero-initializedAssemblyNameDataand read from a textual-identity branch that is never taken. Removed:AssemblyIdentity::m_kContentTypefield + ctor init, andAssemblyIdentity::IDENTITY_FLAG_CONTENT_TYPE.AssemblyNameData::ContentTypeand the corresponding write inAssemblyName::Init.AssemblyName::INCLUDE_FLAGS::INCLUDE_CONTENT_TYPE(and its contribution toINCLUDE_ALL), plus the two&= ~IDENTITY_FLAG_CONTENT_TYPEclears inHash/GetDisplayName.TextualIdentityParser::ToString's unreachableContentType=emission, and the now-orphanedContentTypeToStringhelper.__AssemblyContentTypetypedef inbindertypes.hpp— the binder no longer uses it.Out of scope
System.Reflection.AssemblyContentType(consumed by CoreLib).corhdr.h'safContentType_*flags (still consumed by ilasm/ildasm and the AOT toolchain).Validation
./build.sh clr+libssucceeds with 0 warnings, 0 errors at the tip of the branch.Note
This PR was authored with assistance from GitHub Copilot.
Plan checklist
BaseAssemblySpec::SetContentTypeandBINDER_SPACE::AssemblyName::SetContentTypeInitializeWithAssemblyIdentity/PopulateAssemblyNameData/GetTextualIdentity/Equals/Hash/GetContentTypem_kContentTypefield,IDENTITY_FLAG_CONTENT_TYPE,INCLUDE_CONTENT_TYPE,AssemblyNameData::ContentType,ContentTypeToStringhelper, and__AssemblyContentTypetypedefclr+libs— succeeded with 0 warnings / 0 errors