{"record":{"id":"69836e9bb640a6f8","repo":"stride3d/stride","slug":"paramname-cannot-be-equal-to-value","errorCode":null,"errorMessage":"{paramName} cannot be equal to {value}.","messagePattern":"(.+?) cannot be equal to (.+?)\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Core.Assets.Editor/ArgumentCheck.cs","lineNumber":158,"sourceCode":"\n        /// <summary>\n        /// Checks whether the <paramref name=\"variable\"/> is different from <paramref name=\"value\"/>.\n        /// Otherwise throws an exception.\n        /// </summary>\n        /// <typeparam name=\"T\">The type of the <paramref name=\"variable\"/>.</typeparam>\n        /// <param name=\"variable\">The value to check.</param>\n        /// <param name=\"value\">The value to compare to for inequality.</param>\n        /// <param name=\"variableName\">The name of the variable being checked.</param>\n        /// <exception cref=\"ArgumentException\">\n        /// <paramref name=\"variable\"/> is equal to the <paramref name=\"value\"/>.\n        /// </exception>\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        public static void NotEquals<T>(T variable, T value, string variableName)\n        {\n            var paramName = variableName ?? \"The variable\";\n            if (EqualityComparer<T>.Default.Equals(variable, value))\n            {\n                throw new ArgumentException($\"{paramName} cannot be equal to {value}.\");\n            }\n        }\n\n        /// <summary>\n        /// Checks wether the <paramref name=\"variable\"/> is not <see langword=\"null\"/>.\n        /// Otherwise throws an exception.\n        /// </summary>\n        /// <param name=\"variable\">The value to check.</param>\n        /// <param name=\"variableName\">The name of the variable being checked.</param>\n        /// <exception cref=\"ArgumentNullException\">\n        /// The <paramref name=\"variable\"/> cannot be <see langword=\"null\"/>.\n        /// </exception>\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        public static void NotNull(object variable, string variableName)\n        {\n            var paramName = variableName ?? \"The variable\";\n            if (null == variable)\n            {","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Core.Assets.Editor/ArgumentCheck.cs#L140-L176","documentation":"ArgumentCheck.NotEquals<T> throws ArgumentException when the variable equals the forbidden value under EqualityComparer<T>.Default. It is a guard against assigning placeholder/sentinel values (e.g. default(T), null, or a specific disallowed constant) to a parameter.","triggerScenarios":"Calling ArgumentCheck.NotEquals(variable, value, variableName) where variable compares equal to value, e.g. passing default(Guid) (Guid.Empty), 0, or null for a reference-type T to a parameter that forbids exactly that value.","commonSituations":"Passing an uninitialized identifier (Guid.Empty, 0) because an entity was never persisted; a struct field left at default(T); a deserialized object whose id defaulted to the disallowed sentinel.","solutions":["Ensure the variable holds a real value different from the forbidden one before the call","If variable is an identifier, confirm it was assigned after creation/persistence rather than left at default","Check the equality semantics: if a custom Equals makes them 'equal' unexpectedly, fix the type's Equals/GetHashCode","If equality with that value is actually acceptable, remove the NotEquals guard or pass the correct parameter"],"exampleFix":"// before\nvar id = Guid.Empty;\nArgumentCheck.NotEquals(id, Guid.Empty, nameof(id));\n// after\nvar id = entity?.Id ?? throw new InvalidOperationException(\"Entity must be persisted first\");\nArgumentCheck.NotEquals(id, Guid.Empty, nameof(id));","handlingStrategy":"validation","validationCode":"if (EqualityComparer<T>.Default.Equals(value, forbidden))\n    throw new ArgumentException($\"{nameof(value)} must not be {forbidden}\", nameof(value));","typeGuard":null,"tryCatchPattern":"try { NotEquals(id, Guid.Empty, nameof(id)); }\ncatch (ArgumentException ex) when (ex.ParamName == nameof(id))\n{\n    // assign a real id or abort the operation\n}","preventionTips":["Never persist or forward default(T) identifiers; assign ids at creation","Check sentinel values (Guid.Empty, 0) right after deserialization","Implement Equals/GetHashCode correctly on custom types used with NotEquals"],"tags":["argument-check","argument-exception","equality-guard","stride"],"backgroundTag":"invalid-argument-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}