{"record":{"id":"63bd26748a432f39","repo":"HandyOrg/HandyControl","slug":"the-parameter-must-not-be-the-default-value","errorCode":null,"errorMessage":"The parameter must not be the default value.","messagePattern":"The parameter must not be the default value\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Shared/Microsoft.Windows.Shell/Standard/Verify.cs","lineNumber":59,"sourceCode":"    {\n        if (value == null)\n        {\n            throw new ArgumentNullException(name, \"The parameter can not be either null or empty or consist only of white space characters.\");\n        }\n        if (\"\" == value.Trim())\n        {\n            throw new ArgumentException(\"The parameter can not be either null or empty or consist only of white space characters.\", name);\n        }\n    }\n\n    [SuppressMessage(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n    [DebuggerStepThrough]\n    public static void IsNotDefault<T>(T obj, string name) where T : struct\n    {\n        T t = default(T);\n        if (t.Equals(obj))\n        {\n            throw new ArgumentException(\"The parameter must not be the default value.\", name);\n        }\n    }\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)","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/HandyOrg/HandyControl/blob/2c0875ebd67326e0c67282967e3e809c69282fee/src/Shared/Microsoft.Windows.Shell/Standard/Verify.cs#L41-L77","documentation":"Verify.IsNotDefault throws ArgumentException when a struct parameter equals its default value (e.g. 0, Guid.Empty, default(Point)). The library uses it to reject arguments that were never explicitly initialized. It is an argument-validation guard, not a state error.","triggerScenarios":"Calling any API that internally calls Verify.IsNotDefault(value, paramName) with the C# default of that struct type, e.g. passing Guid.Empty, 0, or default(Point) where a meaningful value is required.","commonSituations":"Uninitialized struct fields (a Guid or handle left at its default), deserialization that skipped a field, calling a method before assigning an ID/size/handle struct member.","solutions":["Initialize the struct parameter/field to a valid non-default value before calling the API.","Check with EqualityComparer<T>.Default.Equals(value, default) before calling and fail fast with a clearer message.","If the default is legitimately acceptable, the caller is using the wrong overload/API; switch to one that permits default values."],"exampleFix":"// before\nGuid id = Guid.Empty;\nwidget.SetId(id); // ArgumentException: The parameter must not be the default value.\n// after\nGuid id = Guid.NewGuid();\nwidget.SetId(id);","handlingStrategy":"validation","validationCode":"if (EqualityComparer<T>.Default.Equals(value, default(T)))\n    throw new ArgumentException($\"{nameof(value)} must not be the default value.\", nameof(value));","typeGuard":"static bool IsDefault<T>(T v) where T : struct => EqualityComparer<T>.Default.Equals(v, default(T));","tryCatchPattern":"try { api.Call(value); }\ncatch (ArgumentException ex) when (ex.ParamName == nameof(value)) { /* handle non-default violation */ }","preventionTips":["Always initialize struct fields with real values (Guid.NewGuid(), explicit constructors), never rely on default(T).","Validate struct inputs at your public boundary before passing them on.","Watch for deserializers that leave fields at default values."],"tags":["argument-validation","struct","dotnet"],"backgroundTag":"invalid-argument-value","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"}