{"record":{"id":"e7c2d26fc3e695d7","repo":"stride3d/stride","slug":"paramname-cannot-be-empty","errorCode":null,"errorMessage":"{paramName} cannot be empty.","messagePattern":"(.+?) cannot be empty\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Core.Assets.Editor/ArgumentCheck.cs","lineNumber":84,"sourceCode":"        /// Otherwise throws an exception.\n        /// </summary>\n        /// <param name=\"collection\">The collection to check.</param>\n        /// <param name=\"variableName\">The name of the variable being checked.</param>\n        /// <exception cref=\"ArgumentNullException\">\n        /// The <paramref name=\"collection\"/> cannot be <see langword=\"null\"/>.\n        /// </exception>\n        /// <exception cref=\"ArgumentOutOfRangeException\">\n        /// The <paramref name=\"collection\"/> is empty.\n        /// </exception>\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        public static void NotEmpty(ICollection collection, string variableName)\n        {\n            var paramName = variableName ?? \"The collection\";\n            // collection cannot be null\n            NotNull(collection, \"collection\");\n            if (collection.Count == 0)\n            {\n                throw new ArgumentOutOfRangeException(paramName, $\"{paramName} cannot be empty.\");\n            }\n        }\n\n        /// <summary>\n        /// Checks wether the <paramref name=\"collection\"/> is not empty.\n        /// Otherwise throws an exception.\n        /// </summary>\n        /// <typeparam name=\"T\">The type of the <paramref name=\"collection\"/>.</typeparam>\n        /// <param name=\"collection\">The collection to check.</param>\n        /// <param name=\"variableName\">The name of the variable being checked.</param>\n        /// <exception cref=\"ArgumentNullException\">\n        /// The <paramref name=\"collection\"/> cannot be <see langword=\"null\"/>.\n        /// </exception>\n        /// <exception cref=\"ArgumentOutOfRangeException\">\n        /// The <paramref name=\"collection\"/> is empty.\n        /// </exception>\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        public static void NotEmpty<T>(ICollection<T> collection, string variableName)","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Core.Assets.Editor/ArgumentCheck.cs#L66-L102","documentation":"ArgumentCheck.NotEmpty throws ArgumentOutOfRangeException when a collection-like argument (with a Count property) has zero elements. The library enforces the contract that the caller must pass a non-null, non-empty collection. The paramName defaults to \"The collection\" when no variable name is supplied.","triggerScenarios":"Calling ArgumentCheck.NotEmpty (IEnumerable or collection overloads at ArgumentCheck.cs:84) with a collection whose Count == 0, e.g. a fresh List<T>, an empty array, or the result of a filtering operation that matched nothing.","commonSituations":"Passing an empty list loaded from config or a database query that returned no rows; constructing an Asset/Package editor operation with no selected items; refactoring that changed a default field initializer from a populated list to a new empty one.","solutions":["Populate the collection with at least one element before calling the API that validates it","Check collection.Count > 0 (or collection.Any()) before invoking, and handle the empty case explicitly in your caller","Verify the upstream data source (config, file, query) actually produced items; fix the loading step if it silently returns an empty collection","If an empty collection is legitimately valid, stop routing it through this API and handle it before the call"],"exampleFix":"// before\nProcessItems(new List<string>());\n// after\nvar items = LoadItems();\nif (items.Count == 0) { /* handle empty case */ return; }\nProcessItems(items);","handlingStrategy":"validation","validationCode":"if (collection == null) throw new ArgumentNullException(nameof(collection));\nif (collection.Count == 0) throw new ArgumentException(\"Collection must contain at least one item\", nameof(collection));","typeGuard":"bool IsNonEmpty<T>(IReadOnlyCollection<T>? c) => c is { Count: > 0 };","tryCatchPattern":"try { NotEmpty(items, nameof(items)); }\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == nameof(items))\n{\n    // handle empty-collection case\n}","preventionTips":["Check Count/Any() before calls guarded by NotEmpty","Never forward results of filtering operations without verifying they matched","Default-initialize collection fields with required items when the contract forbids emptiness","Add unit tests covering the empty-collection path"],"tags":["argument-check","argument-out-of-range","empty-collection","stride"],"backgroundTag":"argument-out-of-range","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"}