-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cross-platform exception serialization support #7222
Add cross-platform exception serialization support #7222
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self review
@@ -82,6 +83,11 @@ public Proto.Msg.ExceptionData ExceptionToProtoNet(Exception exception) | |||
message.StackTrace = exception.StackTrace ?? ""; | |||
message.Source = exception.Source ?? ""; | |||
message.InnerException = ExceptionToProto(exception.InnerException); | |||
|
|||
var forwardedFrom = exceptionType.GetCustomAttribute<TypeForwardedFromAttribute>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.NET standard introduced this attribute to mark a type as being moved from a different assembly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, that would have been good to know a long time ago lol
if (exceptionType is null && proto.TypeForwardedFrom != string.Empty) | ||
{ | ||
var typeName = $"{proto.TypeName[..proto.TypeName.IndexOf(',')]}, {proto.TypeForwardedFrom}"; | ||
exceptionType = Type.GetType(typeName); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retry type loading with a different assembly name, if the type was marked as moved from an older assembly name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -69,6 +69,7 @@ message ExceptionData { | |||
string source = 4; | |||
ExceptionData innerException = 5; | |||
map<string, Payload> customFields = 6; | |||
string typeForwardedFrom = 7; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a single entry in the .proto file
Limiting the blast radius of this change to remoting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
if (exceptionType is null && proto.TypeForwardedFrom != string.Empty) | ||
{ | ||
var typeName = $"{proto.TypeName[..proto.TypeName.IndexOf(',')]}, {proto.TypeForwardedFrom}"; | ||
exceptionType = Type.GetType(typeName); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Discussed with @Arkatufus - we're gonna add a repro to this before we merge it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes #7215
Changes
Embed
TypeForwardedFromAttribute
data inside the wire format so we can mapSystem.Private.Corlib
tomscorlib
types.Checklist
For significant changes, please ensure that the following have been completed (delete if not relevant):