Skip to content

Commit 63b69f4

Browse files
committed
chore: review stuffs
1 parent c4ef714 commit 63b69f4

File tree

16 files changed

+78
-111
lines changed

16 files changed

+78
-111
lines changed

.github/workflows/packages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ jobs:
5757
PostgreSqlConnectionString: Server=localhost;Port=${{ job.services.postgres.ports[5432] }};Database=test;User Id=postgres;Password=postgres;
5858
SQLServerConnectionString: Server=tcp:127.0.0.1,${{ job.services.sqlserver.ports[1433] }};Database=tempdb;User Id=sa;Password=g0d4mm!tSQLServer;
5959
- name: .NET Lib Pack
60-
run: dotnet pack Build.csproj --no-build -c Release /p:Packing=true /p:PackageOutputPath=%CD%\.nupkgs /p:CI=true
60+
run: dotnet pack Build.csproj --no-build -c Release /p:Packing=true /p:PackageOutputPath=$PWD/.nupkgs /p:CI=true

StackExchange.Exceptional.sln

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StackExchange.Exceptional.M
6464
EndProject
6565
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.ConsoleNetCore", "samples\Samples.ConsoleNetCore\Samples.ConsoleNetCore.csproj", "{6CE269E1-6DC9-43A4-B6B8-683CE8A19E6A}"
6666
EndProject
67-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StackExchange.Exceptional.MicrosoftDataSqlClient", "src\StackExchange.Exceptional.MicrosoftDataSqlClient\StackExchange.Exceptional.MicrosoftDataSqlClient.csproj", "{B575D666-06E5-4C5C-84CF-C9749C6D3E6B}"
67+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StackExchange.Exceptional.MicrosoftDataSql", "src\StackExchange.Exceptional.MicrosoftDataSql\StackExchange.Exceptional.MicrosoftDataSql.csproj", "{4FFED4CE-F0B8-4E9E-B7F9-684CA52F5D4F}"
6868
EndProject
69-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StackExchange.Exceptional.SystemDataSqlClient", "src\StackExchange.Exceptional.SystemDataSqlClient\StackExchange.Exceptional.SystemDataSqlClient.csproj", "{DF5184E1-D8FF-4C29-BF87-991596FE30A7}"
69+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StackExchange.Exceptional.SystemDataSql", "src\StackExchange.Exceptional.SystemDataSql\StackExchange.Exceptional.SystemDataSql.csproj", "{41C614C7-2932-4ECD-B592-373BAA515031}"
7070
EndProject
7171
Global
7272
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -122,14 +122,14 @@ Global
122122
{6CE269E1-6DC9-43A4-B6B8-683CE8A19E6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
123123
{6CE269E1-6DC9-43A4-B6B8-683CE8A19E6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
124124
{6CE269E1-6DC9-43A4-B6B8-683CE8A19E6A}.Release|Any CPU.Build.0 = Release|Any CPU
125-
{B575D666-06E5-4C5C-84CF-C9749C6D3E6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
126-
{B575D666-06E5-4C5C-84CF-C9749C6D3E6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
127-
{B575D666-06E5-4C5C-84CF-C9749C6D3E6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
128-
{B575D666-06E5-4C5C-84CF-C9749C6D3E6B}.Release|Any CPU.Build.0 = Release|Any CPU
129-
{DF5184E1-D8FF-4C29-BF87-991596FE30A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
130-
{DF5184E1-D8FF-4C29-BF87-991596FE30A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
131-
{DF5184E1-D8FF-4C29-BF87-991596FE30A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
132-
{DF5184E1-D8FF-4C29-BF87-991596FE30A7}.Release|Any CPU.Build.0 = Release|Any CPU
125+
{4FFED4CE-F0B8-4E9E-B7F9-684CA52F5D4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
126+
{4FFED4CE-F0B8-4E9E-B7F9-684CA52F5D4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
127+
{4FFED4CE-F0B8-4E9E-B7F9-684CA52F5D4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
128+
{4FFED4CE-F0B8-4E9E-B7F9-684CA52F5D4F}.Release|Any CPU.Build.0 = Release|Any CPU
129+
{41C614C7-2932-4ECD-B592-373BAA515031}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
130+
{41C614C7-2932-4ECD-B592-373BAA515031}.Debug|Any CPU.Build.0 = Debug|Any CPU
131+
{41C614C7-2932-4ECD-B592-373BAA515031}.Release|Any CPU.ActiveCfg = Release|Any CPU
132+
{41C614C7-2932-4ECD-B592-373BAA515031}.Release|Any CPU.Build.0 = Release|Any CPU
133133
EndGlobalSection
134134
GlobalSection(SolutionProperties) = preSolution
135135
HideSolutionNode = FALSE
@@ -147,8 +147,8 @@ Global
147147
{0A412433-C2CE-4EBE-BB5A-C3E48983E941} = {8B91532F-A112-4F73-80BD-A95B7359BBC3}
148148
{8CFA59A5-5180-4466-A32E-507F3D541163} = {8B91532F-A112-4F73-80BD-A95B7359BBC3}
149149
{6CE269E1-6DC9-43A4-B6B8-683CE8A19E6A} = {001E5AA4-42C8-4AC3-B14A-AF1DFA02E9FB}
150-
{B575D666-06E5-4C5C-84CF-C9749C6D3E6B} = {8B91532F-A112-4F73-80BD-A95B7359BBC3}
151-
{DF5184E1-D8FF-4C29-BF87-991596FE30A7} = {8B91532F-A112-4F73-80BD-A95B7359BBC3}
150+
{4FFED4CE-F0B8-4E9E-B7F9-684CA52F5D4F} = {8B91532F-A112-4F73-80BD-A95B7359BBC3}
151+
{41C614C7-2932-4ECD-B592-373BAA515031} = {8B91532F-A112-4F73-80BD-A95B7359BBC3}
152152
EndGlobalSection
153153
GlobalSection(ExtensibilityGlobals) = postSolution
154154
SolutionGuid = {7F066A86-14D8-4A2C-848A-D4371BB704FA}

samples/Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
<PackageVersion Include="Microsoft.AspNet.Web.Optimization" Version="1.1.3" />
88
</ItemGroup>
99
<ItemGroup>
10-
<GlobalPackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
10+
<GlobalPackageReference Condition="'$(TargetFramework)'=='net6.0'" Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
1111
</ItemGroup>
1212
</Project>

src/Directory.Packages.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
44
</PropertyGroup>
55
<ItemGroup>
6-
<PackageVersion Include="Dapper" Version="2.0.123" />
6+
<PackageVersion Include="Dapper" Version="2.0.151" />
77
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.1.1" />
88
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
99
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
@@ -16,7 +16,7 @@
1616
<PackageVersion Include="System.Data.SqlClient" Version="4.8.5" />
1717
</ItemGroup>
1818
<ItemGroup>
19-
<GlobalPackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
19+
<GlobalPackageReference Condition="'$(TargetFramework)'!='net462'" Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
2020
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
2121
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.6.132" />
2222
</ItemGroup>

src/StackExchange.Exceptional.MicrosoftDataSqlClient/Stores/SQLErrorStore.cs renamed to src/StackExchange.Exceptional.MicrosoftDataSql/MicrosoftDataSQLErrorStore.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace StackExchange.Exceptional.Stores
1111
/// <summary>
1212
/// An <see cref="ErrorStore"/> implementation that uses SQL Server as its backing store.
1313
/// </summary>
14-
public sealed class SQLErrorStore : ErrorStore
14+
public sealed class MicrosoftDataSQLErrorStore : ErrorStore
1515
{
1616
/// <summary>
1717
/// Name for this error store.
@@ -28,12 +28,12 @@ public sealed class SQLErrorStore : ErrorStore
2828
public const int MaximumDisplayCount = 500;
2929

3030
/// <summary>
31-
/// Creates a new instance of <see cref="SQLErrorStore"/> with the specified connection string.
31+
/// Creates a new instance of <see cref="MicrosoftDataSQLErrorStore"/> with the specified connection string.
3232
/// The default table name is "Exceptions".
3333
/// </summary>
3434
/// <param name="connectionString">The database connection string to use.</param>
3535
/// <param name="applicationName">The application name to use when logging.</param>
36-
public SQLErrorStore(string connectionString, string applicationName)
36+
public MicrosoftDataSQLErrorStore(string connectionString, string applicationName)
3737
: this(new ErrorStoreSettings()
3838
{
3939
ApplicationName = applicationName,
@@ -42,11 +42,11 @@ public SQLErrorStore(string connectionString, string applicationName)
4242
{ }
4343

4444
/// <summary>
45-
/// Creates a new instance of <see cref="SQLErrorStore"/> with the given configuration.
45+
/// Creates a new instance of <see cref="MicrosoftDataSQLErrorStore"/> with the given configuration.
4646
/// The default table name is "Exceptions".
4747
/// </summary>
4848
/// <param name="settings">The <see cref="ErrorStoreSettings"/> for this store.</param>
49-
public SQLErrorStore(ErrorStoreSettings settings) : base(settings)
49+
public MicrosoftDataSQLErrorStore(ErrorStoreSettings settings) : base(settings)
5050
{
5151
_displayCount = Math.Min(settings.Size, MaximumDisplayCount);
5252
_connectionString = settings.ConnectionString;
@@ -346,9 +346,18 @@ protected override async Task<int> GetErrorCountAsync(DateTime? since = null, st
346346

347347
private SqlConnection GetConnection() => new(_connectionString);
348348

349-
static SQLErrorStore()
349+
static MicrosoftDataSQLErrorStore()
350350
{
351-
Statics.Settings.ExceptionActions.AddSqlException();
351+
Statics.Settings.ExceptionActions
352+
.AddHandler<SqlException>((e, se) =>
353+
{
354+
e.AddCommand(new Command("SQL Server Query", se.Data.Contains("SQL") ? se.Data["SQL"] as string : null)
355+
.AddData(nameof(se.Server), se.Server)
356+
.AddData(nameof(se.Number), se.Number.ToString())
357+
.AddData(nameof(se.LineNumber), se.LineNumber.ToString())
358+
.AddData(se.Procedure.HasValue(), nameof(se.Procedure), se.Procedure)
359+
);
360+
});
352361
}
353362
}
354363
}

src/StackExchange.Exceptional.MicrosoftDataSqlClient/StackExchange.Exceptional.MicrosoftDataSqlClient.csproj renamed to src/StackExchange.Exceptional.MicrosoftDataSql/StackExchange.Exceptional.MicrosoftDataSql.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<AssemblyName>StackExchange.Exceptional.MicrosoftDataSqlClient</AssemblyName>
4+
<AssemblyName>StackExchange.Exceptional.MicrosoftDataSql</AssemblyName>
55
<Description>Microsoft.Data.SqlClient storage provider for StackExchange.Exceptional</Description>
66
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
77
<RootNamespace>StackExchange.Exceptional</RootNamespace>

src/StackExchange.Exceptional.MicrosoftDataSqlClient/Extensions.Handlers.cs

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/StackExchange.Exceptional.Shared/Internal/ExceptionalSettingsBase.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void Register(IErrorNotifier notifier)
8181
/// Data handlers, for adding any data desirable to an exception before logging, like Commands.
8282
/// The key here is the full type name, e.g. "System.Data.SqlClient.SqlException"
8383
/// </summary>
84-
public Dictionary<string, Action<Error>> ExceptionActions { get; } = new Dictionary<string, Action<Error>>();
84+
public Dictionary<string, Action<Error>> ExceptionActions { get; } = new();
8585

8686
/// <summary>
8787
/// The <see cref="Regex"/> of data keys to include. For example, "Redis.*" would include all keys that start with Redis.
@@ -218,6 +218,17 @@ public class LogFilterSettings
218218
/// </summary>
219219
protected ExceptionalSettingsBase()
220220
{
221+
ExceptionActions.AddHandler("StackRedis.CacheException",
222+
(e, ex) =>
223+
{
224+
var cmd = e.AddCommand(new Command("Redis"));
225+
foreach (string k in ex.Data.Keys)
226+
{
227+
var val = ex.Data[k] as string;
228+
if (k == "redis-command") cmd.CommandString = val;
229+
if (k.StartsWith("Redis-")) cmd.AddData(k.Substring("Redis-".Length), val);
230+
}
231+
});
221232
Store.PropertyChanged += (_, __) => _defaultStore = null;
222233
}
223234
}

src/StackExchange.Exceptional.SystemDataSqlClient/StackExchange.Exceptional.SystemDataSqlClient.csproj renamed to src/StackExchange.Exceptional.SystemDataSql/StackExchange.Exceptional.SystemDataSql.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<AssemblyName>StackExchange.Exceptional.SystemDataSqlClient</AssemblyName>
4+
<AssemblyName>StackExchange.Exceptional.SystemDataSql</AssemblyName>
55
<Description>System.Data.SqlClient storage provider for StackExchange.Exceptional</Description>
66
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
77
<RootNamespace>StackExchange.Exceptional</RootNamespace>

src/StackExchange.Exceptional.SystemDataSqlClient/Stores/SQLErrorStore.cs renamed to src/StackExchange.Exceptional.SystemDataSql/SystemDataSQLErrorStore.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace StackExchange.Exceptional.Stores
1111
/// <summary>
1212
/// An <see cref="ErrorStore"/> implementation that uses SQL Server as its backing store.
1313
/// </summary>
14-
public sealed class SQLErrorStore : ErrorStore
14+
public sealed class SystemDataSQLErrorStore : ErrorStore
1515
{
1616
/// <summary>
1717
/// Name for this error store.
@@ -28,12 +28,12 @@ public sealed class SQLErrorStore : ErrorStore
2828
public const int MaximumDisplayCount = 500;
2929

3030
/// <summary>
31-
/// Creates a new instance of <see cref="SQLErrorStore"/> with the specified connection string.
31+
/// Creates a new instance of <see cref="SystemDataSQLErrorStore"/> with the specified connection string.
3232
/// The default table name is "Exceptions".
3333
/// </summary>
3434
/// <param name="connectionString">The database connection string to use.</param>
3535
/// <param name="applicationName">The application name to use when logging.</param>
36-
public SQLErrorStore(string connectionString, string applicationName)
36+
public SystemDataSQLErrorStore(string connectionString, string applicationName)
3737
: this(new ErrorStoreSettings()
3838
{
3939
ApplicationName = applicationName,
@@ -42,11 +42,11 @@ public SQLErrorStore(string connectionString, string applicationName)
4242
{ }
4343

4444
/// <summary>
45-
/// Creates a new instance of <see cref="SQLErrorStore"/> with the given configuration.
45+
/// Creates a new instance of <see cref="SystemDataSQLErrorStore"/> with the given configuration.
4646
/// The default table name is "Exceptions".
4747
/// </summary>
4848
/// <param name="settings">The <see cref="ErrorStoreSettings"/> for this store.</param>
49-
public SQLErrorStore(ErrorStoreSettings settings) : base(settings)
49+
public SystemDataSQLErrorStore(ErrorStoreSettings settings) : base(settings)
5050
{
5151
_displayCount = Math.Min(settings.Size, MaximumDisplayCount);
5252
_connectionString = settings.ConnectionString;
@@ -346,9 +346,18 @@ protected override async Task<int> GetErrorCountAsync(DateTime? since = null, st
346346

347347
private SqlConnection GetConnection() => new(_connectionString);
348348

349-
static SQLErrorStore()
349+
static SystemDataSQLErrorStore()
350350
{
351-
Statics.Settings.ExceptionActions.AddSqlException();
351+
Statics.Settings.ExceptionActions
352+
.AddHandler<SqlException>((e, se) =>
353+
{
354+
e.AddCommand(new Command("SQL Server Query", se.Data.Contains("SQL") ? se.Data["SQL"] as string : null)
355+
.AddData(nameof(se.Server), se.Server)
356+
.AddData(nameof(se.Number), se.Number.ToString())
357+
.AddData(nameof(se.LineNumber), se.LineNumber.ToString())
358+
.AddData(se.Procedure.HasValue(), nameof(se.Procedure), se.Procedure)
359+
);
360+
});
352361
}
353362
}
354363
}

0 commit comments

Comments
 (0)