Skip to content

Commit

Permalink
Improve printing of offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv committed Feb 16, 2022
1 parent ce55294 commit 982fb9a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Compilers/Test/Core/CompilationVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ static string printErrorArguments(ILVerify.ErrorArgument[] errorArguments)
var pooledBuilder = PooledStringBuilder.GetInstance();
var builder = pooledBuilder.Builder;
builder.Append(" { ");
var x = errorArguments.Select(a => a.Name + " = " + a.Value.ToString()).ToArray();
var x = errorArguments.Select(a => printErrorArgument(a)).ToArray();
for (int i = 0; i < x.Length; i++)
{
if (i > 0)
Expand All @@ -371,6 +371,23 @@ static string printErrorArguments(ILVerify.ErrorArgument[] errorArguments)

return pooledBuilder.ToStringAndFree();
}

static string printErrorArgument(ILVerify.ErrorArgument errorArgument)
{
var name = errorArgument.Name;

string value;
if (name == "Offset" && errorArgument.Value is int i)
{
value = "0x" + Convert.ToString(i, 16);
}
else
{
value = errorArgument.Value.ToString();
}

return name + " = " + value;
}
}

// TODO(tomat): Fold into CompileAndVerify.
Expand Down

0 comments on commit 982fb9a

Please sign in to comment.