Skip to content

Commit

Permalink
Fewer arg checks; seal message template token classes; encourage inli…
Browse files Browse the repository at this point in the history
…ning
  • Loading branch information
nblumhardt committed Jun 7, 2017
1 parent ce2caef commit e205c07
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/Serilog/Events/MessageTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ public string Render(IReadOnlyDictionary<string, LogEventPropertyValue> properti
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
public void Render(IReadOnlyDictionary<string, LogEventPropertyValue> properties, TextWriter output, IFormatProvider formatProvider = null)
{
if (properties == null) throw new ArgumentNullException(nameof(properties));
if (output == null) throw new ArgumentNullException(nameof(output));
MessageTemplateRenderer.Render(this, properties, output, null, formatProvider);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Serilog/Parsing/PropertyToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Serilog.Parsing
/// <summary>
/// A message template token representing a log event property.
/// </summary>
public class PropertyToken : MessageTemplateToken
public sealed class PropertyToken : MessageTemplateToken
{
readonly string _rawText;
readonly int? _position;
Expand Down
2 changes: 1 addition & 1 deletion src/Serilog/Parsing/TextToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Serilog.Parsing
/// <summary>
/// A message template token representing literal text.
/// </summary>
public class TextToken : MessageTemplateToken
public sealed class TextToken : MessageTemplateToken
{
/// <summary>
/// Construct a <see cref="TextToken"/>.
Expand Down
6 changes: 2 additions & 4 deletions src/Serilog/Rendering/MessageTemplateRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
using Serilog.Events;
using Serilog.Formatting.Json;
using Serilog.Parsing;
Expand All @@ -25,12 +26,9 @@ static class MessageTemplateRenderer
{
static JsonValueFormatter JsonValueFormatter = new JsonValueFormatter("$type");

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Render(MessageTemplate messageTemplate, IReadOnlyDictionary<string, LogEventPropertyValue> properties, TextWriter output, string format = null, IFormatProvider formatProvider = null)
{
if (messageTemplate == null) throw new ArgumentNullException(nameof(messageTemplate));
if (properties == null) throw new ArgumentNullException(nameof(properties));
if (output == null) throw new ArgumentNullException(nameof(output));

bool isLiteral = false, isJson = false;

if (format != null)
Expand Down

0 comments on commit e205c07

Please sign in to comment.