Skip to content

Commit e0ef000

Browse files
committed
Reverted breaking API change
Cannot remove IDisposable from MSSqlServerAuditSink class without bumping major version, so we leave it the same.
1 parent 4c65eb0 commit e0ef000

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/MSSqlServerAuditSink.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace Serilog.Sinks.MSSqlServer
2626
/// Writes log events as rows in a table of MSSqlServer database using Audit logic, meaning that each row is synchronously committed
2727
/// and any errors that occur are propagated to the caller.
2828
/// </summary>
29-
public class MSSqlServerAuditSink : ILogEventSink
29+
public class MSSqlServerAuditSink : ILogEventSink, IDisposable
3030
{
3131
private readonly ISqlLogEventWriter _sqlLogEventWriter;
3232

@@ -97,6 +97,25 @@ internal MSSqlServerAuditSink(
9797
public void Emit(LogEvent logEvent) =>
9898
_sqlLogEventWriter.WriteEvent(logEvent);
9999

100+
/// <summary>
101+
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
102+
/// </summary>
103+
public void Dispose()
104+
{
105+
Dispose(true);
106+
GC.SuppressFinalize(this);
107+
}
108+
109+
/// <summary>
110+
/// Releases the unmanaged resources used by the Serilog.Sinks.MSSqlServer.MSSqlServerAuditSink and optionally
111+
/// releases the managed resources.
112+
/// </summary>
113+
/// <param name="disposing">True to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
114+
protected virtual void Dispose(bool disposing)
115+
{
116+
// This class needn't to dispose anything. This is just here for sink interface compatibility.
117+
}
118+
100119
private static void ValidateParameters(MSSqlServerSinkOptions sinkOptions, ColumnOptions columnOptions)
101120
{
102121
if (sinkOptions?.TableName == null)

0 commit comments

Comments
 (0)