{"record":{"id":"5d5b1caf93104ade","repo":"devlooped/moq","slug":"the-new-syntax-allows-you-to-pass-the-value-in-the","errorCode":null,"errorMessage":"The new syntax allows you to pass the value in the expression itself, like f => f.Value = 25. (thrown unconditionally via [Obsolete(..., true)])","messagePattern":"The new syntax allows you to pass the value in the expression itself, like f => f\\.Value = 25\\. \\(thrown unconditionally via \\[Obsolete\\(\\.\\.\\., true\\)\\]\\)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Moq/Obsolete/Mock.Generic.Legacy.cs","lineNumber":87,"sourceCode":"        }\n    }\n\n    /// <summary>\n    /// Contains obsolete API members as extension methods so that existing code continues to compile,\n    /// but new code doesn't see them.\n    /// </summary>\n    [EditorBrowsable(EditorBrowsableState.Never)]\n    public static class MockLegacyExtensions\n    {\n        /// <summary>\n        /// Obsolete.\n        /// </summary>\n        [EditorBrowsable(EditorBrowsableState.Never)]\n        [Obsolete(\"The new syntax allows you to pass the value in the expression itself, like f => f.Value = 25.\", true)]\n        public static ISetupSetter<T, TProperty> SetupSet<T, TProperty>(this Mock<T> mock, Expression<Func<T, TProperty>> expression, TProperty value)\n            where T : class\n        {\n            throw new NotSupportedException();\n        }\n\n        /// <summary>\n        /// Obsolete.\n        /// </summary>\n        [EditorBrowsable(EditorBrowsableState.Never)]\n        [Obsolete(\"Use the new syntax, which allows you to pass the value in the expression itself, mock.VerifySet(m => m.Value = 25);\", true)]\n        public static void VerifySet<T, TProperty>(this Mock<T> mock, Expression<Func<T, TProperty>> expression, TProperty value)\n            where T : class\n        {\n            throw new NotSupportedException();\n        }\n\n        /// <summary>\n        /// Obsolete.\n        /// </summary>\n        [EditorBrowsable(EditorBrowsableState.Never)]\n        [Obsolete(\"Use the new syntax, which allows you to pass the value in the expression itself, mock.VerifySet(m => m.Value = 25, failMessage);\", true)]","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/devlooped/moq/blob/89a5be629c752960fe403e95ff583e4ae6f00542/src/Moq/Obsolete/Mock.Generic.Legacy.cs#L69-L105","documentation":"This legacy Mock.SetupSet<T,T> extension (with a separate value parameter) is marked [Obsolete(..., true)] and throws NotSupportedException unconditionally. Modern Moq's instance SetupSet takes the value inside the expression, so this two-argument extension exists only to break compilation on old-style calls.","triggerScenarios":"Mock.SetupSet(mock, m => m.Value, 25) — calling the static extension overload in src/Moq/Obsolete/Mock.Generic.Legacy.cs:87 that accepts an explicit value argument.","commonSituations":"Ambiguity or migration errors after upgrading Moq where old call sites targeted the extension overload; old test utilities wrapping the legacy signature.","solutions":["Switch to the instance syntax: mock.SetupSet(m => m.Value = 25).","For flexible value matching use It.Is inside the assignment expression.","Fix compile errors (error-level Obsolete) rather than suppressing with #pragma — the method always throws at runtime."],"exampleFix":"// before\nMock.SetupSet(mock, f => f.Value, 25);\n// after\nmock.SetupSet(f => f.Value = 25);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { Mock.SetupSet(mock, f => f.Value, 25); } catch (NotSupportedException) { mock.SetupSet(f => f.Value = 25); }","preventionTips":["Use the instance SetupSet(expression) syntax with value embedded in the lambda","Never suppress error-level Obsolete diagnostics with pragmas","Update old test helper wrappers to the modern API"],"tags":["moq","obsolete","setupset","deprecated-api"],"backgroundTag":"deprecated-api-usage","analyzedSha":"89a5be629c752960fe403e95ff583e4ae6f00542","analyzedAt":"2026-09-16T05:31:39.496Z","contentChangedAt":"2026-09-16T05:31:39.496Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}