Skip to content

Commit da23ac1

Browse files
[SQ] improvements
1 parent bd04971 commit da23ac1

File tree

133 files changed

+519
-37
lines changed

Some content is hidden

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

133 files changed

+519
-37
lines changed

SysML2.NET.CodeGenerator/Generators/Generator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -------------------------------------------------------------------------------------------------
22
// <copyright file="Generator.cs" company="Starion Group S.A.">
33
//
4-
// Copyright 2022 Starion Group S.A.
4+
// Copyright 2022-2026 Starion Group S.A.
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -135,14 +135,14 @@ protected static async Task WriteAsync(string generatedCode, DirectoryInfo outpu
135135
{
136136
if (string.IsNullOrEmpty(generatedCode))
137137
{
138-
throw new ArgumentException(nameof(generatedCode));
138+
throw new ArgumentException($"the {nameof(generatedCode)} may not be null", nameof(generatedCode));
139139
}
140140

141141
ArgumentNullException.ThrowIfNull(outputDirectory);
142142

143143
if (string.IsNullOrEmpty(fileName))
144144
{
145-
throw new ArgumentException(nameof(fileName));
145+
throw new ArgumentException($"the {nameof(fileName)} may not be null",nameof(fileName));
146146
}
147147

148148
var filePath = Path.Combine(outputDirectory.FullName, fileName);

SysML2.NET.CodeGenerator/Generators/UmlHandleBarsGenerators/UmlHandleBarsGenerator.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ public abstract class UmlHandleBarsGenerator : HandleBarsGenerator
6262
/// </returns>
6363
protected static HandlebarsPayload CreateHandlebarsPayload(XmiReaderResult xmiReaderResult)
6464
{
65-
if (xmiReaderResult == null)
66-
{
67-
throw new ArgumentNullException(nameof(xmiReaderResult));
68-
}
65+
ArgumentNullException.ThrowIfNull(xmiReaderResult);
6966

7067
var enumerations = new List<IEnumeration>();
7168
var primitiveTypes = new List<IPrimitiveType>();

SysML2.NET.CodeGenerator/HandleBarHelpers/SysML2PropertyHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -------------------------------------------------------------------------------------------------
22
// <copyright file="SysML2PropertyHelper.cs" company="Starion Group S.A.">
33
//
4-
// Copyright 2022-2025 Starion Group S.A.
4+
// Copyright 2022-2026 Starion Group S.A.
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -56,7 +56,7 @@ public static void RegisterPropertyHelper(this IHandlebars handlebars)
5656
sb.Append(property.Visibility.ToString().ToLower());
5757
sb.Append(' ');
5858

59-
if (property.RedefinedProperty.Any())
59+
if (property.RedefinedProperty.Count > 0)
6060
{
6161
sb.Append("new ");
6262
}
@@ -125,7 +125,7 @@ public static void RegisterPropertyHelper(this IHandlebars handlebars)
125125
sb.Append(' ');
126126
}
127127

128-
if (property.RedefinedProperty.Any())
128+
if (property.RedefinedProperty.Count > 0)
129129
{
130130
sb.Append("new ");
131131
}

SysML2.NET.Serializer.Json/PIM/ApiDeSerializationProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -------------------------------------------------------------------------------------------------
22
// <copyright file="ApiDeSerializationProvider.cs" company="Starion Group S.A.">
33
//
4-
// Copyright 2022-2025 Starion Group S.A.
4+
// Copyright 2022-2026 Starion Group S.A.
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ namespace SysML2.NET.Serializer.Json.PIM.DTO
3131

3232
/// <summary>
3333
/// Delegate provider for the appropriate deserialization method for <see cref="System.Type"/> from the
34-
/// <see cref="SysML2.NET.API"/> namespace
34+
/// <see cref="SysML2.NET.PIM"/> namespace
3535
/// </summary>
3636
internal static class ApiDeSerializationProvider
3737
{
@@ -57,7 +57,7 @@ private static readonly Dictionary<string, Func<JsonElement, SerializationModeKi
5757
/// The name of the subject <see cref="System.Type"/> that is to be serialized
5858
/// </param>
5959
/// <returns>
60-
/// A Delegate of <see cref="Func{JsonElement, SerializationModeKind, bool, ILoggerFactory, IData}"/>
60+
/// A delegate for <see cref="Func{JsonElement, SerializationModeKind, bool, ILoggerFactory, IData}"/>
6161
/// </returns>
6262
/// <exception cref="NotSupportedException">
6363
/// Thrown when the <see cref="System.Type"/> is not supported.

SysML2.NET.Serializer.Json/PIM/CommitDeSerializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ internal static Commit DeSerialize(JsonElement jsonElement, SerializationModeKin
157157
}
158158
else
159159
{
160-
logger.LogDebug($"the owningProject Json property was not found in the Commit: {dtoInstance.Id}");
160+
logger.LogDebug("the owningProject Json property was not found in the Commit: {Id}", dtoInstance.Id);
161161
}
162162

163163
if (jsonElement.TryGetProperty("resourceIdentifier"u8, out JsonElement resourceIdentifierProperty))

SysML2.NET.Serializer.MessagePack/Core/MessagePackFormatterBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace SysML2.NET.Serializer.MessagePack.Core
3535
/// This base class exists to centralize performance-critical serialization logic
3636
/// that is reused across multiple MessagePack formatters.
3737
/// </remarks>
38-
public class MessagePackFormatterBase
38+
public abstract class MessagePackFormatterBase
3939
{
4040
/// <summary>
4141
/// Thread-local reusable buffer for serializing <see cref="Guid"/> values

SysML2.NET.Serializer.MessagePack/DeSerializer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -------------------------------------------------------------------------------------------------
22
// <copyright file="DeSerializer.cs" company="Starion Group S.A.">
33
//
4-
// Copyright 2022-2025 Starion Group S.A.
4+
// Copyright 2022-2026 Starion Group S.A.
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -74,7 +74,7 @@ public IEnumerable<IData> DeSerialize(Stream stream, SerializationTargetKind ser
7474
throw new ArgumentNullException(nameof(stream), "Stream may not be null");
7575
}
7676

77-
var options = this.CreateSerializerOptions();
77+
var options = CreateSerializerOptions();
7878

7979
var sw = Stopwatch.StartNew();
8080

@@ -135,7 +135,7 @@ public Task<IEnumerable<IData>> DeSerializeAsync(Stream stream, SerializationTar
135135
/// </remarks>
136136
public async Task<IEnumerable<IData>> DeserializeInternalAsync(Stream stream, SerializationTargetKind serializationTargetKind, CancellationToken cancellationToken)
137137
{
138-
var options = this.CreateSerializerOptions();
138+
var options = CreateSerializerOptions();
139139

140140
var sw = Stopwatch.StartNew();
141141

SysML2.NET.Serializer.MessagePack/Helpers/DataFormatterResolver.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,16 @@ public IMessagePackFormatter<T> GetFormatter<T>()
6666
}
6767

6868
/// <summary>
69-
/// A cache from which <see cref="IMessagePackFormatter"/> can be resolved
69+
/// Per-type cache for resolved MessagePack formatters.
7070
/// </summary>
71-
/// <typeparam name="T"></typeparam>
71+
/// <typeparam name="T">The type for which a formatter is cached.</typeparam>
7272
private static class FormatterCache<T>
7373
{
74-
public static readonly IMessagePackFormatter<T> Formatter;
75-
76-
// generic's static constructor should be minimized for reduce type generation size!
77-
// use outer helper method.
78-
static FormatterCache()
79-
{
80-
var type = typeof(T);
81-
82-
Formatter = (IMessagePackFormatter<T>)DataResolverGetFormatterHelper.GetFormatter(type);
83-
}
74+
/// <summary>
75+
/// The cached formatter for <typeparamref name="T"/>, or <see langword="null"/> if none is available.
76+
/// </summary>
77+
public static readonly IMessagePackFormatter<T> Formatter =
78+
(IMessagePackFormatter<T>)DataResolverGetFormatterHelper.GetFormatter(typeof(T));
8479
}
8580
}
8681
}

SysML2.NET.Serializer.MessagePack/Serializer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void Serialize(IEnumerable<IData> dataItems, Stream stream)
7878
throw new ArgumentNullException(nameof(stream));
7979
}
8080

81-
var options = this.CreateSerializerOptions();
81+
var options = CreateSerializerOptions();
8282

8383
var payload = dataItems.ToList().AsReadOnly().ToPayload();
8484

@@ -115,7 +115,7 @@ public void SerializeToBufferWriter(IEnumerable<IData> dataItems, IBufferWriter<
115115
throw new ArgumentNullException(nameof(writer));
116116
}
117117

118-
var options = this.CreateSerializerOptions();
118+
var options = CreateSerializerOptions();
119119

120120
var payload = dataItems.ToList().AsReadOnly().ToPayload();
121121

@@ -169,7 +169,7 @@ public Task SerializeAsync(IEnumerable<IData> dataItems, Stream stream, Cancella
169169
/// </param>
170170
private async Task SerializeInternalAsync(IEnumerable<IData> dataItems, Stream stream, CancellationToken cancellationToken)
171171
{
172-
var options = this.CreateSerializerOptions();
172+
var options = CreateSerializerOptions();
173173

174174
var payload = dataItems.ToList().AsReadOnly().ToPayload();
175175

SysML2.NET.Serializer.MessagePack/SerializerBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -------------------------------------------------------------------------------------------------
22
// <copyright file="SerializerBase.cs" company="Starion Group S.A.">
33
//
4-
// Copyright 2022-2025 Starion Group S.A.
4+
// Copyright 2022-2026 Starion Group S.A.
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ public abstract class SerializerBase
3636
/// <returns>
3737
/// An instance of <see cref="MessagePackSerializerOptions"/>
3838
/// </returns>
39-
protected MessagePackSerializerOptions CreateSerializerOptions()
39+
protected static MessagePackSerializerOptions CreateSerializerOptions()
4040
{
4141
var formatterResolver = CompositeResolver.Create(
4242
DataFormatterResolver.Instance,

0 commit comments

Comments
 (0)