Skip to content

Commit bc792f8

Browse files
remove substring for better syntax
1 parent 66728c6 commit bc792f8

File tree

12 files changed

+15
-15
lines changed

12 files changed

+15
-15
lines changed

Code/ArgumentSystem/Arguments/ColorArgument.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static TryGet<Color> TryParseColor(string value)
2727
var initValue = value;
2828
if (value.StartsWith("#"))
2929
{
30-
value = value.Substring(1);
30+
value = value[1..];
3131
}
3232

3333
switch (value.Length)

Code/EventSystem/EventHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ private static Variable[] InternalGetVariablesFromProperties(List<(object value,
248248

249249
string GetName()
250250
{
251-
return $"ev{name.First().ToString().ToUpper()}{name.Substring(1)}";
251+
return $"ev{name.First().ToString().ToUpper()}{name[1..]}";
252252
}
253253
}
254254

@@ -299,7 +299,7 @@ private static List<string> GetMimicVariablesForEventHelp(List<(Type type, strin
299299

300300
string GetName()
301301
{
302-
return $"ev{name.First().ToString().ToUpper()}{name.Substring(1)}";
302+
return $"ev{name.First().ToString().ToUpper()}{name[1..]}";
303303
}
304304
}
305305

Code/FlagSystem/Flags/CustomCommandFlag.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public static Result RunAttachedScript(CustomCommand requestingCommand, ScriptEx
207207
{
208208
var slice = slices[index];
209209
var argVariable = requestingCommand.Usage[index];
210-
var name = argVariable[0].ToString().ToLower() + argVariable.Substring(1);
210+
var name = argVariable[0].ToString().ToLower() + argVariable[1..];
211211

212212
if (Tokenizer.GetTokenFromSlice(slice, null!, 0)
213213
.WasSuccessful(out var token))

Code/Helpers/Extensions/TypeExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static string GetAccurateName(this Type type)
1919
string name = type.Name;
2020
int index = name.IndexOf('`');
2121
if (index > 0)
22-
name = name.Substring(0, index);
22+
name = name[..index];
2323

2424
sb.Append(name);
2525
sb.Append('<');

Code/Helpers/ResultSystem/Result.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private static string Process(string value)
6262

6363
if (char.IsLower(value.First()))
6464
{
65-
value = value.First().ToString().ToUpper() + value.Substring(1);
65+
value = value.First().ToString().ToUpper() + value[1..];
6666
}
6767

6868
if (!char.IsPunctuation(value.Last()))

Code/MethodSystem/BaseMethods/Method.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected Method()
2626
Subgroup = type.Namespace?
2727
.Split('.')
2828
.LastOrDefault()?
29-
.WithCurrent(name => name.Substring(0, name.Length - "Methods".Length))
29+
.WithCurrent(name => name[..^"Methods".Length])
3030
?? "Unknown";
3131

3232
var name = type.Name;
@@ -35,7 +35,7 @@ protected Method()
3535
throw new AndrzejFuckedUpException($"Method class name '{name}' must end with 'Method'.");
3636
}
3737

38-
Name = name.Substring(0, name.Length - "Method".Length);
38+
Name = name[..^"Method".Length];
3939
Args = new(this);
4040
}
4141

Code/MethodSystem/Methods/NumberMethods/HexToIntMethod.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public override void Execute()
3131
var hex = Args.GetText("hex number");
3232

3333
if (hex.StartsWith("0x"))
34-
hex = hex.Substring(2);
34+
hex = hex[2..];
3535

3636
if (hex.StartsWith("#"))
37-
hex = hex.Substring(1);
37+
hex = hex[1..];
3838

3939
ReturnValue = int.TryParse(
4040
hex,

Code/Plugin/CommandEvents.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static void CaptureCommand(CommandExecutingEventArgs ev)
4242
return;
4343
}
4444

45-
var methodName = ev.CommandName.Substring(1);
45+
var methodName = ev.CommandName[1..];
4646

4747
if (!methodName.Any())
4848
{

Code/TokenSystem/Tokens/DurationToken.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected override IParseResult InternalParse(Script scr)
3232
return new Error("Duration cannot be negative.");
3333
}
3434

35-
var unit = value.Substring(unitIndex);
35+
var unit = value[unitIndex..];
3636
TimeSpan? timeSpan = unit switch
3737
{
3838
"s" => TimeSpan.FromSeconds(valueAsDouble),

Code/TokenSystem/Tokens/VariableTokens/VariableToken.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected override IParseResult InternalParse(Script scr)
5959
return new Ignore();
6060
}
6161

62-
Name = RawRep.Substring(1);
62+
Name = RawRep[1..];
6363
if (Name.Any(c => !char.IsLetter(c) && !char.IsDigit(c) && c != '_'))
6464
{
6565
return new Ignore();

0 commit comments

Comments
 (0)