From 717f82ec59c2156445ca250278beaaef0029d6fa Mon Sep 17 00:00:00 2001 From: Gold856 <117957790+Gold856@users.noreply.github.com> Date: Mon, 26 Aug 2024 21:17:32 -0400 Subject: [PATCH] [cmd] Deprecate Command.schedule() It's a footgun and syntactic sugar over the CommandScheduler's schedule method. We don't need syntactic sugar for a footgun. --- .../main/java/edu/wpi/first/wpilibj2/command/Command.java | 7 ++++++- .../src/main/native/include/frc2/command/Command.h | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index a53d792d0e4..35b23cb8365 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -514,7 +514,12 @@ public WrapperCommand handleInterrupt(Runnable handler) { }); } - /** Schedules this command. */ + /** + * Schedules this command. + * + * @deprecated Use CommandScheduler.getInstance().schedule(Command...) instead + */ + @Deprecated(since = "2025", forRemoval = true) public void schedule() { CommandScheduler.getInstance().schedule(this); } diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h index c4af1afe81b..24d579e1bcd 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h @@ -406,7 +406,10 @@ class Command : public wpi::Sendable, public wpi::SendableHelper { /** * Schedules this command. + * + * @deprecated Use CommandScheduler::GetInstance().Schedule() instead */ + [[deprecated("Use CommandScheduler::GetInstance().Schedule() instead.")]] void Schedule(); /**