{"record":{"id":"5bacf3ab196455bf","repo":"stride3d/stride","slug":"the-given-component-type-does-not-inherit-from","errorCode":null,"errorMessage":"The given component type does not inherit from EntityComponent.","messagePattern":"The given component type does not inherit from EntityComponent\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Assets.Presentation/SceneEditor/Services/StrideDialogService.cs","lineNumber":29,"sourceCode":"    /// <summary>\n    /// This class is the default implementation of the <see cref=\"IStrideDialogService\"/>.\n    /// </summary>\n    internal class StrideDialogService : IStrideDialogService\n    {\n        /// <inheritdoc/>\n        public IEntityPickerDialog CreateEntityPickerDialog(EntityHierarchyEditorViewModel editor)\n        {\n            if (editor == null) throw new ArgumentNullException(nameof(editor));\n            var picker = new EntityPickerWindow(editor, null);\n            return picker;\n        }\n\n        /// <inheritdoc/>\n        public IEntityPickerDialog CreateEntityComponentPickerDialog(EntityHierarchyEditorViewModel editor, Type componentType)\n        {\n            if (editor == null) throw new ArgumentNullException(nameof(editor));\n            if (!typeof(EntityComponent).IsAssignableFrom(componentType) && componentType.IsAbstract == false)\n                throw new ArgumentException(@\"The given component type does not inherit from EntityComponent.\", nameof(componentType));\n\n            var picker = new EntityPickerWindow(editor, componentType);\n            return picker;\n        }\n    }\n}\n","sourceCodeStart":11,"sourceCodeEnd":36,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/SceneEditor/Services/StrideDialogService.cs#L11-L36","documentation":"CreateEntityComponentPickerDialog validates that the component type passed to the entity picker is a concrete subclass of EntityComponent. The guard throws ArgumentException when the type does not inherit from EntityComponent AND is not abstract, since a concrete non-EntityComponent type cannot be used to pick/create entities.","triggerScenarios":"Calling StrideDialogService.CreateEntityComponentPickerDialog with a componentType that is a concrete type not derived from EntityComponent (e.g. passing a ViewModel, a TransformComponent-like unrelated class, or the wrong Type object entirely).","commonSituations":"Plugin/extension developers wiring custom picker dialogs pass typeof(SomeViewModel) or a base class instead of their concrete EntityComponent subclass; refactoring renames/moves component classes and stale Type references get passed.","solutions":["Pass a concrete Type that derives from Stride.Engine.EntityComponent, e.g. typeof(MyComponent)","Check the type with typeof(EntityComponent).IsAssignableFrom(componentType) before calling, and skip or adapt for abstract types","If you intended an abstract type, note the guard only accepts it when componentType.IsAbstract is true; verify you are not passing a concrete unrelated type"],"exampleFix":"// before\ndialogService.CreateEntityComponentPickerDialog(editor, typeof(MyViewModel));\n// after\ndialogService.CreateEntityComponentPickerDialog(editor, typeof(MyEntityComponent));","handlingStrategy":"validation","validationCode":"bool ok = componentType != null && (typeof(EntityComponent).IsAssignableFrom(componentType) || componentType.IsAbstract);\nif (!ok) throw new ArgumentException(nameof(componentType));","typeGuard":"bool IsConcreteEntityComponent(Type t) => t != null && typeof(EntityComponent).IsAssignableFrom(t) && !t.IsAbstract;","tryCatchPattern":"try { var dlg = svc.CreateEntityComponentPickerDialog(editor, componentType); }\ncatch (ArgumentException) { // fall back to default picker or show validation message\n}","preventionTips":["Always pass typeof(YourConcreteComponent) literals rather than dynamically obtained types","Assert typeof(EntityComponent).IsAssignableFrom(t) in unit tests for every component type fed to pickers"],"tags":["argument-validation","stride","editor"],"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-23T08:17:48.524Z"}