{"record":{"id":"61947b97b90e056a","repo":"abpframework/abp","slug":"changetypeprimitiveextended-tproperty-does-not-su","errorCode":null,"errorMessage":"ChangeTypePrimitiveExtended<TProperty> does not support non-primitive types. Use non-generic GetProperty method and handle type casting manually.","messagePattern":"ChangeTypePrimitiveExtended<TProperty> does not support non-primitive types\\. Use non-generic GetProperty method and handle type casting manually\\.","errorType":"exception","errorClass":"AbpException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs","lineNumber":112,"sourceCode":"            if (IsNullable(conversionType))\n            {\n                conversionType = conversionType.GetFirstGenericArgumentIfNullable();\n            }\n\n            if (conversionType == typeof(Guid))\n            {\n                return (TProperty)TypeDescriptor.GetConverter(conversionType).ConvertFromInvariantString(value.ToString()!)!;\n            }\n\n            if (conversionType.IsEnum)\n            {\n                return (TProperty)Enum.Parse(conversionType, value.ToString()!);\n            }\n\n            return (TProperty)Convert.ChangeType(value, conversionType, CultureInfo.InvariantCulture);\n        }\n\n        throw new AbpException(\"ChangeTypePrimitiveExtended<TProperty> does not support non-primitive types. Use non-generic GetProperty method and handle type casting manually.\");\n    }\n\n    public static bool IsNullable(Type type)\n    {\n        return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);\n    }\n\n    public static bool IsNullableEnum(Type type)\n    {\n        return type.IsGenericType &&\n               type.GetGenericTypeDefinition() == typeof(Nullable<>) &&\n               type.GenericTypeArguments.Length == 1 &&\n               type.GenericTypeArguments[0].IsEnum;\n    }\n\n    public static Type GetFirstGenericArgumentIfNullable(this Type t)\n    {\n        if (t.GetGenericArguments().Length > 0 && t.GetGenericTypeDefinition() == typeof(Nullable<>))","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs#L94-L130","documentation":"Thrown by TypeHelper.ChangeTypePrimitiveExtended<TProperty> when TProperty is not a primitive-extended type (primitives, Guid, enums, and their nullables). The method refuses to convert complex/object types and points you to the non-generic GetProperty path. It is an AbpException.","triggerScenarios":"Calling ChangeTypePrimitiveExtended<SomeComplexType>(value) where SomeComplexType is a class/struct that is not in the primitive-extended set.","commonSituations":"Binding a setting/configuration value to a complex POCO via the generic helper, deserializing from a dictionary into a non-primitive property, or a generic property accessor that assumes primitives but receives an object type.","solutions":["Use the non-generic GetProperty variant and perform the cast/deserialization manually (e.g. JsonSerializer.Deserialize).","Restrict TProperty to primitive-extended types; decompose the complex property into primitives.","If you wrote the caller, gate on TypeHelper.IsPrimitiveExtended(typeof(TProperty)) before invoking.","Deserialize complex values to JSON first, then parse them into the target type."],"exampleFix":"// before\nvar obj = TypeHelper.ChangeTypePrimitiveExtended<MyPoco>(raw);\n\n// after\nvar obj = JsonSerializer.Deserialize<MyPoco>(raw.ToString()!);","handlingStrategy":"type-guard","validationCode":"if (!TypeHelper.IsPrimitiveExtended(typeof(TProperty), includeEnums: true))\n    throw new InvalidOperationException(\"Use non-generic GetProperty for complex types\");\n\nvar v = TypeHelper.ChangeTypePrimitiveExtended<TProperty>(raw);","typeGuard":"static bool IsPrimitiveExtended<T>()\n    => TypeHelper.IsPrimitiveExtended(typeof(T), includeEnums: true);","tryCatchPattern":"try { var v = TypeHelper.ChangeTypePrimitiveExtended<TProperty>(raw); }\ncatch (AbpException ex) when (ex.Message.Contains(\"non-primitive\"))\n{\n    // fall back to manual deserialization\n    obj = JsonSerializer.Deserialize<TProperty>(raw.ToString()!);\n}","preventionTips":["Reserve ChangeTypePrimitiveExtended for primitives, Guid, and enums.","For complex types, deserialize JSON directly into the target type.","Gate generic helpers on IsPrimitiveExtended before invoking."],"tags":["reflection","type-conversion","configuration","abp-core"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}