Skip to content

[Feature]: Implementation of MetadataFeatureExtensions.ComputeSyntaxElementOperation #256

@antoineatstariongroup

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

MetadataFeatureExtensions.ComputeSyntaxElementOperation is currently stubbed because the spec body is literally No OCL; the operation requires reflective metamodel infrastructure that the SDK does not yet provide. Issue #154 left this method deferred with a NotSupportedException and a code comment pointing here.

The intent is to mirror the SysML 2 Pilot Implementation (Java) mechanism — ElementAdapter.getMetaclassFeature() + EvaluationUtil.getMetaclassReferenceOf() — adapted to .NET, using a hybrid codegen + runtime cache design.

What has to be done

Three components, suggested as three sequential PRs:

  1. Codegen the standard library skeleton — new generator and Handlebars template under SysML2.NET.CodeGenerator/ that read the existing XMI (Resources/KerML_only_xmi.uml, Resources/SysML_only_xmi.uml) and emit SysML2.NET/Core/AutoGenStandardLibrary/StandardLibrary.cs. Output: a static StandardLibrary.Root exposing a real LibraryPackage graph (KerML::Root, KerML::Core, KerML::Kernel, SysML::Systems, plus Metaobjects, Base, etc.) containing one named metaclass node per metaclass declared in the XMI. Wired with OwningMembership so the existing NamespaceExtensions.ComputeResolveGlobalOperation resolves qualified names like "KerML::Kernel::Class" out of the box. Out of scope: properties, operations, constraints, OCL bodies.

  2. Reflection cache + name resolver under a new SysML2.NET/Core/Reflection/:

    • MetaclassFeatureCache.csConditionalWeakTable<IElement, IMetadataFeature> providing GetOrCreate(IElement) that lazily builds a shadow MetadataFeature wired with a FeatureTyping to the library Metaclass and an Annotation back to the originating element. Mirrors the pilot's ElementAdapter.getMetaclassFeature().
    • MetaclassNameResolver.cs — maps a POCO's runtime type name to a library IMetaclass by trying the same four prefixes used in the pilot (KerML::Root::, KerML::Core::, KerML::Kernel::, SysML::Systems::), anchoring ResolveGlobal at StandardLibrary.Root.
  3. Implement ComputeSyntaxElementOperation at SysML2.NET/Extend/MetadataFeatureExtensions.cs:191 — replace the stub with the pilot's getMetaclassReferenceOf algorithm: for each annotatedElement, return the first one whose cached metaclass-feature is reference-equal to the subject. Remove [ExcludeFromCodeCoverage], keep the <remarks> block verbatim, drop the deferred-implementation comment. Update the fixture to replace VerifyComputeSyntaxElementOperation_ThrowsNotSupportedException with a real roundtrip identity test.

Checklist

  • PR 1: StandardLibraryGenerator + StandardLibrary.hbs + generated StandardLibrary.cs + smoke test asserting StandardLibrary.Root exposes the expected metaclass count and ResolveGlobal("KerML::Kernel::Class") returns a non-null IMetaclass
  • PR 2: MetaclassFeatureCache.cs + MetaclassNameResolver.cs + roundtrip identity unit test
  • PR 3: replace the ComputeSyntaxElementOperation stub in MetadataFeatureExtensions.cs:191; update MetadataFeatureExtensionsTestFixture.cs; tick the corresponding item on issue [Feature]: Implement MetadataFeatureExtensions #154

Out of scope (intentional follow-ups)

  • A real .kerml / .sysml text-file parser for user-loaded libraries (the codegen-emitted standard library covers only the standard library).
  • MetadataAccessExpression.ownedElement and other reflective stubs — MetaclassFeatureCache unblocks them, but each needs its own PR with the right OCL translation.

System Configuration

  • SysML2.NET version: 0.19.0
  • Source file: SysML2.NET/Extend/MetadataFeatureExtensions.cs
  • Reference (Java pilot): org.omg.sysml/src/org/omg/sysml/delegate/invocation/MetadataUsage_syntaxElement_InvocationDelegate.java, org.omg.sysml/src/org/omg/sysml/util/EvaluationUtil.java (lines 285–294), org.omg.sysml/src/org/omg/sysml/util/ElementUtil.java (lines 304–324), org.omg.sysml/src/org/omg/sysml/adapter/ElementAdapter.java (lines 92–109)
  • Blocks: MetadataFeatureExtensions.ComputeSyntaxElementOperation item on issue [Feature]: Implement MetadataFeatureExtensions #154

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions