Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency xunit to v2.4.2 #548

Merged
merged 2 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Source/Serilog.Exceptions/Core/ExceptionEnricher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@ public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
var exceptionType = exception.GetType();

if (this.destructurers.ContainsKey(exceptionType))
if (this.destructurers.TryGetValue(exceptionType, out var destructurer))
{
var data = new ExceptionPropertiesBag(exception, this.destructuringOptions.Filter);

var destructurer = this.destructurers[exceptionType];
destructurer.Destructure(exception, data, this.DestructureException);

return data.GetResultDictionary();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ public void Destructure(
private static string? GetOrGenerateRefId(ref int nextCyclicRefId, IDictionary<string, object?> destructuredObject)
{
string? refId;
if (destructuredObject.ContainsKey(IdLabel))
if (destructuredObject.TryGetValue(IdLabel, out var value))
{
refId = (string?)destructuredObject[IdLabel];
refId = (string?)value;
}
else
{
Expand Down Expand Up @@ -269,9 +269,8 @@ private object DestructureValueDictionary(
IDictionary<object, IDictionary<string, object?>> destructuredObjects,
ref int nextCyclicRefId)
{
if (destructuredObjects.ContainsKey(value))
if (destructuredObjects.TryGetValue(value, out var destructuredObject))
{
var destructuredObject = destructuredObjects[value];
var refId = GetOrGenerateRefId(ref nextCyclicRefId, destructuredObject);

return new Dictionary<string, object?>
Expand Down Expand Up @@ -299,9 +298,8 @@ private object DestructureValueDictionary(
IDictionary<object, IDictionary<string, object?>> destructuredObjects,
ref int nextCyclicRefId)
{
if (destructuredObjects.ContainsKey(value))
if (destructuredObjects.TryGetValue(value, out var destructuredObject))
{
var destructuredObject = destructuredObjects[value];
var refId = GetOrGenerateRefId(ref nextCyclicRefId, destructuredObject);

return new Dictionary<string, object?>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ private static void MarkRedefinedPropertiesWithFullName(ReflectionPropertyInfo[]
var groupedByName = new Dictionary<string, List<ReflectionPropertyInfo>>();
foreach (var propertyInfo in propertyInfos)
{
if (groupedByName.ContainsKey(propertyInfo.Name))
if (groupedByName.TryGetValue(propertyInfo.Name, out var value))
{
groupedByName[propertyInfo.Name].Add(propertyInfo);
value.Add(propertyInfo);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="Moq" Version="4.18.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" PrivateAssets="All" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ public void DestructureComplexException_EachTypeOfPropertyIsDestructuredAsExpect
Assert.DoesNotContain(properties, x => string.Equals(x.Key, "PrivateProperty", StringComparison.Ordinal));
Assert.Equal("MessageValue", properties[nameof(TestException.Message)]);
#if NET461 || NET472
Assert.StartsWith("Void DestructureComplexException_EachTypeOfPropertyIsDestructuredAsExpected(", properties[nameof(TestException.TargetSite)].ToString());
Assert.StartsWith("Void DestructureComplexException_EachTypeOfPropertyIsDestructuredAsExpected(", properties[nameof(TestException.TargetSite)].ToString());
#endif
Assert.NotEmpty(properties[nameof(TestException.StackTrace)]?.ToString());
Assert.NotNull(properties[nameof(TestException.StackTrace)]?.ToString());
Assert.NotEmpty(properties[nameof(TestException.StackTrace)]?.ToString()!);
Assert.Equal("Serilog.Exceptions.Test", properties[nameof(TestException.Source)]);
Assert.Equal(-2146233088, properties[nameof(TestException.HResult)]);
Assert.Contains(typeof(TestException).FullName, properties["Type"]?.ToString(), StringComparison.Ordinal);
Assert.Contains(typeof(TestException).FullName!, properties["Type"]?.ToString(), StringComparison.Ordinal);
}

[Fact]
Expand Down