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

Random opinionated changes #2

Merged
merged 20 commits into from
Nov 13, 2023
Merged

Conversation

davidwengier
Copy link
Contributor

@davidwengier davidwengier commented Nov 9, 2023

No idea if this works, because I couldn't run tests locally Tests pass in a codespace

Reviewing commit-at-a-time will explain what each change is. Feel free to not take any of this if you don't like it :)

A clean error list is a happy error list
There is no need to check if a string is a simple type, only to then check if its a string. Additionally, by capturing the result of the type check, we avoid the extra as (or cast)
At the end of the day, what we want here is null warning suppression, but doing it with an exclamation mark can be quite hidden, and can just result in exceptions sometime later at runtime. The AssumeNotNull method is an aggressive version that throws at the site of the actual null.

Also increased the language version to be able to use nameof to refer to a parameter.
The system never puts nulls in, so it was a little odd that it allowed for them to be retreived. Instead, if a message can't be retreived then the whole message may as well be null.
The BeginScope method is on ILogger, not ILogger<T>, so there was no difference between this and the method below
In particular with Nullable<T> its much nicer to use patterns, rather than .HasValue and then .Value. There is also a minor perf improvement as .Value has to check, and throw, for nulls.
Task.WhenAll returns an array, but returning it as an IEnumerable meant the GetMessageAsync method has to enumerate the results no less than 4 times!
Mainly I wanted to remove yet another enumeration of a collection, but also because this calculation seemed useless to me. If we want to batch into chunks of 20, and there are only 10, then surely it will produce one chunk whether the batch size is set to 10 or 20.
The IDE will automatically show the doc comments from the interface member, without needing to specify inheritdoc everywhere. Also removed some whitespace I saw while checking that no, this isn't producing a documentation file.
Sealed performs better 😛
This is the convention, and clearly communicates intent
Default interface implementations are tempting to use as helper methods, but they are not great, as any new implementor will, at best, think they have to implement them, and at worst get compile errors. Helpers written as extension methods in the same namespace are just as discoverable, and should work regardless of implementation.
Must have crept in when rebasing
No need to force things to stay on the same thread when doing async network I/O to Azure
Why not go all out :D
It didn't build in a codespace, so I guess this is too new.
Copy link

codecov bot commented Nov 9, 2023

Codecov Report

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

Files Coverage Δ
...c/SimpleAzure.Storage.HybridQueue/HybridMessage.cs 100.00% <100.00%> (ø)
...zure.Storage.HybridQueue/IHybridQueueExtensions.cs 100.00% <100.00%> (ø)
...mpleAzure.Storage.HybridQueue/LoggingExtensions.cs 100.00% <ø> (+50.00%) ⬆️
src/SimpleAzure.Storage.HybridQueue/Helpers.cs 83.33% <66.66%> (-16.67%) ⬇️
src/SimpleAzure.Storage.HybridQueue/HybridQueue.cs 93.42% <87.50%> (+8.53%) ⬆️

📢 Thoughts on this report? Let us know!

@PureKrome PureKrome added the enhancement New feature or request label Nov 10, 2023
Check out how awesome patterns are! Didn't have to update any of them even though the return type now has a Count property instaed of a Length property! Yay patterns!!
Copy link
Owner

@PureKrome PureKrome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay - such an awesome learning experience. I think I have about all Approve except 1, which is personal preference.

@PureKrome PureKrome merged commit 5167351 into PureKrome:main Nov 13, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants