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

ParameterInfo.RawDefaultValue throws when default value is string.empty #57238

Closed
mjkkirschner opened this issue Aug 11, 2021 · 4 comments · Fixed by #61457
Closed

ParameterInfo.RawDefaultValue throws when default value is string.empty #57238

mjkkirschner opened this issue Aug 11, 2021 · 4 comments · Fixed by #61457

Comments

@mjkkirschner
Copy link

mjkkirschner commented Aug 11, 2021

Description

When using a metaDataLoadContext to find static methods in an assembly, invoking ParameterInfo.RawDefaultValue throws a badformat exception - I've tracked down the line of code to here:
https://github.com/dotnet/runtime/blob/main/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/Ecma/EcmaDefaultValueProcessing.cs#L18

this appears to throw when the parameter in question is an optional string with a default value of empty string ""
It looks like constantValue.Value is nil in this case. I'm not sure if it's simply an issue with empty strings in all cases or its an environment issue.

Configuration

  • Which version of .NET is the code running on? .net 4.8
  • What OS and version, and what distro if applicable? windows 10 2004
  • What is the architecture (x64, x86, ARM, ARM64)? x64
  • Do you know whether it is specific to that configuration? do not know
  • If you're using Blazor, which web browser(s) do you see this issue in? NA

Regression?

Don't know at this time.

Other information

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Reflection untriaged New issue has not been triaged by the area owner labels Aug 11, 2021
@joperezr
Copy link
Member

@mjkkirschner thanks for the report. Did you try if this repros in .NET 5 or .NET Core? Can you please add a code snippet of the repro so that we can take a look?

@joperezr joperezr added this to the Future milestone Aug 12, 2021
@buyaa-n buyaa-n removed the untriaged New issue has not been triaged by the area owner label Aug 12, 2021
@ghost ghost added the no-recent-activity label Oct 9, 2021
@ghost
Copy link

ghost commented Oct 9, 2021

This issue has been automatically marked no recent activity because it has been marked as needs more info but has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no recent activity.

Please refer to our contribution guidelines for tips on what information might be required.

@ghost
Copy link

ghost commented Nov 5, 2021

This issue will now be closed since it had been marked no recent activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.

@ghost ghost closed this as completed Nov 5, 2021
Repository owner moved this from Future to Done in Triage POD for Reflection, META, etc. Nov 5, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Nov 11, 2021
@svick
Copy link
Contributor

svick commented Nov 11, 2021

I was able to reproduce this issue and have created a PR to fix it: #61457, so I think this should be reopened.

Repository owner moved this from Untriaged to Done in Triage POD for Reflection, META, etc. Nov 24, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Nov 24, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Dec 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

5 participants