diff --git a/README.md b/README.md
index 48db483..f894ca2 100644
--- a/README.md
+++ b/README.md
@@ -55,7 +55,7 @@ public class PersonalData
public string? Name { get; set; }
}
```
-snippet source | anchor
+snippet source | anchor
## 2. Ignoring a property
diff --git a/src/Destructurama.Attributed.Tests/LogWithNameAttributeTests.cs b/src/Destructurama.Attributed.Tests/LogWithNameAttributeTests.cs
index 5df0433..6df87c1 100644
--- a/src/Destructurama.Attributed.Tests/LogWithNameAttributeTests.cs
+++ b/src/Destructurama.Attributed.Tests/LogWithNameAttributeTests.cs
@@ -26,6 +26,41 @@ public void AttributesAreConsultedWhenDestructuring(string name)
literalValue.ShouldBe(name);
}
+ // https://github.com/destructurama/attributed/issues/65
+ [Test]
+ public void Issue65()
+ {
+ var customized = new MessageBase
+ {
+ Context = new ContextClass(),
+ };
+ var evt = DelegatingSink.Execute(customized);
+ var sv = (StructureValue)evt.Properties["Customized"];
+ sv.Properties.Count.ShouldBe(1);
+ sv.Properties[0].Name.ShouldBe("messageContext");
+ var sv2 = sv.Properties[0].Value.ShouldBeOfType();
+ sv2.Properties.Count.ShouldBe(2);
+ sv2.Properties[0].Name.ShouldBe("Foo");
+ sv2.Properties[1].Name.ShouldBe("Bar");
+ sv2.Properties[0].Value.LiteralValue().ShouldBe("MyFoo");
+ sv2.Properties[1].Value.LiteralValue().ShouldBe("MyBar");
+ }
+
+ public class MessageBase
+ {
+ [LogWithName("messageContext")]
+ public ContextClass? Context { get; set; }
+ }
+
+ public class ContextClass
+ {
+ public string Foo { get; set; } = "MyFoo";
+
+ public string Bar { get; set; } = "MyBar";
+
+ public override string ToString() => "ContextClass ToString Output";
+ }
+
#region LogWithName
public class PersonalData
{
diff --git a/src/Destructurama.Attributed.Tests/Support/DelegatingSink.cs b/src/Destructurama.Attributed.Tests/Support/DelegatingSink.cs
index eac333d..a8c00b5 100644
--- a/src/Destructurama.Attributed.Tests/Support/DelegatingSink.cs
+++ b/src/Destructurama.Attributed.Tests/Support/DelegatingSink.cs
@@ -28,5 +28,4 @@ public static LogEvent Execute(object obj, string messageTemplate = "Here is {@C
return evt;
}
-
}
diff --git a/src/Destructurama.Attributed/Attributed/LogWithNameAttribute.cs b/src/Destructurama.Attributed/Attributed/LogWithNameAttribute.cs
index 629fab5..62d0654 100644
--- a/src/Destructurama.Attributed/Attributed/LogWithNameAttribute.cs
+++ b/src/Destructurama.Attributed/Attributed/LogWithNameAttribute.cs
@@ -38,7 +38,7 @@ public LogWithNameAttribute(string newName)
///
public bool TryCreateLogEventProperty(string name, object? value, ILogEventPropertyValueFactory propertyValueFactory, [NotNullWhen(true)] out LogEventProperty? property)
{
- property = new LogEventProperty(_newName, propertyValueFactory.CreatePropertyValue(value));
+ property = new LogEventProperty(_newName, propertyValueFactory.CreatePropertyValue(value, destructureObjects: true));
return true;
}
}