Skip to content

Commit

Permalink
[mono] Fix the formatting of field types FieldInfo.ToString () so it …
Browse files Browse the repository at this point in the history
…matches clr. (#88648)

Fixes #88637.
  • Loading branch information
vargaz authored Jul 11, 2023
1 parent e70f0df commit f44e2e6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@
<Compile Include="System\Reflection\InvokeRefReturn.cs" />
<Compile Include="System\Reflection\InvokeWithRefLikeArgs.cs" />
<Compile Include="System\Reflection\IsCollectibleTests.cs" />
<Compile Include="System\Reflection\FieldInfoTests.cs" />
<Compile Include="System\Reflection\MethodBaseTests.cs" />
<Compile Include="System\Reflection\MethodBodyTests.cs" />
<Compile Include="System\Reflection\ModuleTests.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using Xunit;
using TestAttributes;

namespace System.Reflection.Tests
{
public class FieldInfoTests
{
public int int_field;

[Fact]
public void ToStringFieldType()
{
Assert.Equal("Int32 int_field", typeof(FieldInfoTests).GetField("int_field").ToString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public override object[] GetCustomAttributes(Type attributeType, bool inherit)

public override string ToString()
{
return $"{FieldType} {name}";
return $"{FieldType.FormatTypeName ()} {name}";
}

[MethodImplAttribute(MethodImplOptions.InternalCall)]
Expand Down

0 comments on commit f44e2e6

Please sign in to comment.