-
Notifications
You must be signed in to change notification settings - Fork 6
Fix #218: PackageExtension methods implemented #219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
antoineatstariongroup
merged 1 commit into
development
from
218-feature-implement-package-extension-methods
Apr 21, 2026
+93
−9
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ namespace SysML2.NET.Core.POCO.Kernel.Packages | |
| { | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
|
|
||
| using SysML2.NET.Core.POCO.Kernel.Functions; | ||
| using SysML2.NET.Core.POCO.Root.Annotations; | ||
|
|
@@ -37,16 +38,16 @@ internal static class PackageExtensions | |
| /// <summary> | ||
| /// Computes the derived property. | ||
| /// </summary> | ||
| /// <remarks>OCL2: filterCondition = ownedMembership-> selectByKind(ElementFilterMembership).condition </remarks> | ||
| /// <param name="packageSubject"> | ||
| /// The subject <see cref="IPackage"/> | ||
| /// </param> | ||
| /// <returns> | ||
| /// the computed result | ||
| /// </returns> | ||
| [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] | ||
| internal static List<IExpression> ComputeFilterCondition(this IPackage packageSubject) | ||
| { | ||
| throw new NotSupportedException("Create a GitHub issue when this method is required"); | ||
| return packageSubject == null ? throw new ArgumentNullException(nameof(packageSubject)) : [..packageSubject.ownedMembership.OfType<IElementFilterMembership>().Select(x => x.condition)]; | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -61,10 +62,23 @@ internal static List<IExpression> ComputeFilterCondition(this IPackage packageSu | |
| /// <returns> | ||
| /// The expected collection of <see cref="IMembership" /> | ||
| /// </returns> | ||
| [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] | ||
| internal static List<IMembership> ComputeRedefinedImportedMembershipsOperation(this IPackage packageSubject, List<INamespace> excluded) | ||
| { | ||
| throw new NotSupportedException("Create a GitHub issue when this method is required"); | ||
| if (packageSubject == null) | ||
| { | ||
| throw new ArgumentNullException(nameof(packageSubject)); | ||
| } | ||
|
|
||
| var importedMembership= packageSubject.ComputeImportedMembershipsOperation(excluded); | ||
| var filters = packageSubject.ComputeFilterCondition(); | ||
|
|
||
| if (filters.Count == 0) | ||
| { | ||
| return importedMembership; | ||
| } | ||
|
|
||
| var validImportedMembership = importedMembership.Where(membership => filters.All(x => x.CheckCondition(membership))).ToList(); | ||
| return validImportedMembership; | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -79,10 +93,20 @@ internal static List<IMembership> ComputeRedefinedImportedMembershipsOperation(t | |
| /// <returns> | ||
| /// The expected <see cref="bool" /> | ||
| /// </returns> | ||
| [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] | ||
| internal static bool ComputeIncludeAsMemberOperation(this IPackage packageSubject, IElement element) | ||
| { | ||
| throw new NotSupportedException("Create a GitHub issue when this method is required"); | ||
| if (packageSubject == null) | ||
| { | ||
| throw new ArgumentNullException(nameof(packageSubject)); | ||
| } | ||
|
|
||
| if (element == null) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this not throw an exception, or does the spec allow this to be null? |
||
| { | ||
| return false; | ||
| } | ||
|
|
||
| var filters = packageSubject.ComputeFilterCondition(); | ||
| return filters.Count == 0 || filters.All(x => x.CheckCondition(element)); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ComputeRedefinedImportedMembershipsOperation returns the list from
ComputeImportedMembershipsOperation directly when there are no filters (line 77), but returns a fresh
.ToList() in the filtered branch (line 80). Callers mutating the return would mutate the underlying namespace
computation in one branch and not the other. Return .ToList() (or a new
List(importedMembership)) in both branches for consistent ownership semantics