Skip to content

Commit 4e1cc45

Browse files
committed
Include type name in error message about missing field.
1 parent 4279b89 commit 4e1cc45

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Dasher.Tests/DeserialiserTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public void ThrowsOnMissingField()
283283
() => deserialiser.Deserialise(bytes));
284284

285285
Assert.Equal(typeof(UserScore), ex.TargetType);
286-
Assert.Equal("Missing required field \"score\".", ex.Message);
286+
Assert.Equal("Missing required field \"score\" for type \"UserScore\".", ex.Message);
287287
}
288288

289289
[Fact]

Dasher/DeserialiserEmitter.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,10 @@ public static Func<Unpacker, DasherContext, object> Build(Type type, UnexpectedF
329329
{
330330
// If we got here then one or more values is missing.
331331
ilg.MarkLabel(lblValuesMissing);
332-
ilg.Emit(OpCodes.Ldstr, "Missing required field \"{0}\".");
332+
ilg.Emit(OpCodes.Ldstr, "Missing required field \"{0}\" for type \"{1}\".");
333333
ilg.Emit(OpCodes.Ldloc, paramName);
334-
ilg.Emit(OpCodes.Call, typeof(string).GetMethod(nameof(string.Format), new[] {typeof(string), typeof(object)}));
334+
ilg.Emit(OpCodes.Ldstr, type.Name);
335+
ilg.Emit(OpCodes.Call, typeof(string).GetMethod(nameof(string.Format), new[] {typeof(string), typeof(object), typeof(object)}));
335336
throwException();
336337
}
337338
ilg.MarkLabel(lblValuesOk);

0 commit comments

Comments
 (0)