-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
RawDefaultValue is resolved differently between runtimes #76174
Comments
Tagging subscribers to this area: @dotnet/area-system-reflection Issue DetailsThe issueThe following code gives different results when executed on different runtime flavours:
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
public class Program
{
internal abstract class UsableCustomConstantAttribute : CustomConstantAttribute
{
public sealed override object Value => RealValue;
protected object RealValue { get; set; }
}
private class StringCustomConstantAttribute : UsableCustomConstantAttribute
{
public new object Value { get { return RealValue; } set { RealValue = value; } }
}
private class AnotherStringCustomConstantAttribute : UsableCustomConstantAttribute
{
public new object Value { get { return RealValue; } set { RealValue = value; } }
}
public void Foo([StringCustomConstant(Value = "SomeValue")] [AnotherStringCustomConstant(Value = "SomeOtherValue")] object param) { }
static void Main()
{
Console.WriteLine(typeof(Program).GetMethod("Foo").GetParameters()[0].RawDefaultValue);
}
} ExpectedAll runtimes should produce the same result. TODOAlign the implementation of runtime/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs Line 158 in 19c5d17
CoreCLR: runtime/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs Line 297 in 19c5d17
NativeAOT: Line 206 in 19c5d17
This is related to: #49806
|
cc @jkotas |
(we use only one area per issue) |
Like CoreClr, .NET Framework also returns "SomeOtherValue" so assuming this is the expected result, Mono and NativeAOT should be changed to return the last parameter attribute. If we agree that is the case, then this issue should be moved to This does seem like a niche issue, however, since it requires multiple parameter attributes. |
@steveharter Ivan is fixing this in #75612 |
…tiveAOT runtimes (#75612) Fixes #49806 #76174 Co-authored-by: Jan Kotas <[email protected]>
Closing as completed via 05b8bab |
The issue
The following code gives different results when executed on different runtime flavours:
SomeOtherValue
SomeValue
SomeValue
Expected
All runtimes should produce the same result.
TODO
Align the implementation of
RawDefaultValue
resolution between runtimes.Mono:
runtime/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs
Line 158 in 19c5d17
CoreCLR:
runtime/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs
Line 297 in 19c5d17
NativeAOT:
runtime/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/Helpers.cs
Line 206 in 19c5d17
This is related to: #49806
The text was updated successfully, but these errors were encountered: