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 for custom reference importers in member cloner #93

Closed
Washi1337 opened this issue Sep 5, 2020 · 3 comments
Closed

Support for custom reference importers in member cloner #93

Washi1337 opened this issue Sep 5, 2020 · 3 comments
Labels
dotnet Issues related to AsmResolver.DotNet enhancement
Milestone

Comments

@Washi1337
Copy link
Owner

Summary:
The reference importer (and by extensions the member cloner) performs a deep copy for all metadata members. For type references, this also means it clones the assembly reference it originates from. This can be a problem when we try to import a type that is targeting a different version of .NET than the assembly it is imported into is targeting (e.g. importing from a .NET framework to a .NET Core assembly). The proposal is to add support for automatically fixing up these kinds references to the appropriate .NET assembly reference.

Complications:
For different versions of the same library, this should be doable. But e.g. for .NET Framework to .NET Core, how do we find the assemblies that define the types that need to be fixed up?

@Washi1337 Washi1337 added enhancement dotnet Issues related to AsmResolver.DotNet labels Sep 5, 2020
@Washi1337
Copy link
Owner Author

Making up for differences within .NET versions is probably not going to be possible to do generically. We should probably change this issue to allow for custom ReferenceImporters in the MemberCloner instead, and let the end-user do the fixups.

@Washi1337 Washi1337 changed the title Support for importing / cloning metadata members cross framework versions Support for custom reference importers in member cloner Apr 17, 2021
@Washi1337 Washi1337 added this to the 4.9.0 milestone Feb 2, 2022
@Washi1337 Washi1337 removed this from the 4.9.0 milestone Mar 6, 2022
@ds5678
Copy link
Contributor

ds5678 commented Mar 26, 2022

Support for custom ReferenceImporters in the MemberCloner is important to me, and I'm willing to work on it. How do you want this implemented?

@Washi1337
Copy link
Owner Author

Ideally, the MemberCloner could be initialized using a ReferenceImporter object, or perhaps even extract an IReferenceImporter to allow for even more flexibility.

One problem I encountered when I was trying this initially, is that the CloneContextAwareReferenceImporter still needs to be used somehow, as it is used to create proper references to members that were included in the cloning procedure. This opens up for some interesting edge-cases when it comes to the recursive behavior of the current ReferenceImporter implementation.

I haven't had the time to think it through more, but I am open to suggestions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet Issues related to AsmResolver.DotNet enhancement
Projects
None yet
Development

No branches or pull requests

2 participants