Skip to content

Commit ab16a6e

Browse files
authored
more modern coding style (#196)
* - convert to filescoped namespaces - use collection expressions - removed prefix m_ from private fields * switched to prefix _ for private fields
1 parent a1c0aec commit ab16a6e

File tree

279 files changed

+41177
-41692
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

279 files changed

+41177
-41692
lines changed

.editorconfig

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
1818
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
1919
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
2020

21+
## constant fields should be PascalCase
22+
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = error
23+
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
24+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
25+
dotnet_naming_symbols.constant_fields.applicable_kinds = field
26+
dotnet_naming_symbols.constant_fields.required_modifiers = const
27+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
28+
29+
dotnet_naming_rule.private_members_with_underscore.symbols = private_fields
30+
dotnet_naming_rule.private_members_with_underscore.style = prefix_underscore
31+
dotnet_naming_rule.private_members_with_underscore.severity = suggestion
32+
33+
dotnet_naming_symbols.private_fields.applicable_kinds = field
34+
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
35+
36+
dotnet_naming_style.prefix_underscore.capitalization = camel_case
37+
dotnet_naming_style.prefix_underscore.required_prefix = _
38+
2139
# Symbol specifications
2240

2341
dotnet_naming_symbols.interface.applicable_kinds = interface
@@ -138,4 +156,7 @@ dotnet_diagnostic.SYSLIB0014.severity = none
138156
# SYSLIB0050: Type or member is obsolete
139157
dotnet_diagnostic.SYSLIB0050.severity = none
140158
# SYSLIB0051: Type or member is obsolete
141-
dotnet_diagnostic.SYSLIB0051.severity = none
159+
dotnet_diagnostic.SYSLIB0051.severity = none
160+
161+
# KR1012: Classes should be sealed.
162+
dotnet_diagnostic.KR1012.severity = none

src/integration-testing/log4net-672/Program.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
using log4net;
77
using log4net.Config;
88

9-
const int NO_ERROR = 0;
10-
const int MISSING_LOGS = 1;
11-
const int OVERWRITTEN_LOGS = 2;
9+
const int NoError = 0;
10+
const int MissingLogs = 1;
11+
const int OverwrittenLogs = 2;
1212

1313
var appPath = new Uri(Assembly.GetExecutingAssembly().Location).LocalPath;
1414
var appFolder = Path.GetDirectoryName(appPath);
@@ -38,7 +38,7 @@
3838
var logged = LogWith(identifier, logCount);
3939
if (logged != logCount)
4040
{
41-
Die($"Missing logs immediately for '{identifier}' - found {logged}/{logCount}", MISSING_LOGS);
41+
Die($"Missing logs immediately for '{identifier}' - found {logged}/{logCount}", MissingLogs);
4242
}
4343
}
4444

@@ -47,12 +47,12 @@
4747
var logged = CountIdentifierInLogs(identifier);
4848
if (logged != logCount)
4949
{
50-
Die($"Logs have been overwritten for '{identifier}' - found {logged}/{logCount}", OVERWRITTEN_LOGS);
50+
Die($"Logs have been overwritten for '{identifier}' - found {logged}/{logCount}", OverwrittenLogs);
5151
}
5252
}
5353

5454
Console.WriteLine("All good: LOG4NET-672 is resolved");
55-
return NO_ERROR;
55+
return NoError;
5656

5757
void Die(string message, int exitCode)
5858
{

src/integration-testing/log4net2-SerializeEvent/SerializeEventProgram.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
var stackTrace = new StackTrace(true);
2020

21-
var log4net2Event = new LoggingEvent(new LoggingEventData
21+
var log4Net2Event = new LoggingEvent(new LoggingEventData
2222
{
2323
// Deliberate use of obsolete local timestamp.
2424
#pragma warning disable CS0618 // Type or member is obsolete
@@ -37,8 +37,8 @@
3737
Properties = new PropertiesDictionary { ["foo"] = "bar" },
3838
});
3939

40-
log4net2Event.Fix = FixFlags.All;
40+
log4Net2Event.Fix = FixFlags.All;
4141

4242
using var stream = File.OpenWrite("SerializeV2Event.dat");
4343
var formatter = new BinaryFormatter();
44-
formatter.Serialize(stream, log4net2Event);
44+
formatter.Serialize(stream, log4Net2Event);

src/log4net.Tests/Appender/AdoNet/Log4NetCommand.cs

Lines changed: 70 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -22,88 +22,87 @@
2222
using System;
2323
using System.Data;
2424

25-
namespace log4net.Tests.Appender.AdoNet
25+
namespace log4net.Tests.Appender.AdoNet;
26+
27+
public class Log4NetCommand : IDbCommand
2628
{
27-
public class Log4NetCommand : IDbCommand
29+
public Log4NetCommand()
2830
{
29-
public Log4NetCommand()
30-
{
31-
MostRecentInstance = this;
31+
MostRecentInstance = this;
3232

33-
Parameters = new Log4NetParameterCollection();
34-
}
33+
Parameters = new Log4NetParameterCollection();
34+
}
3535

36-
public void Dispose()
37-
{
38-
// empty
39-
}
36+
public void Dispose()
37+
{
38+
// empty
39+
}
4040

41-
public IDbTransaction? Transaction { get; set; }
41+
public IDbTransaction? Transaction { get; set; }
4242

43-
public int ExecuteNonQuery()
44-
{
45-
ExecuteNonQueryCount++;
46-
return 0;
47-
}
43+
public int ExecuteNonQuery()
44+
{
45+
ExecuteNonQueryCount++;
46+
return 0;
47+
}
4848

49-
public int ExecuteNonQueryCount { get; private set; }
49+
public int ExecuteNonQueryCount { get; private set; }
5050

51-
public IDbDataParameter CreateParameter()
52-
{
53-
return new Log4NetParameter();
54-
}
51+
public IDbDataParameter CreateParameter()
52+
{
53+
return new Log4NetParameter();
54+
}
5555

5656
#pragma warning disable CS8766 // Nullability of reference types in return type doesn't match implicitly implemented member (possibly because of nullability attributes).
57-
public string? CommandText { get; set; }
57+
public string? CommandText { get; set; }
5858
#pragma warning restore CS8766
5959

60-
public CommandType CommandType { get; set; }
61-
62-
public void Prepare()
63-
{
64-
// empty
65-
}
66-
67-
public IDataParameterCollection Parameters { get; }
68-
69-
public static Log4NetCommand? MostRecentInstance { get; private set; }
70-
71-
public void Cancel()
72-
{
73-
throw new NotImplementedException();
74-
}
75-
76-
public IDataReader ExecuteReader()
77-
{
78-
throw new NotImplementedException();
79-
}
80-
81-
public IDataReader ExecuteReader(CommandBehavior behavior)
82-
{
83-
throw new NotImplementedException();
84-
}
85-
86-
public object ExecuteScalar()
87-
{
88-
throw new NotImplementedException();
89-
}
90-
91-
public IDbConnection? Connection
92-
{
93-
get => throw new NotImplementedException();
94-
set => throw new NotImplementedException();
95-
}
96-
97-
public int CommandTimeout
98-
{
99-
get => throw new NotImplementedException();
100-
set => throw new NotImplementedException();
101-
}
102-
103-
public UpdateRowSource UpdatedRowSource
104-
{
105-
get => throw new NotImplementedException();
106-
set => throw new NotImplementedException();
107-
}
60+
public CommandType CommandType { get; set; }
61+
62+
public void Prepare()
63+
{
64+
// empty
65+
}
66+
67+
public IDataParameterCollection Parameters { get; }
68+
69+
public static Log4NetCommand? MostRecentInstance { get; private set; }
70+
71+
public void Cancel()
72+
{
73+
throw new NotImplementedException();
74+
}
75+
76+
public IDataReader ExecuteReader()
77+
{
78+
throw new NotImplementedException();
79+
}
80+
81+
public IDataReader ExecuteReader(CommandBehavior behavior)
82+
{
83+
throw new NotImplementedException();
84+
}
85+
86+
public object ExecuteScalar()
87+
{
88+
throw new NotImplementedException();
89+
}
90+
91+
public IDbConnection? Connection
92+
{
93+
get => throw new NotImplementedException();
94+
set => throw new NotImplementedException();
95+
}
96+
97+
public int CommandTimeout
98+
{
99+
get => throw new NotImplementedException();
100+
set => throw new NotImplementedException();
101+
}
102+
103+
public UpdateRowSource UpdatedRowSource
104+
{
105+
get => throw new NotImplementedException();
106+
set => throw new NotImplementedException();
108107
}
109108
}

src/log4net.Tests/Appender/AdoNet/Log4NetConnection.cs

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,62 +22,61 @@
2222
using System;
2323
using System.Data;
2424

25-
namespace log4net.Tests.Appender.AdoNet
25+
namespace log4net.Tests.Appender.AdoNet;
26+
27+
public class Log4NetConnection : IDbConnection
2628
{
27-
public class Log4NetConnection : IDbConnection
28-
{
29-
private bool _open;
29+
private bool _open;
3030

31-
public Log4NetConnection()
32-
{
33-
MostRecentInstance = this;
34-
}
31+
public Log4NetConnection()
32+
{
33+
MostRecentInstance = this;
34+
}
3535

36-
public void Close()
37-
{
38-
_open = false;
39-
}
36+
public void Close()
37+
{
38+
_open = false;
39+
}
4040

41-
public ConnectionState State => _open ? ConnectionState.Open : ConnectionState.Closed;
41+
public ConnectionState State => _open ? ConnectionState.Open : ConnectionState.Closed;
4242

4343
#pragma warning disable CS8766 // Nullability of reference types in return type doesn't match implicitly implemented member (possibly because of nullability attributes).
44-
public string? ConnectionString { get; set; }
44+
public string? ConnectionString { get; set; }
4545
#pragma warning restore CS8766
4646

47-
public IDbTransaction BeginTransaction()
48-
{
49-
return new Log4NetTransaction();
50-
}
47+
public IDbTransaction BeginTransaction()
48+
{
49+
return new Log4NetTransaction();
50+
}
5151

52-
public IDbCommand CreateCommand()
53-
{
54-
return new Log4NetCommand();
55-
}
52+
public IDbCommand CreateCommand()
53+
{
54+
return new Log4NetCommand();
55+
}
5656

57-
public void Open()
58-
{
59-
_open = true;
60-
}
57+
public void Open()
58+
{
59+
_open = true;
60+
}
6161

62-
public static Log4NetConnection? MostRecentInstance { get; private set; }
62+
public static Log4NetConnection? MostRecentInstance { get; private set; }
6363

64-
public IDbTransaction BeginTransaction(IsolationLevel il)
65-
{
66-
throw new NotImplementedException();
67-
}
64+
public IDbTransaction BeginTransaction(IsolationLevel il)
65+
{
66+
throw new NotImplementedException();
67+
}
6868

69-
public void ChangeDatabase(string databaseName)
70-
{
71-
throw new NotImplementedException();
72-
}
69+
public void ChangeDatabase(string databaseName)
70+
{
71+
throw new NotImplementedException();
72+
}
7373

74-
public int ConnectionTimeout => throw new NotImplementedException();
74+
public int ConnectionTimeout => throw new NotImplementedException();
7575

76-
public string Database => throw new NotImplementedException();
76+
public string Database => throw new NotImplementedException();
7777

78-
public void Dispose()
79-
{
80-
throw new NotImplementedException();
81-
}
78+
public void Dispose()
79+
{
80+
throw new NotImplementedException();
8281
}
8382
}

0 commit comments

Comments
 (0)