- ABP Framework version: v4.4.4
- UI type: Angular
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): no
- Steps to reproduce the issue:
- use CRUD generator to create an entity
- create an enum property for the entity
- select an enum file which contains xmldocs for its members, e.g.
public enum MyEnum
{
///<summary>Value1</summary>
Value1,
///<summary>Value2</summary>
Value2,
}
- apb suite reports error:
Cannot parse the enum file: An item with the same key has already been added. Key: /// <summary>
12 Answer(s)
-
0
After removing the xmldoc and try to save and generate the entity, abp suite reports:
Cannot populate enum localizations! Error code: EN0004. System.NullReferenceException: Object reference not set to an instance of an object. at Volo.Abp.Suite.Areas.AbpSuite.CrudPageGenerator.Commands.EntityGenerateCommand.Qu5cDTUwlI()
-
0
After replacing the enum property with an int type, generating the entity reports the following error:
Error occurred on DB migration step! Make sure the project is compiled and working. Command output: Build started... Build failed. Use dotnet build to see the errors.
Turns out the generated
EntityRepositoryTests
class in theEntityFrameworkCore.Tests
project, and theEntityApplicationTests
class in theApplication.Tests
project does not compile. They have an excessive%%class-attributes%%
text generated above the class signature. E.g.:namespace MyProject.Entities { %%class-attributes%% public class EntityRepositoryTests : MyProjectEntityFrameworkCoreTestBase {
-
0
After unchecking the
Create unit & integration tests
option for the entity, generating the entity still reports the same error:Error occurred on DB migration step! Make sure the project is compiled and working. Command output: Build started... Build failed. Use dotnet build to see the errors.
However
dotnet build
runs just fine!Edit: this one is because the aspnetcore project is running (without debugging). Closing the running project and finally the generation worked.
-
0
Some more minor problems:
- The enum members has to have values, otherwise the generated angular proxy is incorrect:
public enum MyEnum { Value1, Value2, }
turns into
export enum MyEnum { Value1 =, Value2 =, }
- Does not work with C#10 File-scoped namespace declaration, the generated DbContext will be broken
-
0
With all these issues being said, I think the CRUD generator feature of abp suite is not really in a good shape, you have to be very careful and avoid some problematic features to get it working.
-
0
hi,
you need to set enum values (not only for Suite also for the best practises) otherwise the order change of items will make the values change in the future. so pls set value to your enums
-
0
Thanks Albert, I can see it's a good idea to set enum values. Can you have a look at the other issues described above?
-
0
Can you try a new entity to test and create a new enum as below, and tell me the result
public enum Level { Low = 1, Medium = 2, High = 3 }
-
0
Thanks Albert, as I already replied above, it works very well with enums that have values, and I fully understand why the values matter.
However I've also addressed a few other issues related to the CRUD generation feature of abp suite, namely:
- it does not work with enums that has xmldocs on its members (the main post)
- it generates uncompilable test classes
- it does not work with C#10 file scoped namespaces
And even more minor issues as I step further into the jungles, such as the angular UI pages it generates does not compile in typescript strict mode. So my main point is, the CRUD generation feature is somewhat stale nowadays, I'd expect an overhaul before it can really work in modern projects. I'm sorry as some of these points are placed under an unrelated topic.
-
0
The entire ABP Suite cannot handle file scoped namespaces, so that is a bigger issue. With the move to .NET 6 for ABP v5 it would be essential to have this working, e.g. after refactoring your code Suite does not understand it at all.
- So file (re)generation fails, as it cannot find the region where to place the (updated) code
- Loading files leaves the namespace blank as it cannot parse it
As an added feedback on the enums, if the enum is not of type int, everything else fails, this also applies to flagged enums. I am not sure if ABP Suite CRUD generator supports flags enums but I had to refactor it to explicit int values to work.
In addition, the enum values are added to JSON as:
Enum:EnumType:EnumValue
but if you look at https://docs.abp.io/en/abp/5.0/UI/AspNetCore/Tag-Helpers/Form-elements#label-localization-1 it says it looks in the localization texts withEnumType.EnumValue
so right now I have untranslated enums everywhere.Note: It would be very helpful to have a separate v5 issues thread like exists for v4.4 Note: If these issues should be posted on Github instead let us know :)
-
0
the scoped namespace is not supported yet in Suite. but we'll try to support it we already have an internal issue about that. and here's the v5 issues https://support.abp.io/QA/Questions/2209/
-
0
Thank you @albert!