branch icon

Suite - Preserve custom code when regenerating the entity #14629

Description

Resolves #10858

With this PR, ABP Suite allows you to customize the generated code-blocks and preserve your custom code changes in the next CRUD Page Generation. ABP Suite specifies hook-points to allow adding custom code blocks. Then, the code that you wrote to these hook points will be respected and will not be overridden in the next entity generation.

To enable custom code support, you should check the Customizable code option in the crud page generation page. When you enable the custom code support, you will be seeing some hook-points in your application.

For example, on the C# side, you'll be seeing some abstract classes and classes that derive from them (for entities, application services, interfaces, domain services, and so on...). You can write your custom code in those classes (*.Extended.cs) and the next time when you need to re-generate the entity, your custom code will not be overridden (only the base abstract classes will be re-generated and your changes on Suite will be respected).

On the UI side, you can see the comment placeholders on the pages for MVC & Blazor applications. These are hook-points provided by ABP Suite and you can write your custom code between these comment sections.

Note: This PR only includes changes for MVC and Blazor UIs, we haven't implemented the Angular UI yet (#14628).

Checklist

  • I fully tested it as developer / designer and created unit / integration tests
  • I documented it (or no need to document or I will create a separate documentation issue)
  • I worked with the design team to get their idea for UI/UX design (or no need to design for this PR)
  • I've assigned reviewer, related labels and set a milestone for this PR

How to test it?

  • Generate an entity and select the customizable code checkbox in the crud page generation page.
  • After the CRUD page is generated, run the application and add custom code to either one of the *.Extended.cs file or between the <suite-custom-code-block-n>...</suite-custom-code-block-n> comment blocks in the cshtml, razor and js files.
  • Then, add a new property to the related entity via Suite and re-generate the same entity. The custom code that you have written should not be deleted.
Version
7.4.0-rc.1
Release Date
16 augusta, 2023
Labels
abp-suite feature ui-mvc ui-blazor