-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Comments
@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? |
This issue has been automatically marked Please refer to our contribution guidelines for tips on what information might be required. |
This issue will now be closed since it had been marked |
I was able to reproduce this issue and have created a PR to fix it: #61457, so I think this should be reopened. |
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
.net 4.8
windows 10 2004
x64
do not know
NA
Regression?
Don't know at this time.
Other information
The text was updated successfully, but these errors were encountered: