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

use some lambda expressions #1731

Merged
merged 2 commits into from Aug 25, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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