{"record":{"id":"ecf14b3e495a784b","repo":"dotnet/maui","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":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/WPF/Microsoft.Windows.Shell/Standard/Verify.cs","lineNumber":109,"sourceCode":"\t\t\tif (\"\" == value.Trim())\n\t\t\t{\n\t\t\t\tAssert.Fail();\n\t\t\t\tthrow new ArgumentException(errorMessage, name);\n\t\t\t}\n\t\t}\n\n\t\t/// <summary>Verifies that an argument is not null.</summary>\n\t\t/// <typeparam name=\"T\">Type of the object to validate.  Must be a class.</typeparam>\n\t\t/// <param name=\"obj\">The object to validate.</param>\n\t\t/// <param name=\"name\">The name of the parameter that will be presented if an exception is thrown.</param>\n\t\t[SuppressMessage(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n\t\t[DebuggerStepThrough]\n\t\tpublic static void IsNotDefault<T>(T obj, string name) where T : struct\n\t\t{\n\t\t\tif (default(T).Equals(obj))\n\t\t\t{\n\t\t\t\tAssert.Fail();\n\t\t\t\tthrow new ArgumentException(\"The parameter must not be the default value.\", name);\n\t\t\t}\n\t\t}\n\n\t\t/// <summary>Verifies that an argument is not null.</summary>\n\t\t/// <typeparam name=\"T\">Type of the object to validate.  Must be a class.</typeparam>\n\t\t/// <param name=\"obj\">The object to validate.</param>\n\t\t/// <param name=\"name\">The name of the parameter that will be presented if an exception is thrown.</param>\n\t\t[SuppressMessage(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n\t\t[DebuggerStepThrough]\n\t\tpublic static void IsNotNull<T>(T obj, string name) where T : class\n\t\t{\n\t\t\tif (null == obj)\n\t\t\t{\n\t\t\t\tAssert.Fail();\n\t\t\t\tthrow new ArgumentNullException(name);\n\t\t\t}\n\t\t}\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/WPF/Microsoft.Windows.Shell/Standard/Verify.cs#L91-L127","documentation":"Verify.IsNotDefault<T> (where T : struct) throws ArgumentException when obj.Equals(default(T)) — i.e. the value is the zero/default representation of its value type. This guard is used to reject uninitialized structs (Guid.Empty, default IntPtr, IntPtr.Zero, etc.).","triggerScenarios":"Calling a method guarded by Verify.IsNotDefault(value, name) where value is default(T) for its struct type — e.g. Guid.Empty, new IntPtr(0), default(DateTime), or a zero-valued handle struct.","commonSituations":"A Guid was never assigned and left as Guid.Empty; an IntPtr handle was not obtained from the OS; a value-type enum defaulted to 0 which is not a valid member; a struct field was declared but never initialized.","solutions":["Initialize the struct to a meaningful non-default value before the call.","If the value comes from a lookup, check for default(T) before forwarding (e.g. if (handle == IntPtr.Zero)).","Use nullable wrappers (Guid?) when absence is a valid state."],"exampleFix":"// before\nRegister(id); // id may be Guid.Empty\n\n// after\nif (id == Guid.Empty)\n{\n    throw new ArgumentException(\"A valid id is required.\", nameof(id));\n}\nRegister(id);","handlingStrategy":"validation","validationCode":"// Pre-check for default value-type before calling the guarded API\nif (value.Equals(default(T)))\n{\n    throw new ArgumentException($\"Value must not be the default {typeof(T).Name}.\", nameof(value));\n}\nSomeApi(value);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check value-type defaults (Guid.Empty, IntPtr.Zero, etc.) before forwarding to guarded APIs.","Use nullable wrappers (Guid?) when absence is a legitimate state.","Initialize struct fields to meaningful values in constructors."],"tags":["validation","argument","value-type","default","verify"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}