feat: fix existing query values bug by TimothyMakkison · Pull Request #1737 · reactiveui/refit
Closes #1732
Fixes a bug where existing query parameters would have their positions reversed #1732
- Extracted logic into a method
- If the existing
Queryis empty we early return- This early return prevents the allocation of an empty 300 byte
NameValueCollection
- This early return prevents the allocation of an empty 300 byte
- Otherwise the query is parsed with each key pair added
- There might be room for improvement here by using a linq
Selectmethod.Selectwould know the length of the collection andInsertRangewould be able to bulk copy the values. This could only be done if we know for certain that the key can't be empty andWhereis not required.
- There might be room for improvement here by using a linq
Before
| Method | Mean | Error | StdDev | Gen0 | Gen1 | Allocated |
|---|---|---|---|---|---|---|
| ConstantRouteAsync | 2.606 us | 0.0251 us | 0.0235 us | 0.7668 | 0.0038 | 7.06 KB |
| DynamicRouteAsync | 3.306 us | 0.0589 us | 0.0550 us | 0.8087 | - | 7.45 KB |
| ComplexDynamicRouteAsync | 4.635 us | 0.0730 us | 0.0683 us | 0.8926 | 0.0076 | 8.27 KB |
| ObjectRequestAsync | 5.169 us | 0.0992 us | 0.0974 us | 0.9766 | 0.0076 | 8.99 KB |
| ComplexRequestAsync | 13.306 us | 0.1515 us | 0.1343 us | 1.6479 | - | 15.24 KB |
Query changes
| Method | Mean | Error | StdDev | Gen0 | Gen1 | Allocated |
|---|---|---|---|---|---|---|
| ConstantRouteAsync | 2.696 us | 0.0302 us | 0.0236 us | 0.7362 | 0.0038 | 6.77 KB |
| DynamicRouteAsync | 3.369 us | 0.0666 us | 0.0684 us | 0.7782 | - | 7.16 KB |
| ComplexDynamicRouteAsync | 4.529 us | 0.0412 us | 0.0344 us | 0.8621 | - | 7.97 KB |
| ObjectRequestAsync | 5.061 us | 0.0476 us | 0.0445 us | 0.9384 | 0.0076 | 8.69 KB |
| ComplexRequestAsync | 13.274 us | 0.1464 us | 0.1222 us | 1.6174 | 0.0153 | 14.94 KB |
Codecov Report
All modified and coverable lines are covered by tests ✅
Project coverage is 84.63%. Comparing base (
6ebeda5) to head (7291cca).
Report is 47 commits behind head on main.
❗ Current head 7291cca differs from pull request most recent head 713e067
Please upload reports for the commit 713e067 to get more accurate results.
Additional details and impacted files
@@ Coverage Diff @@ ## main #1737 +/- ## ========================================== - Coverage 87.73% 84.63% -3.11% ========================================== Files 33 36 +3 Lines 2348 2512 +164 Branches 294 327 +33 ========================================== + Hits 2060 2126 +66 - Misses 208 304 +96 - Partials 80 82 +2
☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.
Nice, I really want to make some kind of live test, for example two console apps that can execute to test the functionality more fully. There's many parts of the code which are either untestable or have no existing tests.
If you have any ideas how we can achieve this, please shout.
I really want to make some kind of live test, for example two console apps that can execute to test the functionality more fully.
Like a sandbox project? It could be a single file with an interface and dummy http request handler.
There's many parts of the code which are either untestable or have no existing tests.
Which parts did you have in mind? When experimenting with the source generator I have added snapshot testing. The current system is okay because the generator is basic, but any future improvements will need a better test setup. See mapperly as a good example (not biased)😄
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
github-actions
bot
locked as resolved and limited conversation to collaborators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters