diff --git a/src/Serilog.Expressions/Expressions/Compilation/Linq/Intrinsics.cs b/src/Serilog.Expressions/Expressions/Compilation/Linq/Intrinsics.cs index 17ad067..47f6e8b 100644 --- a/src/Serilog.Expressions/Expressions/Compilation/Linq/Intrinsics.cs +++ b/src/Serilog.Expressions/Expressions/Compilation/Linq/Intrinsics.cs @@ -20,7 +20,6 @@ using System.Text.RegularExpressions; using Serilog.Events; using Serilog.Expressions.Runtime; -using Serilog.Formatting.Display; using Serilog.Parsing; using Serilog.Templates.Compilation; @@ -32,7 +31,7 @@ static class Intrinsics { static readonly LogEventPropertyValue NegativeOne = new ScalarValue(-1); static readonly LogEventPropertyValue Tombstone = new ScalarValue("😬 (if you see this you have found a bug.)"); - + public static List CollectSequenceElements(LogEventPropertyValue?[] elements) { return elements.ToList(); @@ -53,7 +52,7 @@ static class Intrinsics if (content is SequenceValue sequence) foreach (var element in sequence.Elements) elements.Add(element); - + return elements; } @@ -61,10 +60,10 @@ public static LogEventPropertyValue ConstructSequenceValue(List el == null)) return new SequenceValue(elements.Where(el => el != null)); - + return new SequenceValue(elements); } - + public static List CollectStructureProperties(string[] names, LogEventPropertyValue?[] values) { var properties = new List(); @@ -85,7 +84,7 @@ public static LogEventPropertyValue ConstructStructureValue(List ExtendStructureValueWithSpread( List properties, LogEventPropertyValue? content) @@ -99,7 +98,7 @@ public static List ExtendStructureValueWithSpread( return properties; } - + public static List ExtendStructureValueWithProperty( List properties, string name, @@ -129,7 +128,7 @@ public static bool CoerceToScalarBoolean(LogEventPropertyValue value) return b; return false; } - + public static LogEventPropertyValue? IndexOfMatch(LogEventPropertyValue value, Regex regex) { if (value is ScalarValue scalar && @@ -193,9 +192,9 @@ public static string RenderMessage(CompiledMessageToken formatter, EvaluationCon if (token is PropertyToken {Format: { }} pt) { elements ??= new List(); - + var space = new StringWriter(); - + pt.Render(logEvent.Properties, space, formatProvider); elements.Add(new ScalarValue(space.ToString())); } diff --git a/src/Serilog.Expressions/Templates/ExpressionTemplate.cs b/src/Serilog.Expressions/Templates/ExpressionTemplate.cs index b463545..6987db8 100644 --- a/src/Serilog.Expressions/Templates/ExpressionTemplate.cs +++ b/src/Serilog.Expressions/Templates/ExpressionTemplate.cs @@ -17,7 +17,6 @@ using System.IO; using Serilog.Events; using Serilog.Expressions; -using Serilog.Expressions.Compilation; using Serilog.Formatting; using Serilog.Templates.Compilation; using Serilog.Templates.Compilation.NameResolution; @@ -32,7 +31,7 @@ namespace Serilog.Templates public class ExpressionTemplate : ITextFormatter { readonly CompiledTemplate _compiled; - + /// /// Construct an . /// @@ -89,10 +88,10 @@ public static bool TryParse( formatProvider, TemplateFunctionNameResolver.Build(nameResolver, planned), SelectTheme(theme, applyThemeWhenOutputIsRedirected))); - + return true; } - + ExpressionTemplate(CompiledTemplate compiled) { _compiled = compiled; @@ -121,9 +120,9 @@ public ExpressionTemplate( var templateParser = new TemplateParser(); if (!templateParser.TryParse(template, out var parsed, out var error)) throw new ArgumentException(error); - + var planned = TemplateLocalNameBinder.BindLocalValueNames(parsed); - + _compiled = TemplateCompiler.Compile( planned, formatProvider, diff --git a/test/Serilog.Expressions.PerformanceTests/Serilog.Expressions.PerformanceTests.csproj b/test/Serilog.Expressions.PerformanceTests/Serilog.Expressions.PerformanceTests.csproj index 3f0032d..db09896 100644 --- a/test/Serilog.Expressions.PerformanceTests/Serilog.Expressions.PerformanceTests.csproj +++ b/test/Serilog.Expressions.PerformanceTests/Serilog.Expressions.PerformanceTests.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.1 + net5.0 true diff --git a/test/Serilog.Expressions.PerformanceTests/Support/NullSink.cs b/test/Serilog.Expressions.PerformanceTests/Support/NullSink.cs deleted file mode 100644 index 88cb50a..0000000 --- a/test/Serilog.Expressions.PerformanceTests/Support/NullSink.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Serilog.Core; -using Serilog.Events; - -namespace Serilog.Expressions.PerformanceTests.Support -{ - public class NullSink : ILogEventSink - { - public void Emit(LogEvent logEvent) - { - } - } -} diff --git a/test/Serilog.Expressions.Tests/ExpressionEvaluationTests.cs b/test/Serilog.Expressions.Tests/ExpressionEvaluationTests.cs index b741159..69bc92a 100644 --- a/test/Serilog.Expressions.Tests/ExpressionEvaluationTests.cs +++ b/test/Serilog.Expressions.Tests/ExpressionEvaluationTests.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Globalization; -using System.IO; -using System.Linq; using Serilog.Events; using Serilog.Expressions.Runtime; using Serilog.Expressions.Tests.Support; diff --git a/test/Serilog.Expressions.Tests/Expressions/NameResolverTests.cs b/test/Serilog.Expressions.Tests/Expressions/NameResolverTests.cs index edbf18a..d4c256a 100644 --- a/test/Serilog.Expressions.Tests/Expressions/NameResolverTests.cs +++ b/test/Serilog.Expressions.Tests/Expressions/NameResolverTests.cs @@ -5,8 +5,6 @@ using Serilog.Expressions.Tests.Support; using Xunit; -#nullable enable - namespace Serilog.Expressions.Tests.Expressions { public class NameResolverTests @@ -15,7 +13,7 @@ public class NameResolverTests { if (!Coerce.Numeric(number, out var num)) return null; - + return new ScalarValue(num + 42); } @@ -23,7 +21,7 @@ public class NameResolverTests { if (!Coerce.Numeric(index, out var i)) return null; - + return new ScalarValue(word[(int)i].ToString()); } @@ -62,7 +60,7 @@ public void UserDefinedFunctionsAreCallableInExpressions() nameResolver: new StaticMemberNameResolver(typeof(NameResolverTests))); Assert.True(Coerce.IsTrue(expr(Some.InformationEvent()))); } - + [Fact] public void UserDefinedFunctionsCanReceiveUserProvidedParameters() {