-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cc74be0
Showing
10 changed files
with
451 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.{js,mjs,css,less}] | ||
indent_style = tab | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.elm] | ||
end_of_line = lf | ||
|
||
# from https://github.com/dotnet/roslyn/blob/49cbdd513ea7a82f6db86abf89998a7542f2f2fc/.editorconfig | ||
|
||
# Xml project files | ||
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] | ||
indent_size = 2 | ||
|
||
# Xml config files | ||
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct,dnn}] | ||
indent_size = 2 | ||
|
||
# Dotnet code style settings: | ||
[*.{cs,vb}] | ||
# Sort using and Import directives with System.* appearing first | ||
dotnet_sort_system_directives_first = true | ||
dotnet_separate_import_directive_groups = true | ||
|
||
# Require "this." and "Me." if not necessary | ||
dotnet_style_qualification_for_field = true:warning | ||
dotnet_style_qualification_for_property = true:warning | ||
dotnet_style_qualification_for_method = true:warning | ||
dotnet_style_qualification_for_event = true:warning | ||
|
||
# Use language keywords instead of framework type names for type references | ||
dotnet_style_predefined_type_for_locals_parameters_members = true:warning | ||
dotnet_style_predefined_type_for_member_access = true:warning | ||
|
||
# Suggest more modern language features when available | ||
dotnet_style_object_initializer = true:suggestion | ||
dotnet_style_collection_initializer = true:suggestion | ||
dotnet_style_coalesce_expression = true:suggestion | ||
dotnet_style_null_propagation = true:suggestion | ||
dotnet_style_explicit_tuple_names = true:suggestion | ||
|
||
# Parentheses | ||
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none | ||
dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:none | ||
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none | ||
|
||
# Require accessbility modifiers | ||
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion | ||
|
||
# Naming | ||
dotnet_naming_rule.private_constants_rule.import_to_resharper = as_predefined | ||
dotnet_naming_rule.private_constants_rule.severity = warning | ||
dotnet_naming_rule.private_constants_rule.style = upper_camel_case_style | ||
dotnet_naming_rule.private_constants_rule.symbols = private_constants_symbols | ||
dotnet_naming_rule.private_instance_fields_rule.import_to_resharper = as_predefined | ||
dotnet_naming_rule.private_instance_fields_rule.severity = warning | ||
dotnet_naming_rule.private_instance_fields_rule.style = lower_camel_case_style | ||
dotnet_naming_rule.private_instance_fields_rule.symbols = private_instance_fields_symbols | ||
dotnet_naming_rule.private_static_fields_rule.import_to_resharper = as_predefined | ||
dotnet_naming_rule.private_static_fields_rule.severity = warning | ||
dotnet_naming_rule.private_static_fields_rule.style = lower_camel_case_style | ||
dotnet_naming_rule.private_static_fields_rule.symbols = private_static_fields_symbols | ||
dotnet_naming_rule.private_static_readonly_rule.import_to_resharper = as_predefined | ||
dotnet_naming_rule.private_static_readonly_rule.severity = warning | ||
dotnet_naming_rule.private_static_readonly_rule.style = upper_camel_case_style | ||
dotnet_naming_rule.private_static_readonly_rule.symbols = private_static_readonly_symbols | ||
dotnet_naming_style.lower_camel_case_style.capitalization = camel_case | ||
dotnet_naming_style.upper_camel_case_style.capitalization = pascal_case | ||
dotnet_naming_symbols.private_constants_symbols.applicable_accessibilities = private | ||
dotnet_naming_symbols.private_constants_symbols.applicable_kinds = field | ||
dotnet_naming_symbols.private_constants_symbols.required_modifiers = const | ||
dotnet_naming_symbols.private_instance_fields_symbols.applicable_accessibilities = private | ||
dotnet_naming_symbols.private_instance_fields_symbols.applicable_kinds = field | ||
dotnet_naming_symbols.private_static_fields_symbols.applicable_accessibilities = private | ||
dotnet_naming_symbols.private_static_fields_symbols.applicable_kinds = field | ||
dotnet_naming_symbols.private_static_fields_symbols.required_modifiers = static | ||
dotnet_naming_symbols.private_static_readonly_symbols.applicable_accessibilities = private | ||
dotnet_naming_symbols.private_static_readonly_symbols.applicable_kinds = field | ||
dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers = static,readonly | ||
|
||
# Code Quality config | ||
dotnet_diagnostic.CA2007.severity = none # Do not directly await a Task (this is only for "library" code) | ||
dotnet_diagnostic.CA2008.severity = none # Do not create tasks without passing a TaskScheduler (this is only for "library" code) | ||
dotnet_code_quality.CA1062.null_check_validation_methods = NotNull|NotNullOrEmpty|NotNullOrHasNoWhiteSpace|GetResponseForInvalidRequest | ||
|
||
dotnet_diagnostic.CS1573.severity = none # Parameter 'parameter' has no matching param tag in the XML comment for 'parameter' (but other parameters do) | ||
dotnet_diagnostic.CS1591.severity = none # Missing XML comment for publicly visible type or member 'Type_or_Member' | ||
dotnet_diagnostic.CS1712.severity = none # Type parameter 'type parameter' has no matching typeparam tag in the XML comment on 'type' (but other type parameters do) | ||
|
||
# C# code style settings: | ||
[*.cs] | ||
# Prefer "var" everywhere | ||
csharp_style_var_for_built_in_types = true:suggestion | ||
csharp_style_var_when_type_is_apparent = true:suggestion | ||
csharp_style_var_elsewhere = true:suggestion | ||
|
||
# Prefer method-like constructs to have a block body | ||
csharp_style_expression_bodied_methods = false:none | ||
csharp_style_expression_bodied_constructors = false:none | ||
csharp_style_expression_bodied_operators = false:none | ||
|
||
# Prefer property-like constructs to have an expression-body | ||
csharp_style_expression_bodied_properties = true:none | ||
csharp_style_expression_bodied_indexers = true:none | ||
csharp_style_expression_bodied_accessors = true:none | ||
|
||
# Suggest more modern language features when available | ||
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion | ||
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion | ||
csharp_style_inlined_variable_declaration = true:suggestion | ||
csharp_style_throw_expression = true:suggestion | ||
csharp_style_conditional_delegate_call = true:suggestion | ||
|
||
# Newline settings | ||
csharp_new_line_before_open_brace = all | ||
csharp_new_line_before_else = true | ||
csharp_new_line_before_catch = true | ||
csharp_new_line_before_finally = true | ||
csharp_new_line_before_members_in_object_initializers = true | ||
csharp_new_line_before_members_in_anonymous_types = true | ||
|
||
# IDE0065: Misplaced using directive | ||
csharp_using_directive_placement = inside_namespace:warning | ||
|
||
# C# Style | ||
csharp_prefer_braces = true:none | ||
csharp_preferred_modifier_order = public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion | ||
csharp_space_after_cast = false | ||
|
||
# ReSharper properties | ||
resharper_align_linq_query = true | ||
resharper_align_multiline_calls_chain = true | ||
resharper_apply_auto_detected_rules = false | ||
resharper_blank_lines_after_start_comment = 0 | ||
resharper_blank_lines_before_single_line_comment = 1 | ||
resharper_braces_for_for = required | ||
resharper_braces_for_foreach = required | ||
resharper_braces_for_ifelse = required | ||
resharper_braces_for_while = required | ||
resharper_braces_redundant = true | ||
resharper_csharp_keep_blank_lines_in_code = 1 | ||
resharper_csharp_keep_blank_lines_in_declarations = 1 | ||
resharper_csharp_place_type_constraints_on_same_line = false | ||
resharper_csharp_wrap_after_declaration_lpar = true | ||
resharper_csharp_wrap_after_invocation_lpar = true | ||
resharper_csharp_wrap_arguments_style = chop_if_long | ||
resharper_csharp_wrap_before_binary_opsign = true | ||
resharper_csharp_wrap_extends_list_style = chop_if_long | ||
resharper_csharp_wrap_multiple_declaration_style = chop_always | ||
resharper_csharp_wrap_parameters_style = chop_if_long | ||
resharper_keep_existing_declaration_parens_arrangement = false | ||
resharper_keep_existing_embedded_arrangement = false | ||
resharper_keep_existing_expr_member_arrangement = false | ||
resharper_keep_existing_initializer_arrangement = false | ||
resharper_keep_existing_invocation_parens_arrangement = false | ||
resharper_keep_existing_property_patterns_arrangement = false | ||
resharper_keep_existing_switch_expression_arrangement = false | ||
resharper_nested_ternary_style = expanded | ||
resharper_object_creation_when_type_evident = explicitly_typed | ||
resharper_place_accessorholder_attribute_on_same_line = false | ||
resharper_place_constructor_initializer_on_same_line = false | ||
resharper_place_field_attribute_on_same_line = false | ||
resharper_place_linq_into_on_new_line = false | ||
resharper_place_simple_embedded_statement_on_same_line = false | ||
resharper_place_simple_switch_expression_on_single_line = true | ||
resharper_qualified_using_at_nested_scope = true | ||
resharper_space_after_attributes = false | ||
resharper_space_after_cast = false | ||
resharper_space_between_attribute_sections = false | ||
resharper_space_within_single_line_array_initializer_braces = true | ||
resharper_use_heuristics_for_body_style = true | ||
resharper_use_indent_from_vs = false | ||
resharper_wrap_array_initializer_style = chop_if_long | ||
resharper_wrap_before_linq_expression = true | ||
resharper_wrap_chained_binary_expressions = chop_if_long | ||
resharper_wrap_chained_method_calls = chop_if_long | ||
resharper_wrap_linq_expressions = chop_always | ||
resharper_xmldoc_attribute_indent = align_by_first_attribute | ||
resharper_xmldoc_blank_line_after_pi = false | ||
resharper_xmldoc_pi_attribute_style = on_single_line | ||
|
||
# ReSharper inspection severities | ||
resharper_arguments_style_anonymous_function_highlighting = none | ||
resharper_arguments_style_literal_highlighting = none | ||
resharper_arguments_style_named_expression_highlighting = none | ||
resharper_arguments_style_other_highlighting = none | ||
resharper_arguments_style_string_literal_highlighting = none | ||
resharper_arrange_accessor_owner_body_highlighting = none | ||
resharper_arrange_object_creation_when_type_evident_highlighting = hint | ||
resharper_arrange_redundant_parentheses_highlighting = hint | ||
resharper_arrange_type_member_modifiers_highlighting = hint | ||
resharper_arrange_type_modifiers_highlighting = hint | ||
resharper_web_config_module_not_resolved_highlighting = warning | ||
resharper_web_config_type_not_resolved_highlighting = warning | ||
resharper_web_config_wrong_module_highlighting = warning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bin/ | ||
obj/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engage.Dnn.Logging", "Engage.Dnn.Logging\Engage.Dnn.Logging.csproj", "{77BDE6C5-E9C7-4CE9-97C3-FD48BBEC1A29}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7ED1AC3B-7D94-4DFC-9345-06A641EBCFC8}" | ||
ProjectSection(SolutionItems) = preProject | ||
stylecop.json = stylecop.json | ||
.editorconfig = .editorconfig | ||
.gitignore = .gitignore | ||
nuget.config = nuget.config | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{77BDE6C5-E9C7-4CE9-97C3-FD48BBEC1A29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{77BDE6C5-E9C7-4CE9-97C3-FD48BBEC1A29}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{77BDE6C5-E9C7-4CE9-97C3-FD48BBEC1A29}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{77BDE6C5-E9C7-4CE9-97C3-FD48BBEC1A29}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<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"> | ||
<s:String x:Key="/Default/CodeStyle/FileHeader/FileHeaderText/@EntryValue"><copyright file="DnnLoggerProvider.cs" company="Engage"> | ||
Engage.Dnn.Logging | ||
Copyright (c) 2023 | ||
</copyright></s:String> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=DNN_0027s/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// <copyright file="DnnLogger.cs" company="Engage"> | ||
// Engage.Dnn.Logging | ||
// Copyright (c) 2023 | ||
// </copyright> | ||
namespace Engage.Dnn.Logging; | ||
|
||
/// <summary>An <see cref="ILogger"/> implementation which wraps DNN's <see cref="ILog"/>.</summary> | ||
public sealed class DnnLogger : ILogger | ||
{ | ||
private readonly ILog log; | ||
|
||
/// <summary>Initializes a new instance of the <see cref="DnnLogger"/> class.</summary> | ||
/// <param name="log">The DNN <see cref="ILog"/> instance to wrap.</param> | ||
public DnnLogger(ILog log) | ||
{ | ||
this.log = log; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter) | ||
{ | ||
if (formatter == null) | ||
{ | ||
throw new ArgumentNullException(nameof(formatter)); | ||
} | ||
|
||
switch (logLevel) | ||
{ | ||
case LogLevel.Trace: | ||
LogWithLevel(this.log.Trace, eventId, state, exception, formatter); | ||
return; | ||
case LogLevel.Debug: | ||
LogWithLevel(this.log.Debug, eventId, state, exception, formatter); | ||
return; | ||
case LogLevel.Information: | ||
LogWithLevel(this.log.Info, eventId, state, exception, formatter); | ||
return; | ||
case LogLevel.Warning: | ||
LogWithLevel(this.log.Warn, eventId, state, exception, formatter); | ||
return; | ||
case LogLevel.Error: | ||
LogWithLevel(this.log.Error, eventId, state, exception, formatter); | ||
return; | ||
case LogLevel.Critical: | ||
LogWithLevel(this.log.Fatal, eventId, state, exception, formatter); | ||
return; | ||
case LogLevel.None: | ||
return; | ||
default: | ||
throw new ArgumentOutOfRangeException(nameof(logLevel), logLevel, FormattableString.Invariant($"Unexpected log level: {logLevel}")); | ||
} | ||
|
||
static void LogWithLevel( | ||
Action<object, Exception?> logException, | ||
EventId eventId, | ||
TState state, | ||
Exception? exception, | ||
Func<TState, Exception?, string> formatter) | ||
{ | ||
logException($"[{eventId}] {formatter(state, exception)}", exception); | ||
} | ||
} | ||
|
||
/// <inheritdoc /> | ||
public bool IsEnabled(LogLevel logLevel) | ||
{ | ||
return logLevel switch | ||
{ | ||
LogLevel.None => false, | ||
LogLevel.Critical => this.log.IsFatalEnabled, | ||
LogLevel.Error => this.log.IsErrorEnabled, | ||
LogLevel.Warning => this.log.IsWarnEnabled, | ||
LogLevel.Information => this.log.IsInfoEnabled, | ||
LogLevel.Debug => this.log.IsDebugEnabled, | ||
LogLevel.Trace => this.log.IsTraceEnabled, | ||
_ => throw new ArgumentOutOfRangeException(nameof(logLevel), logLevel, FormattableString.Invariant($"Unexpected log level: {logLevel}")), | ||
}; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public IDisposable BeginScope<TState>(TState state) | ||
where TState : notnull | ||
{ | ||
this.log.InfoFormat(CultureInfo.InvariantCulture, "[BeginScope] {0}", state); | ||
return new ScopeDisposable(() => this.log.InfoFormat(CultureInfo.InvariantCulture, "[EndScope] {0}", state)); | ||
} | ||
|
||
private sealed class ScopeDisposable : IDisposable | ||
{ | ||
private readonly Action onDispose; | ||
|
||
public ScopeDisposable(Action onDispose) | ||
{ | ||
this.onDispose = onDispose; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
this.onDispose(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// <copyright file="DnnLoggerProvider.cs" company="Engage"> | ||
// Engage.Dnn.Logging | ||
// Copyright (c) 2023 | ||
// </copyright> | ||
namespace Engage.Dnn.Logging; | ||
|
||
/// <summary>An <see cref="ILoggerProvider" /> implementation using DNN's <see cref="LoggerSource"/>.</summary> | ||
public sealed class DnnLoggerProvider : ILoggerProvider | ||
{ | ||
/// <inheritdoc /> | ||
public ILogger CreateLogger(string categoryName) | ||
{ | ||
return new DnnLogger(LoggerSource.Instance.GetLogger(categoryName)); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void Dispose() | ||
{ | ||
} | ||
} |
Oops, something went wrong.