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

Support unloadability in DispatchProxy. #62095

Merged
merged 8 commits into from
Dec 3, 2021

Conversation

teo-tsirpanis
Copy link
Contributor

@teo-tsirpanis teo-tsirpanis commented Nov 27, 2021

The System.Reflection.DispatchProxy type used to be incompatible with unloadability, because the AssemblyBuilder with the generated proxy types is created with AssemblyBuilderAccess.Run and because all proxy types were associated with a single one.

This PR creates a separate AssemblyBuilder, one for each AssemblyLoadContext of the base type's assembly, and passes AssemblyBuilderAccess.RunAndCollect to it (edit: only if the associated ALC is unloadable). It also cleans-up some code.

Besides allowing unneeded proxy types to be granularly unloaded, it also added support for creating proxies for the same type in different ALC. I added tests for both cases.

Fixes #60468
Fixes #62050

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Nov 27, 2021
Copy link

@d066z d066z left a comment

Choose a reason for hiding this comment

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

delete

@teo-tsirpanis
Copy link
Contributor Author

The two tests I added fail on Browser because Assembly.Location returns an empty string. Any idea how to selectively disable them?

@jkotas
Copy link
Member

jkotas commented Nov 27, 2021

I would recomend to early out from the tests if the Location is empty string. It will make the test pass in all situations when the assembly is not physically available on the disk (e.g. #43079).

@teo-tsirpanis
Copy link
Contributor Author

Thanks for the feedback @jkotas, that was my first guess, thought there might be a more elegant way. I updated the tests.

Copy link

@d066hie d066hie left a comment

Choose a reason for hiding this comment

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

change

@teo-tsirpanis
Copy link
Contributor Author

Hello @d066hie, would you like to explain in more detail what to change in this PR?

Use a different name for the default ALC's proxy assembly and make it collectible only if its associated ALC is.
@buyaa-n
Copy link
Member

buyaa-n commented Dec 2, 2021

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@buyaa-n buyaa-n left a comment

Choose a reason for hiding this comment

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

Thank you @teo-tsirpanis, LGTM

@buyaa-n
Copy link
Member

buyaa-n commented Dec 3, 2021

Outerloop test failures are unrelated and reported as needed (#62305, #60753 (comment), #58616 (comment), #56165 (comment)).

Thank you for your review @jkotas @vitek-karas if you have no more comments/concerns the PR is ready for merge.

@buyaa-n buyaa-n merged commit 2f0341d into dotnet:main Dec 3, 2021
@teo-tsirpanis teo-tsirpanis deleted the dispatch-proxy-unloadability branch December 3, 2021 17:53
@vitek-karas
Copy link
Member

Thanks a lot @teo-tsirpanis !!

@ghost ghost locked as resolved and limited conversation to collaborators Jan 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Reflection community-contribution Indicates that the PR has been added by a community member
Projects
None yet
8 participants