You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
yesterday I encountered an exception with a really ambiguous message of what went wrong.
The InvalidOperationException was thrown in MetaBodyWriter class on line 134.
It's in this method: private static string GetMessageContractBodyName(Type type) { if (!TryGetMessageContractBodyMemberInfo(type, out var memberInfo)) { throw new InvalidOperationException(nameof(type)); }
return memberInfo.Name; }
The exception thrown with omitted stack trace looked like this: Unhandled exception. System.InvalidOperationException: type
Proposed solution
I would like to propose using type.ToString() instead of nameof(type) as the InvalidOperationException message.
So the exception message would look something like this: System.InvalidOperationException: The.Types.Namespace.TypeClass
Or even better, add a descriptive message of what is wrong with the type argument and add it's type.ToString() to the new message.
Other remarks
The same problem is present in the same class in an another method called GetMessageContractBodyType at line 120
I could fix this myself, but if you want more descriptive messages I would need examples.
I apologize but English is not my main language. If anything I wrote is not clear I would be more than happy to clarify.
Thanks!
The text was updated successfully, but these errors were encountered:
Issue description
Hello,
yesterday I encountered an exception with a really ambiguous message of what went wrong.
The InvalidOperationException was thrown in MetaBodyWriter class on line 134.
It's in this method:
private static string GetMessageContractBodyName(Type type)
{
if (!TryGetMessageContractBodyMemberInfo(type, out var memberInfo))
{
throw new InvalidOperationException(nameof(type));
}
return memberInfo.Name;
}
The exception thrown with omitted stack trace looked like this:
Unhandled exception. System.InvalidOperationException: type
Proposed solution
I would like to propose using
type.ToString()
instead ofnameof(type)
as the InvalidOperationException message.So the exception message would look something like this:
System.InvalidOperationException: The.Types.Namespace.TypeClass
Or even better, add a descriptive message of what is wrong with the
type
argument and add it'stype.ToString()
to the new message.Other remarks
The same problem is present in the same class in an another method called
GetMessageContractBodyType
at line 120I could fix this myself, but if you want more descriptive messages I would need examples.
I apologize but English is not my main language. If anything I wrote is not clear I would be more than happy to clarify.
Thanks!
The text was updated successfully, but these errors were encountered: