Skip to content

Commit c96dbf8

Browse files
authored
Get already configured policy (#30)
1 parent a52ba95 commit c96dbf8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Benchmarks/JsonNetBenchmarks.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ private class HasName
2929
}
3030

3131
private ILogEventPropertyValueFactory _factory = null!;
32+
private IDestructuringPolicy _policy = null!;
3233
private object _value = null!;
33-
private readonly JsonNetDestructuringPolicy _policy = new();
3434

3535
[GlobalSetup]
3636
public void Setup()
@@ -59,6 +59,8 @@ public void Setup()
5959
var processor = log.GetType().GetField("_messageTemplateProcessor", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)!.GetValue(log)!;
6060
var converter = processor.GetType().GetField("_propertyValueConverter", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)!.GetValue(processor)!;
6161
_factory = (ILogEventPropertyValueFactory)converter;
62+
var policies = (IDestructuringPolicy[])converter.GetType().GetField("_destructuringPolicies", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)!.GetValue(converter)!;
63+
_policy = policies.First(p => p is JsonNetDestructuringPolicy);
6264
}
6365

6466
[Benchmark]

0 commit comments

Comments
 (0)