Fix BuildMap() generating orphaned [Map] attribute when mapped table has no display field#89
Merged
Merged
Conversation
Closed
…eld available When Map attribute specifies only "Table@Id" (no display field) and the mapped table has no Master column or "Name" column, the BuildMap() method was writing a [Map(...)] attribute with no following property declaration, resulting in invalid C# code. Fix 1: In the `else` branch (mapTable is null), guard ss[2] access with `else if (ss.Length > 2)` to avoid IndexOutOfRangeException. Fix 2: Add `(mapName != null || (ss.Length > 2 && ss[2] == "$"))` to the condition for generating the string extension property, so [Map(...)] and the property are only generated when a display field is available. Closes #88
- Extract `ss.Length > 2 && ss[2] == "$"` into `useToString` variable to eliminate duplication - Improve test assertion to verify the exact Extends.Get property declaration is generated
Copilot
AI
changed the title
[WIP] Fix xcodetool generation of entities with Map feature
Fix BuildMap() generating orphaned [Map] attribute when mapped table has no display field
Jul 17, 2026
xxred
marked this pull request as ready for review
July 19, 2026 17:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a column uses
Map="ProductRelease@Id"(table+key only, no display field) and the mapped table has neither aMastercolumn nor aNamecolumn,BuildMap()wrote a[Map(...)]attribute with no following property declaration — invalid C#:Changes
XCode/Code/EntityBuilder.cs&& (mapName != null || useToString)guard on the string extension property block so[Map(...)]is never emitted without a corresponding propertyIndexOutOfRangeExceptionin themapTable == nullbranch:ss[2]access is now guarded byelse if (ss.Length > 2)ss.Length > 2 && ss[2] == "$"into auseToStringlocal variable to eliminate duplicationXUnitTest.XCode/Code/EntityBuilderTests.csBuildMap_NoDisplayField_NoOrphanedMapAttributetest covering the exact scenario from the issue — verifies no orphaned[Map]attribute is emitted and the object-reference property (Extends.Getpattern) is still correctly generated