Skip to content

Commit e81c8c5

Browse files
authored
Merge pull request #48 from SimonCropp/cleanup
A few minor cleanups
2 parents 8941cda + 36b280a commit e81c8c5

File tree

6 files changed

+19
-37
lines changed

6 files changed

+19
-37
lines changed

src/Serilog.Expressions/Expressions/Compilation/Linq/Intrinsics.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
using System.Text.RegularExpressions;
2121
using Serilog.Events;
2222
using Serilog.Expressions.Runtime;
23-
using Serilog.Formatting.Display;
2423
using Serilog.Parsing;
2524
using Serilog.Templates.Compilation;
2625

@@ -32,7 +31,7 @@ static class Intrinsics
3231
{
3332
static readonly LogEventPropertyValue NegativeOne = new ScalarValue(-1);
3433
static readonly LogEventPropertyValue Tombstone = new ScalarValue("😬 (if you see this you have found a bug.)");
35-
34+
3635
public static List<LogEventPropertyValue?> CollectSequenceElements(LogEventPropertyValue?[] elements)
3736
{
3837
return elements.ToList();
@@ -53,18 +52,18 @@ static class Intrinsics
5352
if (content is SequenceValue sequence)
5453
foreach (var element in sequence.Elements)
5554
elements.Add(element);
56-
55+
5756
return elements;
5857
}
5958

6059
public static LogEventPropertyValue ConstructSequenceValue(List<LogEventPropertyValue?> elements)
6160
{
6261
if (elements.Any(el => el == null))
6362
return new SequenceValue(elements.Where(el => el != null));
64-
63+
6564
return new SequenceValue(elements);
6665
}
67-
66+
6867
public static List<LogEventProperty> CollectStructureProperties(string[] names, LogEventPropertyValue?[] values)
6968
{
7069
var properties = new List<LogEventProperty>();
@@ -85,7 +84,7 @@ public static LogEventPropertyValue ConstructStructureValue(List<LogEventPropert
8584

8685
return new StructureValue(properties);
8786
}
88-
87+
8988
public static List<LogEventProperty> ExtendStructureValueWithSpread(
9089
List<LogEventProperty> properties,
9190
LogEventPropertyValue? content)
@@ -99,7 +98,7 @@ public static List<LogEventProperty> ExtendStructureValueWithSpread(
9998

10099
return properties;
101100
}
102-
101+
103102
public static List<LogEventProperty> ExtendStructureValueWithProperty(
104103
List<LogEventProperty> properties,
105104
string name,
@@ -129,7 +128,7 @@ public static bool CoerceToScalarBoolean(LogEventPropertyValue value)
129128
return b;
130129
return false;
131130
}
132-
131+
133132
public static LogEventPropertyValue? IndexOfMatch(LogEventPropertyValue value, Regex regex)
134133
{
135134
if (value is ScalarValue scalar &&
@@ -193,9 +192,9 @@ public static string RenderMessage(CompiledMessageToken formatter, EvaluationCon
193192
if (token is PropertyToken {Format: { }} pt)
194193
{
195194
elements ??= new List<LogEventPropertyValue>();
196-
195+
197196
var space = new StringWriter();
198-
197+
199198
pt.Render(logEvent.Properties, space, formatProvider);
200199
elements.Add(new ScalarValue(space.ToString()));
201200
}

src/Serilog.Expressions/Templates/ExpressionTemplate.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
using System.IO;
1818
using Serilog.Events;
1919
using Serilog.Expressions;
20-
using Serilog.Expressions.Compilation;
2120
using Serilog.Formatting;
2221
using Serilog.Templates.Compilation;
2322
using Serilog.Templates.Compilation.NameResolution;
@@ -32,7 +31,7 @@ namespace Serilog.Templates
3231
public class ExpressionTemplate : ITextFormatter
3332
{
3433
readonly CompiledTemplate _compiled;
35-
34+
3635
/// <summary>
3736
/// Construct an <see cref="ExpressionTemplate"/>.
3837
/// </summary>
@@ -89,10 +88,10 @@ public static bool TryParse(
8988
formatProvider,
9089
TemplateFunctionNameResolver.Build(nameResolver, planned),
9190
SelectTheme(theme, applyThemeWhenOutputIsRedirected)));
92-
91+
9392
return true;
9493
}
95-
94+
9695
ExpressionTemplate(CompiledTemplate compiled)
9796
{
9897
_compiled = compiled;
@@ -121,9 +120,9 @@ public ExpressionTemplate(
121120
var templateParser = new TemplateParser();
122121
if (!templateParser.TryParse(template, out var parsed, out var error))
123122
throw new ArgumentException(error);
124-
123+
125124
var planned = TemplateLocalNameBinder.BindLocalValueNames(parsed);
126-
125+
127126
_compiled = TemplateCompiler.Compile(
128127
planned,
129128
formatProvider,

test/Serilog.Expressions.PerformanceTests/Serilog.Expressions.PerformanceTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net5.0</TargetFramework>
55
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
66
</PropertyGroup>
77

test/Serilog.Expressions.PerformanceTests/Support/NullSink.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

test/Serilog.Expressions.Tests/ExpressionEvaluationTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Globalization;
4-
using System.IO;
5-
using System.Linq;
64
using Serilog.Events;
75
using Serilog.Expressions.Runtime;
86
using Serilog.Expressions.Tests.Support;

test/Serilog.Expressions.Tests/Expressions/NameResolverTests.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
using Serilog.Expressions.Tests.Support;
66
using Xunit;
77

8-
#nullable enable
9-
108
namespace Serilog.Expressions.Tests.Expressions
119
{
1210
public class NameResolverTests
@@ -15,15 +13,15 @@ public class NameResolverTests
1513
{
1614
if (!Coerce.Numeric(number, out var num))
1715
return null;
18-
16+
1917
return new ScalarValue(num + 42);
2018
}
2119

2220
public static LogEventPropertyValue? SecretWordAt(string word, LogEventPropertyValue? index)
2321
{
2422
if (!Coerce.Numeric(index, out var i))
2523
return null;
26-
24+
2725
return new ScalarValue(word[(int)i].ToString());
2826
}
2927

@@ -62,7 +60,7 @@ public void UserDefinedFunctionsAreCallableInExpressions()
6260
nameResolver: new StaticMemberNameResolver(typeof(NameResolverTests)));
6361
Assert.True(Coerce.IsTrue(expr(Some.InformationEvent())));
6462
}
65-
63+
6664
[Fact]
6765
public void UserDefinedFunctionsCanReceiveUserProvidedParameters()
6866
{

0 commit comments

Comments
 (0)