Skip to content

Commit

Permalink
Get already configured policy (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
sungam3r authored Jan 22, 2024
1 parent a52ba95 commit c96dbf8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Benchmarks/JsonNetBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ private class HasName
}

private ILogEventPropertyValueFactory _factory = null!;
private IDestructuringPolicy _policy = null!;
private object _value = null!;
private readonly JsonNetDestructuringPolicy _policy = new();

[GlobalSetup]
public void Setup()
Expand Down Expand Up @@ -59,6 +59,8 @@ public void Setup()
var processor = log.GetType().GetField("_messageTemplateProcessor", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)!.GetValue(log)!;
var converter = processor.GetType().GetField("_propertyValueConverter", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)!.GetValue(processor)!;
_factory = (ILogEventPropertyValueFactory)converter;
var policies = (IDestructuringPolicy[])converter.GetType().GetField("_destructuringPolicies", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)!.GetValue(converter)!;
_policy = policies.First(p => p is JsonNetDestructuringPolicy);
}

[Benchmark]
Expand Down

0 comments on commit c96dbf8

Please sign in to comment.