Skip to content

[Feature]: Expose notation-preference settings on TextualNotationWriterContext #359

Description

@antoineatstariongroup

What type of issue is this?

  • Bug report
  • Feature request

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of the SysML2.NET
  • I have searched open and closed issues to ensure it has not already been reported

Description

The writer hard-codes four notation choices the spec does not rank. Expose each as a setting on
SysML2.NET.Serializer.TextualNotation/Writers/TextualNotationWriterContext.cs, alongside the
existing EmitOperatorParentheses, defaulted to current behaviour so no baseline moves.

1. PreferDeclaredNameForRequirements — emit : MassLimitationRequirement, not : '1'.
Fix site: QueryPreferredRawName in Writers/NameResolutionCache.cs. Must be scoped to
RequirementDefinition/RequirementUsage — a global flip was reverted in folder 09 (breaks
kgkilogram).

2. PreferAliasNames — emit PlaneAngleValue, not AngularMeasureValue. Does not fit
QueryPreferredRawName (an alias is a memberName on another Membership); lands in the index
build. Needs a tie-break (21 library targets have 2 aliases), a visibility check, and a
qualified-name fallback (an alias never appears in qualifiedName).

3. EmitOptionalKeywords — emit or omit the keywords the grammar spells as an OPTIONAL BARE
terminal: EnumeratedValue = 'enum'? Usage, MetadataBodyUsage = 'ref'? ( ':>>' | 'redefines' )? …,
and the KerML 'feature'? / 'of'? / 'first'? productions (6 sites across both grammars, all
found by '…' ? with no ?=). Such a terminal sets no property, so nothing in the abstract syntax
records whether the author wrote it and both spellings re-parse to the identical model —
enum e1;e1;, ref :>> x:>> x.

4. PreferKeywordOverSymbol — emit the word form instead of the symbolic form where the lexical
rules define both, e.g. subsets for :>, redefines for :>>, references for ::>,
specializes for :> on a Specialization, defined by for : in a FeatureTyping. The
SUBSETS = ':>' | 'subsets'-style productions make the two spellings pure synonyms — same token,
same model — so this is presentational only.

Tasks:

  • Add all four settings, default = current behaviour
  • Thread setting 1 into QueryPreferredRawName, metaclass-scoped
  • Specify + implement alias tie-break, visibility, fallback
  • Honour RuleElement.IsOptional in the generator's TerminalElement arm, gated on setting 3
  • Route symbolic/keyword operator literals through one setting-aware helper for setting 4
  • Verify defaults leave validation folders byte-identical
  • Add a [TestCase] per non-default setting with its own Expected/ variant
  • textual-notation-reviewer pass

Steps to Reproduce

N/A — feature request.

System Configuration

  • SysML2.NET version: 0.23.0
  • Environment: n/a
  • .NET Framework version: n/a

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions