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