Skip to content

[Add] Handlebars helpers that SysML2.NET, EORSADB and mycelium share; fixes #512 - #518

Merged
samatstariongroup merged 1 commit into
developmentfrom
GH512-shared-helpers
Oct 11, 2026
Merged

samatstariongroup merged 1 commit into
developmentfrom
GH512-shared-helpers

Conversation

@samatstariongroup

Copy link
Copy Markdown
Member

Fixes #512

Changes

New Handlebars helpers in uml4net.HandleBars:

  • Enumeration.WriteLengthLongestLiteral: writes the number of characters of the longest literal name of an enumeration, 0 when it has no named literals.
  • Property.WithClassContext: a block helper that renders its block with a context that holds the property (as property) and the class in the context of which it is used (as classContext).
  • Property.QueryIsTypeAbstract: a helper for the existing extension method QueryIsTypeAbstract.
  • Property.QueryRequiresInitializer: whether the property has a default value that differs from the default of its type.
  • Property.QueryIsCSharpString and Property.QueryIsByte: whether the C# type of the property is string, or byte.

New extension methods in uml4net.Extensions, behind the last three helpers:

  • IProperty.QueryRequiresInitializer(): for a property that is typed by an enumeration the result of QueryIsEnumPropertyWithDefaultValue; for any other property QueryHasDefaultValue and QueryIsDefaultValueDifferentThanDefault.
  • ITypedElement.QueryIsCSharpString() and ITypedElement.QueryIsByte(): compare QueryCSharpTypeName with string and byte, after the C# type mapping, whatever the kind of the type. QueryIsString is not changed; it requires a primitive type that is named string.

Where the helpers come from

uml4net Source Difference with the source
Enumeration.WriteLengthLongestLiteral SysML2.NET and mycelium-forge accepts any IEnumeration; a wrong argument gives a HandlebarsException, where SysML2.NET fails with a null reference
Property.WithClassContext SysML2.NET and mycelium-sdk (withPropertyClassContext) renamed; the names property and classContext inside the block are the same
Property.QueryIsTypeAbstract SysML2.NET (Property.IsTypeAbstract) renamed
Property.QueryRequiresInitializer SysML2.NET (Property.QueryHasDefaultValueWithDifferentValueThanDefault) renamed
Property.QueryIsCSharpString mycelium-forge, and EORSADB as Property.QueryActsAsString EORSADB compares without regard to case
Property.QueryIsByte mycelium-forge none

The helpers that were rejected and the three that moved to #513 are listed in the comment on #512.

Tests

  • PropertyExtensionsTestFixture and TypedElementExtensionsTestFixture: one test each for the new extension methods, including the null argument and the C# type mapping.
  • PropertyHelperTestFixture: four tests for the five property helpers, including a wrong argument and a wrong number of arguments.
  • EnumHelperTestFixture: one test for Enumeration.WriteLengthLongestLiteral.
  • Full suite: all 1,190 tests pass.

Not in this pull request

The entries for the six helpers on the wiki page UML Handlebars Helpers, to be added when this is released.

🤖 Generated with Claude Code

… with the extension methods behind them; fixes #512
@sonarqubecloud

Copy link
Copy Markdown

@samatstariongroup
samatstariongroup merged commit 46544e2 into development Oct 11, 2026
8 checks passed
@samatstariongroup
samatstariongroup deleted the GH512-shared-helpers branch October 12, 2026 16:40
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.

[Feature]: Move general and duplicated Handlebars helpers from SysML2.NET, EORSADB and mycelium into uml4net.HandleBars

1 participant