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

Output and rendering improvements #977

Merged
merged 16 commits into from Jun 13, 2017
Merged
Changes from 8 commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+592 −365
Diff settings

Always

Just for now

Copy path View file
@@ -2,10 +2,13 @@


<s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/AutoCompleteBasicCompletion/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntelliSenseCompletingCharacters/CSharpCompletingCharacters/UpgradedFromVSSettings/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntelliSenseCompletingCharacters/IntelliSenseCompletingCharactersSettingCSharp/UpgradedFromVSSettings/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/LookupWindow/ShowSummary/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeEditing/Localization/CSharpLocalizationOptions/DontAnalyseVerbatimStrings/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeInspection/Highlighting/AnalysisEnabled/@EntryValue">SOLUTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArgumentsStyleLiteral/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArgumentsStyleNamedExpression/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=AssignToImplicitGlobalInFunctionScope/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=BaseObjectEqualsIsObjectEquals/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CheckNamespace/@EntryIndexedValue">DO_NOT_SHOW</s:String>
@@ -16,6 +19,7 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConditionalTernaryEqualBranch/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConditionIsAlwaysTrueOrFalse/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConstantNullCoalescingCondition/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertIfStatementToConditionalTernaryExpression/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CSharpWarnings_003A_003ACS0109/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=DoubleNegationOperator/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EmptyConstructor/@EntryIndexedValue">ERROR</s:String>
@@ -27,8 +31,9 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ExpressionIsAlwaysNull/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=FieldCanBeMadeReadOnly_002EGlobal/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=FieldCanBeMadeReadOnly_002ELocal/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ForCanBeConvertedToForeach/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ForCanBeConvertedToForeach/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=InconsistentNaming/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=JoinNullCheckWithUsage/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=LocalizableElement/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MemberCanBePrivate_002EGlobal/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MultipleOrderBy/@EntryIndexedValue">ERROR</s:String>
@@ -103,6 +108,7 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UnusedMember_002EGlobal/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UnusedMember_002ELocal/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UnusedVariable/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseNullPropagation/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseObjectOrCollectionInitializer/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ValueParameterNotUsed/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=VBPossibleMistakenCallToGetType_002E1/@EntryIndexedValue">ERROR</s:String>
@@ -111,6 +117,8 @@
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Format_0020My_0020Code_0020Using_0020_0022Particular_0022_0020conventions/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="Format My Code Using &amp;quot;Particular&amp;quot; conventions"&gt;&lt;CSMakeFieldReadonly&gt;True&lt;/CSMakeFieldReadonly&gt;&lt;CSUseVar&gt;&lt;BehavourStyle&gt;CAN_CHANGE_TO_IMPLICIT&lt;/BehavourStyle&gt;&lt;LocalVariableStyle&gt;ALWAYS_IMPLICIT&lt;/LocalVariableStyle&gt;&lt;ForeachVariableStyle&gt;ALWAYS_IMPLICIT&lt;/ForeachVariableStyle&gt;&lt;/CSUseVar&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;CSReorderTypeMembers&gt;True&lt;/CSReorderTypeMembers&gt;&lt;JsInsertSemicolon&gt;True&lt;/JsInsertSemicolon&gt;&lt;JsReformatCode&gt;True&lt;/JsReformatCode&gt;&lt;CssReformatCode&gt;True&lt;/CssReformatCode&gt;&lt;CSArrangeThisQualifier&gt;True&lt;/CSArrangeThisQualifier&gt;&lt;RemoveCodeRedundancies&gt;True&lt;/RemoveCodeRedundancies&gt;&lt;CSUseAutoProperty&gt;True&lt;/CSUseAutoProperty&gt;&lt;HtmlReformatCode&gt;True&lt;/HtmlReformatCode&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;CSharpFormatDocComments&gt;True&lt;/CSharpFormatDocComments&gt;&lt;CssAlphabetizeProperties&gt;True&lt;/CssAlphabetizeProperties&gt;&lt;/Profile&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/RecentlyUsedProfile/@EntryValue">Default: Reformat Code</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">Format My Code Using "Particular" conventions</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/DEFAULT_INTERNAL_MODIFIER/@EntryValue">Implicit</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/DEFAULT_PRIVATE_MODIFIER/@EntryValue">Implicit</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EXPLICIT_PRIVATE_MODIFIER/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_FOR_BRACES_STYLE/@EntryValue">DO_NOT_CHANGE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_FOREACH_BRACES_STYLE/@EntryValue">DO_NOT_CHANGE</s:String>
@@ -477,10 +485,13 @@ II.2.12 &lt;HandlesEvent /&gt;&#xD;
<s:Boolean x:Key="/Default/CodeStyle/Generate/=Global/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Generate/=Global/Options/=PropertyBody/@EntryIndexedValue">Automatic property</s:String>
<s:Boolean x:Key="/Default/CodeStyle/Generate/=Implementations/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Generate/=Implementations/Options/=Async/@EntryIndexedValue">False</s:String>
<s:String x:Key="/Default/CodeStyle/Generate/=Implementations/Options/=WrapInRegion/@EntryIndexedValue">False</s:String>
<s:String x:Key="/Default/CodeStyle/Generate/=Implementations/Options/=XmlDocumentation/@EntryIndexedValue">False</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AD/@EntryIndexedValue">AD</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DB/@EntryIndexedValue">DB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DTC/@EntryIndexedValue">DTC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GT/@EntryIndexedValue">GT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NSB/@EntryIndexedValue">NSB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SLA/@EntryIndexedValue">SLA</s:String>
@@ -17,7 +17,7 @@
using Serilog.Events;
using Serilog.Parsing;

namespace Serilog.Parameters
namespace Serilog.Capturing
{
partial class PropertyValueConverter
{
@@ -17,7 +17,7 @@
using System.Linq;
using System.Reflection;

namespace Serilog.Parameters
namespace Serilog.Capturing
{
static class GetablePropertyFinder
{
@@ -18,11 +18,11 @@
using Serilog.Events;
using Serilog.Parsing;

namespace Serilog.Parameters
namespace Serilog.Capturing
{
class MessageTemplateProcessor : ILogEventPropertyFactory
{
readonly IMessageTemplateParser _parser = new MessageTemplateCache(new MessageTemplateParser());
readonly MessageTemplateCache _parser = new MessageTemplateCache(new MessageTemplateParser());
readonly PropertyBinder _propertyBinder;
readonly PropertyValueConverter _propertyValueConverter;

@@ -19,7 +19,7 @@
using Serilog.Events;
using Serilog.Parsing;

namespace Serilog.Parameters
namespace Serilog.Capturing
{
// Performance relevant - on the hot path when creating log events from existing templates.
class PropertyBinder
@@ -24,7 +24,7 @@
using Serilog.Policies;
using System.Runtime.CompilerServices;

namespace Serilog.Parameters
namespace Serilog.Capturing
{
// Values in Serilog are simplified down into a lowest-common-denominator internal
// type system so that there is a better chance of code written with one sink in
@@ -258,7 +258,7 @@ IEnumerable<LogEventProperty> GetProperties(object value, ILogEventPropertyValue
if (_propagateExceptions)
throw;

propValue = "The property accessor threw an exception: " + ex.InnerException.GetType().Name;
propValue = "The property accessor threw an exception: " + ex.InnerException?.GetType().Name;
}
yield return new LogEventProperty(prop.Name, recursive.CreatePropertyValue(propValue, true));
}
@@ -20,7 +20,6 @@
using Serilog.Events;

#if ASYNCLOCAL
using System.Collections.Generic;
using System.Threading;
#elif REMOTING
using System.Runtime.Remoting;
Copy path View file
@@ -14,10 +14,10 @@

using System;
using System.Collections.Generic;
using Serilog.Capturing;
using Serilog.Core.Enrichers;
using Serilog.Debugging;
using Serilog.Events;
using Serilog.Parameters;

#pragma warning disable Serilog004 // Constant MessageTemplate verifier

@@ -13,9 +13,13 @@
// limitations under the License.

using System;
using System.Collections.Generic;
using Serilog.Events;

#if HASHTABLE
using System.Collections;
#else
using System.Collections.Generic;
#endif

namespace Serilog.Core.Pipeline
{
@@ -15,6 +15,8 @@
using System;
using Serilog.Events;

// ReSharper disable VirtualMemberNeverOverridden.Global

namespace Serilog.Data
{
/// <summary>
@@ -40,7 +42,6 @@ public abstract class LogEventPropertyValueVisitor<TState, TResult>
/// <param name="state">Operation state.</param>
/// <param name="value">The value to visit.</param>
/// <returns>The result of visiting <paramref name="value"/>.</returns>
// ReSharper disable once VirtualMemberNeverOverriden.Global
protected virtual TResult Visit(TState state, LogEventPropertyValue value)
{
if (value == null) throw new ArgumentNullException(nameof(value));
@@ -103,7 +104,6 @@ protected virtual TResult Visit(TState state, LogEventPropertyValue value)
/// <param name="value">The value to visit.</param>
/// <returns>The result of visiting <paramref name="value"/>.</returns>
// ReSharper disable once UnusedParameter.Global
// ReSharper disable once VirtualMemberNeverOverriden.Global
protected virtual TResult VisitUnsupportedValue(TState state, LogEventPropertyValue value)
{
if (value == null) throw new ArgumentNullException(nameof(value));
@@ -18,6 +18,7 @@
using System.Linq;
using Serilog.Debugging;
using Serilog.Parsing;
using Serilog.Rendering;

namespace Serilog.Events
{
@@ -35,15 +36,14 @@ public class MessageTemplate

readonly MessageTemplateToken[] _tokens;

// Optimisation for when the template is bound to
// property values.

/// <summary>
/// Construct a message template using manually-defined text and property tokens.
/// </summary>
/// <param name="tokens">The text and property tokens defining the template.</param>
public MessageTemplate(IEnumerable<MessageTemplateToken> tokens)
// ReSharper disable PossibleMultipleEnumeration
: this(string.Join("", tokens), tokens)
// ReSharper enable PossibleMultipleEnumeration
{
}

@@ -91,7 +91,7 @@ public MessageTemplate(string text, IEnumerable<MessageTemplateToken> tokens)
/// <summary>
/// Similar to <see cref="Enumerable.OfType{TResult}"/>, but faster.
/// </summary>
static TResult[] GetElementsOfTypeToArray<TResult>(object[] tokens)
static TResult[] GetElementsOfTypeToArray<TResult>(MessageTemplateToken[] tokens)
where TResult: class
{
var result = new List<TResult>(tokens.Length / 2);
@@ -125,6 +125,8 @@ public override string ToString()
/// </summary>
public IEnumerable<MessageTemplateToken> Tokens => _tokens;

internal MessageTemplateToken[] TokenArray => _tokens;

internal PropertyToken[] NamedProperties { get; }

internal PropertyToken[] PositionalProperties { get; }
@@ -156,10 +158,7 @@ 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)
{
foreach (var token in _tokens)
{
token.Render(properties, output, formatProvider);
}
MessageTemplateRenderer.Render(this, properties, output, null, formatProvider);
}
}
}
@@ -46,16 +46,21 @@ public ScalarValue(object value)
/// <param name="formatProvider">A format provider to apply to the value, or null to use the default.</param>
/// <seealso cref="LogEventPropertyValue.ToString(string, IFormatProvider)"/>.
public override void Render(TextWriter output, string format = null, IFormatProvider formatProvider = null)
{
Render(Value, output, format, formatProvider);
}

internal static void Render(object value, TextWriter output, string format = null, IFormatProvider formatProvider = null)
{
if (output == null) throw new ArgumentNullException(nameof(output));

if (Value == null)
if (value == null)
{
output.Write("null");
return;
}

var s = Value as string;
var s = value as string;
if (s != null)
{
if (format != "l")
@@ -76,19 +81,19 @@ public override void Render(TextWriter output, string format = null, IFormatProv
var custom = (ICustomFormatter)formatProvider.GetFormat(typeof(ICustomFormatter));
if (custom != null)
{
output.Write(custom.Format(format, Value, formatProvider));
output.Write(custom.Format(format, value, formatProvider));
return;
}
}

var f = Value as IFormattable;
var f = value as IFormattable;
if (f != null)
{
output.Write(f.ToString(format, formatProvider ?? CultureInfo.InvariantCulture));
}
else
{
output.Write(Value.ToString());
output.Write(value.ToString());
}
}

Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.