Repository navigation
[Add] Handlebars helpers that SysML2.NET, EORSADB and mycelium share; fixes #512 - #518
Merged
Merged
Conversation
… with the extension methods behind them; fixes #512
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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 (asproperty) and the class in the context of which it is used (asclassContext).Property.QueryIsTypeAbstract: a helper for the existing extension methodQueryIsTypeAbstract.Property.QueryRequiresInitializer: whether the property has a default value that differs from the default of its type.Property.QueryIsCSharpStringandProperty.QueryIsByte: whether the C# type of the property isstring, orbyte.New extension methods in
uml4net.Extensions, behind the last three helpers:IProperty.QueryRequiresInitializer(): for a property that is typed by an enumeration the result ofQueryIsEnumPropertyWithDefaultValue; for any other propertyQueryHasDefaultValueandQueryIsDefaultValueDifferentThanDefault.ITypedElement.QueryIsCSharpString()andITypedElement.QueryIsByte(): compareQueryCSharpTypeNamewithstringandbyte, after the C# type mapping, whatever the kind of the type.QueryIsStringis not changed; it requires a primitive type that is named string.Where the helpers come from
Enumeration.WriteLengthLongestLiteralIEnumeration; a wrong argument gives aHandlebarsException, where SysML2.NET fails with a null referenceProperty.WithClassContextwithPropertyClassContext)propertyandclassContextinside the block are the sameProperty.QueryIsTypeAbstractProperty.IsTypeAbstract)Property.QueryRequiresInitializerProperty.QueryHasDefaultValueWithDifferentValueThanDefault)Property.QueryIsCSharpStringProperty.QueryActsAsStringProperty.QueryIsByteThe helpers that were rejected and the three that moved to #513 are listed in the comment on #512.
Tests
PropertyExtensionsTestFixtureandTypedElementExtensionsTestFixture: 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 forEnumeration.WriteLengthLongestLiteral.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