-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Fix don't serialize DbContext #117
Fix don't serialize DbContext #117
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.
Just one very quick question in the review. Apart from that, it all looks good to me. I'll merge and release soon after.
@@ -329,6 +329,11 @@ private ReflectionInfo GenerateReflectionInfoForType(Type valueType) | |||
{ | |||
try | |||
{ | |||
if (values.ContainsKey(property.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.
Can you explain this change a little? I think it's just making sure that no duplicates are added. Is that something that can happen?
Perhaps a unit test would also help explain and test 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.
I agree with @RehanSaeed, I reviewed the code and since we iterate over properties name generated by reflection there is no possibility of duplicates.
I would suggest removing the code unless you can demonstrate in the unit test that there is a possibility to introduce duplicates here.
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.
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.
Good spot on this Joel! If this was a separate PR, I think we could have merged now but no worries!
I'm not sure if we should ignore the property if we find a duplicate. We should probably add something to the end of the name and add it, so we don't lost anything. Thoughts @krajek?
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.
I had the same thoughts yesterday.
For sure, dropping one of the properties is not the way to go.
We already had similar issue with Type
property name.
if (propertiesBag.ContainsProperty("Type"))
{
if (!propertiesBag.ContainsProperty("$Type"))
{
propertiesBag.AddProperty("$Type", valueType.FullName);
}
else
{
// If both "Type" and "$Type" are present
// we just give up appending exception type
}
}
else
{
propertiesBag.AddProperty("Type", valueType.FullName);
}
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.
In theory, there could be more than one property like this, so we should append something random to the end of the property 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.
If this was a separate PR, I think we could have merged now but no worries!
It would still have to wait on the separate PR 😜, I noticed it because of this
What do you guys think of prepending the Namespace.TypeName
if there is a collision?
private class ReflectionPropertyInfo
{
public string Name { get; set; }
public Type DeclaringType { get; set; }
public Func<object, object> Getter { get; set; }
}
...
var key = values.ContainsKey(property.Name) ? $"{property.DeclaringType.FullName}.{property.Name}" : property.Name;
values.Add(key, destructuredValue);
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.
That sounds like a great idea.
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.
Done.
Tests/Serilog.Exceptions.Test/Destructurers/ReflectionBasedDestructurerTest.cs
Outdated
Show resolved
Hide resolved
I forgot to mention that we should also mention that this NuGet package exists in the ReadMe.md file. |
As thanks, I've listed you as a contributor on the front page: https://github.com/RehanSaeed/Serilog.Exceptions/blob/master/README.md |
Done, I added a note about Serilog.Exceptions.SqlServer as well, feel free to change the documentation to your liking. |
The build is failing. I think that is because The @krajek Are you happy? It looks good to me. |
Merged. I'll fix up the boken build and release. Thanks for your contribution. |
PR for #100