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

Use expression-bodied members #2361

Merged
merged 1 commit into from
Oct 16, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions src/NLog.Extended/LayoutRenderers/AppSettingLayoutRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public class AppSettingLayoutRenderer : LayoutRenderer

internal IConfigurationManager ConfigurationManager
{
get { return configurationManager; }
set { configurationManager = value; }
get => configurationManager;
set => configurationManager = value;
}

/// <summary>
Expand Down
30 changes: 6 additions & 24 deletions src/NLog/Common/InternalLogger-generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,50 +43,32 @@ public static partial class InternalLogger
/// <summary>
/// Gets a value indicating whether internal log includes Trace messages.
/// </summary>
public static bool IsTraceEnabled
{
get { return LogLevel.Trace >= LogLevel; }
}
public static bool IsTraceEnabled => LogLevel.Trace >= LogLevel;

/// <summary>
/// Gets a value indicating whether internal log includes Debug messages.
/// </summary>
public static bool IsDebugEnabled
{
get { return LogLevel.Debug >= LogLevel; }
}
public static bool IsDebugEnabled => LogLevel.Debug >= LogLevel;

/// <summary>
/// Gets a value indicating whether internal log includes Info messages.
/// </summary>
public static bool IsInfoEnabled
{
get { return LogLevel.Info >= LogLevel; }
}
public static bool IsInfoEnabled => LogLevel.Info >= LogLevel;

/// <summary>
/// Gets a value indicating whether internal log includes Warn messages.
/// </summary>
public static bool IsWarnEnabled
{
get { return LogLevel.Warn >= LogLevel; }
}
public static bool IsWarnEnabled => LogLevel.Warn >= LogLevel;

/// <summary>
/// Gets a value indicating whether internal log includes Error messages.
/// </summary>
public static bool IsErrorEnabled
{
get { return LogLevel.Error >= LogLevel; }
}
public static bool IsErrorEnabled => LogLevel.Error >= LogLevel;

/// <summary>
/// Gets a value indicating whether internal log includes Fatal messages.
/// </summary>
public static bool IsFatalEnabled
{
get { return LogLevel.Fatal >= LogLevel; }
}
public static bool IsFatalEnabled => LogLevel.Fatal >= LogLevel;


/// <summary>
Expand Down
5 changes: 1 addition & 4 deletions src/NLog/Common/InternalLogger-generated.tt
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ namespace NLog.Common
/// <summary>
/// Gets a value indicating whether internal log includes <#=level#> messages.
/// </summary>
public static bool Is<#=level#>Enabled
{
get { return LogLevel.<#=level#> >= LogLevel; }
}
public static bool Is<#=level#>Enabled => LogLevel.<#=level#> >= LogLevel;

<#
}
Expand Down
5 changes: 1 addition & 4 deletions src/NLog/Common/LogEventInfoBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ public LogEventInfoBuffer(int size, bool growAsNeeded, int growLimit)
/// <summary>
/// Gets the number of items in the array.
/// </summary>
public int Size
{
get { return _buffer.Length; }
}
public int Size => _buffer.Length;

/// <summary>
/// Adds the specified log event to the buffer.
Expand Down
56 changes: 16 additions & 40 deletions src/NLog/Config/ConfigurationItemFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static ConfigurationItemFactory Default
defaultInstance = BuildDefaultFactory();
return defaultInstance;
}
set { defaultInstance = value; }
set => defaultInstance = value;
}

/// <summary>
Expand All @@ -134,19 +134,13 @@ public static ConfigurationItemFactory Default
/// Gets the <see cref="Target"/> factory.
/// </summary>
/// <value>The target factory.</value>
public INamedItemFactory<Target, Type> Targets
{
get { return _targets; }
}
public INamedItemFactory<Target, Type> Targets => _targets;

/// <summary>
/// Gets the <see cref="Filter"/> factory.
/// </summary>
/// <value>The filter factory.</value>
public INamedItemFactory<Filter, Type> Filters
{
get { return _filters; }
}
public INamedItemFactory<Filter, Type> Filters => _filters;

/// <summary>
/// gets the <see cref="LayoutRenderer"/> factory
Expand All @@ -162,55 +156,46 @@ internal LayoutRendererFactory GetLayoutRenderers()
/// Gets the <see cref="LayoutRenderer"/> factory.
/// </summary>
/// <value>The layout renderer factory.</value>
public INamedItemFactory<LayoutRenderer, Type> LayoutRenderers
{
get { return _layoutRenderers; }
}
public INamedItemFactory<LayoutRenderer, Type> LayoutRenderers => _layoutRenderers;

/// <summary>
/// Gets the <see cref="LayoutRenderer"/> factory.
/// </summary>
/// <value>The layout factory.</value>
public INamedItemFactory<Layout, Type> Layouts
{
get { return _layouts; }
}
public INamedItemFactory<Layout, Type> Layouts => _layouts;

/// <summary>
/// Gets the ambient property factory.
/// </summary>
/// <value>The ambient property factory.</value>
public INamedItemFactory<LayoutRenderer, Type> AmbientProperties
{
get { return _ambientProperties; }
}

public INamedItemFactory<LayoutRenderer, Type> AmbientProperties => _ambientProperties;

/// <summary>
/// Legacy interface, no longer used by the NLog engine
/// </summary>
[Obsolete("Use JsonConverter property instead. Marked obsolete on NLog 4.5")]
public IJsonSerializer JsonSerializer
{
get { return _jsonSerializer as IJsonSerializer; }
set { _jsonSerializer = value != null ? (IJsonConverter)new JsonConverterLegacy(value) : DefaultJsonSerializer.Instance; }
get => _jsonSerializer as IJsonSerializer;
set => _jsonSerializer = value != null ? (IJsonConverter)new JsonConverterLegacy(value) : DefaultJsonSerializer.Instance;
}

/// <summary>
/// Gets or sets the JSON serializer to use with <see cref="WebServiceTarget"/> or <see cref="JsonLayout"/>
/// </summary>
public IJsonConverter JsonConverter
{
get { return _jsonSerializer; }
set { _jsonSerializer = value ?? DefaultJsonSerializer.Instance; }
get => _jsonSerializer;
set => _jsonSerializer = value ?? DefaultJsonSerializer.Instance;
}

/// <summary>
/// Gets or sets the string serializer to use with <see cref="LogEventInfo.MessageTemplateParameters"/>
/// </summary>
public IValueSerializer ValueSerializer
{
get { return MessageTemplates.ValueSerializer.Instance; }
set { MessageTemplates.ValueSerializer.Instance = value; }
get => MessageTemplates.ValueSerializer.Instance;
set => MessageTemplates.ValueSerializer.Instance = value;
}

/// <summary>
Expand Down Expand Up @@ -238,29 +223,20 @@ public bool? ParseMessageTemplates
return null;
}
}
set
{
LogEventInfo.SetDefaultMessageFormatter(value);
}
set => LogEventInfo.SetDefaultMessageFormatter(value);
}

/// <summary>
/// Gets the time source factory.
/// </summary>
/// <value>The time source factory.</value>
public INamedItemFactory<TimeSource, Type> TimeSources
{
get { return _timeSources; }
}
public INamedItemFactory<TimeSource, Type> TimeSources => _timeSources;

/// <summary>
/// Gets the condition method factory.
/// </summary>
/// <value>The condition method factory.</value>
public INamedItemFactory<MethodInfo, MethodInfo> ConditionMethods
{
get { return _conditionMethods; }
}
public INamedItemFactory<MethodInfo, MethodInfo> ConditionMethods => _conditionMethods;

/// <summary>
/// Registers named items from the assembly.
Expand Down
18 changes: 3 additions & 15 deletions src/NLog/Config/LoggingConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,7 @@ public LoggingConfiguration()
/// <summary>
/// Gets the variables defined in the configuration.
/// </summary>
public IDictionary<string, SimpleLayout> Variables
{
get
{
return _variables;
}
}
public IDictionary<string, SimpleLayout> Variables => _variables;

/// <summary>
/// Gets a collection of named targets specified in the configuration.
Expand All @@ -98,18 +92,12 @@ public IDictionary<string, SimpleLayout> Variables
/// <remarks>
/// Unnamed targets (such as those wrapped by other targets) are not returned.
/// </remarks>
public ReadOnlyCollection<Target> ConfiguredNamedTargets
{
get { return new List<Target>(_targets.Values).AsReadOnly(); }
}
public ReadOnlyCollection<Target> ConfiguredNamedTargets => new List<Target>(_targets.Values).AsReadOnly();

/// <summary>
/// Gets the collection of file names which should be watched for changes by NLog.
/// </summary>
public virtual IEnumerable<string> FileNamesToWatch
{
get { return ArrayHelper.Empty<string>(); }
}
public virtual IEnumerable<string> FileNamesToWatch => ArrayHelper.Empty<string>();

/// <summary>
/// Gets the collection of logging rules.
Expand Down
4 changes: 2 additions & 2 deletions src/NLog/Config/LoggingConfigurationChangedEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ public LoggingConfigurationChangedEventArgs(LoggingConfiguration activatedConfig
/// </summary>
/// <value>The new configuration.</value>
[Obsolete("This option will be removed in NLog 5. Marked obsolete on NLog 4.5")]
public LoggingConfiguration OldConfiguration { get { return ActivatedConfiguration; } }
public LoggingConfiguration OldConfiguration => ActivatedConfiguration;

/// <summary>
/// Gets the old configuration
/// </summary>
/// <value>The old configuration.</value>
[Obsolete("This option will be removed in NLog 5. Marked obsolete on NLog 4.5")]
public LoggingConfiguration NewConfiguration { get { return DeactivatedConfiguration; } }
public LoggingConfiguration NewConfiguration => DeactivatedConfiguration;
}
}
5 changes: 1 addition & 4 deletions src/NLog/Config/LoggingRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,7 @@ internal enum MatchMode
/// </remarks>
public string LoggerNamePattern
{
get
{
return _loggerNamePattern;
}
get => _loggerNamePattern;

set
{
Expand Down
5 changes: 1 addition & 4 deletions src/NLog/Config/MethodFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ internal class MethodFactory<TClassAttributeType, TMethodAttributeType> : INamed
/// of the item and value is the <see cref="MethodInfo"/> of
/// the item.
/// </returns>
public IDictionary<string, MethodInfo> AllRegisteredItems
{
get { return _nameToMethodInfo; }
}
public IDictionary<string, MethodInfo> AllRegisteredItems => _nameToMethodInfo;

/// <summary>
/// Scans the assembly for classes marked with <typeparamref name="TClassAttributeType"/>
Expand Down
5 changes: 1 addition & 4 deletions src/NLog/Config/XmlLoggingConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ public class XmlLoggingConfiguration : LoggingConfiguration

private LogFactory _logFactory = null;

private ConfigurationItemFactory ConfigurationItemFactory
{
get { return ConfigurationItemFactory.Default; }
}
private ConfigurationItemFactory ConfigurationItemFactory => ConfigurationItemFactory.Default;

#endregion

Expand Down
5 changes: 1 addition & 4 deletions src/NLog/Fluent/LogBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ public LogBuilder(ILogger logger, LogLevel logLevel)
/// <summary>
/// Gets the <see cref="LogEventInfo"/> created by the builder.
/// </summary>
public LogEventInfo LogEventInfo
{
get { return _logEvent; }
}
public LogEventInfo LogEventInfo => _logEvent;

/// <summary>
/// Sets the <paramref name="exception"/> information of the logging event.
Expand Down
3 changes: 2 additions & 1 deletion src/NLog/Internal/AppendBuilderCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ internal struct AppendBuilderCreator : IDisposable
/// <summary>
/// Access the new builder allocated
/// </summary>
public StringBuilder Builder { get { return _builder.Item; } }
public StringBuilder Builder => _builder.Item;

private readonly StringBuilderPool.ItemHolder _builder;

public AppendBuilderCreator(StringBuilder appendTarget, bool mustBeEmpty)
Expand Down
8 changes: 1 addition & 7 deletions src/NLog/Internal/ConfigurationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@ public class ConfigurationManager : IConfigurationManager
/// <summary>
/// Gets the wrapper around ConfigurationManager.AppSettings.
/// </summary>
public NameValueCollection AppSettings
{
get
{
return System.Configuration.ConfigurationManager.AppSettings;
}
}
public NameValueCollection AppSettings => System.Configuration.ConfigurationManager.AppSettings;
}
}

Expand Down
Loading