Skip to content

Commit a27ea2c

Browse files
committed
Only reference Microsoft.Data.SqlClient in Dibix.Testing net8.0
1 parent 46ebc61 commit a27ea2c

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/Dibix.Testing/Dibix.Testing.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</ItemGroup>
2121

2222
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
23+
<PackageReference Include="Microsoft.Data.SqlClient" />
2324
<PackageReference Include="System.ComponentModel.Annotations" />
2425
</ItemGroup>
2526

@@ -29,7 +30,6 @@
2930
</ItemGroup>
3031

3132
<ItemGroup>
32-
<PackageReference Include="Microsoft.Data.SqlClient" />
3333
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
3434
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" />
3535
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />

src/Dibix.Testing/Utilities/TaskUtility.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Threading;
33
using System.Threading.Tasks;
4-
using Microsoft.Data.SqlClient;
54

65
namespace Dibix.Testing
76
{
@@ -43,19 +42,22 @@ private static bool IsCancellationException(Exception exception, CancellationTok
4342
switch (exception)
4443
{
4544
case DatabaseAccessException databaseAccessException: return IsCancellationException(databaseAccessException.InnerException, cancellationToken);
46-
case SqlException sqlException: return IsPossiblySqlCommandCancellation(sqlException);
45+
#if NET
46+
case Microsoft.Data.SqlClient.SqlException sqlException: return IsPossiblySqlCommandCancellation(sqlException);
47+
#endif
4748
case TaskCanceledException _: return true;
4849
case OperationCanceledException _: return true;
4950
default: return false;
5051
}
5152

5253
}
53-
54-
private static bool IsPossiblySqlCommandCancellation(SqlException sqlException)
54+
#if NET
55+
private static bool IsPossiblySqlCommandCancellation(Microsoft.Data.SqlClient.SqlException sqlException)
5556
{
5657
// A severe error occurred on the current command. The results, if any, should be discarded.
5758
// Operation cancelled by user.
5859
return sqlException.Class == 11 && sqlException.Number == 0;
5960
}
61+
#endif
6062
}
6163
}

0 commit comments

Comments
 (0)