mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-22 19:38:47 +00:00
Don't return arrays in public properties
This commit is contained in:
parent
66fe507b8d
commit
20481a1bdd
@ -1,4 +1,6 @@
|
|||||||
namespace VpSharp.Commands.Attributes;
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
|
namespace VpSharp.Commands.Attributes;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines the aliases of a command.
|
/// Defines the aliases of a command.
|
||||||
@ -39,14 +41,15 @@ public sealed class AliasesAttribute : Attribute
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Aliases = new string[aliases.Length + 1];
|
var buffer = new string[aliases.Length + 1];
|
||||||
Aliases[0] = alias;
|
buffer[0] = alias;
|
||||||
Array.Copy(aliases, 0, Aliases, 1, aliases.Length);
|
Array.Copy(aliases, 0, buffer, 1, aliases.Length);
|
||||||
|
Aliases = new ReadOnlyCollection<string>(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the command aliases.
|
/// Gets the command aliases.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The command aliases.</value>
|
/// <value>The command aliases.</value>
|
||||||
public string[] Aliases { get; }
|
public IReadOnlyList<string> Aliases { get; }
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Reflection;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace VpSharp.Commands;
|
namespace VpSharp.Commands;
|
||||||
|
|
||||||
@ -10,7 +11,7 @@ public sealed class Command
|
|||||||
internal Command(string name, string[] aliases, MethodInfo method, CommandModule module)
|
internal Command(string name, string[] aliases, MethodInfo method, CommandModule module)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
Aliases = aliases[..];
|
Aliases = new ReadOnlyCollection<string>(aliases);
|
||||||
Method = method;
|
Method = method;
|
||||||
Module = module;
|
Module = module;
|
||||||
Parameters = method.GetParameters()[1..];
|
Parameters = method.GetParameters()[1..];
|
||||||
@ -20,7 +21,7 @@ public sealed class Command
|
|||||||
/// Gets the aliases for this command.
|
/// Gets the aliases for this command.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The aliases.</value>
|
/// <value>The aliases.</value>
|
||||||
public string[] Aliases { get; }
|
public IReadOnlyList<string> Aliases { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name of this command.
|
/// Gets the name of this command.
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Drawing;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Drawing;
|
||||||
using VpSharp.Entities;
|
using VpSharp.Entities;
|
||||||
|
|
||||||
namespace VpSharp.Commands;
|
namespace VpSharp.Commands;
|
||||||
@ -18,7 +19,7 @@ public sealed class CommandContext
|
|||||||
CommandName = commandName;
|
CommandName = commandName;
|
||||||
Alias = alias;
|
Alias = alias;
|
||||||
RawArguments = rawArguments;
|
RawArguments = rawArguments;
|
||||||
Arguments = rawArguments.Split();
|
Arguments = new ReadOnlyCollection<string>(rawArguments.Split());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -31,7 +32,7 @@ public sealed class CommandContext
|
|||||||
/// Gets the arguments of the command.
|
/// Gets the arguments of the command.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The arguments passed by the avatar.</value>
|
/// <value>The arguments passed by the avatar.</value>
|
||||||
public string[] Arguments { get; }
|
public IReadOnlyList<string> Arguments { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the avatar who executed the command.
|
/// Gets the avatar who executed the command.
|
||||||
|
Loading…
Reference in New Issue
Block a user