Skip to content

Commit 6a16737

Browse files
committed
Marked old interfaces without SinkOptions parameter as obsolete.
1 parent 171c55d commit 6a16737

File tree

15 files changed

+191
-92
lines changed

15 files changed

+191
-92
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public static class LoggerConfigurationMSSqlServerExtensions
6262
/// <param name="logEventFormatter">Supplies custom formatter for the LogEvent column, or null</param>
6363
/// <returns>Logger configuration, allowing configuration to continue.</returns>
6464
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
65+
[Obsolete("Use the new interface accepting a SinkOptions parameter instead. This will be removed in a future release.", error: false)]
6566
public static LoggerConfiguration MSSqlServer(
6667
this LoggerSinkConfiguration loggerConfiguration,
6768
string connectionString,
@@ -183,6 +184,7 @@ internal static LoggerConfiguration MSSqlServerInternal(
183184
/// <param name="logEventFormatter">Supplies custom formatter for the LogEvent column, or null</param>
184185
/// <returns>Logger configuration, allowing configuration to continue.</returns>
185186
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
187+
[Obsolete("Use the new interface accepting a SinkOptions parameter instead. This will be removed in a future release.", error: false)]
186188
public static LoggerConfiguration MSSqlServer(
187189
this LoggerAuditSinkConfiguration loggerAuditSinkConfiguration,
188190
string connectionString,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public static partial class LoggerConfigurationMSSqlServerExtensions
5454
/// <param name="logEventFormatter">Supplies custom formatter for the LogEvent column, or null</param>
5555
/// <returns>Logger configuration, allowing configuration to continue.</returns>
5656
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
57+
[Obsolete("Use the new interface accepting a SinkOptions parameter instead. This will be removed in a future release.", error: false)]
5758
public static LoggerConfiguration MSSqlServer(
5859
this LoggerSinkConfiguration loggerConfiguration,
5960
string connectionString,
@@ -147,6 +148,7 @@ public static LoggerConfiguration MSSqlServer(
147148
/// <param name="logEventFormatter">Supplies custom formatter for the LogEvent column, or null</param>
148149
/// <returns>Logger configuration, allowing configuration to continue.</returns>
149150
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
151+
[Obsolete("Use the new interface accepting a SinkOptions parameter instead. This will be removed in a future release.", error: false)]
150152
public static LoggerConfiguration MSSqlServer(
151153
this LoggerAuditSinkConfiguration loggerAuditSinkConfiguration,
152154
string connectionString,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public static class LoggerConfigurationMSSqlServerExtensions
5656
/// <param name="logEventFormatter">Supplies custom formatter for the LogEvent column, or null</param>
5757
/// <returns>Logger configuration, allowing configuration to continue.</returns>
5858
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
59+
[Obsolete("Use the new interface accepting a SinkOptions parameter instead. This will be removed in a future release.", error: false)]
5960
public static LoggerConfiguration MSSqlServer(
6061
this LoggerSinkConfiguration loggerConfiguration,
6162
string connectionString,
@@ -160,6 +161,7 @@ internal static LoggerConfiguration MSSqlServerInternal(
160161
/// <param name="logEventFormatter">Supplies custom formatter for the LogEvent column, or null</param>
161162
/// <returns>Logger configuration, allowing configuration to continue.</returns>
162163
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
164+
[Obsolete("Use the new interface accepting a SinkOptions parameter instead. This will be removed in a future release.", error: false)]
163165
public static LoggerConfiguration MSSqlServer(
164166
this LoggerAuditSinkConfiguration loggerAuditSinkConfiguration,
165167
string connectionString,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public class MSSqlServerAuditSink : ILogEventSink, IDisposable
4343
/// <param name="autoCreateSqlTable">Create log table with the provided name on destination sql server.</param>
4444
/// <param name="columnOptions">Options that pertain to columns</param>
4545
/// <param name="logEventFormatter">Supplies custom formatter for the LogEvent column, or null</param>
46+
[Obsolete("Use the new interface accepting a SinkOptions parameter instead. This will be removed in a future release.", error: false)]
4647
public MSSqlServerAuditSink(
4748
string connectionString,
4849
string tableName,

src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/MSSqlServerSink.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public class MSSqlServerSink : PeriodicBatchingSink
6363
/// <param name="autoCreateSqlTable">Create log table with the provided name on destination sql server.</param>
6464
/// <param name="columnOptions">Options that pertain to columns</param>
6565
/// <param name="logEventFormatter">Supplies custom formatter for the LogEvent column, or null</param>
66+
[Obsolete("Use the new interface accepting a SinkOptions parameter instead. This will be removed in a future release.", error: false)]
6667
public MSSqlServerSink(
6768
string connectionString,
6869
string tableName,

test/Serilog.Sinks.MSSqlServer.Tests/Configuration/Extensions/Hybrid/ConfigurationExtensionsTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using Microsoft.Extensions.Configuration;
34
using Serilog.Sinks.MSSqlServer.Sinks.MSSqlServer.Options;
45
using Serilog.Sinks.MSSqlServer.Tests.TestUtils;
@@ -21,6 +22,7 @@ public ConfigurationExtensionsTests(ITestOutputHelper output) : base(output)
2122
}
2223

2324
[Fact]
25+
[Obsolete("Testing an inteface marked as obsolete", error: false)]
2426
public void ConnectionStringByNameFromConfigLegacyInterface()
2527
{
2628
var appConfig = TestConfiguration();
@@ -60,6 +62,7 @@ public void ConnectionStringByNameFromConfigSinkOptionsInterface()
6062
}
6163

6264
[Fact]
65+
[Obsolete("Testing an inteface marked as obsolete", error: false)]
6366
public void ColumnOptionsFromConfigSectionLegacyInterface()
6467
{
6568
// Arrange

test/Serilog.Sinks.MSSqlServer.Tests/Configuration/Extensions/System.Configuration/ConfigurationExtensionsTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using Serilog.Sinks.MSSqlServer.Configuration.Factories;
34
using Serilog.Sinks.MSSqlServer.Sinks.MSSqlServer.Options;
45
using Serilog.Sinks.MSSqlServer.Tests.TestUtils;
@@ -22,6 +23,7 @@ public ConfigurationExtensionsTests(ITestOutputHelper output) : base(output)
2223
}
2324

2425
[Fact]
26+
[Obsolete("Testing an inteface marked as obsolete", error: false)]
2527
public void ConnectionStringByNameFromConfigLegacyInterface()
2628
{
2729
var ConnectionStringName = "NamedConnection";

test/Serilog.Sinks.MSSqlServer.Tests/CustomStandardColumnNamesTests.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public CustomStandardColumnNamesTests(ITestOutputHelper output) : base(output)
1919
}
2020

2121
[Fact]
22+
[Obsolete("Testing an inteface marked as obsolete", error: false)]
2223
public void CustomIdColumnLegacyInterface()
2324
{
2425
// Arrange
@@ -59,6 +60,7 @@ public void CustomIdColumnSinkOptionsInterface()
5960
}
6061

6162
[Fact]
63+
[Obsolete("Testing an inteface marked as obsolete", error: false)]
6264
public void DefaultIdColumnLegacyInterface()
6365
{
6466
// Arrange
@@ -95,6 +97,7 @@ public void DefaultIdColumnSinkOptionsInterface()
9597
}
9698

9799
[Fact]
100+
[Obsolete("Testing an inteface marked as obsolete", error: false)]
98101
public void TableCreatedWithCustomNamesLegacyInterface()
99102
{
100103
// Arrange
@@ -147,6 +150,7 @@ public void TableCreatedWithCustomNamesSinkOptionsInterface()
147150
}
148151

149152
[Fact]
153+
[Obsolete("Testing an inteface marked as obsolete", error: false)]
150154
public void TableCreatedWithDefaultNamesLegacyInterface()
151155
{
152156
// Arrange
@@ -185,6 +189,7 @@ public void TableCreatedWithDefaultNamesSinkOptionsInterface()
185189
}
186190

187191
[Fact]
192+
[Obsolete("Testing an inteface marked as obsolete", error: false)]
188193
public void WriteEventToCustomStandardColumnsLegacyInterface()
189194
{
190195
// Arrange
@@ -258,6 +263,7 @@ public void WriteEventToCustomStandardColumnsSinkOptionsInterface()
258263
}
259264

260265
[Fact]
266+
[Obsolete("Testing an inteface marked as obsolete", error: false)]
261267
public void WriteEventToDefaultStandardColumnsLegacyInterface()
262268
{
263269
// Arrange
@@ -317,6 +323,7 @@ public void WriteEventToDefaultStandardColumnsSinkOptionsInterface()
317323
}
318324

319325
[Fact]
326+
[Obsolete("Testing an inteface marked as obsolete", error: false)]
320327
public void AuditEventToCustomStandardColumnsLegacyInterface()
321328
{
322329
// Arrange
@@ -396,8 +403,11 @@ public void AuditEventToDefaultStandardColumns()
396403
var loggerConfiguration = new LoggerConfiguration();
397404
Log.Logger = loggerConfiguration.AuditTo.MSSqlServer(
398405
connectionString: DatabaseFixture.LogEventsConnectionString,
399-
tableName: DatabaseFixture.LogTableName,
400-
autoCreateSqlTable: true,
406+
new SinkOptions
407+
{
408+
TableName = DatabaseFixture.LogTableName,
409+
AutoCreateSqlTable = true
410+
},
401411
columnOptions: new ColumnOptions())
402412
.CreateLogger();
403413

test/Serilog.Sinks.MSSqlServer.Tests/IndexingFeaturesTests.cs

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using Dapper;
55
using FluentAssertions;
6+
using Serilog.Sinks.MSSqlServer.Sinks.MSSqlServer.Options;
67
using Serilog.Sinks.MSSqlServer.Tests.TestUtils;
78
using Xunit;
89
using Xunit.Abstractions;
@@ -27,11 +28,14 @@ public void NonClusteredDefaultIdPrimaryKey()
2728
.WriteTo.MSSqlServer
2829
(
2930
connectionString: DatabaseFixture.LogEventsConnectionString,
30-
tableName: DatabaseFixture.LogTableName,
31-
columnOptions: columnOptions,
32-
autoCreateSqlTable: true,
33-
batchPostingLimit: 1,
34-
period: TimeSpan.FromSeconds(10)
31+
new SinkOptions
32+
{
33+
TableName = DatabaseFixture.LogTableName,
34+
AutoCreateSqlTable = true,
35+
BatchPostingLimit = 1,
36+
BatchPeriod = TimeSpan.FromSeconds(10)
37+
},
38+
columnOptions: columnOptions
3539
)
3640
.CreateLogger();
3741
Log.CloseAndFlush();
@@ -59,11 +63,14 @@ public void AlternatePrimaryKey()
5963
.WriteTo.MSSqlServer
6064
(
6165
connectionString: DatabaseFixture.LogEventsConnectionString,
62-
tableName: DatabaseFixture.LogTableName,
63-
columnOptions: columnOptions,
64-
autoCreateSqlTable: true,
65-
batchPostingLimit: 1,
66-
period: TimeSpan.FromSeconds(10)
66+
new SinkOptions
67+
{
68+
TableName = DatabaseFixture.LogTableName,
69+
AutoCreateSqlTable = true,
70+
BatchPostingLimit = 1,
71+
BatchPeriod = TimeSpan.FromSeconds(10)
72+
},
73+
columnOptions: columnOptions
6774
)
6875
.CreateLogger();
6976
Log.CloseAndFlush();
@@ -97,11 +104,14 @@ public void ColumnstoreIndex()
97104
.WriteTo.MSSqlServer
98105
(
99106
connectionString: DatabaseFixture.LogEventsConnectionString,
100-
tableName: DatabaseFixture.LogTableName,
101-
columnOptions: columnOptions,
102-
autoCreateSqlTable: true,
103-
batchPostingLimit: 1,
104-
period: TimeSpan.FromSeconds(10)
107+
new SinkOptions
108+
{
109+
TableName = DatabaseFixture.LogTableName,
110+
AutoCreateSqlTable = true,
111+
BatchPostingLimit = 1,
112+
BatchPeriod = TimeSpan.FromSeconds(10)
113+
},
114+
columnOptions: columnOptions
105115
)
106116
.CreateLogger();
107117
Log.CloseAndFlush();

test/Serilog.Sinks.MSSqlServer.Tests/LevelAsEnumTests.cs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Dapper;
55
using FluentAssertions;
66
using Serilog.Events;
7+
using Serilog.Sinks.MSSqlServer.Sinks.MSSqlServer.Options;
78
using Serilog.Sinks.MSSqlServer.Tests.TestUtils;
89
using Xunit;
910
using Xunit.Abstractions;
@@ -24,10 +25,13 @@ public void CanStoreLevelAsEnum()
2425
var loggerConfiguration = new LoggerConfiguration();
2526
Log.Logger = loggerConfiguration.WriteTo.MSSqlServer(
2627
connectionString: DatabaseFixture.LogEventsConnectionString,
27-
tableName: DatabaseFixture.LogTableName,
28-
autoCreateSqlTable: true,
29-
batchPostingLimit: 1,
30-
period: TimeSpan.FromSeconds(10),
28+
new SinkOptions
29+
{
30+
TableName = DatabaseFixture.LogTableName,
31+
AutoCreateSqlTable = true,
32+
BatchPostingLimit = 1,
33+
BatchPeriod = TimeSpan.FromSeconds(10)
34+
},
3135
columnOptions: new ColumnOptions { Level = { StoreAsEnum = true } })
3236
.CreateLogger();
3337

@@ -56,10 +60,13 @@ public void CanStoreLevelAsString()
5660
var loggerConfiguration = new LoggerConfiguration();
5761
Log.Logger = loggerConfiguration.WriteTo.MSSqlServer(
5862
connectionString: DatabaseFixture.LogEventsConnectionString,
59-
tableName: DatabaseFixture.LogTableName,
60-
autoCreateSqlTable: true,
61-
batchPostingLimit: 1,
62-
period: TimeSpan.FromSeconds(10),
63+
new SinkOptions
64+
{
65+
TableName = DatabaseFixture.LogTableName,
66+
AutoCreateSqlTable = true,
67+
BatchPostingLimit = 1,
68+
BatchPeriod = TimeSpan.FromSeconds(10)
69+
},
6370
columnOptions: new ColumnOptions { Level = { StoreAsEnum = false } })
6471
.CreateLogger();
6572

@@ -88,8 +95,11 @@ public void AuditCanStoreLevelAsEnum()
8895
var loggerConfiguration = new LoggerConfiguration();
8996
Log.Logger = loggerConfiguration.AuditTo.MSSqlServer(
9097
connectionString: DatabaseFixture.LogEventsConnectionString,
91-
tableName: DatabaseFixture.LogTableName,
92-
autoCreateSqlTable: true,
98+
new SinkOptions
99+
{
100+
TableName = DatabaseFixture.LogTableName,
101+
AutoCreateSqlTable = true
102+
},
93103
columnOptions: new ColumnOptions { Level = { StoreAsEnum = true } })
94104
.CreateLogger();
95105

@@ -118,8 +128,11 @@ public void AuditCanStoreLevelAsString()
118128
var loggerConfiguration = new LoggerConfiguration();
119129
Log.Logger = loggerConfiguration.AuditTo.MSSqlServer(
120130
connectionString: DatabaseFixture.LogEventsConnectionString,
121-
tableName: DatabaseFixture.LogTableName,
122-
autoCreateSqlTable: true,
131+
new SinkOptions
132+
{
133+
TableName = DatabaseFixture.LogTableName,
134+
AutoCreateSqlTable = true
135+
},
123136
columnOptions: new ColumnOptions { Level = { StoreAsEnum = false } })
124137
.CreateLogger();
125138

0 commit comments

Comments
 (0)