{"record":{"id":"410b0ad9c5df48c6","repo":"stride3d/stride","slug":"invalid-required-type-requiredtype-expecting-only-an","errorCode":null,"errorMessage":"Invalid required type [{requiredType}]. Expecting only an EntityComponent type","messagePattern":"Invalid required type \\[(.+?)\\]\\. Expecting only an EntityComponent type","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Engine/Engine/EntityProcessor.cs","lineNumber":67,"sourceCode":"        /// <exception cref=\"System.ArgumentNullException\">If parameteters are null</exception>\n        /// <exception cref=\"System.ArgumentException\">If a type does not inherit from EntityComponent</exception>\n        protected EntityProcessor([NotNull] Type mainComponentType, [NotNull] Type[] additionalTypes)\n        {\n            if (mainComponentType == null) throw new ArgumentNullException(nameof(mainComponentType));\n            if (additionalTypes == null) throw new ArgumentNullException(nameof(additionalTypes));\n\n            MainComponentType = mainComponentType;\n            mainTypeInfo = MainComponentType.GetTypeInfo();\n\n            RequiredTypes = new TypeInfo[additionalTypes.Length];\n\n            // Check that types are valid\n            for (var i = 0; i < additionalTypes.Length; i++)\n            {\n                var requiredType = additionalTypes[i];\n                if (!typeof(EntityComponent).GetTypeInfo().IsAssignableFrom(requiredType.GetTypeInfo()))\n                {\n                    throw new ArgumentException($\"Invalid required type [{requiredType}]. Expecting only an EntityComponent type\");\n                }\n\n                RequiredTypes[i] = requiredType.GetTypeInfo();\n            }\n\n            if (RequiredTypes.Length > 0)\n            {\n                componentTypesSupportedAsRequired = new Dictionary<TypeInfo, bool>();\n            }\n\n            UpdateProfilingKey = new ProfilingKey(GameProfilingKeys.GameUpdate, GetType().Name);\n            DrawProfilingKey = new ProfilingKey(GameProfilingKeys.GameDraw, GetType().Name);\n        }\n\n        /// <summary>\n        /// Gets or sets a value indicating whether this <see cref=\"EntityProcessor\"/> is enabled.\n        /// </summary>\n        public bool Enabled { get; set; } = true;","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Engine/Engine/EntityProcessor.cs#L49-L85","documentation":"The EntityProcessor constructor takes additionalTypes of components the processor requires and validates each is assignable to EntityComponent. It throws ArgumentException when a required type does not derive from EntityComponent, since processors only track component types.","triggerScenarios":"Defining a processor whose constructor is passed a Type (e.g. typeof(SomeService) or an interface/base type not derived from EntityComponent) in additionalTypes.","commonSituations":"Copy-pasting processor definitions and editing the type list with wrong types; passing entity/processor base types instead of component types; typos resolving to unrelated classes.","solutions":["Ensure every type in additionalTypes derives from Stride.Engine.EntityComponent","Use typeof(YourComponent) for component types only; non-component dependencies go through Services instead","Add an IsAssignableFrom check at the call site when types are dynamic"],"exampleFix":"// before\nnew MyProcessor(typeof(TransformComponent), typeof(Entity));\n// after\nnew MyProcessor(typeof(TransformComponent), typeof(MyRequiredComponent));","handlingStrategy":"validation","validationCode":"foreach (var t in additionalTypes)\n    if (t == null || !typeof(EntityComponent).GetTypeInfo().IsAssignableFrom(t.GetTypeInfo()))\n        throw new ArgumentException($\"{t} is not an EntityComponent type\");","typeGuard":"static bool IsValidRequiredType(Type t) => t != null && typeof(EntityComponent).GetTypeInfo().IsAssignableFrom(t.GetTypeInfo());","tryCatchPattern":"try { var proc = new MyProcessor(additionalTypes); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Expecting only an EntityComponent type\")) { /* fix the type list */ }","preventionTips":["Only pass typeof(...) of classes deriving from EntityComponent","Resolve non-component dependencies via Services, not required types","Unit-test processor construction to catch bad type lists early"],"tags":["csharp","stride","type-mismatch","constructor"],"backgroundTag":"type-mismatch","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"}