-
Notifications
You must be signed in to change notification settings - Fork 492
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
Use the IDictionary.TryGetValue(TKey, out TValue)
method to fix CA1854 warnings
#12152
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My comments are not requirements, the PR is good.
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/Rounds/MultipartyTransactionStateTests.cs
Outdated
Show resolved
Hide resolved
@@ -163,12 +163,13 @@ private List<SmartCoin> GenerateSmartCoins(IEnumerable<(string Cluster, decimal | |||
{ | |||
var key = KeyManager.GenerateNewKey(new LabelsArray(targetCoin.Cluster), KeyState.Clean, false); | |||
|
|||
if (!generatedKeyGroup.ContainsKey(targetCoin.Cluster)) | |||
if (!generatedKeyGroup.TryGetValue(targetCoin.Cluster, out List<(HdPubKey key, decimal amount)>? value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rider always recommends here to use var
. I know @kiminuo prefers very much to be specific all the time. Personal choice I guess, it's a discussion we're having all the time. Feel free to leave it as you did, simply a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using var
makes reviews less friendly for people not using an IDE. Not everyone has an IDE. Not everytime one wants to switch to a different branch just because a complex line of code is var
ed. var
can silently change code semantics during refactorings, etc. etc.
Anyway, #7153 was rejected, so it's up to everyone who likes what.
IDictionary.TryGetValue(TKey, out TValue)
method to fix CA1854 warnings
https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1854