{"record":{"id":"ecec849b87b74bac","repo":"devlooped/moq","slug":"use-the-new-syntax-which-allows-you-to-pass-the-value-in-the","errorCode":null,"errorMessage":"Use the new syntax, which allows you to pass the value in the expression itself, mock.VerifySet(m => m.Value = 25); (thrown unconditionally via [Obsolete(..., true)])","messagePattern":"Use the new syntax, which allows you to pass the value in the expression itself, mock\\.VerifySet\\(m => m\\.Value = 25\\); \\(thrown unconditionally via \\[Obsolete\\(\\.\\.\\., true\\)\\]\\)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Moq/Obsolete/Mock.Generic.Legacy.cs","lineNumber":98,"sourceCode":"        /// 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)]\n        public static void VerifySet<T, TProperty>(this Mock<T> mock, Expression<Func<T, TProperty>> expression, TProperty value, string failMessage)\n            where T : class\n        {\n            throw new NotSupportedException();\n        }\n    }\n}\n","sourceCodeStart":80,"sourceCodeEnd":113,"githubUrl":"https://github.com/devlooped/moq/blob/89a5be629c752960fe403e95ff583e4ae6f00542/src/Moq/Obsolete/Mock.Generic.Legacy.cs#L80-L113","documentation":"This legacy Mock.VerifySet<T,TProperty> extension (value passed as a separate argument) is marked [Obsolete(..., true)] and always throws NotSupportedException. Verification of property setters now uses the expression-embedded value syntax mock.VerifySet(m => m.Value = 25).","triggerScenarios":"Mock.VerifySet(mock, m => m.Value, 25) — invoking the static extension in src/Moq/Obsolete/Mock.Generic.Legacy.cs:98 that takes the expected value as a parameter.","commonSituations":"Migrating pre-4.0 Moq verification code; bulk-updated test suites where VerifySet call sites were missed during upgrade because they still compiled via the extension.","solutions":["Rewrite as mock.VerifySet(m => m.Value = 25).","Combine with Times for counts: mock.VerifySet(m => m.Value = 25, Times.Once).","Use It.Is<TProperty> in the expression for range/condition checks instead of the old value parameter."],"exampleFix":"// before\nMock.VerifySet(mock, f => f.Value, 25);\n// after\nmock.VerifySet(f => f.Value = 25);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { Mock.VerifySet(mock, f => f.Value, 25); } catch (NotSupportedException) { mock.VerifySet(f => f.Value = 25); }","preventionTips":["Verify setters with mock.VerifySet(m => m.Prop = value)","Use It.Is<TProperty> inside the expression for conditional matching","Audit legacy Verify* calls when upgrading Moq"],"tags":["moq","obsolete","verifyset","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"}