{"record":{"id":"db10a5c2ab9ce09e","repo":"stride3d/stride","slug":"argumentnullexception-paramname","errorCode":null,"errorMessage":"ArgumentNullException: paramName","messagePattern":"ArgumentNullException: paramName","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Core.Assets.Editor/ArgumentCheck.cs","lineNumber":177,"sourceCode":"            }\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            {\n                throw new ArgumentNullException(paramName);\n            }\n        }\n\n        /// <summary>\n        /// Checks wether the <paramref name=\"variable\"/> is not a white-space string.\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        /// <remarks>\n        /// Before checking the <paramref name=\"variable\"/>, a call is made to\n        /// <see cref=\"NotNull\"/>.\n        /// </remarks>\n        /// <exception cref=\"ArgumentNullException\">\n        /// The <paramref name=\"variable\"/> cannot be <see langword=\"null\"/>.\n        /// </exception>\n        /// <exception cref=\"ArgumentException\">\n        /// The <paramref name=\"variable\"/> cannot be an empty <see cref=\"string\"/> or consists only of white-space characters.","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Core.Assets.Editor/ArgumentCheck.cs#L159-L195","documentation":"ArgumentCheck.NotNull throws ArgumentNullException when the object variable is null. The exception's ParamName is the provided variableName (defaulting to \"The variable\"). It is the base guard that NotEmpty, NotWhiteSpace, and Condition also invoke, so a null reaching any of those surfaces as ArgumentNullException paramName.","triggerScenarios":"Passing null to any ArgumentCheck-guarded API: NotNull directly, or indirectly when NotEmpty/NotWhiteSpace/Condition receive a null collection/string/predicate (null fails NotNull before the other checks run).","commonSituations":"An object was not yet initialized (field default null), a lookup (dictionary/FirstOrDefault) returned null and was forwarded, a method parameter of a caller was null and propagated down, or config/ deserialization failed leaving properties null.","solutions":["Null-check or null-coalesce the value before calling the guarded API and fail with a descriptive message identifying the actual source","Find which argument is null from the exception's ParamName and fix the initialization or lookup that produced it","Use the DEBUG-only ArgumentCheck variant's equivalent or Debug.Assert during development to catch it earlier","If null is a valid state, do not pass it to this API; branch before the call"],"exampleFix":"// before\nvar asset = session.FindAsset(id); // may be null\nsession.Delete(asset); // throws ArgumentNullException paramName\n// after\nvar asset = session.FindAsset(id);\nif (asset == null)\n    throw new KeyNotFoundException($\"Asset {id} not found\");\nsession.Delete(asset);","handlingStrategy":"validation","validationCode":"if (variable is null)\n    throw new ArgumentNullException(nameof(variable), \"Value must be initialized before this call\");","typeGuard":"bool HasValue([NotNullWhen(true)] object? o) => o is not null;","tryCatchPattern":"try { NotNull(asset, nameof(asset)); }\ncatch (ArgumentNullException ex) when (ex.ParamName == nameof(asset))\n{\n    // asset lookup failed; recover or rethrow with context\n}","preventionTips":["Null-check lookups (Find/FirstOrDefault) before forwarding results","Use nullable reference types so null flows are caught at compile time","Initialize fields in constructors rather than lazily","Read ex.ParamName to identify which argument was null"],"tags":["argument-check","argument-null","null-reference","stride"],"backgroundTag":"null-argument","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"}