Feature ID: 004-mappingpath-accessor-enhancements Status: Draft
itrond.net
Two enhancements to the path navigation system:
Remove wildcard requirement
[*]
Automatic wildcard generation
Currently, you must include at least one wildcard [*] when creating a MappingPath, or it throws an error.
Allow MappingPath to work with any valid path, with or without wildcards.
"Person.Name"
"Person.Jobs[*].Title"
"A.B.C"
"X.Y[5].Z[3]"
"A[*].B[*].C"
"X[3].Y[7].Z"
"A[3].B[7].C"
✓ MappingPath accepts paths without wildcards ✓ WildcardCount returns 0 when no wildcards present ✓ ApplyIndices returns template unchanged when no wildcards ✓ ApplyIndices correctly substitutes wildcard positions ✓ Mixed scenarios work correctly
Developers must manually figure out where to place wildcards [*] by analyzing type structures.
This is error-prone and time-consuming.
Add method GenerateMappingPath that:
GenerateMappingPath
Key concept: Input is a class path (property names only)
Input: "Jobs.Projects.Name" ↓ Analyze type structure: - Jobs: List<Job> → Add wildcard - Projects: List<Project> → Add wildcard - Name: string → No wildcard ↓ Output: "Jobs[*].Projects[*].Name"
Jobs
List<Job>
"Jobs.Title"
"Jobs[*].Title"
Projects
List<Project>
"Jobs.Projects.Name"
"Jobs[*].Projects[*].Name"
Name
string
"Name"
CurrentJob
PastProjects
"CurrentJob.PastProjects.Description"
"CurrentJob.PastProjects[*].Description"
"Departments.Teams.Members.Name"
"Departments[*].Teams[*].Members[*].Name"
✓ Correctly identifies collection types and adds wildcards ✓ Correctly identifies non-collection types and omits wildcards ✓ Handles nested collections at multiple levels ✓ Handles mixed scenarios ✓ Handles root path without errors ✓ Throws appropriate exception for invalid paths ✓ Works with at least 3 levels of nesting
Before: Different code paths
if (hasCollections) { var mapping = MappingPath.Parse(path); } else { var mapping = /* different approach */ }
After: Uniform API
var mapping = MappingPath.Parse(path); if (mapping.WildcardCount > 0) { // Handle collections }
"OldFormat.Items.SubItems.Value"
"OldFormat.Items[*].SubItems[*].Value"
"NewFormat.Elements.SubElements.Data"
"NewFormat.Elements[*].SubElements[*].Data"
Benefit: No manual wildcard placement, fewer errors
✓ No breaking changes ✓ Existing code continues to work ✓ API is enhanced, not changed
Two powerful enhancements:
Result: Simpler API, fewer errors, faster development
Effort: ~9-12 hours Risk: Low (no breaking changes)