Add rule to use range operator
MODIFY
.editorconfig
.editorconfig
@@ -218,6 +218,9 @@ csharp_style_prefer_index_operator = true:error
# IDE0032: Use auto property
dotnet_style_prefer_auto_properties = true:error
+# IDE0057: Use range operator
+csharp_style_prefer_range_operator = true:error
+
[*.xaml]
indent_style = space
indent_size = 2

MODIFY
WalletWasabi.Gui/Behaviors/BindSelectedTextBehavior.cs
WalletWasabi.Gui/Behaviors/BindSelectedTextBehavior.cs
@@ -37,7 +37,7 @@ namespace WalletWasabi.Gui.Behaviors
{
return "";
}
- return text.Substring(start, end - start);
+ return text[start..end];
}
protected override void OnAttached()

MODIFY
WalletWasabi.Gui/Controls/LockScreen/PinLockScreenViewModel.cs
WalletWasabi.Gui/Controls/LockScreen/PinLockScreenViewModel.cs
@@ -41,7 +41,7 @@ namespace WalletWasabi.Gui.Controls.LockScreen
{
if (PinInput.Length > 0)
{
- PinInput = PinInput.Substring(0, PinInput.Length - 1);
+ PinInput = PinInput[0..^1];
}
}
else if (arg == "CLEAR")

MODIFY
WalletWasabi.Packager/Program.cs
WalletWasabi.Packager/Program.cs
@@ -575,7 +575,7 @@ namespace WalletWasabi.Packager
process.WaitForExit();
}
- var daemonExePath = newExecutablePath.Substring(0, newExecutablePath.Length - 4) + "d.exe";
+ var daemonExePath = newExecutablePath[0..^4] + "d.exe";
File.Copy(newExecutablePath, daemonExePath);
// Do not open console.

MODIFY
WalletWasabi/Helpers/PasswordHelper.cs
WalletWasabi/Helpers/PasswordHelper.cs
@@ -31,7 +31,7 @@ namespace WalletWasabi.Helpers
{
originalPassword,
buggyClipboard, // Should be here for every OP system. If I create a buggy wallet on OSX and transfer it to other system, it should also work.
- $"{buggyClipboard.Substring(0,buggyClipboard.Length-1)}\ufffd" // Later I tested the functionality and experienced that the last character replaced by invalid character.
+ $"{buggyClipboard[0..^1]}\ufffd" // Later I tested the functionality and experienced that the last character replaced by invalid character.
};
return possiblePasswords.ToArray();

MODIFY
WalletWasabi/Mono/Option.cs
WalletWasabi/Mono/Option.cs
@@ -370,7 +370,7 @@ namespace Mono.Options
nameof(Prototype));
}
- seps.Add(name.Substring(start, i - start));
+ seps.Add(name[start..i]);
start = -1;
break;

MODIFY
WalletWasabi/Mono/OptionSet.cs
WalletWasabi/Mono/OptionSet.cs
@@ -659,7 +659,7 @@ namespace Mono.Options
Option p;
string rn;
if (n.Length >= 1 && (n[^1] == '+' || n[^1] == '-') &&
- Contains((rn = n.Substring(0, n.Length - 1))))
+ Contains((rn = n[0..^1])))
{
p = this[rn];
string v = n[^1] == '+' ? option : null;
@@ -968,7 +968,7 @@ namespace Mono.Options
}
else
{
- sb.Append(description.Substring(start, i - start));
+ sb.Append(description[start..i]);
start = -1;
}
break;

MODIFY
WalletWasabi/Mono/StringCoda.cs
WalletWasabi/Mono/StringCoda.cs
@@ -206,7 +206,7 @@ namespace Mono.Options
--end;
continuation = "-";
}
- string line = self.Substring(start, end - start) + continuation;
+ string line = self[start..end] + continuation;
yield return line;
start = end;
if (char.IsWhiteSpace(c))

Add rule to use range operator