Skip to content

Improve ShapeResult functionality#19269

Draft
gvkries wants to merge 3 commits into
mainfrom
gvkries/shaperesult-improvements
Draft

Improve ShapeResult functionality#19269
gvkries wants to merge 3 commits into
mainfrom
gvkries/shaperesult-improvements

Conversation

@gvkries

@gvkries gvkries commented May 20, 2026

Copy link
Copy Markdown
Member

This pull request refactors the way display and editor shapes are initialized throughout multiple OrchardCore modules. The main improvement is the adoption of strongly-typed and static initialization patterns for shape factories and view models, which enhances type safety, testability, and clarity. Additionally, dependencies are now passed explicitly to initialization methods, reducing reliance on closures and instance fields.

The most important changes are:

Refactoring Shape/ViewModel Initialization:

  • Replaces closure-based Initialize and Shape calls with strongly-typed, static lambda overloads (e.g., Initialize<TViewModel, TDependency1, ...>, Factory) across various display drivers, ensuring all dependencies are explicitly passed and improving code maintainability. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]

Explicit Dependency Injection in Shape Initialization:

  • Dependencies such as services and drivers are now injected as parameters to the static initialization lambdas, instead of being captured from the surrounding scope, promoting clearer and more testable code. [1] [2] [3] [4]

Improved Conditional Rendering:

  • Updates to RenderWhen calls to use static lambdas and explicit dependency injection, making conditional rendering logic more robust and explicit. [1] [2] [3] [4]

Consistency and Modernization:

  • Applies these patterns consistently across content fields, admin nodes, localization, content preview, and deployment-related drivers, modernizing the codebase and reducing technical debt. (All references above)

Minor Cleanups:

  • Removes unnecessary instance field accesses and replaces them with parameters, and ensures all shape/view model construction follows the new pattern. (All references above)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant