Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#4043 closed defect (fixed)

The uses annotation should not be set by default in each individual model

Reported by: Francesco Casella Owned by: Adeel Asghar
Priority: blocker Milestone:
Component: OMEdit Version: v1.10.0-dev-nightly
Keywords: Cc:

Description

If I create a package P containing a package Q, and then one model M inside Q, and then drag and drop an instance of model M2 inside M, a uses annotation referring to the version of package P2 containing M2 is automatically generated inside M.

This is definitely not a good idea from the point of view of the future maintenance of package P. For example, when a new version of the MSL is rolled out, it will be necessary to change each and every single uses(Modelica) annotation inside each model contained in package P. Packages created with the current version of OMEdit will thus be infested with redundant, possibly inconsistent uses annotations, which will then have to be removed or updated manually in the source code. Most non-advanced users will not be aware of this mess, further increasing the confusion when they will be asked weird questions about wrong library versions being loaded.

As a default, it would make a lot more sense to put the uses annotation on package P, rather than on each single model, so that it can just be changed once, if and when this is appropriate. In general, it is a good design principle that all models of a top-level package P use the same versions of other packages, that is to say, that the dependencies relations are package-to-package, not model-to-package.

It is of course possible that, e.g., package P contains some models using MSL 3.2.1 and others using MSL 3.2.2, as the specification allows this. However, I would consider this as a special case, not as the default.

I would then suggest the following behaviour

  • when a model M2 is dragged into a model M contained within the top-level package P, a uses annotation referring to the package P2 containing M2 is added to package P, not to model M
  • if such a uses annotation is already there with the same version number, nothing is done
  • if such a uses annotation is already there but with a different version number, the user is asked the following question: "Package P already uses version xxx of package P2. The model you are adding to M uses version yyy instead. Do you want to update the uses annotation in package P? If the answer is yes, the uses annotation in P is updated to the current version of P2, otherwise a uses annotation is added to model M. In fact, we should also run a conversion script in this case, once they are standardized and OMC starts supporting them
  • one more item is added to OMEdit|Options|Libraries: "Set uses annotation on individual models", which corresponds to the current behaviour. By default, this is disabled.

Change History (3)

comment:1 by Francesco Casella, 8 years ago

Milestone: Future1.10.0

comment:2 by Adeel Asghar, 8 years ago

Resolution: fixed
Status: newclosed

Fixed in 489670a/OMEdit.
The uses annotation is only added to the top level class.

comment:3 by Martin Sjölund, 7 years ago

Milestone: 1.10.0

Milestone deleted

Note: See TracTickets for help on using tickets.