Skip to content

[Add] Class and Classifier query extension methods and their Handlebars helpers; refs #511 - #515

Merged
samatstariongroup merged 1 commit into
developmentfrom
GH511-class-queries
Oct 11, 2026
Merged

samatstariongroup merged 1 commit into
developmentfrom
GH511-class-queries

Conversation

@samatstariongroup

Copy link
Copy Markdown
Member

Refs #511 (group 1 of 3: Class)

Changes

New extension methods in uml4net.Extensions:

  • IClass.QueryAllNonDerivedProperties(): the properties of QueryAllProperties that are not derived.
  • IClass.QueryAllNonDerivedNonRedefinedProperties(): as above, without the properties that are redefined in the context of the class.
  • IClass.QueryIsSubclassOf(IClass) and IClass.QueryIsSubclassOf(string): whether the class is a direct or indirect subclass. A class is not a subclass of itself. The overload that takes a name compares on the name only, case-sensitive.
  • IClassifier.QueryConformsTo(IType): the operation Classifier::conformsTo of UML 2.5.1, true for the classifier itself and for its direct and indirect general classifiers.
  • IClass.QueryReferencingProperties(): the owned attributes in the model that are typed by the class, searched in the root package, its nested packages and the packages these import. Empty for a class without a root package.
  • IClass.QueryOwnedManyToManyProperties(): the owned attributes for which QueryIsMemberOfManyToMany is true, ordered by name.

New Handlebars helpers in uml4net.HandleBars:

  • Class.QueryAllNonDerivedNonRedefinedProperties, ordered by name
  • Class.QueryIsSubclassOf, with a class or a class name as second argument
  • Class.QueryReferencingProperties
  • Class.QueryOwnedManyToManyProperties
  • Classifier.QueryConformsTo

The existing helper Class.QueryAllNonDerivedProperties now calls the new extension method. Its result is unchanged.

Where the methods come from

uml4net Source Difference with the source
QueryAllNonDerivedProperties SysML2.NET none
QueryAllNonDerivedNonRedefinedProperties SysML2.NET not sorted; the helper sorts by name
QueryIsSubclassOf(IClass) SysML2.NET false for the class itself, where the source returns true
QueryIsSubclassOf(string) EORSADB and mycelium-forge (QueryDerivesFrom) renamed
QueryConformsTo UML 2.5.1 new
QueryReferencingProperties EORSADB and mycelium-forge (QueryAllOppositeReferencesToMe) renamed; behaviour of mycelium-forge. EORSADB follows imports one level deep and also requires QueryIsReferenceProperty.
QueryOwnedManyToManyProperties EORSADB and mycelium-forge ordered with an ordinal comparison

SysML2.NET registers a helper Class.QueryAllNonDerivedNonRedefinedProperties of its own. After upgrading, its registration replaces the one of uml4net if it is made later, so its output does not change until it removes its own.

Tests

  • ClassExtensionsTestFixture: six tests for the new methods, against UML.xmi, including the null and empty arguments.
  • ClassifierExtensionsTestFixture: two tests for QueryConformsTo.
  • ClassHelperTestFixture and ClassifierHelperTestFixture: one test for each new helper, including a wrong context and a wrong number of arguments.
  • Full suite: all 1,173 tests pass.

Not in this pull request

🤖 Generated with Claude Code

@sonarqubecloud

Copy link
Copy Markdown

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