From b680ba721b17542c90c3c96853d70f95c116d76e Mon Sep 17 00:00:00 2001 From: Christian Kadluba <10721825+ckadluba@users.noreply.github.com> Date: Tue, 11 Oct 2022 00:09:48 +0200 Subject: [PATCH] Removed .NET Core 3.1 and updated to .NET 6.0 --- README.md | 6 +-- sample/AppConfigDemo/App.config | 50 +------------------ sample/AppConfigDemo/AppConfigDemo.csproj | 34 +++---------- sample/AppConfigDemo/packages.config | 20 -------- .../CombinedConfigDemo.csproj | 2 +- .../CustomLogEventFormatterDemo.csproj | 2 +- .../NetStandardDemoApp.csproj | 2 +- .../WorkerServiceDemo.csproj | 2 +- serilog-sinks-mssqlserver.sln | 22 ++++---- ...oggerConfigurationMSSqlServerExtensions.cs | 2 +- ...icrosoftExtensionsColumnOptionsProvider.cs | 4 +- ...ystemConfigurationColumnOptionsProvider.cs | 4 +- .../GlobalSuppressions.cs | 10 ++-- .../Properties/AssemblyInfo.cs | 1 - .../Serilog.Sinks.MSSqlServer.csproj | 10 ++-- .../ColumnOptions/ColumnOptions.cs | 2 +- ...FinalizeConfigurationForSinkConstructor.cs | 2 +- .../ColumnOptions/LogEventColumnOptions.cs | 4 +- .../Output/JsonLogEventFormatter.cs | 2 +- .../Platform/SqlCreateTableWriter.cs | 21 ++++---- .../MSSqlServer/Platform/SqlLogEventWriter.cs | 9 ++-- .../Sinks/MSSqlServer/SqlColumn.cs | 6 +-- .../Serilog.Sinks.MSSqlServer.Tests.csproj | 8 +-- 23 files changed, 68 insertions(+), 157 deletions(-) delete mode 100644 sample/AppConfigDemo/packages.config diff --git a/README.md b/README.md index 09640aa3..14f0511a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ A Serilog sink that writes events to Microsoft SQL Server. This sink will write the log event data to a table and can optionally also store the properties inside an XML or JSON column so they can be queried. Important properties can also be written to their own separate columns. **Package** - [Serilog.Sinks.MSSqlServer](http://nuget.org/packages/serilog.sinks.mssqlserver) -| **Minimum Platforms** - .NET Framework 4.6.2, .NET Core 3.1, .NET Standard 2.0 +| **Minimum Platforms** - .NET Framework 4.6.2, .NET 6.0, .NET Standard 2.0 #### Topics @@ -90,8 +90,8 @@ Because of the way external configuration has been implemented in various .NET f | .NET Framework 4.6.2+ | `net462` | app or library | _System.Configuration_ | | .NET Framework 4.6.2+ | `net462` | app or library | _Microsoft.Extensions.Configuration_ | | .NET Standard 2.0 | `netstandard2.0` | library only | _Microsoft.Extensions.Configuration_ | -| .NET Core 3.1+ | `netcoreapp3.1` | app or library | _System.Configuration_ | -| .NET Core 3.1+ | `netcoreapp3.1` | app or library | _Microsoft.Extensions.Configuration_ | +| .NET 6.0+ | `net6.0` | app or library | _System.Configuration_ | +| .NET 6.0+ | `net6.0` | app or library | _Microsoft.Extensions.Configuration_ | Although it's possible to use both XML and _M.E.C_ configuration with certain frameworks, this is not supported, unintended consequences are possible, and a warning will be emitted to `SelfLog`. If you actually require multiple configuration sources, the _M.E.C_ builder-pattern is designed to support this, and your syntax will be consistent across configuration sources. diff --git a/sample/AppConfigDemo/App.config b/sample/AppConfigDemo/App.config index d5aec883..0e0b3d21 100644 --- a/sample/AppConfigDemo/App.config +++ b/sample/AppConfigDemo/App.config @@ -4,7 +4,7 @@
- + @@ -21,52 +21,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sample/AppConfigDemo/AppConfigDemo.csproj b/sample/AppConfigDemo/AppConfigDemo.csproj index fdca186f..f99b0b48 100644 --- a/sample/AppConfigDemo/AppConfigDemo.csproj +++ b/sample/AppConfigDemo/AppConfigDemo.csproj @@ -4,7 +4,7 @@ Debug AnyCPU - {7DC530B1-68FD-4F07-A2F9-910C338562C1} + {6BFE1D21-1442-4375-AB69-14160B906A64} Exe AppConfigDemo AppConfigDemo @@ -12,8 +12,6 @@ 512 true true - - AnyCPU @@ -35,29 +33,12 @@ 4 - - ..\..\packages\Microsoft.Extensions.Configuration.Abstractions.3.1.4\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll - - - ..\..\packages\Serilog.2.9.0\lib\net46\Serilog.dll - - - - ..\..\packages\System.Data.Common.4.3.0\lib\net451\System.Data.Common.dll - True - True - - - - - - @@ -65,7 +46,6 @@ - @@ -76,12 +56,10 @@ + + + 2.5.0 + + - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - \ No newline at end of file diff --git a/sample/AppConfigDemo/packages.config b/sample/AppConfigDemo/packages.config deleted file mode 100644 index d8182196..00000000 --- a/sample/AppConfigDemo/packages.config +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sample/CombinedConfigDemo/CombinedConfigDemo.csproj b/sample/CombinedConfigDemo/CombinedConfigDemo.csproj index d81a4fc9..45d3ffd2 100644 --- a/sample/CombinedConfigDemo/CombinedConfigDemo.csproj +++ b/sample/CombinedConfigDemo/CombinedConfigDemo.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net6.0 diff --git a/sample/CustomLogEventFormatterDemo/CustomLogEventFormatterDemo.csproj b/sample/CustomLogEventFormatterDemo/CustomLogEventFormatterDemo.csproj index f466472d..de5bab75 100644 --- a/sample/CustomLogEventFormatterDemo/CustomLogEventFormatterDemo.csproj +++ b/sample/CustomLogEventFormatterDemo/CustomLogEventFormatterDemo.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net6.0 diff --git a/sample/NetStandardDemo/NetStandardDemoApp/NetStandardDemoApp.csproj b/sample/NetStandardDemo/NetStandardDemoApp/NetStandardDemoApp.csproj index 7817b0b6..0ebc5312 100644 --- a/sample/NetStandardDemo/NetStandardDemoApp/NetStandardDemoApp.csproj +++ b/sample/NetStandardDemo/NetStandardDemoApp/NetStandardDemoApp.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net6.0 diff --git a/sample/WorkerServiceDemo/WorkerServiceDemo.csproj b/sample/WorkerServiceDemo/WorkerServiceDemo.csproj index 5684d933..82ac55e2 100644 --- a/sample/WorkerServiceDemo/WorkerServiceDemo.csproj +++ b/sample/WorkerServiceDemo/WorkerServiceDemo.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0 dotnet-WorkerServiceDemo-A4DFF8A6-AC69-443B-A3B8-34E284CD1C78 diff --git a/serilog-sinks-mssqlserver.sln b/serilog-sinks-mssqlserver.sln index f3604c58..87938b34 100644 --- a/serilog-sinks-mssqlserver.sln +++ b/serilog-sinks-mssqlserver.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29806.167 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.32916.344 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{04226074-C72F-42BC-AB02-4D70A7BAE7E1}" EndProject @@ -15,8 +15,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{AA3463 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CustomLogEventFormatterDemo", "sample\CustomLogEventFormatterDemo\CustomLogEventFormatterDemo.csproj", "{873320F1-8F6D-45E2-A853-D321C86793EC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppConfigDemo", "sample\AppConfigDemo\AppConfigDemo.csproj", "{7DC530B1-68FD-4F07-A2F9-910C338562C1}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkerServiceDemo", "sample\WorkerServiceDemo\WorkerServiceDemo.csproj", "{04F523D9-F00B-4C63-9287-31A244378E06}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CombinedConfigDemo", "sample\CombinedConfigDemo\CombinedConfigDemo.csproj", "{98F21125-AF7A-46E8-8C08-E3E4F5DBEDB9}" @@ -30,12 +28,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetStandardDemoLib", "sample\NetStandardDemo\NetStandardDemoLib\NetStandardDemoLib.csproj", "{8E69E31B-61C7-4175-B886-9C2078FCA477}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetStandardDemoLib", "sample\NetStandardDemo\NetStandardDemoLib\NetStandardDemoLib.csproj", "{8E69E31B-61C7-4175-B886-9C2078FCA477}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetStandardDemoApp", "sample\NetStandardDemo\NetStandardDemoApp\NetStandardDemoApp.csproj", "{F908C46D-E72E-41E4-975D-73733294F93F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetStandardDemoApp", "sample\NetStandardDemo\NetStandardDemoApp\NetStandardDemoApp.csproj", "{F908C46D-E72E-41E4-975D-73733294F93F}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NetStandardDemo", "NetStandardDemo", "{7B2B80DE-427A-4FEC-A7CE-7AD81FED73DE}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppConfigDemo", "sample\AppConfigDemo\AppConfigDemo.csproj", "{6BFE1D21-1442-4375-AB69-14160B906A64}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -54,10 +54,6 @@ Global {873320F1-8F6D-45E2-A853-D321C86793EC}.Debug|Any CPU.Build.0 = Debug|Any CPU {873320F1-8F6D-45E2-A853-D321C86793EC}.Release|Any CPU.ActiveCfg = Release|Any CPU {873320F1-8F6D-45E2-A853-D321C86793EC}.Release|Any CPU.Build.0 = Release|Any CPU - {7DC530B1-68FD-4F07-A2F9-910C338562C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7DC530B1-68FD-4F07-A2F9-910C338562C1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7DC530B1-68FD-4F07-A2F9-910C338562C1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7DC530B1-68FD-4F07-A2F9-910C338562C1}.Release|Any CPU.Build.0 = Release|Any CPU {04F523D9-F00B-4C63-9287-31A244378E06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {04F523D9-F00B-4C63-9287-31A244378E06}.Debug|Any CPU.Build.0 = Debug|Any CPU {04F523D9-F00B-4C63-9287-31A244378E06}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -74,6 +70,10 @@ Global {F908C46D-E72E-41E4-975D-73733294F93F}.Debug|Any CPU.Build.0 = Debug|Any CPU {F908C46D-E72E-41E4-975D-73733294F93F}.Release|Any CPU.ActiveCfg = Release|Any CPU {F908C46D-E72E-41E4-975D-73733294F93F}.Release|Any CPU.Build.0 = Release|Any CPU + {6BFE1D21-1442-4375-AB69-14160B906A64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6BFE1D21-1442-4375-AB69-14160B906A64}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6BFE1D21-1442-4375-AB69-14160B906A64}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6BFE1D21-1442-4375-AB69-14160B906A64}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -82,12 +82,12 @@ Global {803CD13A-D54B-4CEC-A55F-E22AE3D93B3C} = {04226074-C72F-42BC-AB02-4D70A7BAE7E1} {3C2D8E01-5580-426A-BDD9-EC59CD98E618} = {F02D6513-6F45-452E-85A0-41A872A2C1F8} {873320F1-8F6D-45E2-A853-D321C86793EC} = {AA346332-5BAF-47F1-B8FB-7600ED61265D} - {7DC530B1-68FD-4F07-A2F9-910C338562C1} = {AA346332-5BAF-47F1-B8FB-7600ED61265D} {04F523D9-F00B-4C63-9287-31A244378E06} = {AA346332-5BAF-47F1-B8FB-7600ED61265D} {98F21125-AF7A-46E8-8C08-E3E4F5DBEDB9} = {AA346332-5BAF-47F1-B8FB-7600ED61265D} {8E69E31B-61C7-4175-B886-9C2078FCA477} = {7B2B80DE-427A-4FEC-A7CE-7AD81FED73DE} {F908C46D-E72E-41E4-975D-73733294F93F} = {7B2B80DE-427A-4FEC-A7CE-7AD81FED73DE} {7B2B80DE-427A-4FEC-A7CE-7AD81FED73DE} = {AA346332-5BAF-47F1-B8FB-7600ED61265D} + {6BFE1D21-1442-4375-AB69-14160B906A64} = {AA346332-5BAF-47F1-B8FB-7600ED61265D} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {AAA6BF8D-7B53-4A5F-A79A-D1B306383B45} diff --git a/src/Serilog.Sinks.MSSqlServer/Configuration/Extensions/Hybrid/LoggerConfigurationMSSqlServerExtensions.cs b/src/Serilog.Sinks.MSSqlServer/Configuration/Extensions/Hybrid/LoggerConfigurationMSSqlServerExtensions.cs index 13f02336..e808546e 100644 --- a/src/Serilog.Sinks.MSSqlServer/Configuration/Extensions/Hybrid/LoggerConfigurationMSSqlServerExtensions.cs +++ b/src/Serilog.Sinks.MSSqlServer/Configuration/Extensions/Hybrid/LoggerConfigurationMSSqlServerExtensions.cs @@ -22,7 +22,7 @@ using Serilog.Sinks.MSSqlServer.Configuration.Factories; // The "Hybrid" configuration system supports both Microsoft.Extensions.Configuration and System.Configuration. -// This is necessary because .NET Framework 4.6.1+ and .NET Core 2.0+ apps support both approaches, whereas the +// This is necessary because .NET Framework 4.6.2+ and .NET Core 2.0+ apps support both approaches, whereas the namespace Serilog { diff --git a/src/Serilog.Sinks.MSSqlServer/Configuration/Implementations/Microsoft.Extensions.Configuration/MicrosoftExtensionsColumnOptionsProvider.cs b/src/Serilog.Sinks.MSSqlServer/Configuration/Implementations/Microsoft.Extensions.Configuration/MicrosoftExtensionsColumnOptionsProvider.cs index 85ac9164..abdc8dc5 100644 --- a/src/Serilog.Sinks.MSSqlServer/Configuration/Implementations/Microsoft.Extensions.Configuration/MicrosoftExtensionsColumnOptionsProvider.cs +++ b/src/Serilog.Sinks.MSSqlServer/Configuration/Implementations/Microsoft.Extensions.Configuration/MicrosoftExtensionsColumnOptionsProvider.cs @@ -162,7 +162,7 @@ private static void ReadMiscColumnOptions(IConfigurationSection config, ColumnOp foreach (var standardCol in columnOptions.Store) { var stdColcolumnOptions = columnOptions.GetStandardColumnOptions(standardCol); - if (pkName.Equals(stdColcolumnOptions.ColumnName, StringComparison.InvariantCultureIgnoreCase)) + if (pkName.Equals(stdColcolumnOptions.ColumnName, StringComparison.OrdinalIgnoreCase)) { columnOptions.PrimaryKey = stdColcolumnOptions; break; @@ -173,7 +173,7 @@ private static void ReadMiscColumnOptions(IConfigurationSection config, ColumnOp { foreach (var col in columnOptions.AdditionalColumns) { - if (pkName.Equals(col.ColumnName, StringComparison.InvariantCultureIgnoreCase)) + if (pkName.Equals(col.ColumnName, StringComparison.OrdinalIgnoreCase)) { columnOptions.PrimaryKey = col; break; diff --git a/src/Serilog.Sinks.MSSqlServer/Configuration/Implementations/System.Configuration/SystemConfigurationColumnOptionsProvider.cs b/src/Serilog.Sinks.MSSqlServer/Configuration/Implementations/System.Configuration/SystemConfigurationColumnOptionsProvider.cs index dfa8b28a..4979549c 100644 --- a/src/Serilog.Sinks.MSSqlServer/Configuration/Implementations/System.Configuration/SystemConfigurationColumnOptionsProvider.cs +++ b/src/Serilog.Sinks.MSSqlServer/Configuration/Implementations/System.Configuration/SystemConfigurationColumnOptionsProvider.cs @@ -138,7 +138,7 @@ private static void ReadMiscColumnOptions(MSSqlServerConfigurationSection config foreach (var standardCol in columnOptions.Store) { var stdColOpts = columnOptions.GetStandardColumnOptions(standardCol); - if (pkName.Equals(stdColOpts.ColumnName, StringComparison.InvariantCultureIgnoreCase)) + if (pkName.Equals(stdColOpts.ColumnName, StringComparison.OrdinalIgnoreCase)) { columnOptions.PrimaryKey = stdColOpts; break; @@ -149,7 +149,7 @@ private static void ReadMiscColumnOptions(MSSqlServerConfigurationSection config { foreach (var col in columnOptions.AdditionalColumns) { - if (pkName.Equals(col.ColumnName, StringComparison.InvariantCultureIgnoreCase)) + if (pkName.Equals(col.ColumnName, StringComparison.OrdinalIgnoreCase)) { columnOptions.PrimaryKey = col; break; diff --git a/src/Serilog.Sinks.MSSqlServer/GlobalSuppressions.cs b/src/Serilog.Sinks.MSSqlServer/GlobalSuppressions.cs index c01fcaca..91069e5e 100644 --- a/src/Serilog.Sinks.MSSqlServer/GlobalSuppressions.cs +++ b/src/Serilog.Sinks.MSSqlServer/GlobalSuppressions.cs @@ -5,14 +5,16 @@ using System.Diagnostics.CodeAnalysis; -[assembly: SuppressMessage("Globalization", "CA1303:Do not pass literals as localized parameters", Justification = "Supplying string literals and not using resources is accepted within this project.", Scope = "namespaceanddescendants", Target = "Serilog.Sinks.MSSqlServer")] -[assembly: SuppressMessage("Security", "CA2100:Review SQL queries for security vulnerabilities", Justification = "Too hard to change. Accepted for now.", Scope = "namespaceanddescendants", Target = "Serilog.Sinks.MSSqlServer")] +[assembly: SuppressMessage("Globalization", "CA1303:Do not pass literals as localized parameters", Justification = "Supplying string literals and not using resources is accepted within this project.", Scope = "namespaceanddescendants", Target = "~N:Serilog.Sinks.MSSqlServer")] +[assembly: SuppressMessage("Security", "CA2100:Review SQL queries for security vulnerabilities", Justification = "Too hard to change. Accepted for now.", Scope = "namespaceanddescendants", Target = "~N:Serilog.Sinks.MSSqlServer")] [assembly: SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Too hard to change. Accepted for now.", Scope = "member", Target = "~M:Serilog.Sinks.MSSqlServer.SetProperty.IfNotNull``1(System.String,Serilog.Sinks.MSSqlServer.SetProperty.PropertySetter{``0})")] [assembly: SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Too hard to change. Accepted for now.", Scope = "member", Target = "~M:Serilog.Sinks.MSSqlServer.Platform.SqlTableCreator.CreateTable(System.Data.DataTable)")] [assembly: SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Too hard to change. Accepted for now.", Scope = "member", Target = "~M:Serilog.Sinks.MSSqlServer.Platform.SqlBulkBatchWriter.WriteBatch(System.Collections.Generic.IEnumerable{Serilog.Events.LogEvent},System.Data.DataTable)~System.Threading.Tasks.Task")] [assembly: SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Too hard to change. Accepted for now.", Scope = "member", Target = "~M:Serilog.Sinks.MSSqlServer.Output.StandardColumnDataGenerator.ConvertPropertiesToXmlStructure(System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,Serilog.Events.LogEventPropertyValue}})~System.String")] [assembly: SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Too hard to change. Accepted for now.", Scope = "member", Target = "~M:Serilog.Sinks.MSSqlServer.Output.PropertiesColumnDataGenerator.TryChangeType(System.Object,System.Type,System.Object@)~System.Boolean")] -[assembly: SuppressMessage("Design", "CA1034:Nested types should not be visible", Justification = "Cannot be changed on public classes for backward compatibility reasons.", Scope = "namespaceanddescendants", Target = "Serilog.Sinks.MSSqlServer")] +[assembly: SuppressMessage("Design", "CA1034:Nested types should not be visible", Justification = "Cannot be changed on public classes for backward compatibility reasons.", Scope = "namespaceanddescendants", Target = "~N:Serilog.Sinks.MSSqlServer")] [assembly: SuppressMessage("Usage", "CA2227:Collection properties should be read only", Justification = "Cannot be changed on public classes for backward compatibility reasons.", Scope = "type", Target = "~T:Serilog.Sinks.MSSqlServer.ColumnOptions")] -[assembly: SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "Cannot be changed on public classes for backward compatibility reasons.", Scope = "namespaceanddescendants", Target = "Serilog.Sinks.MSSqlServer")] +[assembly: SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "Cannot be changed on public classes for backward compatibility reasons.", Scope = "namespaceanddescendants", Target = "~N:Serilog.Sinks.MSSqlServer")] [assembly: SuppressMessage("Performance", "CA1822: Member AllowNull does not access instance data and can be marked as static (Shared in VisualBasic)", Justification = "Cannot be changed on public classes for backward compatibility reasons.", Scope = "member", Target = "~P:Serilog.Sinks.MSSqlServer.ColumnOptions.IdColumnOptions.AllowNull")] +[assembly: SuppressMessage("Naming", "CA1711:Identifiers should not have incorrect suffix", Justification = "Cannot be changed on public classes for backward compatibility reasons.", Scope = "type", Target = "~T:Serilog.Sinks.MSSqlServer.StandardColumnConfigException")] +[assembly: SuppressMessage("Naming", "CA1725:Parameter names should match base declaration", Justification = "Cannot be changed on public classes for backward compatibility reasons.", Scope = "member", Target = "~M:Serilog.Sinks.MSSqlServer.MSSqlServerSink.EmitBatchAsync(System.Collections.Generic.IEnumerable{Serilog.Events.LogEvent})~System.Threading.Tasks.Task")] diff --git a/src/Serilog.Sinks.MSSqlServer/Properties/AssemblyInfo.cs b/src/Serilog.Sinks.MSSqlServer/Properties/AssemblyInfo.cs index ac4ccae1..41108e73 100644 --- a/src/Serilog.Sinks.MSSqlServer/Properties/AssemblyInfo.cs +++ b/src/Serilog.Sinks.MSSqlServer/Properties/AssemblyInfo.cs @@ -3,7 +3,6 @@ [assembly: AssemblyTitle("Serilog.Sinks.MSSqlServer")] [assembly: AssemblyDescription("Serilog sink for MSSqlServer")] -[assembly: AssemblyCopyright("Copyright © Serilog Contributors 2020")] [assembly: InternalsVisibleTo("Serilog.Sinks.MSSqlServer.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100fb8d13fd344a1c" + "6fe0fe83ef33c1080bf30690765bc6eb0df26ebfdf8f21670c64265b30db09f73a0dea5b3db4c9" + diff --git a/src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj b/src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj index 4342e8af..ef0c2332 100644 --- a/src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj +++ b/src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj @@ -4,7 +4,7 @@ A Serilog sink that writes events to Microsoft SQL Server 5.9.0 Michiel van Oudheusden;Christian Kadluba;Serilog Contributors - netstandard2.0;net462;net472;netcoreapp3.1 + netstandard2.0;net462;net472;net6.0 true true Serilog.Sinks.MSSqlServer @@ -26,14 +26,12 @@ false false false + 6.0-recommended + False - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - @@ -72,7 +70,7 @@ - + diff --git a/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/ColumnOptions/ColumnOptions.cs b/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/ColumnOptions/ColumnOptions.cs index 670dea24..00f392e8 100644 --- a/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/ColumnOptions/ColumnOptions.cs +++ b/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/ColumnOptions/ColumnOptions.cs @@ -84,7 +84,7 @@ public ICollection Store /// index. Prior to SQL Server 2017 you must NOT use any NVARCHAR(MAX) columns, and /// this restriction includes the Standard Columns (you must change their size). /// - public bool ClusteredColumnstoreIndex { get; set; } = false; + public bool ClusteredColumnstoreIndex { get; set; } /// /// Indicates if triggers should be disabled when inserting log entries. diff --git a/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/ColumnOptions/FinalizeConfigurationForSinkConstructor.cs b/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/ColumnOptions/FinalizeConfigurationForSinkConstructor.cs index 81395226..53c7abe1 100644 --- a/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/ColumnOptions/FinalizeConfigurationForSinkConstructor.cs +++ b/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/ColumnOptions/FinalizeConfigurationForSinkConstructor.cs @@ -6,7 +6,7 @@ namespace Serilog.Sinks.MSSqlServer { public partial class ColumnOptions { - private bool _configurationFinalized = false; + private bool _configurationFinalized; /// /// The logging sink and audit sink constructors call this. Defaults are resolved (like ensuring the diff --git a/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/ColumnOptions/LogEventColumnOptions.cs b/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/ColumnOptions/LogEventColumnOptions.cs index bb61e3fb..cb3c10cc 100644 --- a/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/ColumnOptions/LogEventColumnOptions.cs +++ b/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/ColumnOptions/LogEventColumnOptions.cs @@ -37,13 +37,13 @@ public LogEventColumnOptions() : base() /// Exclude properties from the LogEvent column if they are being saved to additional columns. /// Defaults to false for backwards-compatibility, but true is the recommended setting. /// - public bool ExcludeAdditionalProperties { get; set; } = false; + public bool ExcludeAdditionalProperties { get; set; } /// /// Whether to include Standard Columns in the LogEvent column (for backwards compatibility). /// Defaults to false for backwards-compatibility, but true is the recommended setting. /// - public bool ExcludeStandardColumns { get; set; } = false; + public bool ExcludeStandardColumns { get; set; } } } } diff --git a/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Output/JsonLogEventFormatter.cs b/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Output/JsonLogEventFormatter.cs index 590f7906..fc8aaaeb 100644 --- a/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Output/JsonLogEventFormatter.cs +++ b/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Output/JsonLogEventFormatter.cs @@ -181,7 +181,7 @@ private static void WriteRenderings(IEnumerable output.Write(",\"Rendering\":"); using (var sw = new StringWriter()) { - format.Render(properties, sw); + format.Render(properties, sw, CultureInfo.InvariantCulture); JsonValueFormatter.WriteQuotedJsonString(sw.ToString(), output); } output.Write('}'); diff --git a/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Platform/SqlCreateTableWriter.cs b/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Platform/SqlCreateTableWriter.cs index d8575e8a..65e09cb2 100644 --- a/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Platform/SqlCreateTableWriter.cs +++ b/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Platform/SqlCreateTableWriter.cs @@ -1,6 +1,7 @@ using System.Data; using System.Globalization; using System.Text; +using static System.FormattableString; namespace Serilog.Sinks.MSSqlServer.Platform { @@ -13,15 +14,15 @@ public string GetSqlFromDataTable(string schemaName, string tableName, DataTable var indexCount = 1; // start schema check and DDL (wrap in EXEC to make a separate batch) - sql.AppendLine($"IF(NOT EXISTS(SELECT * FROM sys.schemas WHERE name = '{schemaName}'))"); + sql.AppendLine(Invariant($"IF(NOT EXISTS(SELECT * FROM sys.schemas WHERE name = '{schemaName}'))")); sql.AppendLine("BEGIN"); - sql.AppendLine($"EXEC('CREATE SCHEMA [{schemaName}] AUTHORIZATION [dbo]')"); + sql.AppendLine(Invariant($"EXEC('CREATE SCHEMA [{schemaName}] AUTHORIZATION [dbo]')")); sql.AppendLine("END"); // start table-creatin batch and DDL - sql.AppendLine($"IF NOT EXISTS (SELECT s.name, t.name FROM sys.tables t JOIN sys.schemas s ON t.schema_id = s.schema_id WHERE s.name = '{schemaName}' AND t.name = '{tableName}')"); + sql.AppendLine(Invariant($"IF NOT EXISTS (SELECT s.name, t.name FROM sys.tables t JOIN sys.schemas s ON t.schema_id = s.schema_id WHERE s.name = '{schemaName}' AND t.name = '{tableName}')")); sql.AppendLine("BEGIN"); - sql.AppendLine($"CREATE TABLE [{schemaName}].[{tableName}] ( "); + sql.AppendLine(Invariant($"CREATE TABLE [{schemaName}].[{tableName}] ( ")); // build column list var i = 1; @@ -30,19 +31,19 @@ public string GetSqlFromDataTable(string schemaName, string tableName, DataTable var common = (SqlColumn)column.ExtendedProperties["SqlColumn"]; sql.Append(GetColumnDDL(common)); - if (dataTable.Columns.Count > i++) sql.Append(","); + if (dataTable.Columns.Count > i++) sql.Append(','); sql.AppendLine(); // collect non-PK indexes for separate output after the table DDL if (common != null && common.NonClusteredIndex && common != columnOptions.PrimaryKey) - ix.AppendLine($"CREATE NONCLUSTERED INDEX [IX{indexCount++}_{tableName}] ON [{schemaName}].[{tableName}] ([{common.ColumnName}]);"); + ix.AppendLine(Invariant($"CREATE NONCLUSTERED INDEX [IX{indexCount++}_{tableName}] ON [{schemaName}].[{tableName}] ([{common.ColumnName}]);")); } // primary key constraint at the end of the table DDL if (columnOptions.PrimaryKey != null) { var clustering = (columnOptions.PrimaryKey.NonClusteredIndex ? "NON" : string.Empty); - sql.AppendLine($" CONSTRAINT [PK_{tableName}] PRIMARY KEY {clustering}CLUSTERED ([{columnOptions.PrimaryKey.ColumnName}])"); + sql.AppendLine(Invariant($" CONSTRAINT [PK_{tableName}] PRIMARY KEY {clustering}CLUSTERED ([{columnOptions.PrimaryKey.ColumnName}])")); } // end of CREATE TABLE @@ -50,7 +51,7 @@ public string GetSqlFromDataTable(string schemaName, string tableName, DataTable // CCI is output separately after table DDL if (columnOptions.ClusteredColumnstoreIndex) - sql.AppendLine($"CREATE CLUSTERED COLUMNSTORE INDEX [CCI_{tableName}] ON [{schemaName}].[{tableName}]"); + sql.AppendLine(Invariant($"CREATE CLUSTERED COLUMNSTORE INDEX [CCI_{tableName}] ON [{schemaName}].[{tableName}]")); // output any extra non-clustered indexes sql.Append(ix); @@ -68,12 +69,12 @@ private static string GetColumnDDL(SqlColumn column) { var sb = new StringBuilder(); - sb.Append($"[{column.ColumnName}] "); + sb.Append(Invariant($"[{column.ColumnName}] ")); sb.Append(column.DataType.ToString().ToUpperInvariant()); if (SqlDataTypes.DataLengthRequired.Contains(column.DataType)) - sb.Append("(").Append(column.DataLength == -1 ? "MAX" : column.DataLength.ToString(CultureInfo.InvariantCulture)).Append(")"); + sb.Append('(').Append(column.DataLength == -1 ? "MAX" : column.DataLength.ToString(CultureInfo.InvariantCulture)).Append(')'); if (column.StandardColumnIdentifier == StandardColumn.Id) sb.Append(" IDENTITY(1,1)"); diff --git a/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Platform/SqlLogEventWriter.cs b/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Platform/SqlLogEventWriter.cs index ada43fde..e47dc877 100644 --- a/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Platform/SqlLogEventWriter.cs +++ b/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Platform/SqlLogEventWriter.cs @@ -4,6 +4,7 @@ using Serilog.Debugging; using Serilog.Events; using Serilog.Sinks.MSSqlServer.Output; +using static System.FormattableString; namespace Serilog.Sinks.MSSqlServer.Platform { @@ -37,7 +38,7 @@ public void WriteEvent(LogEvent logEvent) { command.CommandType = CommandType.Text; - var fieldList = new StringBuilder($"INSERT INTO [{_schemaName}].[{_tableName}] ("); + var fieldList = new StringBuilder(Invariant($"INSERT INTO [{_schemaName}].[{_tableName}] (")); var parameterList = new StringBuilder(") VALUES ("); var index = 0; @@ -49,17 +50,17 @@ public void WriteEvent(LogEvent logEvent) parameterList.Append(','); } - fieldList.Append($"[{field.Key}]"); + fieldList.Append(Invariant($"[{field.Key}]")); parameterList.Append("@P"); parameterList.Append(index); - command.AddParameter($"@P{index}", field.Value); + command.AddParameter(Invariant($"@P{index}"), field.Value); index++; } parameterList.Append(')'); - fieldList.Append(parameterList.ToString()); + fieldList.Append(parameterList); command.CommandText = fieldList.ToString(); diff --git a/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/SqlColumn.cs b/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/SqlColumn.cs index fd9f1010..cce0c92b 100644 --- a/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/SqlColumn.cs +++ b/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/SqlColumn.cs @@ -94,7 +94,7 @@ public SqlDbType DataType /// Determines whether a non-clustered index is created for this column. Compound indexes are not /// supported for auto-created log tables. This property is only used when auto-creating a log table. /// - public bool NonClusteredIndex { get; set; } = false; + public bool NonClusteredIndex { get; set; } /// /// The name of the Serilog property to use as the value when filling the DataTable. @@ -109,8 +109,8 @@ public string PropertyName // Set by the constructors of the Standard Column classes that inherit from this; // allows Standard Columns and user-defined columns to coexist but remain identifiable // and allows casting back to the Standard Column without a lot of switch gymnastics. - internal StandardColumn? StandardColumnIdentifier { get; set; } = null; - internal Type StandardColumnType { get; set; } = null; + internal StandardColumn? StandardColumnIdentifier { get; set; } + internal Type StandardColumnType { get; set; } /// /// Converts a SQL sink SqlColumn object to a System.Data.DataColumn object. The original diff --git a/test/Serilog.Sinks.MSSqlServer.Tests/Serilog.Sinks.MSSqlServer.Tests.csproj b/test/Serilog.Sinks.MSSqlServer.Tests/Serilog.Sinks.MSSqlServer.Tests.csproj index 55593096..414889fe 100644 --- a/test/Serilog.Sinks.MSSqlServer.Tests/Serilog.Sinks.MSSqlServer.Tests.csproj +++ b/test/Serilog.Sinks.MSSqlServer.Tests/Serilog.Sinks.MSSqlServer.Tests.csproj @@ -1,7 +1,7 @@  - net462;net472;netcoreapp3.1 + net462;net472;net6.0 netstandard2.0 true Serilog.Sinks.MSSqlServer.Tests @@ -11,6 +11,7 @@ Serilog.Sinks.MSSqlServer.Tests true win + AnyCPU @@ -18,10 +19,9 @@ - - + @@ -50,7 +50,7 @@ - +