121 feature implement elementextensions#213
121 feature implement elementextensions#213antoineatstariongroup wants to merge 3 commits intodevelopmentfrom
Conversation
| /// </summary> | ||
| /// <param name="name">The name to verifies</param> | ||
| /// <returns><c>true</c> if the name is a basic name, <c>false</c> otherwise</returns> | ||
| public static bool QueryIsBasicName(this string name) |
There was a problem hiding this comment.
rename to QueryIsValidBasicName
| /// <summary> | ||
| /// Provides access to specification defined keywords | ||
| /// </summary> | ||
| public static class Keywords |
There was a problem hiding this comment.
can this be generated you think, or are these only in the PDF document?
| internal static IElement ComputeOwnedMemberElement(this IOwningMembership owningMembershipSubject) | ||
| { | ||
| throw new NotSupportedException("Create a GitHub issue when this method is required"); | ||
| return owningMembershipSubject == null ? throw new ArgumentNullException(nameof(owningMembershipSubject)) : owningMembershipSubject.OwnedRelatedElement.Single(); |
There was a problem hiding this comment.
Single throws an exception if it is not set... is that what you want to happen?
if you do want to throw an exception, i propose we make it an explicit sysml2 related exception basicaly stating the model is incomplete.
| .Where(name => name != null) | ||
| .ToHashSet(StringComparer.Ordinal); | ||
|
|
||
| var importedMembershipsNameFrequency = importedMemberships |
There was a problem hiding this comment.
Null MemberName handling: GroupBy(x => x.MemberName, ...), if MemberName is null, all null-named memberships will be grouped together under a null key. Then on line 221, ToFrozenDictionary(g =>
g.Key, ...) will try to use null as a dictionary key. FrozenDictionary with StringComparer.Ordinal will throw ArgumentNullException if any membership has a null MemberName. You need to filter out null names before the GroupBy, e.g.:
.Where(x => x.MemberName != null)
.GroupBy(x => x.MemberName, StringComparer.Ordinal)
| { | ||
| var name = x.MemberName; | ||
|
|
||
| return !string.IsNullOrWhiteSpace(name) && !ownedMembershipNames.Contains(name) && (!importedMembershipsNameFrequency.TryGetValue(name, out var frequency) || frequency <= 1); |
There was a problem hiding this comment.
The filter !string.IsNullOrWhiteSpace(name) excludes memberships with null/empty names from the result. This means unnamed imported memberships are silently dropped. Is that intentional per the SysML
spec? The spec says to exclude those with "distinguishability collisions" — unnamed memberships arguably don't collide. Worth verifying against the spec.
Prerequisites
Description
Fix #121
Implemented and tested extensions method for Derived Properties and Operations