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
So, my question is, could not the runtime do something like below and improve the exception message by having both the "From" and the "To" in its message?
auto thCastFrom = obj->GetTypeHandle();
auto thCastTo = TypeHandle(boxTypeClsHnd);
RealCOMPlusThrowInvalidCastException(thCastFrom, thCastTo);
I am still trying to compile the coreclr repository to make deeper analysis, so forget me if there is something obvious that I am no seeing.
The text was updated successfully, but these errors were encountered:
I was analyzing the runtime code and realized that maybe it is possible to improve the unbox.any exception message with the involved types.
For more details see:
http://stackoverflow.com/questions/39914845/why-does-unbox-any-not-provide-a-helpful-exception-text-the-way-castclass-do
For example:
As far as I understood, the runtime will step through these functions:
wich will throw the InvalidCastException
COMPlusThrow(kInvalidCastException, IDS_EE_CANNOTCAST, strCastFromName.GetUnicode(), strCastToName.GetUnicode());
This exception is detailed, it has both the castFromName and the castToName.
But with the following IL:
The runtime will call this function
at
https://github.com/dotnet/coreclr/blob/32f0f9721afb584b4a14d69135bea7ddc129f755/src/vm/interpreter.cpp#L8766
for some reason the exception is thrown as
COMPlusThrow(kInvalidCastException);
So, my question is, could not the runtime do something like below and improve the exception message by having both the "From" and the "To" in its message?
I am still trying to compile the coreclr repository to make deeper analysis, so forget me if there is something obvious that I am no seeing.
The text was updated successfully, but these errors were encountered: