Suite: Fix failing test generations when ShowOnCreateModal/ShowOnEditModal is unchecked #21765
BackDescription
Resolves #21764
Generated test code produces invalid C# syntax (spurious/leading commas) when any property has "Show on create modal" unchecked, set as readonly on edit modal, or excluded from edit modal.
Root causes fixed in UnitTestCommandCommand.cs:
AddNewLineIfLastItemchecked the wrong list — compared against_options.Entity.Properties.Last()(full list) while iterating a filtered subset. When the overall last property was excluded by the filter, every filtered item — including the last — got a trailing comma appended.- Fix: pass the filtered
List<PropertyModel> propertiesinto the method and compare against its.Last().
- Fix: pass the filtered
Leading comma in
PopulateDtoCtorElements— when all properties are excluded from the create/edit modal but required navigation properties exist,AddNewLine(valueAssignments, ",")prepended,to an emptyStringBuilder, producing{ , NavProp = id }.- Fix: guard with
if (valueAssignments.Length > 0)before appending the separator.
- Fix: guard with
Leading comma in
PopulateDataSeederCtorElements— same pattern for non-Guid PKs: navigation property loop unconditionally prepended,\nbefore the first nav argument when noShowOnCreateModalproperties existed.- Fix: guard with
if (propertiesWithValues.Length > 0)before appendingnewLine.
- Fix: guard with
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?
- Create an entity in ABP Suite with at least two properties. Uncheck Show on the create modal for one property (especially the last one in the list).
- Generate code and verify
*DataSeedContributor.csand*AppServiceTests.cscompile without errors. - Repeat with Show on edit modal unchecked, and with Readonly on edit modal checked — confirm
UpdateAsynctest also compiles cleanly.
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
nuget.abp.io- Triggering command:
/usr/bin/dotnet dotnet build --no-restore plates/Frontend.Angular/app_module_import.txt plat plates/Frontend.Angular/Page/Routing_module_path.txt plates/Frontend.Angular/Page/Routing_module_ts.txt(dns block) - Triggering command:
/usr/bin/dotnet dotnet build(dns block)
- Triggering command:
www.myget.org- Triggering command:
/usr/bin/dotnet dotnet build --no-restore plates/Frontend.Angular/app_module_import.txt plat plates/Frontend.Angular/Page/Routing_module_path.txt plates/Frontend.Angular/Page/Routing_module_ts.txt(dns block) - Triggering command:
/usr/bin/dotnet dotnet build(dns block)
- Triggering command:
If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to the custom allowlist in this repository's (admins only)
Original prompt
This section details on the original issue you should resolve
<issue_title>Suite: Fix failing test generations (occurs when on create modal option is unchecked)</issue_title>
<issue_description>Reported at https://abp.io/support/questions/10473/BUG-ABP-Suite-tests-break-when-Show-on-the-create-modal-is-false
The customer's error description:
When using ABP Studio, it seems like the generated code for tests breaks when you do not have the "Show on the create modal" selected for a property. If you select that option and regenerate, it will work     Same problem seem to happen if you select the "Show on the create modal" but also that it should be read only. ```</issue_description> <agent_instructions>Check the test command classes (and all generated codes regarding tests) on ABP Suite, and also check ABP Suite code templates (under /licensing/ folder) -only for test templates-. After you check that, in the code, you should be able to understand, when the relevant property is not added or added, and this creates build problem on the generated codes. (As clearly can be seen from the image link in the issue description, property name/parameter written as empty, but trailing ',' added anyway. The relevant place should always same with the entity constructor or for the relevant input class's constructor to overcome this problem!</agent_instructions> ## Comments on the Issue (you are @copilot in this section) <comments> </comments>
- Fixes volosoft/volo#21764
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.