throw new BadImageFormatException();
Constant constantValue = metadataReader.GetConstant(constantHandle);
- if (constantValue.Value.IsNil)
+ // Partition II section 24.2.4:
+ // The first entry in both these heaps is the empty 'blob' that consists of the single byte 0x00.
+ //
+ // This means zero value is valid for string and is used to represent the empty string.
+ if (constantValue.Value.IsNil && constantValue.TypeCode != ConstantTypeCode.String)
throw new BadImageFormatException();
BlobReader reader = metadataReader.GetBlobReader(constantValue.Value);
public void Foo4(short s = -34) { }
public void Foo5(decimal d = 1234m) { }
public void Foo6([DateTimeConstant(ticks: 8736726782)] DateTime dt) { }
+ public void Foo7(string s1 = "foo", string s2 = "", string s3 = null) { }
+ public void Foo8(Action a = null) { }
}
public class ParametersWithPseudoCustomtAttributes
}
[Fact]
+ public static void TestRawDefaultValue7()
+ {
+ var parameters = typeof(ParametersWithDefaultValues).Project().GetTypeInfo().GetDeclaredMethod("Foo7").GetParameters();
+ ParameterInfo p1 = parameters[0];
+ Assert.True(p1.HasDefaultValue);
+ object dv1 = p1.RawDefaultValue;
+ Assert.Equal("foo", dv1);
+ ParameterInfo p2 = parameters[1];
+ Assert.True(p2.HasDefaultValue);
+ object dv2 = p2.RawDefaultValue;
+ Assert.Equal("", dv2);
+ ParameterInfo p3 = parameters[2];
+ Assert.True(p3.HasDefaultValue);
+ Assert.Null(p3.RawDefaultValue);
+ }
+
+ [Fact]
+ public static void TestRawDefaultValue8()
+ {
+ ParameterInfo p = typeof(ParametersWithDefaultValues).Project().GetTypeInfo().GetDeclaredMethod("Foo8").GetParameters()[0];
+ Assert.True(p.HasDefaultValue);
+ object dv = p.RawDefaultValue;
+ Assert.Null(dv);
+ }
+
+ [Fact]
[ActiveIssue("https://github.com/mono/mono/issues/15340", TestRuntimes.Mono)]
public static void TestPseudoCustomAttributes()
{