{"record":{"id":"859ed0fc8375f96b","repo":"HandyOrg/HandyControl","slug":"the-parameter-must-be-null","errorCode":null,"errorMessage":"The parameter must be null.","messagePattern":"The parameter must be null\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Shared/Microsoft.Windows.Shell/Standard/Verify.cs","lineNumber":79,"sourceCode":"    }\n\n    [DebuggerStepThrough]\n    [SuppressMessage(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n    public static void IsNotNull<T>(T obj, string name) where T : class\n    {\n        if (obj == null)\n        {\n            throw new ArgumentNullException(name);\n        }\n    }\n\n    [SuppressMessage(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n    [DebuggerStepThrough]\n    public static void IsNull<T>(T obj, string name) where T : class\n    {\n        if (obj != null)\n        {\n            throw new ArgumentException(\"The parameter must be null.\", name);\n        }\n    }\n\n    [DebuggerStepThrough]\n    [SuppressMessage(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n    public static void PropertyIsNotNull<T>(T obj, string name) where T : class\n    {\n        if (obj == null)\n        {\n            throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, \"The property {0} cannot be null at this time.\", new object[]\n            {\n                name\n            }));\n        }\n    }\n\n    [DebuggerStepThrough]\n    [SuppressMessage(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/HandyOrg/HandyControl/blob/2c0875ebd67326e0c67282967e3e809c69282fee/src/Shared/Microsoft.Windows.Shell/Standard/Verify.cs#L61-L97","documentation":"Verify.IsNull throws ArgumentException when a reference-type parameter is NOT null but the API requires it to be null. It is a rare inverted guard used to enforce that an argument has not been set yet or must remain unset.","triggerScenarios":"Calling an API whose implementation calls Verify.IsNull(obj, paramName) while passing any non-null object reference (e.g. a pre-initialized or cached instance where the API expects null/empty).","commonSituations":"Passing an existing/initialized object to a setter or factory slot that must start empty; re-calling an API that only accepts null the first time; confusion between 'absent' and 'empty object' in interop code.","solutions":["Pass null instead of an object instance for this parameter.","If you need the object set, use the corresponding API that validates non-null (e.g. Verify.IsNotNull paths) rather than this one.","Add a caller-side check that the value is null before invoking, and otherwise skip or reset the call."],"exampleFix":"// before\nwidget.Bind(existingValue); // ArgumentException: The parameter must be null.\n// after\nif (existingValue == null)\n{\n    widget.Bind(existingValue);\n}","handlingStrategy":"validation","validationCode":"if (value != null)\n    throw new ArgumentException($\"{nameof(value)} must be null for this call.\", nameof(value));","typeGuard":"static bool IsNull<T>(T v) where T : class => v is null;","tryCatchPattern":"try { api.Call(value); }\ncatch (ArgumentException ex) when (ex.ParamName == nameof(value)) { /* handle must-be-null violation */ }","preventionTips":["Read the API contract: some slots deliberately require null (unset semantics).","Do not pass cached/default-constructed objects where the API expects an empty slot.","Distinguish 'absent' from 'empty instance' in interop-style APIs."],"tags":["argument-validation","null-check","dotnet"],"backgroundTag":"null-argument","analyzedSha":"2c0875ebd67326e0c67282967e3e809c69282fee","analyzedAt":"2026-09-14T14:45:29.754Z","contentChangedAt":"2026-09-14T14:45:29.754Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}