Skip to content

Conversation

@lambdageek
Copy link
Member

Fixes #39001

@lambdageek lambdageek requested review from thaystg and vargaz as code owners July 9, 2021 15:34
@ghost ghost added the area-VM-meta-mono label Jul 9, 2021
@ghost
Copy link

ghost commented Jul 9, 2021

Tagging subscribers to this area:
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #39001

Author: lambdageek
Assignees: -
Labels:

area-VM-meta-mono

Milestone: -

@lambdageek lambdageek added area-VM-reflection-mono Reflection issues specific to MonoVM and removed area-VM-meta-mono labels Jul 9, 2021
@ghost
Copy link

ghost commented Jul 9, 2021

Tagging subscribers to this area:
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #39001

Author: lambdageek
Assignees: -
Labels:

area-System.Reflection-mono

Milestone: -

Copy link
Member

@fanyang-mono fanyang-mono left a comment

Choose a reason for hiding this comment

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

LGTM

check_for_invalid_array_type (klass, error);
check_for_invalid_array_type (type, error);
return_val_if_nok (error, MONO_HANDLE_CAST (MonoReflectionType, NULL_HANDLE));
MonoClass *klass = mono_class_from_mono_type_internal (type);
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it is better to pass MonoClass *klass to check_for_invalid_array_type, since line 6298 will always be executed. That way we could save one function call.

Copy link
Member Author

@lambdageek lambdageek Jul 9, 2021

Choose a reason for hiding this comment

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

So the problem is that if you start with a MonoType and then call mono_class_from_mono_type_internal it is not an exact roundtrip. In particular you lose the MonoType:byref bit. Because a MonoClass is not able to represent a byref type. (This is kind of an annoying limitation in Mono but fixing it is probably a ton of work).

I thought about instead returning the klass from check_for_invalid_array_type, but it's kind of a weird incidental return value. In any case mono_class_from_mono_type_internal is pretty quick to call since it's just a switch on a value (MonoType:type) that we already looked at.

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha! My original thought was to returning the klass from check_for_invalid_array_type. But since it is not costly, I am okay with current implementation.

@ghost
Copy link

ghost commented Jul 9, 2021

Hello @lambdageek!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit b7ce14c into dotnet:main Jul 9, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Aug 8, 2021
@lambdageek lambdageek deleted the fix-gh-39001 branch March 19, 2022 16:45
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-VM-reflection-mono Reflection issues specific to MonoVM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mono Type.MakeArrayType allows arrays of byref types

2 participants