Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ecs): Make commands case-insensitive #440

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MrDave1999
Copy link
Contributor

Resolves #439

@ikkentim
Copy link
Owner

ikkentim commented Mar 1, 2025

This would make all commands case-insensitive instead of allowing commands to be case-insensitive. Might be good to make it a configuration option on EcsBuilder

@MrDave1999
Copy link
Contributor Author

MrDave1999 commented Mar 16, 2025

@ikkentim This is the expected behavior. All SA-MP server commands are case-insensitive.
In my opinion, this should not be a configuration option. This should be the default behavior, otherwise the Principle of least astonishment would be violated.

PD: I have updated the title of the PR, it is a fix rather than a feature.

@MrDave1999 MrDave1999 changed the title feat(ecs): Allow command names to be case-insensitive fix(ecs): Make commands case-insensitive Mar 16, 2025
@bssth
Copy link

bssth commented Mar 16, 2025

@ikkentim This is the expected behavior. All SA-MP server commands are case-insensitive. In my opinion, this should not be a configuration option. This should be the default behavior, otherwise the Principle of least astonishment would be violated.

When you use OnPlayerCommandText, it's up to you to decide how to handle the command text, including case sensitive, isn't it? Even strcmp accepts such a parameter. Command processors and the fact that it is a de facto standard is another matter

@ikkentim
Copy link
Owner

In my opinion (...) This should be the default behavior

You counter your own point here, besides, it would be a breaking change due to behavioral changes in existing systems

@MrDave1999
Copy link
Contributor Author

MrDave1999 commented Mar 16, 2025

Yes, it is a breaking change, but it is worth it, and even if we use a configuration option, it also introduces a breaking change, because we would have to inject an EcsOptions class in the CommandServiceBase constructor.

PD: To merge this PR, tell me specifically what I need to modify.

@ikkentim
Copy link
Owner

ikkentim commented Mar 17, 2025

the easiest way would be a simple extension on IEcsBuilder.

public static class CommandEcsBuilderExtensions
{
    // note: default values in parameters reflect the default
    // todo: xml doc block
    public static IEcsBuilder ConfigureCommandService(this IEcsBuilder builder, bool ignoreCase = false) 
    {
        var commandService = builder.Services.GetRequiredService<ICommandService>();
        commandService.IgnoreCase = ignoreCase; // todo: add property to service
        return builder;
    }
}

might also want to use a method instead of a property for IgnoreCase in the command service, since it needs to recreate the commands dictionary with a different key comparator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ecs] Allow command names to be case-insensitive
3 participants