dsmsuite / dsmsuite.sourcecode

MIT License
14 stars 9 forks source link

Freshly compiled DsmViewer does not load model that contains actions. #30

Open ernstaii opened 2 months ago

ernstaii commented 2 months ago

When I compile the viewer and then use the compiled program to load a model that contains actions, an exception occurs. This is due to the ActionStore.LoadFromModel lines

object[] args = { _model, _actionManager.GetContext(), action.Data };
IAction instance = Activator.CreateInstance(type, args) as IAction;

The activator cannot find a constructor that takes 3 arguments, because (e.g.) ElementSortAction has a constructor that takes a single argument, an object array. Many tests pertaining to actions also fail. Now, the funny thing is that the compiled program from the website DOES load such a model. I can only assume this due to a change in the way the .net framework library works, possibly a bugfix, since according to the C# specification such a constructor(object[]) should indeed not match.

Assuming you are interested in a fix for this (otherwise I'll just fix it in my own fork), what would you prefer?

  1. Remove the array constructors and replace them by explicit arguments, possibly with optional arguments. Seems to be the cleanest, but may lose compatibility with older library versions.
  2. Have two constructors, array and explicit arguments. Compatibility with different CLRs, but also more code to maintain.
  3. Change the LoadModel code to wrap the object array in another object array so there is again a single object[] argument. More a hack than a fix, IMHO, unless there are constructors that really depend on a variable number of arguments.