Conversation
…nd_processor * origin/main: fix: Windows build scripts fail correctly on build errors (#518) Fix 'cdecl' attribute ignored warnings in Linux x86_64 builds (#516) Include ECS libraries in SampSharp.Sdk meta-package (#512) Separate test projects into test/ directory (#510) Add WeaponInfo related extensions #502 (#508)
- Renamed CommandOverload to CommandDefinition (merged type) - Renamed CommandDefinition wrapper to CommandCommand (internal only) - Added Name/Group/FullName properties to CommandDefinition - Updated CommandScanner to build individual CommandDefinitions with grouping data - Updated CommandRegistry to accept flat CommandDefinitions and group them internally - Updated CommandDispatcher to work with CommandRegistry internal methods - Updated message service interfaces to accept IReadOnlyList<CommandDefinition> - Updated DefaultCommandEnumerator to group definitions by name/group - All overloads of a command can now be properly registered and accessed
…andSet naming Agent-Logs-Url: https://github.com/ikkentim/SampSharp/sessions/bb3bb95c-10ab-473f-85ff-fde834f84f5f Co-authored-by: ikkentim <2820647+ikkentim@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ikkentim/SampSharp/sessions/bb3bb95c-10ab-473f-85ff-fde834f84f5f Co-authored-by: ikkentim <2820647+ikkentim@users.noreply.github.com>
Done in
Also fixed alias |
| wordLen++; | ||
| } | ||
|
|
||
| var word = trimmed.Take(wordLen).ToString(); |
There was a problem hiding this comment.
This should not happen. Should stay StringSpan instead of transforming to string. TryFindChild should ge changed to use StringSpan instead. Dictionary lookup may be more difficult, but the item count will not be endless, we can iterate through.
There was a problem hiding this comment.
Fixed in 21f9efa. TryGetChild now accepts ReadOnlySpan<char> and iterates through _children using word.Equals(kvp.Key, StringComparison.OrdinalIgnoreCase) — no .ToString() allocation. Traverse uses trimmed.AsSpan()[..wordLen] to get the word span directly.
|
@copilot address code comments |
…ses per-overload only Agent-Logs-Url: https://github.com/ikkentim/SampSharp/sessions/2e3b0b35-34d7-4c8a-a1e7-591af7a90704 Co-authored-by: ikkentim <2820647+ikkentim@users.noreply.github.com>
Done in
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 114 out of 114 changed files in this pull request and generated 13 comments.
Comments suppressed due to low confidence (1)
src/SampSharp.OpenMp.Entities.Commands/Player/PlayerCommandProcessingMiddleware.cs:39
- IsHandled no longer treats integer return values specially. With the current switch, an
intresult (including 0) will fall into the default arm and be treated as handled, which changes behavior compared to the previous implementation (where 0 was unhandled). If any OnPlayerCommandText handlers/middleware return int (legacy pattern), restoreint i => i != 0handling (or explicitly restrict supported result types).
| /// <inheritdoc /> | ||
| public bool SendPermissionDenied(Player player, CommandDefinition overload) | ||
| { | ||
| var message = FormatPermissionDenied(""); // TODO input text | ||
| player.SendClientMessage(message); | ||
| return true;// TODO: option to not print message | ||
| } |
|
|
||
| /// <summary>Searches for commands matching a query.</summary> | ||
| IEnumerable<CommandDefinition> SearchCommands(string query); | ||
|
|
||
| /// <summary>Finds a specific command by name.</summary> | ||
| CommandDefinition? FindCommand(string name); |
There was a problem hiding this comment.
Implementation should be non-null
There was a problem hiding this comment.
Fixed in 95d805d. Removed the null-handling (query?.ToLowerInvariant() ?? ""); implementation now uses query.ToLowerInvariant() directly, consistent with the non-nullable interface contract. Also removed the SearchCommands_NullQuery_ReturnsAll test.
| [Fact] | ||
| public void CreateSuccess_MessageIsNullByDefault() | ||
| { | ||
| var result = DispatchResult.CreateSuccess(); | ||
| } |
| [PlayerCommand(Name = "ping")] | ||
| public void PingCommand(Player player, IEntityManager entityManager) | ||
| { | ||
| player.SendClientMessage($"Your ping: {player.Ping}ms"); | ||
| } |
| internal class UnhandledExceptionHandlerImpl: IUnhandledExceptionHandler | ||
| { |
| [PlayerCommand("announce")] | ||
| public void AnnounceCommand(IWorldService server) | ||
| { | ||
| server.SendClientMessage("Hello everyone!"); | ||
| } |
| /// <inheritdoc /> | ||
| public bool Equals(CommandGroup other) | ||
| { | ||
| return _parts.SequenceEqual(other._parts); | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public override int GetHashCode() | ||
| { | ||
| var hash = new HashCode(); | ||
| foreach (var part in _parts) | ||
| { | ||
| hash.Add(part); | ||
| } | ||
| return hash.ToHashCode(); |
There was a problem hiding this comment.
A string comparer should be set in the service and passed through with other calls. Maybe even better would be an ioptions pattern with command service options (one for console commands, one for players commands, common base type)
There was a problem hiding this comment.
Done in 95d805d. Added CommandServiceOptions (base class), PlayerCommandServiceOptions, and ConsoleCommandServiceOptions registered via AddOptions<T>() in DI. CommandGroup.Equals/GetHashCode now use OrdinalIgnoreCase to match tree lookup behaviour. The options classes provide the foundation for wiring a configurable StringComparison through the services.
|
@copilot address review comments |
…mmandGroup OrdinalIgnoreCase, CommandServiceOptions, empty tests, SampleCommandsSystem fixes Agent-Logs-Url: https://github.com/ikkentim/SampSharp/sessions/6bdff1d0-3cf0-4097-8290-f9de78550f30 Co-authored-by: ikkentim <2820647+ikkentim@users.noreply.github.com>
Done in
|
|
@copilot I'm not yet happy with how registration of commands work. I dont see the point in ScanPlayerCommands (and similarly the console variant) of grouping comands by method etc. anymore. I think we should just iterate through the found methods -> validate command name ->
Registration should:
That way |
…simplify scanner/registry/tree) Agent-Logs-Url: https://github.com/ikkentim/SampSharp/sessions/f6e0b1a7-d7d3-44a5-9fc5-c6d199902375 Co-authored-by: ikkentim <2820647+ikkentim@users.noreply.github.com>
Done in
|
No description provided.