Skip to content

Commit

Permalink
naming, linting
Browse files Browse the repository at this point in the history
  • Loading branch information
WAcry authored and nblumhardt committed Oct 30, 2024
1 parent 29137db commit abf32a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/Serilog/Capturing/PropertyValueConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ IEnumerable<KeyValuePair<ScalarValue, LogEventPropertyValue>> MapToDictionaryEle
}
}

// To handle multidimensional arrays.
if (value is Array array && array.Rank > 1)
{
result = BuildArrayValue(array, new int[array.Rank], 0, destructuring);
Expand Down
18 changes: 9 additions & 9 deletions test/Serilog.Tests/Core/LoggerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,39 +319,39 @@ public void NullMessageTemplateParametersDoNotBreakBinding()

// https://github.com/serilog/serilog/issues/2019
[Fact]
public void Two_Dimensional_Array_Should_Be_Logger_As_Sequence()
public void TwoDimensionalArrayShouldBeLoggedAsSequence()
{
var evt = DelegatingSink.GetLogEvent(l =>
{
var a = new object[3, 2] { { "a", "b" }, { "c", "d" }, { "e", "f" } };
l.Error("{@Value}", a);
});

Assert.Equal(1, evt.Properties.Count);
Assert.Single(evt.Properties);
var arr = (SequenceValue)evt.Properties["Value"];
Assert.Equal(3, arr.Elements.Count);
Assert.Equal("[[a,b],[c,d],[e,f]]", arr.LiteralValue());
}

// https://github.com/serilog/serilog/issues/2019
[Fact]
public void Three_Dimensional_Array_Should_Be_Logger_As_Sequence()
public void ThreeDimensionalArrayShouldBeLoggedAsSequence()
{
var evt = DelegatingSink.GetLogEvent(l =>
{
var a = new object[3, 2, 1] { { { "a" }, { "b" } }, { { "c" }, { "d" } }, { { "e" }, { "f" } } };
l.Error("{@Value}", a);
});

Assert.Equal(1, evt.Properties.Count);
Assert.Single(evt.Properties);
var arr = (SequenceValue)evt.Properties["Value"];
Assert.Equal(3, arr.Elements.Count);
Assert.Equal("[[[a],[b]],[[c],[d]],[[e],[f]]]", arr.LiteralValue());
}

// https://github.com/serilog/serilog/issues/2019
[Fact]
public void Four_Dimensional_Array_Should_Be_Logged_As_Sequence()
public void FourDimensionalArrayShouldBeLoggedAsSequence()
{
var evt = DelegatingSink.GetLogEvent(l =>
{
Expand Down Expand Up @@ -381,15 +381,15 @@ public void Four_Dimensional_Array_Should_Be_Logged_As_Sequence()
l.Error("{@Value}", a);
});

Assert.Equal(1, evt.Properties.Count);
Assert.Single(evt.Properties);
var arr = (SequenceValue)evt.Properties["Value"];
Assert.Equal(2, arr.Elements.Count);
Assert.Equal("[[[[a,b],[c,d]],[[e,f],[g,h]]],[[[i,j],[k,l]],[[m,n],[o,p]]]]", arr.LiteralValue());
}

// https://github.com/serilog/serilog/issues/2019
[Fact]
public void Empty_Multi_Dimensional_Arrays_Should_Be_Serialized() // Same behaviour as Newtonsoft.Json
public void EmptyMultiDimensionalArraysShouldBeSerializedProperly() // Same behaviour as Newtonsoft.Json
{
var evt = DelegatingSink.GetLogEvent(l =>
{
Expand All @@ -410,7 +410,7 @@ public void Empty_Multi_Dimensional_Arrays_Should_Be_Serialized() // Same behavi

// https://github.com/serilog/serilog/issues/2019
[Fact]
public void JaggedArray_Should_Respect_MaximumCollectionCount()
public void JaggedArrayShouldRespectMaximumCollectionCount()
{
// Arrange
var collectingSink = new CollectingSink();
Expand Down Expand Up @@ -449,7 +449,7 @@ public void JaggedArray_Should_Respect_MaximumCollectionCount()

// https://github.com/serilog/serilog/issues/2019
[Fact]
public void MultiDimensionalArray_Should_Respect_MaximumCollectionCount()
public void MultiDimensionalArrayShouldRespectMaximumCollectionCount()
{
// Arrange
var collectingSink = new CollectingSink();
Expand Down

0 comments on commit abf32a1

Please sign in to comment.