File tree Expand file tree Collapse file tree
src/Microsoft.Data.SqlClient/src
Microsoft/Data/ProviderBase Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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" />
Original file line number Diff line number Diff line change 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" />
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" />
Original file line number Diff line number Diff 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>
You can’t perform that action at this time.
0 commit comments