- ABP Framework version: v8.2.1
- UI Type: Angular
- Database System: EF Core (SQL Server)
- Tiered (for MVC) or Auth Server Separated (for Angular): yes
- Exception message and full stack trace: multiple warnings in console
- Steps to reproduce the issue:
- Create a new Enum
- Extend an existing module following the abp documentation and set the new property type as the new Enum.
- Angular frontend renders the Label but not the dropdown.
This happens both with our current abp version as well as with a new solution using abp v9.0.1, .net 9 and Angular v18.
Edit: at least in the new solution, removing the null annotation seems to fix the issue and renders the input, but at least in our case the property should be nullable so this would not be a fix.
6 Answer(s)
-
0
-
0
Thanks for the reply, have you tried setting it as nullable as per the abp documentation itself and similar with my example and use case?
-
0
I have tried with your example and use case its work fine.
have you tried setting it as nullable as per the abp documentation itself
Can you explain in details and which document you can refer.
-
0
I have tried with your example and use case its work fine.
have you tried setting it as nullable as per the abp documentation itself
Can you explain in details and which document you can refer.
sorry, I should have been more clear in my initial repro steps: Steps to reproduce the issue:
- Create a new Enum
- Extend an existing module following the abp documentation, set the new property type as the new Enum and set is as nullable.
- Angular frontend renders the Label but not the dropdown.
See screenshot bellow, same one as the initial one, line 78, "<OrganizationStatus?>"
I'm not sure what exactly you mean by "which document you can refer", maybe the abp documentation itself if you click on the link.
Screenshot from the documentation below in which it's explained how to handle nullable Enums.
-
0
Hello, thank you for reporting this. We will be fixing the problem as soon as possible and refunding your ticket.
-
0
hi
We will fix this in the next version. You can temporarily solve it by replace the
CachedObjectExtensionsDtoService
https://github.com/abpframework/abp/pull/21675
using System; using System.Collections.Generic; using System.Linq; using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; using Volo.Abp.DependencyInjection; using Volo.Abp.ObjectExtending; using Volo.Abp.ObjectExtending.Modularity; namespace MyCompanyName.MyProjectName.Web; [Dependency(ReplaceServices = true)] [ExposeServices(typeof(MyCachedObjectExtensionsDtoService), typeof(CachedObjectExtensionsDtoService), typeof(ICachedObjectExtensionsDtoService))] public class MyCachedObjectExtensionsDtoService : CachedObjectExtensionsDtoService { public MyCachedObjectExtensionsDtoService(IExtensionPropertyAttributeDtoFactory extensionPropertyAttributeDtoFactory) : base(extensionPropertyAttributeDtoFactory) { } protected override void FillEnums(ObjectExtensionsDto objectExtensionsDto) { var enumProperties = ObjectExtensionManager.Instance.Modules().Values .SelectMany( m => m.Entities.Values.SelectMany( e => e.GetProperties() ) ) .Where(p => p.Type.IsEnum || IsNullableEnum(p.Type)) .ToList(); foreach (var enumProperty in enumProperties) { // ReSharper disable once AssignNullToNotNullAttribute (enumProperty.Type.FullName can not be null for this case) objectExtensionsDto.Enums[enumProperty.Type.FullName!] = CreateExtensionEnumDto(enumProperty); } } protected override ExtensionEnumDto CreateExtensionEnumDto(ExtensionPropertyConfiguration enumProperty) { var extensionEnumDto = new ExtensionEnumDto { Fields = new List<ExtensionEnumFieldDto>(), LocalizationResource = enumProperty.GetLocalizationResourceNameOrNull() }; var enumType = enumProperty.Type.IsEnum ? enumProperty.Type : IsNullableEnum(enumProperty.Type) ? Nullable.GetUnderlyingType(enumProperty.Type) : null; if (enumType == null) { return extensionEnumDto; } foreach (var enumValue in enumType.GetEnumValues()) { extensionEnumDto.Fields.Add( new ExtensionEnumFieldDto { Name = enumType.GetEnumName(enumValue)!, Value = enumValue } ); } return extensionEnumDto; } public bool IsNullableEnum(Type type) { return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) && type.GenericTypeArguments.Length == 1 && type.GenericTypeArguments[0].IsEnum; } }