Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for .NET 8 #1144

Merged
merged 12 commits into from
Nov 14, 2023
Merged

Add support for .NET 8 #1144

merged 12 commits into from
Nov 14, 2023

Conversation

martincostello
Copy link
Member

@martincostello martincostello commented Apr 18, 2023

Relates to #1141, depends on #1738, resolves #1786.

@martincostello martincostello added the v8 Issues related to the new version 8 of the Polly library. label Apr 18, 2023
@martincostello martincostello added this to the v8.0.0 milestone Apr 18, 2023
@codecov-commenter
Copy link

codecov-commenter commented Apr 18, 2023

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (65b0bdc) 84.56% compared to head (d3e0fec) 84.59%.
Report is 1 commits behind head on main.

Files Patch % Lines
src/Polly/AsyncPolicy.ExecuteOverloads.cs 50.00% 6 Missing ⚠️
src/Polly/AsyncPolicy.TResult.ExecuteOverloads.cs 50.00% 3 Missing ⚠️
src/Polly/Policy.ExecuteOverloads.cs 75.00% 2 Missing ⚠️
src/Polly/Policy.TResult.ExecuteOverloads.cs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1144      +/-   ##
==========================================
+ Coverage   84.56%   84.59%   +0.02%     
==========================================
  Files         308      308              
  Lines        6791     6802      +11     
  Branches     1044     1049       +5     
==========================================
+ Hits         5743     5754      +11     
  Misses        839      839              
  Partials      209      209              
Flag Coverage Δ
linux 84.59% <83.09%> (+0.02%) ⬆️
macos 84.59% <83.09%> (+0.02%) ⬆️
windows 84.59% <83.09%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@martincostello
Copy link
Member Author

@martintmk Do you want to push your changes to use System.TimeProvider into this branch?

@martintmk
Copy link
Contributor

@martintmk Do you want to push your changes to use System.TimeProvider into this branch?

Yup, but first let me create another PR that's prerequisite for this. Then I'll push changes directly to yours.

eng/Analyzers.targets Outdated Show resolved Hide resolved
@martincostello
Copy link
Member Author

I'll rebase this once #1192 is merged, then you should be able to put the TimeProvider changes on top of that.

@martincostello martincostello force-pushed the dotnet-8 branch 2 times, most recently from 614277f to e75c9d2 Compare May 18, 2023 10:01
@martincostello
Copy link
Member Author

@martintmk Could you rebase this onto main so we can update to preview 5?

@martintmk
Copy link
Contributor

@martintmk Could you rebase this onto main so we can update to preview 5?

Rebased. Few tests are failing, we can address that later.

@martincostello
Copy link
Member Author

I'll look at bumping this to preview 5 and fixing the tests today.

@martincostello
Copy link
Member Author

I tweaked a few assertions with what I thought was the correct change, but I wasn't 100% what the intended behaviour change was for the other failures.

@martincostello
Copy link
Member Author

I'll try and update this again once #1355 is merged.

@martincostello
Copy link
Member Author

Blocked on adopting Microsoft.Extensions.TimeProvider.Testing until the fix for dotnet/runtime#88000 is in a publicly available preview of .NET 8, which is probably not going to be until preview 7.

@martincostello
Copy link
Member Author

@martintmk Would be good to get some feedback on the changes in 7be0f93. I've removed the Moq-based implementation so we're not introspecting on the implementation details of the clock too much, but I'm not 100% sure the test refactoring is correct, even though they pass locally.

I also simplified the TimeProviderExtensions code as comparing it to the code in the NuGet version, we seem to duplicate a fair number of the conditions already in that code. If we just call it then we can remove the "is it a mock or not?" branching - assuming I understood it correctly.

@martintmk
Copy link
Contributor

@martintmk Would be good to get some feedback on the changes in 7be0f93. I've removed the Moq-based implementation so we're not introspecting on the implementation details of the clock too much, but I'm not 100% sure the test refactoring is correct, even though they pass locally.

I also simplified the TimeProviderExtensions code as comparing it to the code in the NuGet version, we seem to duplicate a fair number of the conditions already in that code. If we just call it then we can remove the "is it a mock or not?" branching - assuming I understood it correctly.

@martincostello, the extra code in TimeProviderExtensions for the synchronous path was done to avoid the sync-over-async pattern. But honestly, I am pretty fine with this change. It makes out code simpler and it only happens when resilience event occurs, so not on the hot path.

Your test refactorings are fine, otherwise some mutants would have survived. But I suggest to make those changes in the main branch too.

@martincostello
Copy link
Member Author

Cool, thanks. Yep, today I'll tidy up this branch a bit and then cherry-pick some of the changes to go into main now rather than wait on 8.0 RTM.

@martintmk martintmk mentioned this pull request Jun 27, 2023
4 tasks
martincostello added a commit to martincostello/Polly that referenced this pull request Jun 27, 2023
Backport various changes from App-vNext#1144:
- Simplify NuGet package version management.
- Simplify TimeProviderExtensions.
- Enable .NET analyzers.
- Remove `MockTimeProvider`.
- Minor code formatting clean-ups.
@martincostello
Copy link
Member Author

Build failures are due to a known issue in the RC2 SDK when a newer version of a global tool is available than in the config file.

Build with the .NET 8 RC2 SDK.
Use new artifacts output.
- Use C#12 collection initializers where relevant.
- Suppress false positives when using `TheoryData`.
- Remove some redundant code analysis suppressions.
Resolve CP0001 and CP0002 warnings with the .NET 8 SDK.
Fix mutation tests by switching to Windows and updating the settings to support .NET 8 and C# 12.
- Fix NETSDK1204 error as cannot publish AoT on macOS.
- Fix NETSDK1201 error on Linux and Windows.
martincostello and others added 5 commits November 14, 2023 14:58
Use the stable release of the .NET 8 SDK.
- Add `net8.0` targets.
- Use .NET `TimeProvider` implementation.
- Use `FakeTimeProvider` for tests.
- Use new .NET 8 APIs where relevant.

Co-Authored-By: martintmk <103487740+martintmk@users.noreply.github.com>
Update comment grammar.
Use stable .NET 8 NuGet package versions.
@martincostello
Copy link
Member Author

Looks like there's a flaky test when testing for .NET Framework related to the metrics stuff.

@martincostello martincostello marked this pull request as ready for review November 14, 2023 15:32
@martincostello martincostello enabled auto-merge (squash) November 14, 2023 15:33
@martincostello martincostello merged commit a2559b1 into main Nov 14, 2023
16 of 17 checks passed
@martincostello martincostello deleted the dotnet-8 branch November 14, 2023 16:29
@burger100
Copy link

Does it means Polly doesn't support .net version prior to .net 8.0 anymore ?
After an update to version 8.2.0 I got build error saying that TimeProvider is ambigous between our internal TimeProvider and the new System.TimeProvider added in .net8.0. Our project is still targetting .net7.0.

@martincostello
Copy link
Member Author

No it doesn't - it just means that Polly now includes a net8.0 target and exposes a property to allow you to configure a custom TimeProvider.

Previously we also had our own internal copy of TimeProvider, which we were able to delete by using the NuGet package instead.

If you have your own copy of it you'll either need to remove it, rename it or alias it to resolve the conflict.

This isn't an issue unique to your use of Polly, you would have the same problem if you used any other NuGet package that also added a dependency on the new TimeProvider APIs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/build dependencies Pull requests that update a dependency file .NET Pull requests that update .NET code v8 Issues related to the new version 8 of the Polly library.
Projects
No open projects
Status: Done
4 participants