Generate explicit IShape wrappers for display drivers#19087
Generate explicit IShape wrappers for display drivers#19087
Conversation
Agent-Logs-Url: https://github.com/OrchardCMS/OrchardCore/sessions/5cc057b5-b159-41c4-88ad-bbe3ecf22edc Co-authored-by: gvkries <7062785+gvkries@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OrchardCMS/OrchardCore/sessions/5cc057b5-b159-41c4-88ad-bbe3ecf22edc Co-authored-by: gvkries <7062785+gvkries@users.noreply.github.com>
|
@copilot Generating shape proxies with Castle must be kept as a fallback. Additionally, avoid using a registry for generated types, if possible. |
Agent-Logs-Url: https://github.com/OrchardCMS/OrchardCore/sessions/d027a51d-de8f-43da-8ac9-96d9793e9ca6 Co-authored-by: gvkries <7062785+gvkries@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OrchardCMS/OrchardCore/sessions/d027a51d-de8f-43da-8ac9-96d9793e9ca6 Co-authored-by: gvkries <7062785+gvkries@users.noreply.github.com>
Addressed in dcf71ba. The runtime Castle proxy path is restored as the fallback in |
|
@copilot Simplify the source generator by only intercepting calls to |
I investigated this path, but simplifying the generator to only intercept that |
|
@copilot Can you intercept the nested |
I checked that path, but intercepting the nested |
|
@copilot The issue is that all calls to the shape factory (extensions) via display drivers are not detected and no source gets generated for all the shapes creating by them. We need to find a better approach, e.g. try to refactor the ShapeFactoryExtensions so that it's easier to intercept. Or you may need to intercept calls to the display drivers |
Agent-Logs-Url: https://github.com/OrchardCMS/OrchardCore/sessions/80756543-2fd3-4bb6-8f71-c47f8f8aa8b5 Co-authored-by: gvkries <7062785+gvkries@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OrchardCMS/OrchardCore/sessions/80756543-2fd3-4bb6-8f71-c47f8f8aa8b5 Co-authored-by: gvkries <7062785+gvkries@users.noreply.github.com>
Addressed in 51b3407. I extended the generator to intercept display-driver Warning 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:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot The generated shapes should not allocate an |
Agent-Logs-Url: https://github.com/OrchardCMS/OrchardCore/sessions/679b3934-3f02-46c7-952a-88927a1f8e84 Co-authored-by: gvkries <7062785+gvkries@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OrchardCMS/OrchardCore/sessions/679b3934-3f02-46c7-952a-88927a1f8e84 Co-authored-by: gvkries <7062785+gvkries@users.noreply.github.com>
Addressed in 936f670. The generated wrappers now implement the |
Previously, sorting was triggered whenever the _sorted flag was false, even if the _items list was empty. Now, sorting only occurs if there are items in the list, preventing unnecessary operations on empty collections.
Description
CreateAsync<TModel>for non-IShapemodels currently relies on Castle class proxies plus aShapeViewModelmixin. This change adds a source-generated wrapper path for supported call sites while preserving the existing Castle proxy behavior as the fallback.Shape creation
IShape.ShapeFactoryExtensionsas the runtime fallback when no generated wrapper path is available.CreateAsync<TModel...>call sites instead of routing runtime activation through a generated-type registry.DisplayDriverBase.Initialize<TModel>(...)call sites in consuming projects.Source generation
CreateAsync<TModel...>call sites for non-IShapeclasses.IShape/IPositioneddirectly, mimickingShapeViewModelbehavior without allocating an internalShapeViewModelinstance.CreateAsync<TModel...>and display-driverInitialize<TModel>(...)call sites so wrappers can be instantiated directly without a registry.newonly when the model type or its base types already define conflicting members.Dependency cleanup
Castle.Coredependency because it remains the fallback path for non-generated scenarios.Coverage
IShapemembers directly with the same behavior asShapeViewModelInitialize<TModel>(...)creating generated strongly typed wrappersShapeViewModelfieldTesting
dotnet test --project test/OrchardCore.Tests/OrchardCore.Tests.csproj --filter-class "OrchardCore.Tests.DisplayManagement.ShapeFactoryTests"✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.