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

MemberCloner doesn't handle custom attribute arguments corresponding to cloned types #482

Closed
Zetrith opened this issue Sep 12, 2023 · 1 comment
Labels
bug dotnet Issues related to AsmResolver.DotNet
Milestone

Comments

@Zetrith
Copy link

Zetrith commented Sep 12, 2023

AsmResolver Version

5.4.0

.NET Version

No response

Operating System

Windows

Describe the Bug

Custom attribute arguments which are System.Types don't get fixed up by MemberCloner.

How To Reproduce

For the metadata cloning test suite:

[TestCase(typeof(TypeArguments))]
public class TypeArguments
{
}

var clonedType = CloneType(typeof(TypeArguments), out _);
Assert.Equal(
    ((TypeDefOrRefSignature)clonedType.CustomAttributes[0].Signature.FixedArguments[0].Element).Type,
    clonedType
);

Expected Behavior

The type argument of TestCaseAttribute should be equal to the cloned type.

Actual Behavior

The type argument of TestCaseAttribute still refers to the original type.

Additional Context

One detail is that right now attribute arguments which are types never get resolved into TypeDefinitions and always stay TypeReferences. This makes a potential fix more complicated because MemberCloner depends on the identity of definition objects.

@Zetrith Zetrith added the bug label Sep 12, 2023
@Washi1337 Washi1337 added the dotnet Issues related to AsmResolver.DotNet label Sep 13, 2023
@Washi1337 Washi1337 added this to the 5.5.0 milestone Sep 18, 2023
@Washi1337
Copy link
Owner

Thanks for the report. I finally got around to addressing this issue. A potential fix has been pushed to #493. If you could verify that this indeed solves your issue that would be great :)

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

No branches or pull requests

2 participants