Skip to content

Commit

Permalink
use some lambda expressions (#1731)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Aug 25, 2022
1 parent ec15a62 commit 0ecc14b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
7 changes: 2 additions & 5 deletions src/Serilog/Filters/Matching.cs
Expand Up @@ -80,11 +80,8 @@ public static class Matching
if (propertyName == null) throw new ArgumentNullException(nameof(propertyName));

var scalar = new ScalarValue(scalarValue);
return e =>
{
return e.Properties.TryGetValue(propertyName, out var propertyValue) &&
scalar.Equals(propertyValue);
};
return e => e.Properties.TryGetValue(propertyName, out var propertyValue) &&
scalar.Equals(propertyValue);
}

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions test/Serilog.Tests/Core/AuditSinkTests.cs
Expand Up @@ -11,7 +11,7 @@ public class AuditSinkTests
public void ExceptionsThrownByAuditSinksArePropagated()
{
var logger = new LoggerConfiguration()
.AuditTo.Sink(new DelegatingSink(_ => { throw new Exception("Boom!"); }))
.AuditTo.Sink(new DelegatingSink(_ => throw new Exception("Boom!")))
.CreateLogger();

Assert.Throws<AggregateException>(() => logger.Write(Some.InformationEvent()));
Expand All @@ -22,7 +22,7 @@ public void ExceptionsThrownByFiltersArePropagatedIfAuditingEnabled()
{
var logger = new LoggerConfiguration()
.AuditTo.Sink(new DelegatingSink(_ => { }))
.Filter.ByExcluding(_ => { throw new Exception("Boom!"); })
.Filter.ByExcluding(_ => throw new Exception("Boom!"))
.CreateLogger();

Assert.Throws<Exception>(() => logger.Write(Some.InformationEvent()));
Expand All @@ -32,7 +32,7 @@ public void ExceptionsThrownByFiltersArePropagatedIfAuditingEnabled()
public void ExceptionsThrownByAuditSinksArePropagatedFromChildLoggers()
{
var logger = new LoggerConfiguration()
.AuditTo.Sink(new DelegatingSink(_ => { throw new Exception("Boom!"); }))
.AuditTo.Sink(new DelegatingSink(_ => throw new Exception("Boom!")))
.CreateLogger();

Assert.Throws<AggregateException>(() => logger
Expand All @@ -45,7 +45,7 @@ public void ExceptionsThrownByDestructuringPoliciesArePropagatedIfAuditingEnable
{
var logger = new LoggerConfiguration()
.AuditTo.Sink(new CollectingSink())
.Destructure.ByTransforming<Value>(_ => { throw new Exception("Boom!"); })
.Destructure.ByTransforming<Value>(_ => throw new Exception("Boom!"))
.CreateLogger();

Assert.Throws<Exception>(() => logger.Information("{@Value}", new Value()));
Expand Down
2 changes: 1 addition & 1 deletion test/Serilog.Tests/Core/SafeAggregateSinkTests.cs
Expand Up @@ -29,7 +29,7 @@ public void WhenASinkThrowsOtherSinksAreStillInvoked()

var s = new SafeAggregateSink(new[] {
new DelegatingSink(_ => called1 = true),
new DelegatingSink(_ => { throw new Exception("No go, pal."); }),
new DelegatingSink(_ => throw new Exception("No go, pal.")),
new DelegatingSink(_ => called2 = true)
});

Expand Down

0 comments on commit 0ecc14b

Please sign in to comment.