Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Change TypeMapLazyDictionary to use direct cast instead of 'as' operator for RuntimeAssembly - #122885

#122885
Merged
jtschuster merged 2 commits into
maindotnet/runtime:mainfrom
copilot/update-lazytypemaps-dictionarydotnet/runtime:copilot/update-lazytypemaps-dictionaryCopy head branch name to clipboard
Jan 6, 2026
Merged

Change TypeMapLazyDictionary to use direct cast instead of 'as' operator for RuntimeAssembly#122885
jtschuster merged 2 commits into
maindotnet/runtime:mainfrom
copilot/update-lazytypemaps-dictionarydotnet/runtime:copilot/update-lazytypemaps-dictionaryCopy head branch name to clipboard

Conversation

Copilot AI commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

Description

Replaced as RuntimeAssembly with direct cast (RuntimeAssembly?) in TypeMapLazyDictionary.CreateMaps() for both Assembly.Load() and Assembly.GetEntryAssembly() calls.

Direct cast surfaces type mismatches as InvalidCastException rather than silently returning null, which is the correct behavior since these methods should always return RuntimeAssembly when non-null in the runtime environment.

Customer Impact

None. This is a code quality improvement addressing review feedback.

Regression

No.

Testing

Existing System.Runtime.InteropServices test suite (2547 tests passed).

Risk

Low. Minimal change to type conversion semantics with identical behavior for valid inputs.

Original prompt

Can you address Aaron's comment and update the code in LazyTypeMapDictionary to cast to RuntimeAssembly instead of using 'as' #121513 (comment)

Create a PR for this.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Jan 5, 2026
…untimeAssembly

Co-authored-by: jtschuster <36744439+jtschuster@users.noreply.github.com>
Copilot AI changed the title [WIP] Update LazyTypeMapDictionary to cast to RuntimeAssembly Change TypeMapLazyDictionary to use direct cast instead of 'as' operator for RuntimeAssembly Jan 5, 2026
Copilot AI requested a review from jtschuster January 5, 2026 18:51

@AaronRobinsonMSFT AaronRobinsonMSFT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@jtschuster
jtschuster marked this pull request as ready for review January 6, 2026 05:03
Copilot AI review requested due to automatic review settings January 6, 2026 05:03
@jtschuster
jtschuster merged commit 6c54ede into main Jan 6, 2026
146 of 150 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 changes the type conversion approach from the as operator to a direct cast for converting Assembly to RuntimeAssembly? in the TypeMapLazyDictionary.CreateMaps() method. The change affects two calls: Assembly.Load(string) and Assembly.GetEntryAssembly().

Key Changes:

  • Changed Assembly.Load(entryAssemblyName) as RuntimeAssembly to (RuntimeAssembly?)Assembly.Load(entryAssemblyName)
  • Changed Assembly.GetEntryAssembly() as RuntimeAssembly to (RuntimeAssembly?)Assembly.GetEntryAssembly()

@jkotas
jkotas deleted the copilot/update-lazytypemaps-dictionary branch January 24, 2026 03:51
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.