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

Spell check and cleanup #55

Merged
merged 7 commits into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public EventPropertyTokenRenderer(ConsoleTheme theme, PropertyToken token, IForm
public override void Render(LogEvent logEvent, TextWriter output)
{
// If a property is missing, don't render anything (message templates render the raw token here).
LogEventPropertyValue propertyValue;
if (!logEvent.Properties.TryGetValue(_token.PropertyName, out propertyValue))
if (!logEvent.Properties.TryGetValue(_token.PropertyName, out LogEventPropertyValue propertyValue))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will not compile

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake, it fits.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

{
Padding.Apply(output, "", _token.Alignment);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class LevelTokenRenderer : OutputTemplateTokenRenderer
{
readonly ConsoleTheme _theme;
readonly PropertyToken _levelToken;

static readonly Dictionary<LogEventLevel, ConsoleThemeStyle> Levels = new Dictionary<LogEventLevel, ConsoleThemeStyle>
{
{ LogEventLevel.Verbose, ConsoleThemeStyle.LevelVerbose },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ int RenderTextToken(TextToken tt, TextWriter output)

int RenderPropertyToken(PropertyToken pt, IReadOnlyDictionary<string, LogEventPropertyValue> properties, TextWriter output)
{
LogEventPropertyValue propertyValue;
if (!properties.TryGetValue(pt.PropertyName, out propertyValue))
if (!properties.TryGetValue(pt.PropertyName, out LogEventPropertyValue propertyValue))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

{
var count = 0;
using (_theme.Apply(output, ConsoleThemeStyle.Invalid, ref count))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class AnsiConsoleTheme : ConsoleTheme
public static AnsiConsoleTheme Grayscale { get; } = AnsiConsoleThemes.Grayscale;

/// <summary>
/// A theme in the syle of the original <i>Serilog.Sinks.Literate</i>.
/// A theme in the style of the original <i>Serilog.Sinks.Literate</i>.
/// </summary>
public static AnsiConsoleTheme Literate { get; } = AnsiConsoleThemes.Literate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public enum ConsoleThemeStyle
Scalar,

/// <summary>
/// Unrecogized literal values, e.g. <see cref="System.Guid"/> instances.
/// Unrecognized literal values, e.g. <see cref="System.Guid"/> instances.
/// </summary>
[Obsolete("Use ConsoleThemeStyle.Scalar instead"), EditorBrowsable(EditorBrowsableState.Never)]
Object = Scalar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class SystemConsoleTheme : ConsoleTheme
public static SystemConsoleTheme Grayscale { get; } = SystemConsoleThemes.Grayscale;

/// <summary>
/// A theme in the syle of the original <i>Serilog.Sinks.Literate</i>.
/// A theme in the style of the original <i>Serilog.Sinks.Literate</i>.
/// </summary>
public static SystemConsoleTheme Literate { get; } = SystemConsoleThemes.Literate;

Expand All @@ -40,20 +40,18 @@ public class SystemConsoleTheme : ConsoleTheme
/// </summary>
public static SystemConsoleTheme Colored { get; } = SystemConsoleThemes.Colored;

readonly IReadOnlyDictionary<ConsoleThemeStyle, SystemConsoleThemeStyle> _styles;

/// <summary>
/// Construct a theme given a set of styles.
/// </summary>
/// <param name="styles">Styles to apply within the theme.</param>
public SystemConsoleTheme(IReadOnlyDictionary<ConsoleThemeStyle, SystemConsoleThemeStyle> styles)
{
if (styles == null) throw new ArgumentNullException(nameof(styles));
_styles = styles.ToDictionary(kv => kv.Key, kv => kv.Value);
Styles = styles.ToDictionary(kv => kv.Key, kv => kv.Value);
}

/// <inheritdoc/>
public IReadOnlyDictionary<ConsoleThemeStyle, SystemConsoleThemeStyle> Styles => _styles;
public IReadOnlyDictionary<ConsoleThemeStyle, SystemConsoleThemeStyle> Styles { get; private set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 - if assignment only happens in the constructor, this doesn't need private set - { get; } alone will do the job.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


/// <inheritdoc/>
public override bool CanBuffer => false;
Expand All @@ -64,7 +62,7 @@ public SystemConsoleTheme(IReadOnlyDictionary<ConsoleThemeStyle, SystemConsoleTh
/// <inheritdoc/>
public override int Set(TextWriter output, ConsoleThemeStyle style)
{
if (_styles.TryGetValue(style, out var wcts))
if (Styles.TryGetValue(style, out var wcts))
{
if (wcts.Foreground.HasValue)
Console.ForegroundColor = wcts.Foreground.Value;
Expand Down
3 changes: 1 addition & 2 deletions test/Serilog.Sinks.Console.Tests/Support/DelegatingSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ public class DelegatingSink : ILogEventSink

public DelegatingSink(Action<LogEvent> write)
{
if (write == null) throw new ArgumentNullException(nameof(write));
_write = write;
_write = write ?? throw new ArgumentNullException(nameof(write));
}

public void Emit(LogEvent logEvent)
Expand Down