Add rule to use index operator
MODIFY
.editorconfig
.editorconfig
@@ -212,6 +212,9 @@ dotnet_naming_style.T_pascal_case_style.required_prefix = T
dotnet_naming_style.T_pascal_case_style.capitalization = pascal_case
+# IDE0056: Use index operator
+csharp_style_prefer_index_operator = true:error
+
[*.xaml]
indent_style = space
indent_size = 2

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
@@ -923,7 +923,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
else
{
- words[words.Length - 1] = word;
+ words[^1] = word;
Label = string.Join(", ", words) + ", ";
}

MODIFY
WalletWasabi.Gui/Tabs/WalletManager/RecoverWalletViewModel.cs
WalletWasabi.Gui/Tabs/WalletManager/RecoverWalletViewModel.cs
@@ -216,7 +216,7 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
}
else
{
- words[words.Length - 1] = word;
+ words[^1] = word;
MnemonicWords = string.Join(' ', words) + " ";
}

MODIFY
WalletWasabi/Blockchain/Analysis/FeesEstimation/FeeProviders.cs
WalletWasabi/Blockchain/Analysis/FeesEstimation/FeeProviders.cs
@@ -63,7 +63,7 @@ namespace WalletWasabi.Blockchain.Analysis.FeesEstimation
}
}
- Status = providerArray[providerArray.Length - 1].Status;
+ Status = providerArray[^1].Status;
}
}

MODIFY
WalletWasabi/Gma/QrCodeNet/Encoding/ReedSolomon/Polynomial.cs
WalletWasabi/Gma/QrCodeNet/Encoding/ReedSolomon/Polynomial.cs
@@ -60,7 +60,7 @@ namespace Gma.QrCodeNet.Encoding.ReedSolomon
{
//eg: x^2 + x + 1. degree 1, reverse position = degree + 1 = 2.
//Pos = 3 - 2 = 1
- return Coefficients[Coefficients.Length - (degree + 1)];
+ return Coefficients[^(degree + 1)];
}
/// <summary>

MODIFY
WalletWasabi/Mono/OptionSet.cs
WalletWasabi/Mono/OptionSet.cs
@@ -658,11 +658,11 @@ namespace Mono.Options
{
Option p;
string rn;
- if (n.Length >= 1 && (n[n.Length - 1] == '+' || n[n.Length - 1] == '-') &&
+ if (n.Length >= 1 && (n[^1] == '+' || n[^1] == '-') &&
Contains((rn = n.Substring(0, n.Length - 1))))
{
p = this[rn];
- string v = n[n.Length - 1] == '+' ? option : null;
+ string v = n[^1] == '+' ? option : null;
c.OptionName = option;
c.Option = p;
c.OptionValues.Add(v);
@@ -912,7 +912,7 @@ namespace Mono.Options
// for maxIndex=1 it can be {foo} or {0:foo}
if (maxIndex == 1)
{
- argName = parts[parts.Length - 1];
+ argName = parts[^1];
}
// look for {i:foo} if maxIndex > 1
if (maxIndex > 1 && parts.Length == 2 &&

Add rule to use index operator