Skip to content

Fix exceptions serialization #1514

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

Merged
merged 1 commit into from
Jan 8, 2018

Conversation

hazzik
Copy link
Member

@hazzik hazzik commented Jan 5, 2018

This is a partial rework of #1469 in a non-breaking way concerning only exceptions.

@hazzik hazzik added this to the 5.1 milestone Jan 5, 2018
var typeName = entry.Value?.ToString();
if (!string.IsNullOrEmpty(typeName))
TargetType = System.Type.GetType(typeName, true);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When having many values, a switch seems more appropriate.

switch (entry.Name)
{
	case "PropertyName":
		PropertyName = entry.Value?.ToString();
		break;
	case "AccessorType":
		AccessorType= entry.Value?.ToString();
		break;
	case "TargetType":
		var typeName = entry.Value?.ToString();
		if (!string.IsNullOrEmpty(typeName))
			TargetType = System.Type.GetType(typeName, true);
		break;
}

(DuplicateMappingException and LazyInitializationException have two values, others only one.)

Copy link
Member Author

@hazzik hazzik Jan 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did consider this option and even written it this way at first, but for some reasons decided against it. The underlying byte-code would be the same anyway.

@@ -16,7 +18,7 @@ public SchemaValidationException(string msg, IList<string> validationErrors) : b

protected SchemaValidationException(SerializationInfo info, StreamingContext context) : base(info, context)
{
ValidationErrors =
ValidationErrors =
(ReadOnlyCollection<string>) info.GetValue("ValidationErrors", typeof(ReadOnlyCollection<string>));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undue added space.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force-pushed with revert

@hazzik hazzik force-pushed the exceptions-serialization-fixes branch from 37aefbd to db61060 Compare January 8, 2018 21:55
@hazzik hazzik merged commit db61060 into nhibernate:master Jan 8, 2018
@hazzik hazzik added the r: Fixed label Jan 8, 2018
@hazzik hazzik deleted the exceptions-serialization-fixes branch June 17, 2018 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants