From 6a1011237506c7031e789aba2bb0c3c9cce38e43 Mon Sep 17 00:00:00 2001 From: TanaseMariusatstarion Date: Thu, 18 Jun 2026 14:49:16 +0200 Subject: [PATCH 1/3] First extension only implementation --- SysML2.NET/Extend/ClassifierExtensions.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SysML2.NET/Extend/ClassifierExtensions.cs b/SysML2.NET/Extend/ClassifierExtensions.cs index cef3bc35..faa6eaa2 100644 --- a/SysML2.NET/Extend/ClassifierExtensions.cs +++ b/SysML2.NET/Extend/ClassifierExtensions.cs @@ -22,6 +22,7 @@ namespace SysML2.NET.Core.POCO.Core.Classifiers { using System; using System.Collections.Generic; + using System.Linq; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Root.Namespaces; @@ -53,10 +54,13 @@ internal static class ClassifierExtensions /// /// the computed result /// - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + /// [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal static List ComputeOwnedSubclassification(this IClassifier classifierSubject) { - throw new NotSupportedException("Create a GitHub issue when this method is required"); + return classifierSubject == null + ? throw new ArgumentNullException(nameof(classifierSubject)) + : [..classifierSubject.ownedSpecialization.OfType()]; + //throw new NotSupportedException("Create a GitHub issue when this method is required"); } } From 299ec9ed40340123f8a47adb543f2db710974a8a Mon Sep 17 00:00:00 2001 From: TanaseMariusatstarion Date: Fri, 19 Jun 2026 18:37:26 +0200 Subject: [PATCH 2/3] Extensions implementation and unit test for classifier --- .../Extend/ClassifierExtensionsTestFixture.cs | 29 ++++++++++++--- SysML2.NET/Extend/ClassifierExtensions.cs | 35 +++++++------------ 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/SysML2.NET.Tests/Extend/ClassifierExtensionsTestFixture.cs b/SysML2.NET.Tests/Extend/ClassifierExtensionsTestFixture.cs index e77764c6..5fa982e8 100644 --- a/SysML2.NET.Tests/Extend/ClassifierExtensionsTestFixture.cs +++ b/SysML2.NET.Tests/Extend/ClassifierExtensionsTestFixture.cs @@ -1,7 +1,7 @@ // ------------------------------------------------------------------------------------------------- // // -// Copyright 2022-2026 Starion Group S.A. +// Copyright (C) 2022-2026 Starion Group S.A. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -21,18 +21,39 @@ namespace SysML2.NET.Tests.Extend { using System; - + using NUnit.Framework; using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Extensions; [TestFixture] public class ClassifierExtensionsTestFixture { [Test] - public void ComputeOwnedSubclassification_ThrowsNotSupportedException() + public void VerifyComputeOwnedSubclassification() { - Assert.That(() => ((IClassifier)null).ComputeOwnedSubclassification(), Throws.TypeOf()); + // Null subject: + Assert.That(() => ((IClassifier)null).ComputeOwnedSubclassification(), Throws.TypeOf()); + + // Empty classifier: + var subject = new Classifier(); + Assert.That(subject.ComputeOwnedSubclassification(), Has.Count.EqualTo(0)); + + var superClassifier = new Classifier(); + + var subclassification = new Subclassification + { + Subclassifier = subject, + Superclassifier = superClassifier + }; + + subject.AssignOwnership(subclassification); + + Assert.That(subject.ComputeOwnedSubclassification(), Is.EquivalentTo([subclassification])); + + //Assert.That(() => ((IClassifier)null).ComputeOwnedSubclassification(), Throws.TypeOf()); } } } diff --git a/SysML2.NET/Extend/ClassifierExtensions.cs b/SysML2.NET/Extend/ClassifierExtensions.cs index faa6eaa2..0ab4c593 100644 --- a/SysML2.NET/Extend/ClassifierExtensions.cs +++ b/SysML2.NET/Extend/ClassifierExtensions.cs @@ -1,20 +1,20 @@ // ------------------------------------------------------------------------------------------------- // -// -// Copyright (C) 2022-2026 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// +// +// Copyright (C) 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// +// // // ------------------------------------------------------------------------------------------------ @@ -24,17 +24,9 @@ namespace SysML2.NET.Core.POCO.Core.Classifiers using System.Collections.Generic; using System.Linq; - using SysML2.NET.Core.Core.Types; - using SysML2.NET.Core.Root.Namespaces; - using SysML2.NET.Core.POCO.Core.Features; - using SysML2.NET.Core.POCO.Core.Types; - using SysML2.NET.Core.POCO.Root.Annotations; - using SysML2.NET.Core.POCO.Root.Elements; - using SysML2.NET.Core.POCO.Root.Namespaces; - /// - /// The class provides extensions methods for - /// the interface + /// The class provides extensions methods for + /// the interface /// internal static class ClassifierExtensions { @@ -49,19 +41,16 @@ internal static class ClassifierExtensions /// /// /// - /// The subject + /// The subject /// /// /// the computed result /// - /// [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal static List ComputeOwnedSubclassification(this IClassifier classifierSubject) { return classifierSubject == null ? throw new ArgumentNullException(nameof(classifierSubject)) : [..classifierSubject.ownedSpecialization.OfType()]; - //throw new NotSupportedException("Create a GitHub issue when this method is required"); } - } } From 7d9b20ac038151f9593468038cc7bc016a260431 Mon Sep 17 00:00:00 2001 From: TanaseMariusatstarion Date: Mon, 22 Jun 2026 09:49:14 +0200 Subject: [PATCH 3/3] Small comment deletion --- SysML2.NET.Tests/Extend/ClassifierExtensionsTestFixture.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/SysML2.NET.Tests/Extend/ClassifierExtensionsTestFixture.cs b/SysML2.NET.Tests/Extend/ClassifierExtensionsTestFixture.cs index 5fa982e8..b2d62527 100644 --- a/SysML2.NET.Tests/Extend/ClassifierExtensionsTestFixture.cs +++ b/SysML2.NET.Tests/Extend/ClassifierExtensionsTestFixture.cs @@ -53,7 +53,6 @@ public void VerifyComputeOwnedSubclassification() Assert.That(subject.ComputeOwnedSubclassification(), Is.EquivalentTo([subclassification])); - //Assert.That(() => ((IClassifier)null).ComputeOwnedSubclassification(), Throws.TypeOf()); } } }