{"record":{"id":"70e2a1631c2e92d6","repo":"abpframework/abp","slug":"given-type-item-assemblyqualifiedname-should-b","errorCode":null,"errorMessage":"Given type ({item.AssemblyQualifiedName}) should be instance of {typeof(TBaseType).AssemblyQualifiedName} ","messagePattern":"Given type \\((.+?)\\) should be instance of (.+?) ","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Core/Volo/Abp/Collections/TypeList.cs","lineNumber":149,"sourceCode":"        _typeList.CopyTo(array, arrayIndex);\n    }\n\n    /// <inheritdoc/>\n    public IEnumerator<Type> GetEnumerator()\n    {\n        return _typeList.GetEnumerator();\n    }\n\n    IEnumerator IEnumerable.GetEnumerator()\n    {\n        return _typeList.GetEnumerator();\n    }\n\n    private static void CheckType(Type item)\n    {\n        if (!typeof(TBaseType).GetTypeInfo().IsAssignableFrom(item))\n        {\n            throw new ArgumentException($\"Given type ({item.AssemblyQualifiedName}) should be instance of {typeof(TBaseType).AssemblyQualifiedName} \", nameof(item));\n        }\n    }\n}\n","sourceCodeStart":131,"sourceCodeEnd":153,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Core/Volo/Abp/Collections/TypeList.cs#L131-L153","documentation":"Thrown by TypeList<TBaseType>.CheckType when an item added to a strongly-typed TypeList is not assignable to the list's TBaseType constraint (checked via TypeInfo.IsAssignableFrom). It is an ArgumentException naming 'item' and reports both the offending and expected AssemblyQualifiedNames.","triggerScenarios":"Calling Add/Insert on a TypeList<TBaseType> (or a class deriving from it, e.g. a module's ContributionTypes) with a Type that does not inherit/implement TBaseType.","commonSituations":"Registering a contributor type that is missing the required interface, a plugin assembly returning a type that no longer implements the expected base after a refactor, or a copy-paste of the wrong concrete class.","solutions":["Confirm item inherits or implements TBaseType; fix the type being registered.","If TBaseType is too narrow for your need, widen the generic constraint on the list or use a plain List<Type>.","Add a compile-time guard by filtering candidate types through typeof(TBaseType).IsAssignableFrom(t) before Add.","Verify the plugin assembly matches the host framework version so the expected base type is present."],"exampleFix":"// before\nlist.Add(typeof(SomeUnrelatedClass));\n\n// after\nif (typeof(TBaseType).IsAssignableFrom(typeof(SomeRelatedClass)))\n{\n    list.Add(typeof(SomeRelatedClass));\n}","handlingStrategy":"type-guard","validationCode":"static bool CanAdd<TBaseType>(Type t)\n    => typeof(TBaseType).IsAssignableFrom(t);\n\nif (CanAdd<IMyContract>(candidate)) list.Add(candidate);","typeGuard":"static bool IsKindOf<TBase>(Type t) => typeof(TBase).IsAssignableFrom(t);","tryCatchPattern":"try\n{\n    list.Add(candidate);\n}\ncatch (ArgumentException ex) when (ex.ParamName == nameof(candidate))\n{\n    logger.LogWarning(\"Rejected non-conforming type {Type}\", candidate);\n}","preventionTips":["Filter reflection-discovered types through IsAssignableFrom before adding to a TypeList.","Keep the TBaseType constraint aligned with the actual interface your contributors implement.","Add a unit test that registers each known contributor type against the list."],"tags":["validation","type-system","argument","collections","abp-core"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}