{"record":{"id":"81c294570995605d","repo":"dotnet/maui","slug":"the-property-0-must-be-null-at-this-time","errorCode":null,"errorMessage":"The property {0} must be null at this time.","messagePattern":"The property (.+?) must be null at this time\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/WPF/Microsoft.Windows.Shell/Standard/Verify.cs","lineNumber":161,"sourceCode":"\t\t[SuppressMessage(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n\t\t[DebuggerStepThrough]\n\t\tpublic static void PropertyIsNotNull<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 InvalidOperationException(string.Format(CultureInfo.InvariantCulture, \"The property {0} cannot be null at this time.\", name));\n\t\t\t}\n\t\t}\n\n\t\t[SuppressMessage(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n\t\t[DebuggerStepThrough]\n\t\tpublic static void PropertyIsNull<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 InvalidOperationException(string.Format(CultureInfo.InvariantCulture, \"The property {0} must be null at this time.\", name));\n\t\t\t}\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Verifies the specified statement is true.  Throws an ArgumentException if it's not.\n\t\t/// </summary>\n\t\t/// <param name=\"statement\">The statement to be verified as true.</param>\n\t\t/// <param name=\"name\">Name of the parameter to include in the ArgumentException.</param>\n\t\t/// <param name=\"message\">The message to include in the ArgumentException.</param>\n\t\t[SuppressMessage(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n\t\t[DebuggerStepThrough]\n\t\tpublic static void IsTrue(bool statement, string name, string message = null)\n\t\t{\n\t\t\tif (!statement)\n\t\t\t{\n\t\t\t\tAssert.Fail();\n\t\t\t\tthrow new ArgumentException(message ?? \"\", name);\n\t\t\t}","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/WPF/Microsoft.Windows.Shell/Standard/Verify.cs#L143-L179","documentation":"Verify.PropertyIsNull<T> (where T : class) throws InvalidOperationException when the property value is NOT null. This is the inverse state guard — it asserts a property must be unset at this point. Used in lifecycle transitions where a non-null property means the object has already been configured and should not be reconfigured.","triggerScenarios":"Calling a method guarded by Verify.PropertyIsNull(_prop, \"Prop\") when _prop has already been assigned. The guard fires because the operation expects the property to be cleared first.","commonSituations":"Double-configuration of an object (calling Configure twice); re-initialization without reset; a setter that should only fire once but is invoked again on a second binding pass.","solutions":["Reset the property to null before re-invoking the method that requires it unset.","Guard against re-entry at the call site (if (_prop != null) return or throw).","Restructure the lifecycle so the property is set exactly once."],"exampleFix":"// before\nmanager.Configure(); // already configured\n\n// after\nmanager.Reset(); // clears the property to null\nmanager.Configure();","handlingStrategy":"validation","validationCode":"// Pre-check: property must be null before the operation\nif (obj.SomeProperty != null)\n{\n    throw new InvalidOperationException(\"SomeProperty must be null before reconfiguration. Call Reset() first.\");\n}\nobj.Reconfigure();","typeGuard":null,"tryCatchPattern":"try\n{\n    obj.Reconfigure();\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"must be null\"))\n{\n    obj.Reset();\n    obj.Reconfigure();\n}","preventionTips":["Reset state to null before re-invoking one-shot configuration methods.","Guard against double-configuration at the call site.","Use an IsConfigured flag instead of relying on null state for lifecycle control."],"tags":["validation","invalid-operation","state","lifecycle","verify"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}