Repository: serilog/serilog

Issue:
Destructuring behaviour of objects with private getter has changed 
**Description**
With the latest version of Serilog it appears that the behaviour of what properties are logged has changed from an earlier version (2.12) 

Here's the old output:
`2024-08-20 09:12:09 [Information] Testing of destructing! OuterObjectToLog { Name: "Test", Description: "My Description" }`

Here's the new output with the same object structure.
`[09:09:52 INF] Testing of destructing! {"Name": "Test", "Description": "My Description", "InnerObject": {"InnerObjectName": "InnerObject", "InnerObjectDescription": "My Inner Object Description", "$type": "InnerObjectNotToLog"}, "$type": "OuterObjectToLog"}`

**Reproduction**
```
using Serilog;

namespace SerilogTest
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                  .WriteTo.Console()
                  .CreateLogger();

            OuterObjectToLog outerObjectToLog = new OuterObjectToLog("Test", "My Description",
                 new InnerObjectNotToLog("InnerObject", "My Inner Object Description"));
                        
            Log.Information("Testing of destructing! {@OuterObject}", outerObjectToLog);            

            // Finally, once just before the application exits...
            Log.CloseAndFlush();
        }
    }

    public class OuterObjectToLog (string name, string description, InnerObjectNotToLog innerObject)    
    {
        public string Name { get; set; } = name;
        public string Description { get; set; } = description;
        **public InnerObjectNotToLog InnerObject { private get; set; } = innerObject;** // note the private getter and likely unexpected 
    }

    public class InnerObjectNotToLog(string name, string description)
    {
        public string InnerObjectName { get; set; } = name;
        public string InnerObjectDescription { get; set; } = description;
    }
}

```

**Expected behavior**
Expecting that the property InnerObject is not included in the serilog output.

**Relevant package, tooling and runtime versions**
Version 4.0.1, .NET 8 on Windows 11.

Likely related to changes made in this commit? https://github.com/serilog/serilog/commit/580c55fd01bd0dc2c4ace63f1308e4c74fd3d95c



Hints:

Patch:
diff --git a/src/Serilog/Capturing/PropertyValueConverter.cs b/src/Serilog/Capturing/PropertyValueConverter.cs
index f113680b6..642fa736b 100644
--- a/src/Serilog/Capturing/PropertyValueConverter.cs
+++ b/src/Serilog/Capturing/PropertyValueConverter.cs
@@ -397,7 +397,7 @@ internal StructureValue CreateStructureValue(object value, [DynamicallyAccessedM
         for (var i = 0; i < properties.Length; ++i)
         {
             var property = properties[i];
-            if (!property.CanRead)
+            if (property.GetMethod == null || !property.GetMethod.IsPublic)
             {
                 continue;
             }


Test patch:
diff --git a/test/Serilog.Tests/Capturing/PropertyValueConverterTests.cs b/test/Serilog.Tests/Capturing/PropertyValueConverterTests.cs
index b0c73ac62..b863df7a9 100644
--- a/test/Serilog.Tests/Capturing/PropertyValueConverterTests.cs
+++ b/test/Serilog.Tests/Capturing/PropertyValueConverterTests.cs
@@ -488,4 +488,18 @@ public class SubclassWithOverride : BaseClass
     {
         public override string Name => "override";
     }
+
+    [Fact]
+    public void PrivateGettersAreIgnoredWhenCapturing()
+    {
+        var structure = _converter.CreateStructureValue(new HasPropertyWithPrivateGetter(), typeof(HasPropertyWithPrivateGetter), false);
+        Assert.Contains(structure.Properties, p => p.Name == "A");
+        Assert.DoesNotContain(structure.Properties, p => p.Name == "B");
+    }
+
+    public class HasPropertyWithPrivateGetter
+    {
+        public string A { get; set; } = "A";
+        public string B { private get; set; } = "B";
+    }
 }