-
Notifications
You must be signed in to change notification settings - Fork 5k
Fix: using default value for nullable enum parameter throws ArgumentException #71388
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
Conversation
Tagging subscribers to this area: @dotnet/area-system-reflection Issue DetailsFix: Type.Missing doesn't convert to nullable enum in Method.Invoke The root cause is: ParameterInfo.DefaultValue returns the raw value if the enum is nullable. So the root cause is a known issue and we choose to not fix for compatibility reason: runtime/src/coreclr/System.Private.CoreLib/src/System/Reflection/MdConstant.cs Lines 16 to 20 in fd31f1f
Though for Fixes #70925
|
Looks like some of the new tests are failing in NativeAOT. You likely will want an ActiveIssue there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once CI green for NativeAOT
Apparently, the new tests work on Mono? |
Could you please look into fixing the failing tests as part of this PR? |
src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBase.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBase.cs
Outdated
Show resolved
Hide resolved
835b818
to
832bfdd
Compare
Fix: Type.Missing doesn't convert to nullable enum in Method.Invoke
The root cause is: ParameterInfo.DefaultValue returns the raw value if the enum is nullable. So the root cause is a known issue and we choose to not fix for compatibility reason:
runtime/src/coreclr/System.Private.CoreLib/src/System/Reflection/MdConstant.cs
Lines 16 to 20 in fd31f1f
Though for
MethodInfo.Invoke
we could parse the raw value into the correspondingEnum
and avoid throwing ArgumentExceptionFixes #70925