From 731ffb67a8c8874beb6cb62251fa032d3f7d1c46 Mon Sep 17 00:00:00 2001 From: atheate Date: Fri, 2 Oct 2026 10:08:04 +0200 Subject: [PATCH 1/2] Add PagedResult and namespace harmonization --- .editorconfig | 12 +- SySML2.NET.REST/IRestClient.cs | 16 +- SySML2.NET.REST/RestClient.cs | 22 +- SysML2.NET.Serializer.Json/DeSerializer.cs | 1 + SysML2.NET.Serializer.Json/IDeSerializer.cs | 11 +- SysML2.NET.Serializer.Json/ISerializer.cs | 11 +- .../PSM/ConstraintValueReader.cs | 1 + .../PSM/DeSerializeRequestDelegate.cs | 1 + .../PSM/DeSerializeResponseDelegate.cs | 1 + .../PSM/PsmDeSerializationDispatcher.cs | 1 + SysML2.NET.Serializer.Json/Serializer.cs | 15 +- .../PSM/PagedResultTestFixture.cs | 67 ++++++ SysML2.NET/PSM/{ => DTO}/ConstraintValue.cs | 0 .../PSM/{ => DTO}/ConstraintValueKind.cs | 0 SysML2.NET/PSM/{ => DTO}/IRequest.cs | 0 SysML2.NET/PSM/{ => DTO}/IResponse.cs | 0 SysML2.NET/PSM/Page.cs | 51 ++++ SysML2.NET/PSM/PagedResult.cs | 61 +++++ SysML2.NET/{PIM => PSM}/QueryParameters.cs | 219 ++++++++---------- 19 files changed, 327 insertions(+), 163 deletions(-) create mode 100644 SysML2.NET.Tests/PSM/PagedResultTestFixture.cs rename SysML2.NET/PSM/{ => DTO}/ConstraintValue.cs (100%) rename SysML2.NET/PSM/{ => DTO}/ConstraintValueKind.cs (100%) rename SysML2.NET/PSM/{ => DTO}/IRequest.cs (100%) rename SysML2.NET/PSM/{ => DTO}/IResponse.cs (100%) create mode 100644 SysML2.NET/PSM/Page.cs create mode 100644 SysML2.NET/PSM/PagedResult.cs rename SysML2.NET/{PIM => PSM}/QueryParameters.cs (76%) diff --git a/.editorconfig b/.editorconfig index bdcd41aff..2475d4b1f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,25 +6,29 @@ indent_size = 4 [*.cs] -#### 1. Layout & wrapping — Rider: WRAP_LIMIT, WRAP_LINES, LINE_FEED_AT_FILE_END, PLACE_COMMENTS_AT_FIRST_COLUMN, MAX_ENUM_MEMBERS_ON_LINE +#### 1. Layout & wrapping — Rider: WRAP_LIMIT, WRAP_LINES, LINE_FEED_AT_FILE_END, PLACE_COMMENTS_AT_FIRST_COLUMN, MAX_ENUM_MEMBERS_ON_LINE, WRAP_OBJECT_AND_COLLECTION_INITIALIZER_STYLE, WRAP_ARRAY_INITIALIZER_STYLE indent_style = space indent_size = 4 tab_width = 4 insert_final_newline = true trim_trailing_whitespace = true max_line_length = 180 -resharper_wrap_lines = false +resharper_wrap_lines = true resharper_place_comments_at_first_column = true resharper_max_enum_members_on_line = 1 resharper_place_accessorholder_attribute_on_same_line = never +resharper_wrap_object_and_collection_initializer_style = wrap_if_long +resharper_wrap_array_initializer_style = wrap_if_long +resharper_place_simple_initializer_on_single_line = true +resharper_max_initializer_elements_on_line = 100 #### 2. Braces — Allman, and required on every control statement (Rider: BRACES_FOR_IFELSE/_FOR/_FOREACH/_WHILE = Required) csharp_new_line_before_open_brace = all csharp_new_line_before_else = true csharp_new_line_before_catch = true csharp_new_line_before_finally = true -csharp_new_line_before_members_in_object_initializers = true -csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = false +csharp_new_line_before_members_in_anonymous_types = false csharp_new_line_between_query_expression_clauses = true csharp_prefer_braces = true:warning resharper_braces_for_ifelse = required diff --git a/SySML2.NET.REST/IRestClient.cs b/SySML2.NET.REST/IRestClient.cs index 6ea93e07b..3cffc469f 100644 --- a/SySML2.NET.REST/IRestClient.cs +++ b/SySML2.NET.REST/IRestClient.cs @@ -1,20 +1,20 @@ // ------------------------------------------------------------------------------------------------- // -// +// // Copyright 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,9 +24,9 @@ namespace SySML2.NET.REST using System.Collections.Generic; using System.Threading.Tasks; using System.Threading; - - using SysML2.NET.PIM; - using SysML2.NET.PIM.DTO; + + using SysML2.NET.PSM; + using SysML2.NET.PSM.DTO; using SysML2.NET.Core.DTO.Root.Elements; /// diff --git a/SySML2.NET.REST/RestClient.cs b/SySML2.NET.REST/RestClient.cs index db8d8c3df..880f25182 100644 --- a/SySML2.NET.REST/RestClient.cs +++ b/SySML2.NET.REST/RestClient.cs @@ -1,20 +1,20 @@ // ------------------------------------------------------------------------------------------------- // -// +// // Copyright 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. -// +// // // ------------------------------------------------------------------------------------------------ @@ -30,10 +30,10 @@ namespace SySML2.NET.REST using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; - using SysML2.NET.PIM; - using SysML2.NET.PIM.DTO; + using SysML2.NET.PSM; using SysML2.NET.Common; using SysML2.NET.Core.DTO.Root.Elements; + using SysML2.NET.PSM.DTO; using SysML2.NET.Serializer.Json; /// @@ -113,7 +113,7 @@ public async Task> Open(string username, string password, s try { this.baseUri = uri; - + var projects = await this.RequestProjects(null, null, cancellationToken); return projects; } @@ -157,7 +157,7 @@ public async Task> RequestProjects(Guid? project, QueryPara var requestUri = project == null ? new Uri($"{this.baseUri}/projects{queryParameters}") : new Uri($"{this.baseUri}/projects/{project}{queryParameters}"); var data = await this.RequestData(requestUri, cancellationToken); - + if (data != null && data.Any()) { return data.OfType(); @@ -336,7 +336,7 @@ public async Task> RequestElements(Guid project, Guid comm } return Enumerable.Empty(); - + } /// @@ -406,7 +406,7 @@ private async Task> RequestData(Uri requestUri, Cancell Method = HttpMethod.Get, RequestUri = requestUri, }; - + using var response = await this.httpClient.SendAsync(requestMessage, HttpCompletionOption.ResponseHeadersRead, cancellationToken); response.EnsureSuccessStatusCode(); diff --git a/SysML2.NET.Serializer.Json/DeSerializer.cs b/SysML2.NET.Serializer.Json/DeSerializer.cs index 45056f4a0..afef965a3 100644 --- a/SysML2.NET.Serializer.Json/DeSerializer.cs +++ b/SysML2.NET.Serializer.Json/DeSerializer.cs @@ -34,6 +34,7 @@ namespace SysML2.NET.Serializer.Json using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.PSM; using SysML2.NET.PSM.DTO; using SysML2.NET.Serializer.Json.Core.DTO; using SysML2.NET.Serializer.Json.PIM.DTO; diff --git a/SysML2.NET.Serializer.Json/IDeSerializer.cs b/SysML2.NET.Serializer.Json/IDeSerializer.cs index 820cea3a1..38fc1f0ee 100644 --- a/SysML2.NET.Serializer.Json/IDeSerializer.cs +++ b/SysML2.NET.Serializer.Json/IDeSerializer.cs @@ -1,20 +1,20 @@ // ------------------------------------------------------------------------------------------------- // -// +// // Copyright 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. -// +// // // ------------------------------------------------------------------------------------------------ @@ -26,6 +26,7 @@ namespace SysML2.NET.Serializer.Json using System.Threading.Tasks; using SysML2.NET.Common; + using SysML2.NET.PSM; using SysML2.NET.PSM.DTO; /// diff --git a/SysML2.NET.Serializer.Json/ISerializer.cs b/SysML2.NET.Serializer.Json/ISerializer.cs index 11436fb65..7820f0fc0 100644 --- a/SysML2.NET.Serializer.Json/ISerializer.cs +++ b/SysML2.NET.Serializer.Json/ISerializer.cs @@ -1,20 +1,20 @@ // ------------------------------------------------------------------------------------------------- // -// +// // Copyright 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. -// +// // // ------------------------------------------------------------------------------------------------ @@ -27,6 +27,7 @@ namespace SysML2.NET.Serializer.Json using System.Threading.Tasks; using SysML2.NET.Common; + using SysML2.NET.PSM; using SysML2.NET.PSM.DTO; /// diff --git a/SysML2.NET.Serializer.Json/PSM/ConstraintValueReader.cs b/SysML2.NET.Serializer.Json/PSM/ConstraintValueReader.cs index 0659e4e1c..c494eda40 100644 --- a/SysML2.NET.Serializer.Json/PSM/ConstraintValueReader.cs +++ b/SysML2.NET.Serializer.Json/PSM/ConstraintValueReader.cs @@ -22,6 +22,7 @@ namespace SysML2.NET.Serializer.Json.PSM { using System.Text.Json; + using SysML2.NET.PSM; using SysML2.NET.PSM.DTO; using SysML2.NET.Serializer.Json.Utility; diff --git a/SysML2.NET.Serializer.Json/PSM/DeSerializeRequestDelegate.cs b/SysML2.NET.Serializer.Json/PSM/DeSerializeRequestDelegate.cs index 9bc0a32bd..24aceca34 100644 --- a/SysML2.NET.Serializer.Json/PSM/DeSerializeRequestDelegate.cs +++ b/SysML2.NET.Serializer.Json/PSM/DeSerializeRequestDelegate.cs @@ -24,6 +24,7 @@ namespace SysML2.NET.Serializer.Json.PSM using Microsoft.Extensions.Logging; + using SysML2.NET.PSM; using SysML2.NET.PSM.DTO; /// diff --git a/SysML2.NET.Serializer.Json/PSM/DeSerializeResponseDelegate.cs b/SysML2.NET.Serializer.Json/PSM/DeSerializeResponseDelegate.cs index efe92c455..2663d90bd 100644 --- a/SysML2.NET.Serializer.Json/PSM/DeSerializeResponseDelegate.cs +++ b/SysML2.NET.Serializer.Json/PSM/DeSerializeResponseDelegate.cs @@ -24,6 +24,7 @@ namespace SysML2.NET.Serializer.Json.PSM using Microsoft.Extensions.Logging; + using SysML2.NET.PSM; using SysML2.NET.PSM.DTO; /// diff --git a/SysML2.NET.Serializer.Json/PSM/PsmDeSerializationDispatcher.cs b/SysML2.NET.Serializer.Json/PSM/PsmDeSerializationDispatcher.cs index 193721f77..a53a3821f 100644 --- a/SysML2.NET.Serializer.Json/PSM/PsmDeSerializationDispatcher.cs +++ b/SysML2.NET.Serializer.Json/PSM/PsmDeSerializationDispatcher.cs @@ -26,6 +26,7 @@ namespace SysML2.NET.Serializer.Json.PSM using Microsoft.Extensions.Logging; using SysML2.NET.Common; + using SysML2.NET.PSM; using SysML2.NET.PSM.DTO; using SysML2.NET.Serializer.Json.Utility; diff --git a/SysML2.NET.Serializer.Json/Serializer.cs b/SysML2.NET.Serializer.Json/Serializer.cs index 9fb0ab404..8a8d5aff1 100644 --- a/SysML2.NET.Serializer.Json/Serializer.cs +++ b/SysML2.NET.Serializer.Json/Serializer.cs @@ -1,20 +1,20 @@ // ------------------------------------------------------------------------------------------------- // -// +// // Copyright 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. -// +// // // ------------------------------------------------------------------------------------------------ @@ -25,9 +25,10 @@ namespace SysML2.NET.Serializer.Json using System.Text.Json; using System.Threading; using System.Threading.Tasks; - + using SysML2.NET.Common; using SysML2.NET.Core.DTO.Root.Elements; + using SysML2.NET.PSM; using SysML2.NET.PSM.DTO; using SysML2.NET.Serializer.Json.PIM.DTO; using SysML2.NET.Serializer.Json.Core.DTO; @@ -113,7 +114,7 @@ public void Serialize(IIdentified dataItem, SerializationModeKind serializationM serializationAction(dataItem, writer, serializationModeKind, includeDerivedProperties); writer.Flush(); } - else + else { var serializationAction = SerializationProvider.Provide(dataItem.GetType()); serializationAction(dataItem, writer, serializationModeKind, includeDerivedProperties); diff --git a/SysML2.NET.Tests/PSM/PagedResultTestFixture.cs b/SysML2.NET.Tests/PSM/PagedResultTestFixture.cs new file mode 100644 index 000000000..f428a6070 --- /dev/null +++ b/SysML2.NET.Tests/PSM/PagedResultTestFixture.cs @@ -0,0 +1,67 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2025 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. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Tests.PSM +{ + using System; + + using NUnit.Framework; + + using SysML2.NET.PSM; + + [TestFixture] + public class PagedResultTestFixture + { + private static readonly Guid FirstIdentifier = Guid.Parse("2f1a0e1c-6b2a-4d5e-9c3f-8a7b6d5e4c3b"); + + private static readonly Guid LastIdentifier = Guid.Parse("7c4b2a19-3e5d-4f6a-8b9c-1d2e3f4a5b6c"); + + [Test] + public void VerifyPagedResult() + { + var pagedResult = new PagedResult(); + + using (Assert.EnterMultipleScope()) + { + Assert.That(pagedResult.Records, Has.Count.EqualTo(0)); + Assert.That(pagedResult.Next, Is.Null); + Assert.That(pagedResult.Previous, Is.Null); + } + + pagedResult.Records = ["the first record", "the last record"]; + + using (Assert.EnterMultipleScope()) + { + Assert.That(pagedResult.Records, Has.Count.EqualTo(2)); + Assert.That(pagedResult.Records[0], Is.EqualTo("the first record")); + Assert.That(pagedResult.Records[^1], Is.EqualTo("the last record")); + } + + pagedResult.Previous = new Page { Epoch = 1700000000, Identifier = FirstIdentifier }; + pagedResult.Next = new Page { Epoch = 1700000600, Identifier = LastIdentifier }; + + using (Assert.EnterMultipleScope()) + { + Assert.That(pagedResult.Previous.Value.ToString(), Is.EqualTo($"1700000000|{FirstIdentifier}")); + Assert.That(pagedResult.Next.Value.ToString(), Is.EqualTo($"1700000600|{LastIdentifier}")); + } + } + } +} diff --git a/SysML2.NET/PSM/ConstraintValue.cs b/SysML2.NET/PSM/DTO/ConstraintValue.cs similarity index 100% rename from SysML2.NET/PSM/ConstraintValue.cs rename to SysML2.NET/PSM/DTO/ConstraintValue.cs diff --git a/SysML2.NET/PSM/ConstraintValueKind.cs b/SysML2.NET/PSM/DTO/ConstraintValueKind.cs similarity index 100% rename from SysML2.NET/PSM/ConstraintValueKind.cs rename to SysML2.NET/PSM/DTO/ConstraintValueKind.cs diff --git a/SysML2.NET/PSM/IRequest.cs b/SysML2.NET/PSM/DTO/IRequest.cs similarity index 100% rename from SysML2.NET/PSM/IRequest.cs rename to SysML2.NET/PSM/DTO/IRequest.cs diff --git a/SysML2.NET/PSM/IResponse.cs b/SysML2.NET/PSM/DTO/IResponse.cs similarity index 100% rename from SysML2.NET/PSM/IResponse.cs rename to SysML2.NET/PSM/DTO/IResponse.cs diff --git a/SysML2.NET/PSM/Page.cs b/SysML2.NET/PSM/Page.cs new file mode 100644 index 000000000..695c9c002 --- /dev/null +++ b/SysML2.NET/PSM/Page.cs @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2025 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. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.PSM +{ + using System; + + /// + /// Defines the structure of the page for the pagination process + /// + public struct Page + { + /// + /// the epoch time + /// + public int Epoch { get; set; } + + /// + /// The page identifier + /// + public Guid Identifier { get; set; } + + /// + /// Returns a string that represents the + /// + /// + /// a string representation + /// + public override string ToString() + { + return $"{this.Epoch}|{this.Identifier}"; + } + } +} diff --git a/SysML2.NET/PSM/PagedResult.cs b/SysML2.NET/PSM/PagedResult.cs new file mode 100644 index 000000000..173c4633e --- /dev/null +++ b/SysML2.NET/PSM/PagedResult.cs @@ -0,0 +1,61 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2025 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. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.PSM +{ + using System.Collections.Generic; + + /// + /// One page of records together with the cursors that address the pages either side of it. + /// + /// + /// The type of the records that the page carries. + /// + /// + /// A service applies the of a request when it queries its store, so the + /// cursors are known there and not by the caller. Several record types carry no timestamp of their own, + /// which makes a underivable from the records alone. + /// + public class PagedResult + { + /// + /// Initializes a new instance of the class. + /// + public PagedResult() + { + this.Records = []; + } + + /// + /// The records of this page, in the order the service returned them. + /// + public IReadOnlyList Records { get; set; } + + /// + /// The cursor of the page succeeding this one, or null when this is the last page. + /// + public Page? Next { get; set; } + + /// + /// The cursor of the page preceding this one, or null when this is the first page. + /// + public Page? Previous { get; set; } + } +} diff --git a/SysML2.NET/PIM/QueryParameters.cs b/SysML2.NET/PSM/QueryParameters.cs similarity index 76% rename from SysML2.NET/PIM/QueryParameters.cs rename to SysML2.NET/PSM/QueryParameters.cs index 06ca6d582..107601caa 100644 --- a/SysML2.NET/PIM/QueryParameters.cs +++ b/SysML2.NET/PSM/QueryParameters.cs @@ -1,123 +1,96 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright 2022-2025 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. -// -// -// ------------------------------------------------------------------------------------------------ - -namespace SysML2.NET.PIM -{ - using System; - using System.Collections.Generic; - using System.Linq; - - /// - /// Provide object structure for parameters than could be defined inside a queyr - /// - public class QueryParameters - { - /// - /// specifies the maximum number of records that will be returned per page in the response - /// - public int PageSize { get; set; } = 0; - - /// - /// specifies the URL of the page succeeding the page being requested - /// - /// - /// format: epoch|GUID, where epoch is Unix epoch: DateTime(1970, 1, 1, 0, 0, 0, 0) - /// - public Page? PageAfter { get; set; } = null; - - /// - /// specifies the URL of a page preceding the page being requested - /// - /// - /// format: epoch|GUID, where epoch is Unix epoch: DateTime(1970, 1, 1, 0, 0, 0, 0) - /// - public Page? PageBefore { get; set; } = null; - - /// - /// Returns a string that represents the - /// - /// - /// a string representation - /// - public override string ToString() - { - var queryParameters = new List(); - - if (this.PageSize > 0) - { - queryParameters.Add($"page[size]={this.PageSize}"); - } - - if (this.PageAfter != null) - { - queryParameters.Add($"page[after]={this.PageAfter}"); - } - - if (this.PageBefore != null) - { - queryParameters.Add($"page[before]={this.PageBefore}"); - } - - if (!queryParameters.Any()) - { - return string.Empty; - } - - return "?" + string.Join("&", queryParameters); - } - - /// - /// Creates an instance - /// - /// A - /// - public static QueryParameters FromString() - { - throw new NotImplementedException(); - } - } - - /// - /// Defines the structure of the page for the pagination process - /// - public struct Page - { - /// - /// the epoch time - /// - public int Epoch { get; set; } - - /// - /// The page identifier - /// - public Guid Identifier { get; set; } - - /// - /// Returns a string that represents the - /// - /// - /// a string representation - /// - public override string ToString() - { - return $"{this.Epoch}|{this.Identifier}"; - } - } -} +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2025 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. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.PSM +{ + using System; + using System.Collections.Generic; + using System.Linq; + + /// + /// Provide object structure for parameters than could be defined inside a queyr + /// + public class QueryParameters + { + /// + /// specifies the maximum number of records that will be returned per page in the response + /// + public int PageSize { get; set; } = 0; + + /// + /// specifies the URL of the page succeeding the page being requested + /// + /// + /// format: epoch|GUID, where epoch is Unix epoch: DateTime(1970, 1, 1, 0, 0, 0, 0) + /// + public Page? PageAfter { get; set; } = null; + + /// + /// specifies the URL of a page preceding the page being requested + /// + /// + /// format: epoch|GUID, where epoch is Unix epoch: DateTime(1970, 1, 1, 0, 0, 0, 0) + /// + public Page? PageBefore { get; set; } = null; + + /// + /// Returns a string that represents the + /// + /// + /// a string representation + /// + public override string ToString() + { + var queryParameters = new List(); + + if (this.PageSize > 0) + { + queryParameters.Add($"page[size]={this.PageSize}"); + } + + if (this.PageAfter != null) + { + queryParameters.Add($"page[after]={this.PageAfter}"); + } + + if (this.PageBefore != null) + { + queryParameters.Add($"page[before]={this.PageBefore}"); + } + + if (!queryParameters.Any()) + { + return string.Empty; + } + + return "?" + string.Join("&", queryParameters); + } + + /// + /// Creates an instance + /// + /// A + /// + public static QueryParameters FromString() + { + throw new NotImplementedException(); + } + } +} From e8308e10e7f5b3d87e02889f2d688b79164692df Mon Sep 17 00:00:00 2001 From: atheate Date: Fri, 2 Oct 2026 10:18:22 +0200 Subject: [PATCH 2/2] version bump --- SySML2.NET.REST/SySML2.NET.REST.csproj | 4 ++-- SysML2.NET.CodeGenerator/SysML2.NET.CodeGenerator.csproj | 2 +- SysML2.NET.Dal/SysML2.NET.Dal.csproj | 4 ++-- SysML2.NET.Extensions/SysML2.NET.Extensions.csproj | 4 ++-- SysML2.NET.Kpar/SysML2.NET.Kpar.csproj | 4 ++-- SysML2.NET.Semantics/SysML2.NET.Semantics.csproj | 4 ++-- .../SysML2.NET.Serializer.Json.csproj | 4 ++-- .../SysML2.NET.Serializer.MessagePack.csproj | 4 ++-- .../SysML2.NET.Serializer.TextualNotation.csproj | 6 ++---- .../SysML2.NET.Serializer.Xmi.csproj | 5 ++--- SysML2.NET/SysML2.NET.csproj | 9 +++------ 11 files changed, 22 insertions(+), 28 deletions(-) diff --git a/SySML2.NET.REST/SySML2.NET.REST.csproj b/SySML2.NET.REST/SySML2.NET.REST.csproj index adb7f567a..b4238afed 100644 --- a/SySML2.NET.REST/SySML2.NET.REST.csproj +++ b/SySML2.NET.REST/SySML2.NET.REST.csproj @@ -3,7 +3,7 @@ netstandard2.1;net10.0 14.0 - 0.24.0 + 0.24.1 A .NET implementation of the OMG SysML v2 REST/HTTP PSM Client SysML2.NET.REST Starion Group S.A. @@ -14,7 +14,7 @@ Sam Gerené true - [Fix] Build warnings cleared; log statements in the RestClient are guarded by a level check (#280) + [Update] IRestClient and RestClient aligned with the move of QueryParameters, Page and PagedResult to the SysML2.NET.PSM namespace cdp4-icon.png README.md diff --git a/SysML2.NET.CodeGenerator/SysML2.NET.CodeGenerator.csproj b/SysML2.NET.CodeGenerator/SysML2.NET.CodeGenerator.csproj index 425e23dcb..c30454177 100644 --- a/SysML2.NET.CodeGenerator/SysML2.NET.CodeGenerator.csproj +++ b/SysML2.NET.CodeGenerator/SysML2.NET.CodeGenerator.csproj @@ -2,7 +2,7 @@ net10.0 14.0 - 0.24.0 + 0.24.1 A Library to generate SysML v2 code. SysML2.NET Starion Group S.A. diff --git a/SysML2.NET.Dal/SysML2.NET.Dal.csproj b/SysML2.NET.Dal/SysML2.NET.Dal.csproj index 8cd62ae82..9dd4043f2 100644 --- a/SysML2.NET.Dal/SysML2.NET.Dal.csproj +++ b/SysML2.NET.Dal/SysML2.NET.Dal.csproj @@ -3,7 +3,7 @@ netstandard2.1;net10.0 14.0 - 0.24.0 + 0.24.1 A .NET implementation of the OMG SysML v2 specification data-acces-layer. SysML2.NET.Dal Starion Group S.A. @@ -14,7 +14,7 @@ Sam Gerené true - [Fix] Build warnings cleared; log statements in the Assembler are guarded by a level check (#280) + [Update] Aligned with SysML2.NET 0.24.1 cdp4-icon.png README.md diff --git a/SysML2.NET.Extensions/SysML2.NET.Extensions.csproj b/SysML2.NET.Extensions/SysML2.NET.Extensions.csproj index 556a9da37..c98b3e13f 100644 --- a/SysML2.NET.Extensions/SysML2.NET.Extensions.csproj +++ b/SysML2.NET.Extensions/SysML2.NET.Extensions.csproj @@ -3,7 +3,7 @@ netstandard2.1;net10.0 14.0 - 0.24.0 + 0.24.1 A .NET implementation of the OMG SysML v2 specification Extension and Helper methods. SysML2.NET.Extensions Starion Group S.A. @@ -14,7 +14,7 @@ Sam Gerené true - [Add] Enum providers for the PSM constraint operator enumerations, generated from the Systems Modeling API and Services OpenAPI document (#367) + [Update] Aligned with SysML2.NET 0.24.1 cdp4-icon.png README.md diff --git a/SysML2.NET.Kpar/SysML2.NET.Kpar.csproj b/SysML2.NET.Kpar/SysML2.NET.Kpar.csproj index 0d34f7145..f59cbbb1e 100644 --- a/SysML2.NET.Kpar/SysML2.NET.Kpar.csproj +++ b/SysML2.NET.Kpar/SysML2.NET.Kpar.csproj @@ -5,7 +5,7 @@ netstandard2.1;net10.0 14.0 - 0.24.0 + 0.24.1 A .NET implementation of the OMG SysML v2 specification. SysML2.NET.Kpar Starion Group S.A. @@ -16,7 +16,7 @@ Sam Gerené true - [Fix] Build warnings cleared; log statements in the Reader are guarded by a level check (#280) + [Update] Aligned with SysML2.NET 0.24.1 cdp4-icon.png README.md diff --git a/SysML2.NET.Semantics/SysML2.NET.Semantics.csproj b/SysML2.NET.Semantics/SysML2.NET.Semantics.csproj index d28a62eaa..fe0f3942d 100644 --- a/SysML2.NET.Semantics/SysML2.NET.Semantics.csproj +++ b/SysML2.NET.Semantics/SysML2.NET.Semantics.csproj @@ -4,7 +4,7 @@ netstandard2.1;net10.0 14.0 disable - 0.24.0 + 0.24.1 A .NET implementation of the OMG SysML v2 specification semantic constraints and implied Relationships. SysML2.NET.Semantics Starion Group S.A. @@ -15,7 +15,7 @@ Sam Gerené true - [Fix] FeatureParameterRedefinitionRule resolves supertypes over the effective model, following implied Specializations as well as declared ones (KerML 8.4.2) + [Update] Aligned with SysML2.NET 0.24.1 cdp4-icon.png README.md diff --git a/SysML2.NET.Serializer.Json/SysML2.NET.Serializer.Json.csproj b/SysML2.NET.Serializer.Json/SysML2.NET.Serializer.Json.csproj index 7cf43e0bd..8e46c8a66 100644 --- a/SysML2.NET.Serializer.Json/SysML2.NET.Serializer.Json.csproj +++ b/SysML2.NET.Serializer.Json/SysML2.NET.Serializer.Json.csproj @@ -3,7 +3,7 @@ netstandard2.1;net10.0 14.0 - 0.24.0 + 0.24.1 A .NET implementation of the OMG SysML v2 JSON serializer. SysML2.NET.Serializer.Json Starion Group S.A. @@ -14,7 +14,7 @@ Sam Gerené true - [Add] PSM serializers and deserializers for the Systems Modeling API and Services payload types, generated from the OpenAPI document (#371, #367) + [Update] Serializer and DeSerializer aligned with the move of QueryParameters, Page and PagedResult to the SysML2.NET.PSM namespace cdp4-icon.png README.md diff --git a/SysML2.NET.Serializer.MessagePack/SysML2.NET.Serializer.MessagePack.csproj b/SysML2.NET.Serializer.MessagePack/SysML2.NET.Serializer.MessagePack.csproj index 6d6d31bff..4793750d4 100644 --- a/SysML2.NET.Serializer.MessagePack/SysML2.NET.Serializer.MessagePack.csproj +++ b/SysML2.NET.Serializer.MessagePack/SysML2.NET.Serializer.MessagePack.csproj @@ -2,7 +2,7 @@ netstandard2.1;net10.0 14.0 - 0.24.0 + 0.24.1 A .NET implementation of the OMG SysML v2 MessagePack serializer. SysML2.NET.Serializer.MessagePack Starion Group S.A. @@ -13,7 +13,7 @@ Sam Gerené true - [Add] PSM formatters, payload factory and resolver for the Systems Modeling API and Services payload types, generated from the OpenAPI document (#367) + [Update] Aligned with SysML2.NET 0.24.1 cdp4-icon.png README.md diff --git a/SysML2.NET.Serializer.TextualNotation/SysML2.NET.Serializer.TextualNotation.csproj b/SysML2.NET.Serializer.TextualNotation/SysML2.NET.Serializer.TextualNotation.csproj index ea98fc80f..7c258259f 100644 --- a/SysML2.NET.Serializer.TextualNotation/SysML2.NET.Serializer.TextualNotation.csproj +++ b/SysML2.NET.Serializer.TextualNotation/SysML2.NET.Serializer.TextualNotation.csproj @@ -5,7 +5,7 @@ netstandard2.1;net10.0 14.0 - 0.24.0 + 0.24.1 A .NET implementation of the OMG SysML v2 Textual Notation serializer. SysML2.NET.Serializer.TextualNotation Starion Group S.A. @@ -17,9 +17,7 @@ Sam Gerené, Antoine Théate true - [Add] Validation coverage extended to dependency relationships, model containment, language extensions, properties-values-expressions, sequence modeling and use cases (#299 - #304) - [Add] A NameResolution layer emitting the shortest unambiguous name for a reference per KerML 8.2.3.5, resolving over namespace bindings, import expansion and implied Relationships - [Fix] Build warnings cleared across the generated builders (#280) + [Update] Aligned with SysML2.NET 0.24.1 cdp4-icon.png README.md diff --git a/SysML2.NET.Serializer.Xmi/SysML2.NET.Serializer.Xmi.csproj b/SysML2.NET.Serializer.Xmi/SysML2.NET.Serializer.Xmi.csproj index ae2144a71..b13d2af1b 100644 --- a/SysML2.NET.Serializer.Xmi/SysML2.NET.Serializer.Xmi.csproj +++ b/SysML2.NET.Serializer.Xmi/SysML2.NET.Serializer.Xmi.csproj @@ -3,7 +3,7 @@ netstandard2.1;net10.0 14.0 - 0.24.0 + 0.24.1 A .NET implementation of the OMG SysML v2 Xmi serializer. SysML2.NET.Serializer.Xmi Starion Group S.A. @@ -14,8 +14,7 @@ Sam Gerené, Théate Antoine true - [Add] IXmiDataCache.RegisterRootNamespace records the root Namespace of each resource read, so a resource re-entered through a circular reference is registered once - [Fix] Build warnings cleared across the generated readers and writers (#280) + [Update] Aligned with SysML2.NET 0.24.1 cdp4-icon.png README.md diff --git a/SysML2.NET/SysML2.NET.csproj b/SysML2.NET/SysML2.NET.csproj index 43f4abe5e..d4490c3c8 100644 --- a/SysML2.NET/SysML2.NET.csproj +++ b/SysML2.NET/SysML2.NET.csproj @@ -5,7 +5,7 @@ netstandard2.1;net10.0 14.0 - 0.24.0 + 0.24.1 A .NET implementation of the OMG SysML v2 specification. SysML2.NET Starion Group S.A. @@ -16,11 +16,8 @@ Sam Gerené true - [Add] DerivedPropertyAttribute and OperationAttribute decorate every generated Extend method, distinguishing a derived property from an operation (#211) - [Add] PSM DTOs, interfaces and enumerations generated from the Systems Modeling API and Services OpenAPI document (#367, #371) - [Add] ModelLevelEvaluableFunctions exposes the Kernel Functions Library membership set backing Function::isModelLevelEvaluable (#364) - [Update] IData splits into IIdentified and IDataRequest, separating what carries an identifier from what may be sent without one (#371) - [Fix] Build warnings reduced; generated files carry an auto-generated marker so analyzers skip them (#280) + [Add] PagedResult<T> and Page carry one page of records together with the cursors that address the pages either side of it + [Update] QueryParameters, ConstraintValue, ConstraintValueKind, IRequest and IResponse moved from the PIM namespace to PSM and PSM.DTO cdp4-icon.png README.md