Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

## constant fields should be PascalCase
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = error
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.required_modifiers = const
dotnet_naming_style.pascal_case_style.capitalization = pascal_case

dotnet_naming_rule.private_members_with_underscore.symbols = private_fields
dotnet_naming_rule.private_members_with_underscore.style = prefix_underscore
dotnet_naming_rule.private_members_with_underscore.severity = suggestion

dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private

dotnet_naming_style.prefix_underscore.capitalization = camel_case
dotnet_naming_style.prefix_underscore.required_prefix = _

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
Expand Down Expand Up @@ -138,4 +156,7 @@ dotnet_diagnostic.SYSLIB0014.severity = none
# SYSLIB0050: Type or member is obsolete
dotnet_diagnostic.SYSLIB0050.severity = none
# SYSLIB0051: Type or member is obsolete
dotnet_diagnostic.SYSLIB0051.severity = none
dotnet_diagnostic.SYSLIB0051.severity = none

# KR1012: Classes should be sealed.
dotnet_diagnostic.KR1012.severity = none
12 changes: 6 additions & 6 deletions src/integration-testing/log4net-672/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
using log4net;
using log4net.Config;

const int NO_ERROR = 0;
const int MISSING_LOGS = 1;
const int OVERWRITTEN_LOGS = 2;
const int NoError = 0;
const int MissingLogs = 1;
const int OverwrittenLogs = 2;

var appPath = new Uri(Assembly.GetExecutingAssembly().Location).LocalPath;
var appFolder = Path.GetDirectoryName(appPath);
Expand Down Expand Up @@ -38,7 +38,7 @@
var logged = LogWith(identifier, logCount);
if (logged != logCount)
{
Die($"Missing logs immediately for '{identifier}' - found {logged}/{logCount}", MISSING_LOGS);
Die($"Missing logs immediately for '{identifier}' - found {logged}/{logCount}", MissingLogs);
}
}

Expand All @@ -47,12 +47,12 @@
var logged = CountIdentifierInLogs(identifier);
if (logged != logCount)
{
Die($"Logs have been overwritten for '{identifier}' - found {logged}/{logCount}", OVERWRITTEN_LOGS);
Die($"Logs have been overwritten for '{identifier}' - found {logged}/{logCount}", OverwrittenLogs);
}
}

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

void Die(string message, int exitCode)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

var stackTrace = new StackTrace(true);

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

log4net2Event.Fix = FixFlags.All;
log4Net2Event.Fix = FixFlags.All;

using var stream = File.OpenWrite("SerializeV2Event.dat");
var formatter = new BinaryFormatter();
formatter.Serialize(stream, log4net2Event);
formatter.Serialize(stream, log4Net2Event);
141 changes: 70 additions & 71 deletions src/log4net.Tests/Appender/AdoNet/Log4NetCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,88 +22,87 @@
using System;
using System.Data;

namespace log4net.Tests.Appender.AdoNet
namespace log4net.Tests.Appender.AdoNet;

public class Log4NetCommand : IDbCommand
{
public class Log4NetCommand : IDbCommand
public Log4NetCommand()
{
public Log4NetCommand()
{
MostRecentInstance = this;
MostRecentInstance = this;

Parameters = new Log4NetParameterCollection();
}
Parameters = new Log4NetParameterCollection();
}

public void Dispose()
{
// empty
}
public void Dispose()
{
// empty
}

public IDbTransaction? Transaction { get; set; }
public IDbTransaction? Transaction { get; set; }

public int ExecuteNonQuery()
{
ExecuteNonQueryCount++;
return 0;
}
public int ExecuteNonQuery()
{
ExecuteNonQueryCount++;
return 0;
}

public int ExecuteNonQueryCount { get; private set; }
public int ExecuteNonQueryCount { get; private set; }

public IDbDataParameter CreateParameter()
{
return new Log4NetParameter();
}
public IDbDataParameter CreateParameter()
{
return new Log4NetParameter();
}

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

public CommandType CommandType { get; set; }

public void Prepare()
{
// empty
}

public IDataParameterCollection Parameters { get; }

public static Log4NetCommand? MostRecentInstance { get; private set; }

public void Cancel()
{
throw new NotImplementedException();
}

public IDataReader ExecuteReader()
{
throw new NotImplementedException();
}

public IDataReader ExecuteReader(CommandBehavior behavior)
{
throw new NotImplementedException();
}

public object ExecuteScalar()
{
throw new NotImplementedException();
}

public IDbConnection? Connection
{
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}

public int CommandTimeout
{
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}

public UpdateRowSource UpdatedRowSource
{
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}
public CommandType CommandType { get; set; }

public void Prepare()
{
// empty
}

public IDataParameterCollection Parameters { get; }

public static Log4NetCommand? MostRecentInstance { get; private set; }

public void Cancel()
{
throw new NotImplementedException();
}

public IDataReader ExecuteReader()
{
throw new NotImplementedException();
}

public IDataReader ExecuteReader(CommandBehavior behavior)
{
throw new NotImplementedException();
}

public object ExecuteScalar()
{
throw new NotImplementedException();
}

public IDbConnection? Connection
{
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}

public int CommandTimeout
{
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}

public UpdateRowSource UpdatedRowSource
{
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}
}
81 changes: 40 additions & 41 deletions src/log4net.Tests/Appender/AdoNet/Log4NetConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,62 +22,61 @@
using System;
using System.Data;

namespace log4net.Tests.Appender.AdoNet
namespace log4net.Tests.Appender.AdoNet;

public class Log4NetConnection : IDbConnection
{
public class Log4NetConnection : IDbConnection
{
private bool _open;
private bool _open;

public Log4NetConnection()
{
MostRecentInstance = this;
}
public Log4NetConnection()
{
MostRecentInstance = this;
}

public void Close()
{
_open = false;
}
public void Close()
{
_open = false;
}

public ConnectionState State => _open ? ConnectionState.Open : ConnectionState.Closed;
public ConnectionState State => _open ? ConnectionState.Open : ConnectionState.Closed;

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

public IDbTransaction BeginTransaction()
{
return new Log4NetTransaction();
}
public IDbTransaction BeginTransaction()
{
return new Log4NetTransaction();
}

public IDbCommand CreateCommand()
{
return new Log4NetCommand();
}
public IDbCommand CreateCommand()
{
return new Log4NetCommand();
}

public void Open()
{
_open = true;
}
public void Open()
{
_open = true;
}

public static Log4NetConnection? MostRecentInstance { get; private set; }
public static Log4NetConnection? MostRecentInstance { get; private set; }

public IDbTransaction BeginTransaction(IsolationLevel il)
{
throw new NotImplementedException();
}
public IDbTransaction BeginTransaction(IsolationLevel il)
{
throw new NotImplementedException();
}

public void ChangeDatabase(string databaseName)
{
throw new NotImplementedException();
}
public void ChangeDatabase(string databaseName)
{
throw new NotImplementedException();
}

public int ConnectionTimeout => throw new NotImplementedException();
public int ConnectionTimeout => throw new NotImplementedException();

public string Database => throw new NotImplementedException();
public string Database => throw new NotImplementedException();

public void Dispose()
{
throw new NotImplementedException();
}
public void Dispose()
{
throw new NotImplementedException();
}
}
Loading