{"record":{"id":"79ff175601a0a64d","repo":"ppy/osu","slug":"nameof-modtestdata-autoplay-must-be-false-when","errorCode":null,"errorMessage":"{nameof(ModTestData.Autoplay)} must be false when {nameof(ModTestData.ReplayFrames)} is specified.","messagePattern":"(.+?) must be false when (.+?) is specified\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"osu.Game/Tests/Visual/ModTestScene.cs","lineNumber":78,"sourceCode":"\r\n        protected partial class ModTestPlayer : TestPlayer\r\n        {\r\n            private readonly bool allowFail;\r\n            private readonly ModTestData currentTestData;\r\n\r\n            protected override bool CheckModsAllowFailure() => allowFail;\r\n\r\n            public ModTestPlayer(ModTestData data, bool allowFail)\r\n                : base(true, false)\r\n            {\r\n                this.allowFail = allowFail;\r\n                currentTestData = data;\r\n            }\r\n\r\n            protected override void PrepareReplay()\r\n            {\r\n                if (currentTestData.Autoplay && currentTestData.ReplayFrames?.Count > 0)\r\n                    throw new InvalidOperationException(@$\"{nameof(ModTestData.Autoplay)} must be false when {nameof(ModTestData.ReplayFrames)} is specified.\");\r\n\r\n                if (currentTestData.ReplayFrames != null)\r\n                {\r\n                    DrawableRuleset?.SetReplayScore(new Score\r\n                    {\r\n                        Replay = new Replay { Frames = currentTestData.ReplayFrames },\r\n                        ScoreInfo = new ScoreInfo { User = new APIUser { Username = @\"Test\" } },\r\n                    });\r\n                }\r\n\r\n                base.PrepareReplay();\r\n            }\r\n        }\r\n\r\n        protected class ModTestData\r\n        {\r\n            /// <summary>\r\n            /// Whether to use a replay to simulate an autoplay. True by default.\r","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/ppy/osu/blob/d9c73e12adff2feaae4a3e158d36fe5883faf6ca/osu.Game/Tests/Visual/ModTestScene.cs#L60-L96","documentation":"Thrown in ModTestPlayer.PrepareReplay when currentTestData.Autoplay is true AND currentTestData.ReplayFrames has a non-zero count. The test harness cannot honor both an autoplay mod (which generates its own replay) and explicit replay frames, so the combination is rejected as a contradictory test setup.","triggerScenarios":"Constructing a ModTestData with Autoplay = true and a non-empty ReplayFrames list, then running the ModTestScene.","commonSituations":"Test authoring mistake: enabling an autoplay mod while also providing canned replay frames; copy-pasting a test config and forgetting to clear Autoplay.","solutions":["Set ModTestData.Autoplay = false when you supply ReplayFrames.","If you want autoplay-generated input, leave ReplayFrames null.","Add an assertion/guard in test helpers to fail fast at test-definition time rather than at runtime."],"exampleFix":"// before\nnew ModTestData { Autoplay = true, ReplayFrames = new List<ReplayFrame> { ... } };\n\n// after\nnew ModTestData { Autoplay = false, ReplayFrames = new List<ReplayFrame> { ... } };","handlingStrategy":"validation","validationCode":"if (data.Autoplay && data.ReplayFrames?.Count > 0)\n    throw new ArgumentException(\"Cannot set both Autoplay and ReplayFrames.\");","typeGuard":"static bool IsValidModTestData(ModTestData d)\n    => !(d.Autoplay && (d.ReplayFrames?.Count ?? 0) > 0);","tryCatchPattern":null,"preventionTips":["Set Autoplay = false when providing ReplayFrames.","Leave ReplayFrames null for autoplay-driven tests.","Validate ModTestData at construction."],"tags":["test","mod-test","replay","autoplay","validation"],"backgroundTag":null,"analyzedSha":"d9c73e12adff2feaae4a3e158d36fe5883faf6ca","analyzedAt":"2026-08-13T14:12:54.015Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}