{"record":{"id":"b0200b642b60507b","repo":"stride3d/stride","slug":"paramname-can-t-be-an-empty-string","errorCode":null,"errorMessage":"{paramName} can't be an empty string.","messagePattern":"(.+?) can't be an empty string\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Core.Assets.Editor/ArgumentCheck.cs","lineNumber":137,"sourceCode":"        /// <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\"/>.\n        /// </exception>\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        public static void NotEmpty(string variable, string variableName)\n        {\n            var paramName = variableName ?? \"The variable\";\n            // Variable cannot be null\n            NotNull(variable, paramName);\n            if (variable.Length == 0)\n            {\n                throw new ArgumentException($\"{paramName} can't be an empty string.\");\n            }\n        }\n\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\";","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Core.Assets.Editor/ArgumentCheck.cs#L119-L155","documentation":"ArgumentCheck.NotEmpty (string overload) throws ArgumentException when a string variable is the empty string (Length == 0). Null is rejected separately by NotNull first. This enforces that string parameters must contain at least one character.","triggerScenarios":"Calling ArgumentCheck.NotEmpty(variable, variableName) with string.Empty or \"\" (e.g. \"\"); a name/identifier field initialized to empty rather than a real value.","commonSituations":"Empty asset name or package name read from a form or config file; string.Split producing an empty first token; uninitialized string properties submitted by a UI.","solutions":["Supply a non-empty string value before the call","Trim/validate user or config input and reject empty strings early with a clearer message","Check string.IsNullOrEmpty(variable) in the caller and handle it with a default or error","If whitespace-only should also fail, use NotWhiteSpace instead and validate with string.IsNullOrWhiteSpace"],"exampleFix":"// before\nvar name = config[\"AssetName\"]; // \"\"\nArgumentCheck.NotEmpty(name, nameof(name));\n// after\nvar name = config[\"AssetName\"];\nif (string.IsNullOrWhiteSpace(name))\n    throw new InvalidDataException(\"AssetName must be a non-empty string\");","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(value))\n    throw new ArgumentException(\"A non-empty string is required\", nameof(value));","typeGuard":"bool IsPresent([NotNullWhen(true)] string? s) => !string.IsNullOrEmpty(s);","tryCatchPattern":"try { NotEmpty(name, nameof(name)); }\ncatch (ArgumentException ex) when (ex.ParamName == nameof(name))\n{\n    // prompt user / substitute default\n}","preventionTips":["Trim and validate text input at entry points","Use [NotNullWhen(true)] guards for nullable strings","Never accept string.Empty as a default for name-like fields"],"tags":["argument-check","argument-exception","empty-string","stride"],"backgroundTag":"empty-required-field","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"}