Skip to content

Commit 741f75e

Browse files
[Add] generator and generated DTO Comparer classes; fixes #60
[Add] GuidSequenceEquality, StringSequenceEquality, FloatingPointComparer
1 parent ea2f6a8 commit 741f75e

File tree

199 files changed

+27831
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+27831
-1
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
// -------------------------------------------------------------------------------------------------
2+
// <copyright file="AnnotatingElementComparer.cs" company="Starion Group S.A.">
3+
//
4+
// Copyright (C) 2022-2026 Starion Group S.A.
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// </copyright>
19+
// ------------------------------------------------------------------------------------------------
20+
21+
// ------------------------------------------------------------------------------------------------
22+
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
23+
// ------------------------------------------------------------------------------------------------
24+
25+
namespace SysML2.NET.Extensions.Core.DTO.Comparers
26+
{
27+
using System;
28+
using System.CodeDom.Compiler;
29+
using System.Collections.Generic;
30+
31+
using SysML2.NET.Core.DTO.Root.Annotations;
32+
using SysML2.NET.Extensions.Comparers;
33+
34+
/// <summary>
35+
/// Provides an equality comparison for <see cref="IAnnotatingElement"/> instances
36+
/// based on their semantic content rather than object reference identity.
37+
/// </summary>
38+
/// <remarks>
39+
/// This comparer is intended for use in deserialization, testing, and model
40+
/// validation scenarios where two <see cref="IAnnotatingElement"/> instances
41+
/// originating from different sources (e.g. JSON and MessagePack) must be
42+
/// considered equal if they represent the same SysML v2 model element.
43+
/// </remarks>
44+
[GeneratedCode("SysML2.NET", "latest")]
45+
public sealed class AnnotatingElementComparer : IEqualityComparer<IAnnotatingElement>
46+
{
47+
/// <summary>
48+
/// The <see cref="StringComparer"/> used for all string comparisons performed
49+
/// by this comparer.
50+
/// </summary>
51+
/// <remarks>
52+
/// <see cref="StringComparer.Ordinal"/> is used to ensure culture-independent,
53+
/// deterministic comparison semantics suitable for identifiers and
54+
/// model-level string values.
55+
/// </remarks>
56+
private static readonly StringComparer OrdinalStringComparer = StringComparer.Ordinal;
57+
58+
/// <summary>
59+
/// Determines whether two <see cref="IAnnotatingElement"/> instances are equal.
60+
/// </summary>
61+
/// <param name="x">
62+
/// The first <see cref="IAnnotatingElement"/> to compare.
63+
/// </param>
64+
/// <param name="y">
65+
/// The second <see cref="IAnnotatingElement"/> to compare.
66+
/// </param>
67+
/// <returns>
68+
/// <c>true</c> if both instances represent the same <see cref="IAnnotatingElement"/>
69+
/// according to their semantic content; otherwise, <c>false</c>.
70+
/// </returns>
71+
/// <remarks>
72+
/// This method performs a deep, deterministic comparison of all relevant
73+
/// properties, ignoring object reference identity and any transient or
74+
/// derived state.
75+
/// </remarks>
76+
public bool Equals(IAnnotatingElement x, IAnnotatingElement y)
77+
{
78+
if (ReferenceEquals(x, y)) return true;
79+
80+
if (x is null || y is null) return false;
81+
82+
if (x.Id != y.Id) return false;
83+
84+
if (!StringSequenceEquality.OrderedEqual(x.AliasIds, y.AliasIds)) return false;
85+
86+
if (!OrdinalStringComparer.Equals(x.DeclaredName, y.DeclaredName)) return false;
87+
88+
if (!OrdinalStringComparer.Equals(x.DeclaredShortName, y.DeclaredShortName)) return false;
89+
90+
if (!OrdinalStringComparer.Equals(x.ElementId, y.ElementId)) return false;
91+
92+
if (x.IsImpliedIncluded != y.IsImpliedIncluded) return false;
93+
94+
if (!GuidSequenceEquality.OrderedEqual(x.OwnedRelationship, y.OwnedRelationship)) return false;
95+
96+
if (x.OwningRelationship != y.OwningRelationship) return false;
97+
98+
return true;
99+
}
100+
101+
/// <summary>
102+
/// Returns a hash code for the specified <see cref="IAnnotatingElement"/>.
103+
/// </summary>
104+
/// <param name="obj">
105+
/// The <see cref="IAnnotatingElement"/> for which a hash code is to be returned.
106+
/// </param>
107+
/// <returns>
108+
/// A hash code based on the stable identity of the element.
109+
/// </returns>
110+
/// <remarks>
111+
/// The hash code is intentionally derived from the element identity only,
112+
/// ensuring stability and compatibility with collection-based equality
113+
/// checks
114+
/// </remarks>
115+
public int GetHashCode(IAnnotatingElement obj)
116+
{
117+
return HashCode.Combine(typeof(IAnnotatingElement), obj.Id);
118+
}
119+
}
120+
}
121+
122+
// ------------------------------------------------------------------------------------------------
123+
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
124+
// ------------------------------------------------------------------------------------------------
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
// -------------------------------------------------------------------------------------------------
2+
// <copyright file="AssociationComparer.cs" company="Starion Group S.A.">
3+
//
4+
// Copyright (C) 2022-2026 Starion Group S.A.
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// </copyright>
19+
// ------------------------------------------------------------------------------------------------
20+
21+
// ------------------------------------------------------------------------------------------------
22+
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
23+
// ------------------------------------------------------------------------------------------------
24+
25+
namespace SysML2.NET.Extensions.Core.DTO.Comparers
26+
{
27+
using System;
28+
using System.CodeDom.Compiler;
29+
using System.Collections.Generic;
30+
31+
using SysML2.NET.Core.DTO.Kernel.Associations;
32+
using SysML2.NET.Extensions.Comparers;
33+
34+
/// <summary>
35+
/// Provides an equality comparison for <see cref="IAssociation"/> instances
36+
/// based on their semantic content rather than object reference identity.
37+
/// </summary>
38+
/// <remarks>
39+
/// This comparer is intended for use in deserialization, testing, and model
40+
/// validation scenarios where two <see cref="IAssociation"/> instances
41+
/// originating from different sources (e.g. JSON and MessagePack) must be
42+
/// considered equal if they represent the same SysML v2 model element.
43+
/// </remarks>
44+
[GeneratedCode("SysML2.NET", "latest")]
45+
public sealed class AssociationComparer : IEqualityComparer<IAssociation>
46+
{
47+
/// <summary>
48+
/// The <see cref="StringComparer"/> used for all string comparisons performed
49+
/// by this comparer.
50+
/// </summary>
51+
/// <remarks>
52+
/// <see cref="StringComparer.Ordinal"/> is used to ensure culture-independent,
53+
/// deterministic comparison semantics suitable for identifiers and
54+
/// model-level string values.
55+
/// </remarks>
56+
private static readonly StringComparer OrdinalStringComparer = StringComparer.Ordinal;
57+
58+
/// <summary>
59+
/// Determines whether two <see cref="IAssociation"/> instances are equal.
60+
/// </summary>
61+
/// <param name="x">
62+
/// The first <see cref="IAssociation"/> to compare.
63+
/// </param>
64+
/// <param name="y">
65+
/// The second <see cref="IAssociation"/> to compare.
66+
/// </param>
67+
/// <returns>
68+
/// <c>true</c> if both instances represent the same <see cref="IAssociation"/>
69+
/// according to their semantic content; otherwise, <c>false</c>.
70+
/// </returns>
71+
/// <remarks>
72+
/// This method performs a deep, deterministic comparison of all relevant
73+
/// properties, ignoring object reference identity and any transient or
74+
/// derived state.
75+
/// </remarks>
76+
public bool Equals(IAssociation x, IAssociation y)
77+
{
78+
if (ReferenceEquals(x, y)) return true;
79+
80+
if (x is null || y is null) return false;
81+
82+
if (x.Id != y.Id) return false;
83+
84+
if (!StringSequenceEquality.OrderedEqual(x.AliasIds, y.AliasIds)) return false;
85+
86+
if (!OrdinalStringComparer.Equals(x.DeclaredName, y.DeclaredName)) return false;
87+
88+
if (!OrdinalStringComparer.Equals(x.DeclaredShortName, y.DeclaredShortName)) return false;
89+
90+
if (!OrdinalStringComparer.Equals(x.ElementId, y.ElementId)) return false;
91+
92+
if (x.IsAbstract != y.IsAbstract) return false;
93+
94+
if (x.IsImplied != y.IsImplied) return false;
95+
96+
if (x.IsImpliedIncluded != y.IsImpliedIncluded) return false;
97+
98+
if (x.IsSufficient != y.IsSufficient) return false;
99+
100+
if (!GuidSequenceEquality.OrderedEqual(x.OwnedRelatedElement, y.OwnedRelatedElement)) return false;
101+
102+
if (!GuidSequenceEquality.OrderedEqual(x.OwnedRelationship, y.OwnedRelationship)) return false;
103+
104+
if (x.OwningRelatedElement != y.OwningRelatedElement) return false;
105+
106+
if (x.OwningRelationship != y.OwningRelationship) return false;
107+
108+
return true;
109+
}
110+
111+
/// <summary>
112+
/// Returns a hash code for the specified <see cref="IAssociation"/>.
113+
/// </summary>
114+
/// <param name="obj">
115+
/// The <see cref="IAssociation"/> for which a hash code is to be returned.
116+
/// </param>
117+
/// <returns>
118+
/// A hash code based on the stable identity of the element.
119+
/// </returns>
120+
/// <remarks>
121+
/// The hash code is intentionally derived from the element identity only,
122+
/// ensuring stability and compatibility with collection-based equality
123+
/// checks
124+
/// </remarks>
125+
public int GetHashCode(IAssociation obj)
126+
{
127+
return HashCode.Combine(typeof(IAssociation), obj.Id);
128+
}
129+
}
130+
}
131+
132+
// ------------------------------------------------------------------------------------------------
133+
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
134+
// ------------------------------------------------------------------------------------------------
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
// -------------------------------------------------------------------------------------------------
2+
// <copyright file="DependencyComparer.cs" company="Starion Group S.A.">
3+
//
4+
// Copyright (C) 2022-2026 Starion Group S.A.
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// </copyright>
19+
// ------------------------------------------------------------------------------------------------
20+
21+
// ------------------------------------------------------------------------------------------------
22+
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
23+
// ------------------------------------------------------------------------------------------------
24+
25+
namespace SysML2.NET.Extensions.Core.DTO.Comparers
26+
{
27+
using System;
28+
using System.CodeDom.Compiler;
29+
using System.Collections.Generic;
30+
31+
using SysML2.NET.Core.DTO.Root.Dependencies;
32+
using SysML2.NET.Extensions.Comparers;
33+
34+
/// <summary>
35+
/// Provides an equality comparison for <see cref="IDependency"/> instances
36+
/// based on their semantic content rather than object reference identity.
37+
/// </summary>
38+
/// <remarks>
39+
/// This comparer is intended for use in deserialization, testing, and model
40+
/// validation scenarios where two <see cref="IDependency"/> instances
41+
/// originating from different sources (e.g. JSON and MessagePack) must be
42+
/// considered equal if they represent the same SysML v2 model element.
43+
/// </remarks>
44+
[GeneratedCode("SysML2.NET", "latest")]
45+
public sealed class DependencyComparer : IEqualityComparer<IDependency>
46+
{
47+
/// <summary>
48+
/// The <see cref="StringComparer"/> used for all string comparisons performed
49+
/// by this comparer.
50+
/// </summary>
51+
/// <remarks>
52+
/// <see cref="StringComparer.Ordinal"/> is used to ensure culture-independent,
53+
/// deterministic comparison semantics suitable for identifiers and
54+
/// model-level string values.
55+
/// </remarks>
56+
private static readonly StringComparer OrdinalStringComparer = StringComparer.Ordinal;
57+
58+
/// <summary>
59+
/// Determines whether two <see cref="IDependency"/> instances are equal.
60+
/// </summary>
61+
/// <param name="x">
62+
/// The first <see cref="IDependency"/> to compare.
63+
/// </param>
64+
/// <param name="y">
65+
/// The second <see cref="IDependency"/> to compare.
66+
/// </param>
67+
/// <returns>
68+
/// <c>true</c> if both instances represent the same <see cref="IDependency"/>
69+
/// according to their semantic content; otherwise, <c>false</c>.
70+
/// </returns>
71+
/// <remarks>
72+
/// This method performs a deep, deterministic comparison of all relevant
73+
/// properties, ignoring object reference identity and any transient or
74+
/// derived state.
75+
/// </remarks>
76+
public bool Equals(IDependency x, IDependency y)
77+
{
78+
if (ReferenceEquals(x, y)) return true;
79+
80+
if (x is null || y is null) return false;
81+
82+
if (x.Id != y.Id) return false;
83+
84+
if (!StringSequenceEquality.OrderedEqual(x.AliasIds, y.AliasIds)) return false;
85+
86+
if (!GuidSequenceEquality.OrderedEqual(x.Client, y.Client)) return false;
87+
88+
if (!OrdinalStringComparer.Equals(x.DeclaredName, y.DeclaredName)) return false;
89+
90+
if (!OrdinalStringComparer.Equals(x.DeclaredShortName, y.DeclaredShortName)) return false;
91+
92+
if (!OrdinalStringComparer.Equals(x.ElementId, y.ElementId)) return false;
93+
94+
if (x.IsImplied != y.IsImplied) return false;
95+
96+
if (x.IsImpliedIncluded != y.IsImpliedIncluded) return false;
97+
98+
if (!GuidSequenceEquality.OrderedEqual(x.OwnedRelatedElement, y.OwnedRelatedElement)) return false;
99+
100+
if (!GuidSequenceEquality.OrderedEqual(x.OwnedRelationship, y.OwnedRelationship)) return false;
101+
102+
if (x.OwningRelatedElement != y.OwningRelatedElement) return false;
103+
104+
if (x.OwningRelationship != y.OwningRelationship) return false;
105+
106+
if (!GuidSequenceEquality.OrderedEqual(x.Supplier, y.Supplier)) return false;
107+
108+
return true;
109+
}
110+
111+
/// <summary>
112+
/// Returns a hash code for the specified <see cref="IDependency"/>.
113+
/// </summary>
114+
/// <param name="obj">
115+
/// The <see cref="IDependency"/> for which a hash code is to be returned.
116+
/// </param>
117+
/// <returns>
118+
/// A hash code based on the stable identity of the element.
119+
/// </returns>
120+
/// <remarks>
121+
/// The hash code is intentionally derived from the element identity only,
122+
/// ensuring stability and compatibility with collection-based equality
123+
/// checks
124+
/// </remarks>
125+
public int GetHashCode(IDependency obj)
126+
{
127+
return HashCode.Combine(typeof(IDependency), obj.Id);
128+
}
129+
}
130+
}
131+
132+
// ------------------------------------------------------------------------------------------------
133+
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
134+
// ------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)