Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SetEntryAssembly() API to System.Reflection #102271

Merged
merged 14 commits into from
May 21, 2024
Merged

Add SetEntryAssembly() API to System.Reflection #102271

merged 14 commits into from
May 21, 2024

Conversation

ivdiazsa
Copy link
Member

Implements the API proposal detailed and approved in issue #101616. This new API will allow developers to change the entry assembly of their .NET apps on the fly, should they require it. One important scenario is app launchers. With the usage of this API, then functions like GetEntryAssembly() will return the right value, and thus we will be able to ensure the information is consistent and correct.

Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-reflection
See info in area-owners.md if you want to be subscribed.

"s_overriddenEntryAssembly", added an API doc to SetEntryAssembly(),
added validation for it to be a Runtime Assembly, and changed the type
to allow a null entry assembly.
@jkotas
Copy link
Member

jkotas commented May 15, 2024

This needs some tests (

is a good place to add them)

…embly.cs

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
@ivdiazsa
Copy link
Member Author

Seems I got an import wrong. Will look into it.

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you!

@ivdiazsa
Copy link
Member Author

I wonder where that trailing whitespace came from... Let me fix it so we can merge. Thanks a lot for your guidance with this @jkotas!

@ivdiazsa
Copy link
Member Author

Might be just my ptsd of breaking the outerloop with a PR I did last year, so I'll kick off an outerloop run just to be safe we can merge this.

@ivdiazsa
Copy link
Member Author

/azp run runtime-coreclr outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ivdiazsa ivdiazsa merged commit 362a95d into dotnet:main May 21, 2024
142 of 146 checks passed
Ruihan-Yin pushed a commit to Ruihan-Yin/runtime that referenced this pull request May 30, 2024
* Trying out JanK's approach to override the entry assembly...

* Fixed what was missing for this reflection scenario to work correctly.

* Reverted the compatibility suppressions added by the build script.

* Forgot to revert also the nativeaot part of the suppressions.

* Addressed PR comments: Updated the tests to use the new
"s_overriddenEntryAssembly", added an API doc to SetEntryAssembly(),
added validation for it to be a Runtime Assembly, and changed the type
to allow a null entry assembly.

* Added tests and addressed more comments on the PR.

* Added exception test case for SetEntryAssembly, and wrapped all its
test cases in a RemoteExecutor.Invoke() call, in order to avoid
potentially interferring with the GetEntryAssembly tests.

* Update src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs

Co-authored-by: Jan Kotas <jkotas@microsoft.com>

* Refactored further the tests that force a null entry assembly, and
fixed the issue with the remote executor.

* Apply Jan's suggestions

Co-authored-by: Jan Kotas <jkotas@microsoft.com>

* Fixed a sneaky trailing whitespace that was messing up with the code analyzers.

* Changed ConditionalTheory to ConditionalFact in the tests because we're not passing parameters to it.

* Disabled building the CustomHostTests test file when .NET Framework

---------

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
@github-actions github-actions bot locked and limited conversation to collaborators Jun 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants