Skip to content

Commit 05f21f1

Browse files
committed
Remove TimeProvider for .NET
1 parent 884d3b4 commit 05f21f1

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@
295295
<!-- References for netcore -->
296296
<ItemGroup Condition="'$(TargetFramework)' != 'net462'">
297297
<PackageReference Include="Microsoft.Bcl.Cryptography" />
298-
<PackageReference Include="Microsoft.Bcl.TimeProvider" />
299298
<PackageReference Include="Microsoft.Data.SqlClient.SNI.runtime" />
300299
<PackageReference Include="Microsoft.Extensions.Caching.Memory" />
301300
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" />

src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.nuspec

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
</group>
5757
<group targetFramework="net8.0">
5858
<dependency id="Microsoft.Bcl.Cryptography" version="8.0.0" />
59-
<dependency id="Microsoft.Bcl.TimeProvider" version="8.0.1" />
6059
<dependency id="Microsoft.Data.SqlClient.Extensions.Abstractions" version="$AbstractionsPackageVersion$" />
6160
<dependency id="Microsoft.Data.SqlClient.Internal.Logging" version="$LoggingPackageVersion$" />
6261
<dependency id="Microsoft.Data.SqlClient.SNI.runtime" version="6.0.2" exclude="Compile" />
@@ -69,7 +68,6 @@
6968
</group>
7069
<group targetFramework="net9.0">
7170
<dependency id="Microsoft.Bcl.Cryptography" version="9.0.13" />
72-
<dependency id="Microsoft.Bcl.TimeProvider" version="9.0.16" />
7371
<dependency id="Microsoft.Data.SqlClient.Extensions.Abstractions" version="$AbstractionsPackageVersion$" />
7472
<dependency id="Microsoft.Data.SqlClient.Internal.Logging" version="$LoggingPackageVersion$" />
7573
<dependency id="Microsoft.Data.SqlClient.SNI.runtime" version="6.0.2" exclude="Compile" />

src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/TimeoutTimer.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,17 @@ internal CancellationTokenSource CreateCancellationTokenSource()
366366
// Route the timer through the configured TimeProvider so that fake
367367
// time providers can advance virtual time and trigger cancellation
368368
// deterministically in tests.
369-
// Use the extension method rather than the CancellationTokenSource
370-
// constructor overload, which doesn't exist on .NET Framework.
369+
#if NET
370+
// On .NET 8+ the BCL provides this constructor directly; avoid the
371+
// Microsoft.Bcl.TimeProvider extension so the produced assembly
372+
// doesn't carry a hard reference to the polyfill package, which the
373+
// .NET SDK prunes from downstream consumers' restore graphs.
374+
return new CancellationTokenSource(TimeSpan.FromMilliseconds(remaining), TimeProvider);
375+
#else
376+
// .NET Framework lacks the constructor overload; use the extension
377+
// method shipped by Microsoft.Bcl.TimeProvider.
371378
return TimeProvider.CreateCancellationTokenSource(TimeSpan.FromMilliseconds(remaining));
379+
#endif
372380
}
373381

374382
/// <summary>

0 commit comments

Comments
 (0)