diff --git a/.editorconfig b/.editorconfig
index c5b83d7e..ba257f5c 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,5 +1,5 @@
-# Version: 2.0.1 (Using https://semver.org/)
-# Updated: 2020-12-11
+# Version: 2.1.0 (Using https://semver.org/)
+# Updated: 2021-03-03
# See https://github.com/RehanSaeed/EditorConfig/releases for release notes.
# See https://github.com/RehanSaeed/EditorConfig for updates to this file.
# See http://EditorConfig.org for more information about .editorconfig files.
@@ -73,84 +73,64 @@ indent_style = tab
dotnet_analyzer_diagnostic.severity = warning
##########################################
-# File Header (Uncomment to support file headers)
-# https://docs.microsoft.com/visualstudio/ide/reference/add-file-header
+# Language Rules
+# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules
##########################################
-# [*.{cs,csx,cake,vb,vbx}]
-# file_header_template = \n© PROJECT-AUTHOR\n
-
-# SA1636: File header copyright text should match
-# Justification: .editorconfig supports file headers. If this is changed to a value other than "none", a stylecop.json file will need to added to the project.
-# dotnet_diagnostic.SA1636.severity = none
-
-##########################################
-# .NET Language Conventions
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions
-##########################################
-
-# .NET Code Style Settings
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#net-code-style-settings
+# .NET Style Rules
+# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#net-style-rules
[*.{cs,csx,cake,vb,vbx}]
# "this." and "Me." qualifiers
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#this-and-me
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
# Language keywords instead of framework type names for type references
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#language-keywords
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
dotnet_style_predefined_type_for_member_access = true:warning
# Modifier preferences
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#normalize-modifiers
dotnet_style_require_accessibility_modifiers = always:warning
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning
visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:warning
dotnet_style_readonly_field = true:warning
# Parentheses preferences
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#parentheses-preferences
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning
dotnet_style_parentheses_in_other_operators = always_for_clarity:suggestion
# Expression-level preferences
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#expression-level-preferences
dotnet_style_object_initializer = true:warning
dotnet_style_collection_initializer = true:warning
dotnet_style_explicit_tuple_names = true:warning
dotnet_style_prefer_inferred_tuple_names = true:warning
dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning
dotnet_style_prefer_auto_properties = true:warning
-dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
dotnet_style_prefer_conditional_expression_over_assignment = false:suggestion
dotnet_diagnostic.IDE0045.severity = suggestion
dotnet_style_prefer_conditional_expression_over_return = false:suggestion
dotnet_diagnostic.IDE0046.severity = suggestion
dotnet_style_prefer_compound_assignment = true:warning
+dotnet_style_prefer_simplified_interpolation = true:warning
+dotnet_style_prefer_simplified_boolean_expressions = true:warning
# Null-checking preferences
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#null-checking-preferences
dotnet_style_coalesce_expression = true:warning
dotnet_style_null_propagation = true:warning
-# Parameter preferences
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#parameter-preferences
-dotnet_code_quality_unused_parameters = all:warning
-# More style options (Undocumented)
-# https://github.com/MicrosoftDocs/visualstudio-docs/issues/3641
+dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
+# File header preferences
+# file_header_template = \n© PROJECT-AUTHOR\n
+# If you use StyleCop, you'll need to disable SA1636: File header copyright text should match.
+# dotnet_diagnostic.SA1636.severity = none
+# Undocumented
dotnet_style_operator_placement_when_wrapping = end_of_line
-# https://github.com/dotnet/roslyn/pull/40070
-dotnet_style_prefer_simplified_interpolation = true:warning
-# C# Code Style Settings
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#c-code-style-settings
+# C# Style Rules
+# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#c-style-rules
[*.{cs,csx,cake}]
-# Implicit and explicit types
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#implicit-and-explicit-types
+# 'var' preferences
csharp_style_var_for_built_in_types = true:warning
csharp_style_var_when_type_is_apparent = true:warning
csharp_style_var_elsewhere = true:warning
# Expression-bodied members
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#expression-bodied-members
csharp_style_expression_bodied_methods = true:warning
csharp_style_expression_bodied_constructors = true:warning
csharp_style_expression_bodied_operators = true:warning
@@ -159,50 +139,64 @@ csharp_style_expression_bodied_indexers = true:warning
csharp_style_expression_bodied_accessors = true:warning
csharp_style_expression_bodied_lambdas = true:warning
csharp_style_expression_bodied_local_functions = true:warning
-# Pattern matching
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#pattern-matching
+# Pattern matching preferences
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
csharp_style_pattern_matching_over_as_with_null_check = true:warning
-# Inlined variable declarations
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#inlined-variable-declarations
-csharp_style_inlined_variable_declaration = true:warning
+csharp_style_prefer_switch_expression = true:warning
+csharp_style_prefer_pattern_matching = true:warning
+csharp_style_prefer_not_pattern = true:warning
# Expression-level preferences
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#expression-level-preferences
+csharp_style_inlined_variable_declaration = true:warning
csharp_prefer_simple_default_expression = true:warning
+csharp_style_pattern_local_over_anonymous_function = true:warning
+csharp_style_deconstructed_variable_declaration = true:warning
+csharp_style_prefer_index_operator = true:warning
+csharp_style_prefer_range_operator = true:warning
+csharp_style_implicit_object_creation_when_type_is_apparent = true:warning
# "Null" checking preferences
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#c-null-checking-preferences
csharp_style_throw_expression = true:warning
csharp_style_conditional_delegate_call = true:warning
# Code block preferences
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#code-block-preferences
csharp_prefer_braces = true:warning
-# Unused value preferences
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#unused-value-preferences
+csharp_prefer_simple_using_statement = true:suggestion
+dotnet_diagnostic.IDE0063.severity = suggestion
+# 'using' directive preferences
+csharp_using_directive_placement = inside_namespace:warning
+# Modifier preferences
+csharp_prefer_static_local_function = true:warning
+
+##########################################
+# Unnecessary Code Rules
+# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/unnecessary-code-rules
+##########################################
+
+# .NET Unnecessary code rules
+[*.{cs,csx,cake,vb,vbx}]
+dotnet_code_quality_unused_parameters = all:warning
+dotnet_remove_unnecessary_suppression_exclusions = none:warning
+
+# C# Unnecessary code rules
+[*.{cs,csx,cake}]
csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
dotnet_diagnostic.IDE0058.severity = suggestion
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
dotnet_diagnostic.IDE0059.severity = suggestion
-# Index and range preferences
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#index-and-range-preferences
-csharp_style_prefer_index_operator = true:warning
-csharp_style_prefer_range_operator = true:warning
-# Miscellaneous preferences
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#miscellaneous-preferences
-csharp_style_deconstructed_variable_declaration = true:warning
-csharp_style_pattern_local_over_anonymous_function = true:warning
-csharp_using_directive_placement = inside_namespace:warning
-csharp_prefer_static_local_function = true:warning
-csharp_prefer_simple_using_statement = true:suggestion
-dotnet_diagnostic.IDE0063.severity = suggestion
##########################################
-# .NET Formatting Conventions
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-code-style-settings-reference#formatting-conventions
+# Formatting Rules
+# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules
##########################################
-# Organize usings
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#organize-using-directives
+# .NET formatting rules
+# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#net-formatting-rules
+[*.{cs,csx,cake,vb,vbx}]
+# Organize using directives
dotnet_sort_system_directives_first = true
+dotnet_separate_import_directive_groups = false
+
+# C# formatting rules
+# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#c-formatting-rules
+[*.{cs,csx,cake}]
# Newline options
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#new-line-options
csharp_new_line_before_open_brace = all
@@ -244,14 +238,14 @@ csharp_space_around_declaration_statements = false
csharp_space_before_open_square_brackets = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_square_brackets = false
-# Wrapping options
+# Wrap options
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#wrap-options
csharp_preserve_single_line_statements = false
csharp_preserve_single_line_blocks = true
##########################################
-# .NET Naming Conventions
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-naming-conventions
+# .NET Naming Rules
+# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/naming-rules
##########################################
[*.{cs,csx,cake,vb,vbx}]
diff --git a/Benchmarks/Serilog.Exceptions.Benchmark/DestructuringBenchmark.cs b/Benchmarks/Serilog.Exceptions.Benchmark/DestructuringBenchmark.cs
index ee05d495..1b011963 100644
--- a/Benchmarks/Serilog.Exceptions.Benchmark/DestructuringBenchmark.cs
+++ b/Benchmarks/Serilog.Exceptions.Benchmark/DestructuringBenchmark.cs
@@ -17,8 +17,8 @@ namespace Serilog.Exceptions.Benchmark
[SimpleJob(RuntimeMoniker.NetCoreApp30)]
public class DestructuringBenchmark
{
- private readonly ReflectionBasedDestructurer reflectionBasedDestructurer = new ReflectionBasedDestructurer(10);
- private readonly BenchmarkExceptionDestructurer benchmarkExceptionDestructurer = new BenchmarkExceptionDestructurer();
+ private readonly ReflectionBasedDestructurer reflectionBasedDestructurer = new(10);
+ private readonly BenchmarkExceptionDestructurer benchmarkExceptionDestructurer = new();
private BenchmarkException benchmarkException;
[GlobalSetup]
diff --git a/Benchmarks/Serilog.Exceptions.Benchmark/ExceptionPropertiesBag.cs b/Benchmarks/Serilog.Exceptions.Benchmark/ExceptionPropertiesBag.cs
index f72183a6..f45a47e4 100644
--- a/Benchmarks/Serilog.Exceptions.Benchmark/ExceptionPropertiesBag.cs
+++ b/Benchmarks/Serilog.Exceptions.Benchmark/ExceptionPropertiesBag.cs
@@ -9,7 +9,7 @@ internal class ExceptionPropertiesBag : IExceptionPropertiesBag
{
private readonly Exception exception;
private readonly IExceptionPropertyFilter filter;
- private readonly Dictionary properties = new Dictionary();
+ private readonly Dictionary properties = new();
// We keep a note on whether the results were collected to be sure that
// after that there are no changes. This is the application of fail-fast principle.
diff --git a/Source/Serilog.Exceptions.EntityFrameworkCore/Destructurers/DbUpdateExceptionDestructurer.cs b/Source/Serilog.Exceptions.EntityFrameworkCore/Destructurers/DbUpdateExceptionDestructurer.cs
index d5104e16..b0f07563 100644
--- a/Source/Serilog.Exceptions.EntityFrameworkCore/Destructurers/DbUpdateExceptionDestructurer.cs
+++ b/Source/Serilog.Exceptions.EntityFrameworkCore/Destructurers/DbUpdateExceptionDestructurer.cs
@@ -28,10 +28,14 @@ public override void Destructure(
var dbUpdateException = (DbUpdateException)exception;
var entriesValue = dbUpdateException.Entries?
.Select(
+#pragma warning disable IDE0050 // Convert to tuple
e => new
+#pragma warning restore IDE0050 // Convert to tuple
{
EntryProperties = e.Properties.Select(
+#pragma warning disable IDE0050 // Convert to tuple
p => new
+#pragma warning restore IDE0050 // Convert to tuple
{
PropertyName = p.Metadata.Name,
p.OriginalValue,
diff --git a/Source/Serilog.Exceptions/Core/DestructuringOptionsBuilder.cs b/Source/Serilog.Exceptions/Core/DestructuringOptionsBuilder.cs
index bef140cd..7dbee3ef 100644
--- a/Source/Serilog.Exceptions/Core/DestructuringOptionsBuilder.cs
+++ b/Source/Serilog.Exceptions/Core/DestructuringOptionsBuilder.cs
@@ -42,7 +42,7 @@ public class DestructuringOptionsBuilder : IDestructuringOptions
nameof(Exception.StackTrace));
#endif
- private readonly List destructurers = new List();
+ private readonly List destructurers = new();
///
/// Gets the name of the property which value will be filled with destructured exception.
diff --git a/Source/Serilog.Exceptions/Core/ExceptionPropertiesBag.cs b/Source/Serilog.Exceptions/Core/ExceptionPropertiesBag.cs
index beaa2049..16dfdb26 100644
--- a/Source/Serilog.Exceptions/Core/ExceptionPropertiesBag.cs
+++ b/Source/Serilog.Exceptions/Core/ExceptionPropertiesBag.cs
@@ -9,7 +9,7 @@ internal class ExceptionPropertiesBag : IExceptionPropertiesBag
{
private readonly Exception exception;
private readonly IExceptionPropertyFilter filter;
- private readonly Dictionary properties = new Dictionary();
+ private readonly Dictionary properties = new();
///
/// We keep a note on whether the results were collected to be sure that after that there are no changes. This
diff --git a/Source/Serilog.Exceptions/Destructurers/ReflectionBasedDestructurer.cs b/Source/Serilog.Exceptions/Destructurers/ReflectionBasedDestructurer.cs
index 22e57e55..30fd777f 100644
--- a/Source/Serilog.Exceptions/Destructurers/ReflectionBasedDestructurer.cs
+++ b/Source/Serilog.Exceptions/Destructurers/ReflectionBasedDestructurer.cs
@@ -23,9 +23,9 @@ public class ReflectionBasedDestructurer : IExceptionDestructurer
private const string RefLabel = "$ref";
private const string CyclicReferenceMessage = "Cyclic reference";
private readonly int destructuringDepth;
- private readonly object lockObj = new object();
+ private readonly object lockObj = new();
- private readonly Dictionary reflectionInfoCache = new Dictionary();
+ private readonly Dictionary reflectionInfoCache = new();
private readonly PropertyInfo[] baseExceptionPropertiesForDestructuring;
///
diff --git a/Source/Serilog.Exceptions/Destructurers/TaskCanceledExceptionDestructurer.cs b/Source/Serilog.Exceptions/Destructurers/TaskCanceledExceptionDestructurer.cs
index 77e6ad80..b9ca34ab 100644
--- a/Source/Serilog.Exceptions/Destructurers/TaskCanceledExceptionDestructurer.cs
+++ b/Source/Serilog.Exceptions/Destructurers/TaskCanceledExceptionDestructurer.cs
@@ -54,7 +54,9 @@ internal static object DestructureTask(
if (task.IsFaulted && task.Exception is not null)
{
+#pragma warning disable IDE0050 // Convert to tuple
return new
+#pragma warning restore IDE0050 // Convert to tuple
{
task.Id,
Status = taskStatus,
@@ -63,7 +65,9 @@ internal static object DestructureTask(
};
}
+#pragma warning disable IDE0050 // Convert to tuple
return new
+#pragma warning restore IDE0050 // Convert to tuple
{
task.Id,
Status = taskStatus,
diff --git a/Tests/Serilog.Exceptions.Test/Destructurers/ReflectionBasedDestructurerTest.cs b/Tests/Serilog.Exceptions.Test/Destructurers/ReflectionBasedDestructurerTest.cs
index 93025521..0167a844 100644
--- a/Tests/Serilog.Exceptions.Test/Destructurers/ReflectionBasedDestructurerTest.cs
+++ b/Tests/Serilog.Exceptions.Test/Destructurers/ReflectionBasedDestructurerTest.cs
@@ -432,7 +432,7 @@ private static Exception ThrowAndCatchException(Action throwingAction)
}
private static ReflectionBasedDestructurer CreateReflectionBasedDestructurer() =>
- new ReflectionBasedDestructurer(10);
+ new(10);
public class MyObject
{
diff --git a/Tests/Serilog.Exceptions.Test/Destructurers/TaskCanceledExceptionDestructurerTest.cs b/Tests/Serilog.Exceptions.Test/Destructurers/TaskCanceledExceptionDestructurerTest.cs
index f2ab73b5..b4f04a29 100644
--- a/Tests/Serilog.Exceptions.Test/Destructurers/TaskCanceledExceptionDestructurerTest.cs
+++ b/Tests/Serilog.Exceptions.Test/Destructurers/TaskCanceledExceptionDestructurerTest.cs
@@ -10,7 +10,7 @@ namespace Serilog.Exceptions.Test.Destructurers
public sealed class TaskCanceledExceptionDestructurerTest : IDisposable
{
- private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
+ private readonly CancellationTokenSource cancellationTokenSource = new();
[Fact]
public void TaskCanceledException_SimplePropertiesAreAttached()