Skip to content

Commit 5b3d3dd

Browse files
committed
Added default csharp and dotnet rules to .editorconfig and fixed all violations.
1 parent 41d47ec commit 5b3d3dd

35 files changed

+305
-238
lines changed

.editorconfig

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,72 @@
11
root = true
22

33
[*]
4-
trim_trailing_whitespace = true
5-
insert_final_newline = true
6-
indent_style = space
74
indent_size = 4
5+
indent_style = space
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
88

99
[*.{csproj,json,config,yml}]
1010
indent_size = 2
1111

1212
[*.sh]
1313
end_of_line = lf
1414

15-
[*.{cmd, bat}]
15+
[*.{cmd,bat}]
1616
end_of_line = crlf
17+
18+
[*.cs]
19+
csharp_indent_case_contents = true
20+
csharp_indent_case_contents_when_block = true
21+
csharp_indent_labels = flush_left
22+
csharp_indent_switch_labels = true
23+
csharp_new_line_before_catch = true
24+
csharp_new_line_before_else = true
25+
csharp_new_line_before_finally = true
26+
csharp_new_line_before_members_in_anonymous_types = true
27+
csharp_new_line_before_members_in_object_initializers = true
28+
csharp_new_line_before_open_brace = all
29+
csharp_new_line_between_query_expression_clauses = true
30+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:error
31+
csharp_prefer_braces = true:silent
32+
csharp_prefer_simple_default_expression = true:suggestion
33+
csharp_style_deconstructed_variable_declaration = true:suggestion
34+
csharp_preserve_single_line_blocks = true
35+
csharp_preserve_single_line_statements = true
36+
csharp_space_after_cast = false
37+
csharp_space_after_colon_in_inheritance_clause = true
38+
csharp_space_after_keywords_in_control_flow_statements = true
39+
csharp_space_around_binary_operators = before_and_after
40+
csharp_space_before_colon_in_inheritance_clause = true
41+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
42+
csharp_space_between_method_call_name_and_opening_parenthesis = false
43+
csharp_space_between_method_call_parameter_list_parentheses = false
44+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
45+
csharp_space_between_method_declaration_parameter_list_parentheses = false
46+
csharp_space_between_parentheses = false
47+
csharp_style_conditional_delegate_call = true:suggestion
48+
csharp_style_expression_bodied_accessors = true:silent
49+
csharp_style_expression_bodied_constructors = false:silent
50+
csharp_style_expression_bodied_indexers = true:silent
51+
csharp_style_expression_bodied_methods = false:silent
52+
csharp_style_expression_bodied_operators = false:silent
53+
csharp_style_expression_bodied_properties = true:silent
54+
csharp_style_inlined_variable_declaration = true:suggestion
55+
csharp_style_pattern_local_over_anonymous_function = true:suggestion
56+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
57+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
58+
csharp_style_throw_expression = true:suggestion
59+
csharp_style_var_elsewhere = true:silent
60+
csharp_style_var_for_built_in_types = true:warning
61+
csharp_style_var_when_type_is_apparent = true:warning
62+
csharp_using_directive_placement = outside_namespace:warning
63+
64+
dotnet_naming_rule.private_members_with_underscore.symbols = private_fields
65+
dotnet_naming_rule.private_members_with_underscore.style = prefix_underscore
66+
dotnet_naming_rule.private_members_with_underscore.severity = error
67+
dotnet_naming_symbols.private_fields.applicable_kinds = field
68+
dotnet_naming_symbols.private_fields.applicable_accessibilities = private,protected
69+
dotnet_naming_style.prefix_underscore.capitalization = camel_case
70+
dotnet_naming_style.prefix_underscore.required_prefix = _
71+
dotnet_sort_system_directives_first = true
72+
dotnet_style_require_accessibility_modifiers = always:error

sample/AppConfigDemo/Program.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
using Serilog;
1+
using System;
2+
using System.Threading;
3+
using Serilog;
24
using Serilog.Events;
35
using Serilog.Sinks.MSSqlServer;
4-
using System;
5-
using System.Threading;
66

77
namespace AppConfigDemo
88
{
99
public static class Program
1010
{
11-
const string _connectionString = "Server=localhost;Database=LogTest;Integrated Security=SSPI;";
12-
const string _schemaName = "dbo";
13-
const string _tableName = "LogEvents";
11+
private const string _connectionString = "Server=localhost;Database=LogTest;Integrated Security=SSPI;";
12+
private const string _schemaName = "dbo";
13+
private const string _tableName = "LogEvents";
1414

1515
public static void Main()
1616
{

sample/CombinedConfigDemo/Program.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using Microsoft.Extensions.Configuration;
2-
using Serilog;
3-
using System;
1+
using System;
42
using System.Threading;
3+
using Microsoft.Extensions.Configuration;
4+
using Serilog;
55

66
namespace CombinedConfigDemo
77
{
@@ -10,9 +10,9 @@ namespace CombinedConfigDemo
1010
// as parameters to the MSSqlServer() method.
1111
public static class Program
1212
{
13-
const string _connectionStringName = "LogDatabase";
14-
const string _schemaName = "dbo";
15-
const string _tableName = "LogEvents";
13+
private const string _connectionStringName = "LogDatabase";
14+
private const string _schemaName = "dbo";
15+
private const string _tableName = "LogEvents";
1616

1717
public static void Main()
1818
{

sample/CustomLogEventFormatterDemo/FlatLogEventFormatter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using Serilog.Events;
2-
using Serilog.Formatting;
3-
using System.IO;
1+
using System.IO;
42
using System.Linq;
3+
using Serilog.Events;
4+
using Serilog.Formatting;
55

66
namespace CustomLogEventFormatterDemo
77
{

sample/CustomLogEventFormatterDemo/Program.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
using Serilog;
2-
using Serilog.Sinks.MSSqlServer;
3-
using System;
1+
using System;
42
using System.Threading;
3+
using Serilog;
4+
using Serilog.Sinks.MSSqlServer;
55

66
namespace CustomLogEventFormatterDemo
77
{
88
public static class Program
99
{
10-
const string _connectionString = "Server=localhost;Database=LogTest;Integrated Security=SSPI;";
11-
const string _schemaName = "dbo";
12-
const string _tableName = "LogEvents";
10+
private const string _connectionString = "Server=localhost;Database=LogTest;Integrated Security=SSPI;";
11+
private const string _schemaName = "dbo";
12+
private const string _tableName = "LogEvents";
1313

1414
public static void Main()
1515
{
@@ -49,7 +49,7 @@ public static void Main()
4949
Log.CloseAndFlush();
5050
}
5151

52-
static void Fail()
52+
private static void Fail()
5353
{
5454
throw new DivideByZeroException();
5555
}

sample/WorkerServiceDemo/CustomLogEventFormatter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using Serilog.Events;
2-
using Serilog.Formatting;
3-
using System.IO;
1+
using System.IO;
42
using System.Linq;
3+
using Serilog.Events;
4+
using Serilog.Formatting;
55

66
namespace WorkerServiceDemo
77
{

serilog-sinks-mssqlserver.sln

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{04226074-C72
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{F02D6513-6F45-452E-85A0-41A872A2C1F8}"
99
EndProject
10-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{70667ADA-A2FD-4821-A6A1-8D18D0D71507}"
11-
ProjectSection(SolutionItems) = preProject
12-
appveyor.yml = appveyor.yml
13-
Build.ps1 = Build.ps1
14-
CHANGES.md = CHANGES.md
15-
README.md = README.md
16-
EndProjectSection
17-
EndProject
1810
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Sinks.MSSqlServer", "src\Serilog.Sinks.MSSqlServer\Serilog.Sinks.MSSqlServer.csproj", "{803CD13A-D54B-4CEC-A55F-E22AE3D93B3C}"
1911
EndProject
2012
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Sinks.MSSqlServer.Tests", "test\Serilog.Sinks.MSSqlServer.Tests\Serilog.Sinks.MSSqlServer.Tests.csproj", "{3C2D8E01-5580-426A-BDD9-EC59CD98E618}"
@@ -27,7 +19,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppConfigDemo", "sample\App
2719
EndProject
2820
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkerServiceDemo", "sample\WorkerServiceDemo\WorkerServiceDemo.csproj", "{04F523D9-F00B-4C63-9287-31A244378E06}"
2921
EndProject
30-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CombinedConfigDemo", "sample\CombinedConfigDemo\CombinedConfigDemo.csproj", "{98F21125-AF7A-46E8-8C08-E3E4F5DBEDB9}"
22+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CombinedConfigDemo", "sample\CombinedConfigDemo\CombinedConfigDemo.csproj", "{98F21125-AF7A-46E8-8C08-E3E4F5DBEDB9}"
23+
EndProject
24+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3C0AA8A2-9446-41A9-AD2A-24593C2CF168}"
25+
ProjectSection(SolutionItems) = preProject
26+
.editorconfig = .editorconfig
27+
appveyor.yml = appveyor.yml
28+
Build.ps1 = Build.ps1
29+
CHANGES.md = CHANGES.md
30+
README.md = README.md
31+
EndProjectSection
3132
EndProject
3233
Global
3334
GlobalSection(SolutionConfigurationPlatforms) = preSolution

src/Serilog.Sinks.MSSqlServer/Configuration/Extensions/Hybrid/LoggerConfigurationMSSqlServerExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
// limitations under the License.
1414

1515
using System;
16-
using Serilog.Configuration;
17-
using Serilog.Events;
18-
using Serilog.Sinks.MSSqlServer;
19-
using Microsoft.Extensions.Configuration;
2016
using System.Configuration;
17+
using Microsoft.Extensions.Configuration;
18+
using Serilog.Configuration;
2119
using Serilog.Debugging;
20+
using Serilog.Events;
2221
using Serilog.Formatting;
22+
using Serilog.Sinks.MSSqlServer;
2323

2424
// The "Hybrid" configuration system supports both Microsoft.Extensions.Configuration and System.Configuration.
2525
// This is necessary because .NET Framework 4.6.1+ and .NET Core 2.0+ apps support both approaches, whereas the

src/Serilog.Sinks.MSSqlServer/Configuration/Extensions/Microsoft.Extensions.Configuration/LoggerConfigurationMSSqlServerExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
// limitations under the License.
1414

1515
using System;
16+
using Microsoft.Extensions.Configuration;
1617
using Serilog.Configuration;
1718
using Serilog.Events;
18-
using Serilog.Sinks.MSSqlServer;
19-
using Microsoft.Extensions.Configuration;
2019
using Serilog.Formatting;
20+
using Serilog.Sinks.MSSqlServer;
2121

2222
// M.E.C. support for .NET Standard 2.0 libraries.
2323

src/Serilog.Sinks.MSSqlServer/Configuration/Extensions/System.Configuration/LoggerConfigurationMSSqlServerExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
// limitations under the License.
1414

1515
using System;
16+
using System.Configuration;
1617
using Serilog.Configuration;
1718
using Serilog.Events;
18-
using Serilog.Sinks.MSSqlServer;
19-
using System.Configuration;
2019
using Serilog.Formatting;
20+
using Serilog.Sinks.MSSqlServer;
2121

2222
// System.Configuration support for .NET Framework 4.5.2 libraries and apps.
2323

0 commit comments

Comments
 (0)