{"record":{"id":"5bafdafad3a112bf","repo":"stride3d/stride","slug":"the-isenabled-property-of-the-disabledcommand-cannot-be","errorCode":null,"errorMessage":"The IsEnabled property of the DisabledCommand cannot be modified","messagePattern":"The IsEnabled property of the DisabledCommand cannot be modified","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"warning","filePath":"sources/presentation/Stride.Core.Presentation/Commands/DisabledCommand.cs","lineNumber":28,"sourceCode":"public sealed class DisabledCommand : ICommandBase\n{\n    /// <summary>\n    /// Gets a singleton instance of the <see cref=\"DisabledCommand\"/>\n    /// </summary>\n    public static DisabledCommand Instance { get; } = new DisabledCommand();\n\n    /// <summary>\n    /// Initializes a new instance of the <see cref=\"DisabledCommand\"/> class.\n    /// </summary>\n    private DisabledCommand()\n    {\n    }\n\n    /// <inheritdoc/>\n    public bool IsEnabled\n    {\n        get { return false; }\n        set { if (!value) throw new InvalidOperationException($\"The {nameof(IsEnabled)} property of the {nameof(DisabledCommand)} cannot be modified\"); }\n    }\n\n    /// <inheritdoc/>\n    public event EventHandler? CanExecuteChanged\n    {\n        add { }\n        remove { }\n    }\n\n    /// <inheritdoc/>\n    public bool CanExecute(object? parameter)\n    {\n        return false;\n    }\n\n    /// <inheritdoc/>\n    public void Execute(object? parameter)\n    {","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation/Commands/DisabledCommand.cs#L10-L46","documentation":"DisabledCommand is an immutable always-disabled command. Its IsEnabled setter throws InvalidOperationException for any `true` value; only setting it to false is tolerated. The command can never be enabled.","triggerScenarios":"Assigning `disabledCommand.IsEnabled = true` directly, or a view-model/framework routine that bulk-enables commands including this singleton.","commonSituations":"Toggle-all-commands logic, re-enabling commands after an async operation, mistakenly treating DisabledCommand as a regular configurable command.","solutions":["Do not attempt to enable DisabledCommand; replace the instance with a real command implementation when action is needed","Skip DisabledCommand instances in code that enables commands in bulk","Use CommandBase with IsEnabled toggling if dynamic enablement is required"],"exampleFix":"// before\ncurrentCommand.IsEnabled = true; // currentCommand is DisabledCommand\n// after\nif (currentCommand is not DisabledCommand) currentCommand.IsEnabled = true;","handlingStrategy":"validation","validationCode":"if (command is DisabledCommand) return; // never attempt to enable","typeGuard":"bool IsEnabledMutable(ICommand c) => c is not DisabledCommand;","tryCatchPattern":"try { cmd.IsEnabled = true; } catch (InvalidOperationException) { /* DisabledCommand stays disabled */ }","preventionTips":["Skip DisabledCommand in bulk enable loops","Swap in a real CommandBase when dynamic enablement is needed","Treat DisabledCommand as a read-only singleton"],"tags":["csharp","command","invalid-state"],"backgroundTag":"invalid-state-transition","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}