{"record":{"id":"6bf5e084ad811e6a","repo":"devlooped/moq","slug":"use-the-new-syntax-which-allows-you-to-pass-the-value-in-the-6bf5e0","errorCode":null,"errorMessage":"Use the new syntax, which allows you to pass the value in the expression itself, mock.VerifySet(m => m.Value = 25, failMessage); (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, failMessage\\); \\(thrown unconditionally via \\[Obsolete\\(\\.\\.\\., true\\)\\]\\)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Moq/Obsolete/Mock.Generic.Legacy.cs","lineNumber":109,"sourceCode":"        /// 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":91,"sourceCodeEnd":113,"githubUrl":"https://github.com/devlooped/moq/blob/89a5be629c752960fe403e95ff583e4ae6f00542/src/Moq/Obsolete/Mock.Generic.Legacy.cs#L91-L113","documentation":"This obsolete overload of Mock.VerifySet was compiled with an Error=true Obsolete attribute, so referencing it fails to compile; if somehow invoked at runtime it throws NotSupportedException. Moq replaced this (expression, value, failMessage) overload with the newer syntax where the assigned value is written directly inside the lambda, e.g. mock.VerifySet(m => m.Value == 25) / m => m.Value = 25 with the setter expression form.","triggerScenarios":"Calling mock.VerifySet(m => m.Value, 25, \"fail\") with the three-argument legacy overload on a Mock<T>. Using this overload produces a compiler error due to [Obsolete(..., true)].","commonSituations":"Upgrading Moq across major versions; old test code or snippets copied from pre-4.x documentation still using the value-passing VerifySet overload.","solutions":["Use the modern setter-expression syntax: mock.VerifySet(m => m.Value == 25, failMessage);","Remove the separate value and failMessage parameters and fold the expected value into the lambda expression","If the overload is referenced via reflection/dynamic, delete that call site and rewrite it against the current API"],"exampleFix":"// before\nmock.VerifySet(m => m.Value, 25, \"Value should be 25\");\n// after\nmock.VerifySet(m => m.Value == 25, \"Value should be 25\");","handlingStrategy":"validation","validationCode":"// Compile-time: avoid the obsolete overload entirely.\n// Assert the expected assignment with the modern syntax:\nmock.VerifySet(m => m.Value == 25, \"Value should be 25\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enable 'Treat warnings as errors' for CS0619/CS0618 so obsolete API usage fails the build","Grep legacy tests for VerifySet( with a three-argument form when upgrading Moq","Pin Moq version and read breaking-change notes before upgrading"],"tags":["moq","obsolete-api","verifyset","compile-error"],"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"}