Skip to content

Commit 3198122

Browse files
authored
Merge pull request #117 from nblumhardt/v4-updates
Update to Serilog 4, tidy up
2 parents ed917a8 + fde5bfb commit 3198122

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+190
-151
lines changed

serilog-expressions.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CI/@EntryIndexedValue">CI</s:String>
23
<s:Boolean x:Key="/Default/UserDictionary/Words/=Acerola/@EntryIndexedValue">True</s:Boolean>
34
<s:Boolean x:Key="/Default/UserDictionary/Words/=Comparand/@EntryIndexedValue">True</s:Boolean>
45
<s:Boolean x:Key="/Default/UserDictionary/Words/=delim/@EntryIndexedValue">True</s:Boolean>

src/Serilog.Expressions/Expressions/Ast/AccessorExpression.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414

1515
namespace Serilog.Expressions.Ast;
1616

17+
/// <summary>
18+
/// An accessor retrieves a property from a (structured) object. For example, in the expression
19+
/// <code>Headers.ContentType</code> the <code>.</code> operator forms an accessor expression that
20+
/// retrieves the <code>ContentType</code> property from the <code>Headers</code> object.
21+
/// </summary>
22+
/// <remarks>Note that the AST type can represent accessors that cannot be validly written using
23+
/// <code>.</code> notation. In these cases, if the accessor is formatted back out as an expression,
24+
/// <see cref="IndexerExpression"/> notation will be used.</remarks>
1725
class AccessorExpression : Expression
1826
{
1927
public AccessorExpression(Expression receiver, string memberName)

src/Serilog.Expressions/Expressions/Ast/AmbientNameExpression.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414

1515
namespace Serilog.Expressions.Ast;
1616

17+
/// <summary>
18+
/// An ambient name is generally a property name or built-in that appears standalone in an expression. For example,
19+
/// in <code>Headers.ContentType</code>, <code>Headers</code> is an ambient name that produces an
20+
/// <see cref="AmbientNameExpression"/>. Built-ins like <code>@Level</code> are also parsed as ambient names.
21+
/// </summary>
1722
class AmbientNameExpression : Expression
1823
{
1924
readonly bool _requiresEscape;

src/Serilog.Expressions/Expressions/Ast/ArrayExpression.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414

1515
namespace Serilog.Expressions.Ast;
1616

17+
/// <summary>
18+
/// An array expression constructs an array from a list of elements. For example, <code>[1, 2, 3]</code> is an
19+
/// array expression. The items in an array expression can be literal values or expressions, like in the
20+
/// above example, or they can be spread expressions that describe zero or more elements to include in the
21+
/// list. Whether included via regular elements or spread expressions, undefined values are ignored and won't
22+
/// appear in the resulting array value.
23+
/// </summary>
1724
class ArrayExpression : Expression
1825
{
1926
public ArrayExpression(Element[] elements)

src/Serilog.Expressions/Expressions/Ast/CallExpression.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414

1515
namespace Serilog.Expressions.Ast;
1616

17+
/// <summary>
18+
/// A <see cref="CallExpression"/> is a function call made up of the function name, parenthesised argument
19+
/// list, and optional postfix <code>ci</code> modifier. For example, <code>Substring(RequestPath, 0, 5)</code>.
20+
/// </summary>
1721
class CallExpression : Expression
1822
{
1923
public CallExpression(bool ignoreCase, string operatorName, params Expression[] operands)

src/Serilog.Expressions/Expressions/Ast/ConstantExpression.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
namespace Serilog.Expressions.Ast;
1919

20+
/// <summary>
21+
/// A constant such as <code>'hello'</code>, <code>true</code>, <code>null</code>, or <code>123.45</code>.
22+
/// </summary>
2023
class ConstantExpression : Expression
2124
{
2225
public ConstantExpression(LogEventPropertyValue constant)
@@ -30,19 +33,14 @@ public override string ToString()
3033
{
3134
if (Constant is ScalarValue sv)
3235
{
33-
switch (sv.Value)
36+
return sv.Value switch
3437
{
35-
case string s:
36-
return "'" + s.Replace("'", "''") + "'";
37-
case true:
38-
return "true";
39-
case false:
40-
return "false";
41-
case IFormattable formattable:
42-
return formattable.ToString(null, CultureInfo.InvariantCulture);
43-
default:
44-
return (sv.Value ?? "null").ToString() ?? "<ToString() returned null>";
45-
}
38+
string s => "'" + s.Replace("'", "''") + "'",
39+
true => "true",
40+
false => "false",
41+
IFormattable formattable => formattable.ToString(null, CultureInfo.InvariantCulture),
42+
_ => (sv.Value ?? "null").ToString() ?? "<ToString() returned null>"
43+
};
4644
}
4745

4846
return Constant.ToString();

src/Serilog.Expressions/Expressions/Ast/Element.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
namespace Serilog.Expressions.Ast;
1616

17-
abstract class Element
18-
{
19-
}
17+
/// <summary>
18+
/// An element in an <see cref="ArrayExpression"/>.
19+
/// </summary>
20+
abstract class Element;

src/Serilog.Expressions/Expressions/Ast/Expression.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@
1414

1515
namespace Serilog.Expressions.Ast;
1616

17+
/// <summary>
18+
/// An AST node.
19+
/// </summary>
1720
abstract class Expression
1821
{
19-
// Used only as an enabler for testing and debugging.
22+
/// <summary>
23+
/// The <see cref="ToString"/> representation of an <see cref="Expression"/> is <strong>not</strong>
24+
/// guaranteed to be syntactically valid: this is provided for debugging purposes only.
25+
/// </summary>
26+
/// <returns>A textual representation of the expression.</returns>
2027
public abstract override string ToString();
2128
}

src/Serilog.Expressions/Expressions/Ast/IndexOfMatchExpression.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
namespace Serilog.Expressions.Ast;
1818

19+
/// <summary>
20+
/// A non-syntax expression tree node used when compiling the <see cref="Operators.OpIndexOfMatch"/>,
21+
/// <see cref="Operators.OpIsMatch"/>, and SQL-style <code>like</code> expressions.
22+
/// </summary>
1923
class IndexOfMatchExpression : Expression
2024
{
2125
public Expression Corpus { get; }

src/Serilog.Expressions/Expressions/Ast/IndexerExpression.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414

1515
namespace Serilog.Expressions.Ast;
1616

17+
/// <summary>
18+
/// An <see cref="IndexerExpression"/> retrieves a property from an object, by name, or an item from an array
19+
/// by zero-based numeric index. For example, <code>Headers['Content-Type']</code> and <code>Items[2]</code> are
20+
/// parsed as indexer expressions.
21+
/// </summary>
1722
class IndexerExpression : Expression
1823
{
1924
public Expression Receiver { get; }

0 commit comments

Comments
 (0)