Skip to content

Commit cbc077d

Browse files
committed
chore: extract sqlclient dependency from shared to two packages
1 parent cd4f6c6 commit cbc077d

File tree

15 files changed

+477
-46
lines changed

15 files changed

+477
-46
lines changed

StackExchange.Exceptional.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ 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}"
68+
EndProject
69+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StackExchange.Exceptional.SystemDataSqlClient", "src\StackExchange.Exceptional.SystemDataSqlClient\StackExchange.Exceptional.SystemDataSqlClient.csproj", "{DF5184E1-D8FF-4C29-BF87-991596FE30A7}"
70+
EndProject
6771
Global
6872
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6973
Debug|Any CPU = Debug|Any CPU
@@ -118,6 +122,14 @@ Global
118122
{6CE269E1-6DC9-43A4-B6B8-683CE8A19E6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
119123
{6CE269E1-6DC9-43A4-B6B8-683CE8A19E6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
120124
{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
121133
EndGlobalSection
122134
GlobalSection(SolutionProperties) = preSolution
123135
HideSolutionNode = FALSE
@@ -135,6 +147,8 @@ Global
135147
{0A412433-C2CE-4EBE-BB5A-C3E48983E941} = {8B91532F-A112-4F73-80BD-A95B7359BBC3}
136148
{8CFA59A5-5180-4466-A32E-507F3D541163} = {8B91532F-A112-4F73-80BD-A95B7359BBC3}
137149
{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}
138152
EndGlobalSection
139153
GlobalSection(ExtensibilityGlobals) = postSolution
140154
SolutionGuid = {7F066A86-14D8-4A2C-848A-D4371BB704FA}

src/Directory.Build.props

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,24 @@
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
66
<LangVersion>Latest</LangVersion>
77

8-
<Authors>Nick Craver</Authors>
8+
<Authors>Nick Craver</Authors>
99
<PackageId>$(AssemblyName)</PackageId>
1010
<PackageLicenseExpression>MIT OR Apache-2.0</PackageLicenseExpression>
1111
<PackageProjectUrl>https://github.com/NickCraver/StackExchange.Exceptional</PackageProjectUrl>
1212
<PackageReleaseNotes>https://nickcraver.com/StackExchange.Exceptional/Releases</PackageReleaseNotes>
13-
<Deterministic>false</Deterministic>
14-
13+
1514
<DebugSymbols>true</DebugSymbols>
1615
<DebugType>pdbonly</DebugType>
1716
<DefaultLanguage>en-US</DefaultLanguage>
1817
<PublishRepositoryUrl>true</PublishRepositoryUrl>
1918
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
2019
</PropertyGroup>
2120

21+
<PropertyGroup Condition="'$(CI)'=='true'">
22+
<Deterministic>true</Deterministic>
23+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
24+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
25+
<DebugType>embedded</DebugType>
26+
</PropertyGroup>
27+
2228
</Project>

src/Directory.Packages.props

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
1010
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
1111
<PackageVersion Include="Microsoft.Extensions.Options" Version="6.0.0" />
12-
<PackageVersion Include="MongoDB.Driver" Version="2.19.1" />
12+
<PackageVersion Include="MongoDB.Driver" Version="2.19.1" />
1313
<PackageVersion Include="MySqlConnector" Version="2.2.6" />
1414
<PackageVersion Include="Newtonsoft.Json" Version="13.0.1" />
15-
<PackageVersion Include="Npgsql" Version="7.0.4" />
15+
<PackageVersion Include="Npgsql" Version="7.0.4" />
16+
<PackageVersion Include="System.Data.SqlClient" Version="4.8.5" />
1617
</ItemGroup>
1718
<ItemGroup>
1819
<GlobalPackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using StackExchange.Exceptional.Internal;
2+
using System;
3+
using System.Collections.Generic;
4+
using Microsoft.Data.SqlClient;
5+
6+
namespace StackExchange.Exceptional
7+
{
8+
/// <summary>
9+
/// Extensions methods for <see cref="Exception"/>s.
10+
/// </summary>
11+
public static class Extensions
12+
{
13+
/// <summary>
14+
/// Adds the default data handlers to a handlers collection.
15+
/// </summary>
16+
/// <param name="handlers">The dictionary to register these default handlers on.</param>
17+
public static Dictionary<string, Action<Error>> AddSqlException(this Dictionary<string, Action<Error>> handlers)
18+
{
19+
handlers?.AddHandler<SqlException>((e, se) =>
20+
{
21+
e.AddCommand(new Command("SQL Server Query", se.Data.Contains("SQL") ? se.Data["SQL"] as string : null)
22+
.AddData(nameof(se.Server), se.Server)
23+
.AddData(nameof(se.Number), se.Number.ToString())
24+
.AddData(nameof(se.LineNumber), se.LineNumber.ToString())
25+
.AddData(se.Procedure.HasValue(), nameof(se.Procedure), se.Procedure)
26+
);
27+
});
28+
return handlers;
29+
}
30+
}
31+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<AssemblyName>StackExchange.Exceptional.MicrosoftDataSqlClient</AssemblyName>
5+
<Description>Microsoft.Data.SqlClient storage provider for StackExchange.Exceptional</Description>
6+
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
7+
<RootNamespace>StackExchange.Exceptional</RootNamespace>
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<PackageReference Include="Dapper" />
11+
<PackageReference Include="Microsoft.Data.SqlClient" />
12+
</ItemGroup>
13+
<ItemGroup>
14+
<ProjectReference Include="..\StackExchange.Exceptional.Shared\StackExchange.Exceptional.Shared.csproj" />
15+
</ItemGroup>
16+
</Project>

src/StackExchange.Exceptional.Shared/Stores/SQLErrorStore.cs renamed to src/StackExchange.Exceptional.MicrosoftDataSqlClient/Stores/SQLErrorStore.cs

File renamed without changes.

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

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,10 @@
1-
using StackExchange.Exceptional.Internal;
2-
using System;
1+
using System;
32
using System.Collections.Generic;
4-
using Microsoft.Data.SqlClient;
53

64
namespace StackExchange.Exceptional
75
{
86
public static partial class Extensions
97
{
10-
/// <summary>
11-
/// Adds the default data handlers to a handlers collection.
12-
/// </summary>
13-
/// <param name="handlers">The dictionary to register these default handlers on.</param>
14-
public static Dictionary<string, Action<Error>> AddDefault(this Dictionary<string, Action<Error>> handlers)
15-
{
16-
handlers?.AddHandler<SqlException>((e, se) =>
17-
{
18-
if (se.Data == null) return;
19-
e.AddCommand(new Command("SQL Server Query", se.Data.Contains("SQL") ? se.Data["SQL"] as string : null)
20-
.AddData(nameof(se.Server), se.Server)
21-
.AddData(nameof(se.Number), se.Number.ToString())
22-
.AddData(nameof(se.LineNumber), se.LineNumber.ToString())
23-
.AddData(se.Procedure.HasValue(), nameof(se.Procedure), se.Procedure)
24-
);
25-
});
26-
handlers?.AddHandler("StackRedis.CacheException", (e, ex) =>
27-
{
28-
var cmd = e.AddCommand(new Command("Redis"));
29-
foreach (string k in ex.Data.Keys)
30-
{
31-
var val = ex.Data[k] as string;
32-
if (k == "redis-command") cmd.CommandString = val;
33-
if (k.StartsWith("Redis-")) cmd.AddData(k.Substring("Redis-".Length), val);
34-
}
35-
});
36-
37-
return handlers;
38-
}
39-
408
/// <summary>
419
/// Convenience method for adding a handler for an exception type.
4210
/// </summary>

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

Lines changed: 1 addition & 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>>().AddDefault();
84+
public Dictionary<string, Action<Error>> ExceptionActions { get; } = new Dictionary<string, Action<Error>>();
8585

8686
/// <summary>
8787
/// The <see cref="Regex"/> of data keys to include. For example, "Redis.*" would include all keys that start with Redis.

src/StackExchange.Exceptional.Shared/StackExchange.Exceptional.Shared.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
<RootNamespace>StackExchange.Exceptional</RootNamespace>
77
</PropertyGroup>
88
<ItemGroup>
9-
<PackageReference Include="Dapper" />
10-
<PackageReference Include="Microsoft.Data.SqlClient" />
119
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
1210
<PackageReference Include="Newtonsoft.Json" />
1311
</ItemGroup>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using StackExchange.Exceptional.Internal;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Data.SqlClient;
5+
6+
namespace StackExchange.Exceptional
7+
{
8+
/// <summary>
9+
/// Extensions methods for <see cref="Exception"/>s.
10+
/// </summary>
11+
public static class Extensions
12+
{
13+
/// <summary>
14+
/// Adds the default data handlers to a handlers collection.
15+
/// </summary>
16+
/// <param name="handlers">The dictionary to register these default handlers on.</param>
17+
public static Dictionary<string, Action<Error>> AddSqlException(this Dictionary<string, Action<Error>> handlers)
18+
{
19+
handlers?.AddHandler<SqlException>((e, se) =>
20+
{
21+
e.AddCommand(new Command("SQL Server Query", se.Data.Contains("SQL") ? se.Data["SQL"] as string : null)
22+
.AddData(nameof(se.Server), se.Server)
23+
.AddData(nameof(se.Number), se.Number.ToString())
24+
.AddData(nameof(se.LineNumber), se.LineNumber.ToString())
25+
.AddData(se.Procedure.HasValue(), nameof(se.Procedure), se.Procedure)
26+
);
27+
});
28+
return handlers;
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)