Skip to content

problems when porting CollectionEditor #46

@LukasGelke

Description

@LukasGelke

I'm currently in the process of porting our custom editor(s).

The situation is as follows:

  • we have custom Types to manage certain Actions that can be done in our applications (that interact with BindingSources, other Forms,...)
  • CommandProvider is a Component which will be placed on ViewModel-Classes (Components themself)
  • CommandProvider has a Property Commands of Type CommandCollection (Inherits from Collection<IKomsaCommand>)
  • CommandCollection has an DesignreAttribute
  • There are different Types of Commands
    • several Default-Commands, which take some Bindings/Properties to do pre-defined actions
    • an empty Default-Command, which is intended for simple actions (mainly its public Executing Event Handler)
    • manually defined classes which implement IKomsaCommand - these are not part of the Designer
  • each Default-Command is a Component themself, which also live on the ViewModel as fields and should be "editable via designer"
  • the CollectionEditor allows for the individual Commands to be editable
  • from what I understand after many hours of trying and failing is that the default ComponentCodeDomSerializer should work
    • in the past we did not need a custom serializer

I've tried to inherit relevant classes (as per example: https://github.com/KlausLoeffelmann/NetControlDesigners/tree/main/src/Samples/Previous%20Versions/Sophisticated%20-%20CollectionEditor );
But also tried a "less convoluted" approach with less classes using the TileRepeater_Medium example.

I'm using the CollectionEditorViewModel.CreateInstance()/IDesignerHost.CreateComponent() mechanisms to have the needed Command-Fields in the ViewModel and DestroyInstance()/host.DestryComponent() to remove them again (hoping to leverage DesignerHostTransactions)

Currently I'm exhibiting the following problems:

  • the CollectionEditor has no way to edit Events (the same way the PropertyBrowser in VisualStudio can)
    • also ComponentProxy seems to have no way to interact with Events of the object
  • Fields of removed Commands are still present in the *.Designer.cs
  • Added Commands may be added as a field, and initialized, but are not added to the CommandCollection
  • Sophisticated: adding a new Command, also removes the first Command from the Collection (but leaves it in the *.Designer.cs) (new Command also not Added to Collection)
  • Sophisticated: just removing a Command in the Editor does not do anything

The entire architecture of the new model (producing and consuming a NuGet Package withing the same solution) makes it hard and slow to iterate and debug. Also I'm now unsure which problems occur in which implementation due to swapping halfway through.
We don't have a single lightweight "controls only" project and due to dependencies cannot extract such.
There is a need to "Rebuild" the "Design.Package" Project and then the consuming project (in this case a UnitTest project).
Debugging only works with as seconds instance of Visual Studio, but having the same solution open causes sometimes problems that the debugger complains about changes the second instance makes. Thus having to unload the Test project in the first, but having to "Reload" it in the second.
Sometimes Breakpoints wont be active because of apparent discrepancies. Implying the need for an additional sln(f), just for this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions