Skip to content

Commit 27c460d

Browse files
1) The prefixes 'Calibration' and 'DataMatrix' have been dropped to shorten and simplify various type names.
2) Some method and property names have been simplified. 3) Some types have been scoped as internal rather than public. 4) Language support has been added for all (24) EU official languages, and also for Norwegian and Icelandic. 5) Additional code clean-up has been performed through application of StyleCop rules. 6) A number of legacy (pre-C#9) record-type classes have been re-written as records. 7) Calibration data has been optimised for JSON by removing redundant ASCII 0s. 8) A new error type has been introduced for situations where no valid calibration is provided when calibrating. 9) Public API analysis support has been provided to help track breaking changes in future.
1 parent 841496f commit 27c460d

13 files changed

+12533
-1506
lines changed

Solidsoft.Reply.Parsers.AnsiMhDi/Category.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// --------------------------------------------------------------------------------------------------------------------
2-
// <copyright file="Category.cs" company="Solidsoft Reply Ltd.">
3-
// (c) 2018-2024 Solidsoft Reply Ltd. All rights reserved.
4-
// </copyright>
5-
// <license>
2+
// <copyright file="Category.cs" company="Solidsoft Reply Ltd">
3+
// Copyright (c) 2018-2024 Solidsoft Reply Ltd. All rights reserved.
64
// Licensed under the Apache License, Version 2.0 (the "License");
75
// you may not use this file except in compliance with the License.
86
// You may obtain a copy of the License at
@@ -14,23 +12,22 @@
1412
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1513
// See the License for the specific language governing permissions and
1614
// limitations under the License.
17-
// </license>
15+
// </copyright>
1816
// <summary>
1917
// Defined ASC MH10.8.2 categories.
2018
// </summary>
2119
// --------------------------------------------------------------------------------------------------------------------
2220

2321
// ReSharper disable UnusedMember.Global
24-
2522
namespace Solidsoft.Reply.Parsers.AnsiMhDi;
2623

2724
/// <summary>
28-
/// Defined ASC MH10.8.2 categories
25+
/// Defined ASC MH10.8.2 categories.
2926
/// </summary>
3027
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1700:Do not name enum values 'Reserved'", Justification = "<Pending>")]
28+
3129
// ReSharper disable once UnusedType.Global
32-
public enum Category
33-
{
30+
public enum Category {
3431
/// <summary>
3532
/// CATEGORY 0 Special Characters Employed as Data Identifiers
3633
/// </summary>
@@ -165,5 +162,5 @@ public enum Category
165162
/// <summary>
166163
/// CATEGORY 26 Mutually Defined
167164
/// </summary>
168-
MutuallyDefined = 26
165+
MutuallyDefined = 26,
169166
}

Solidsoft.Reply.Parsers.AnsiMhDi/DataIdentifier.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// --------------------------------------------------------------------------------------------------------------------
2-
// <copyright file="DataIdentifier.cs" company="Solidsoft Reply Ltd.">
3-
// (c) 2018-2024 Solidsoft Reply Ltd. All rights reserved.
4-
// </copyright>
5-
// <license>
2+
// <copyright file="DataIdentifier.cs" company="Solidsoft Reply Ltd">
3+
// Copyright (c) 2018-2024 Solidsoft Reply Ltd. All rights reserved.
64
// Licensed under the Apache License, Version 2.0 (the "License");
75
// you may not use this file except in compliance with the License.
86
// You may obtain a copy of the License at
@@ -14,15 +12,14 @@
1412
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1513
// See the License for the specific language governing permissions and
1614
// limitations under the License.
17-
// </license>
15+
// </copyright>
1816
// <summary>
1917
// ASC MH10.8 0 Data Identifiers.
2018
// </summary>
2119
// --------------------------------------------------------------------------------------------------------------------
2220

2321
// ReSharper disable UnusedMember.Global
2422
// ReSharper disable CommentTypo
25-
2623
namespace Solidsoft.Reply.Parsers.AnsiMhDi;
2724

2825
using System.Diagnostics.CodeAnalysis;
@@ -36,8 +33,7 @@ namespace Solidsoft.Reply.Parsers.AnsiMhDi;
3633
/// Identifier") not defined herein is reserved for future assignment by the body controlling
3734
/// these guidelines.
3835
/// </remarks>
39-
public enum DataIdentifier
40-
{
36+
public enum DataIdentifier {
4137
/// <summary>
4238
/// Unrecognised entity.
4339
/// </summary>
@@ -1298,7 +1294,7 @@ public enum DataIdentifier
12981294
/// DNV certificate reference.
12991295
/// </summary>
13001296
DnvCertificateReference = 16055,
1301-
1297+
13021298
/// <summary>
13031299
/// The quantity.
13041300
/// </summary>
@@ -2508,5 +2504,5 @@ public enum DataIdentifier
25082504
/// <summary>
25092505
/// The line 89.
25102506
/// </summary>
2511-
Line89 = 26099
2507+
Line89 = 26099,
25122508
}

Solidsoft.Reply.Parsers.AnsiMhDi/Descriptors/EntityDescriptor.cs

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// --------------------------------------------------------------------------------------------------------------------
2-
// <copyright file="EntityDescriptor.cs" company="Solidsoft Reply Ltd.">
3-
// (c) 2018-2024 Solidsoft Reply Ltd. All rights reserved.
4-
// </copyright>
5-
// <license>
2+
// <copyright file="EntityDescriptor.cs" company="Solidsoft Reply Ltd">
3+
// Copyright (c) 2018-2024 Solidsoft Reply Ltd. All rights reserved.
64
// Licensed under the Apache License, Version 2.0 (the "License");
75
// you may not use this file except in compliance with the License.
86
// You may obtain a copy of the License at
@@ -14,7 +12,7 @@
1412
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1513
// See the License for the specific language governing permissions and
1614
// limitations under the License.
17-
// </license>
15+
// </copyright>
1816
// <summary>
1917
// A descriptor for an ASC MH10.8.2 entity.
2018
// </summary>
@@ -33,52 +31,43 @@ namespace Solidsoft.Reply.Parsers.AnsiMhDi.Descriptors;
3331
/// <summary>
3432
/// A descriptor for an ASC MH10.8.2 entity.
3533
/// </summary>
36-
34+
/// <remarks>
35+
/// Initializes a new instance of the <see cref="EntityDescriptor" /> class.
36+
/// </remarks>
37+
/// <param name="dataTitle">
38+
/// The data title.
39+
/// </param>
40+
/// <param name="description">
41+
/// The description.
42+
/// </param>
43+
/// <param name="pattern">
44+
/// The pattern.
45+
/// </param>
3746
// ReSharper disable once ClassWithVirtualMembersNeverInherited.Global
38-
public class EntityDescriptor
39-
{
47+
public class EntityDescriptor(string? dataTitle, string? description, Func<Regex> pattern) {
4048
/// <summary>
4149
/// The regular expression pattern of the entity.
4250
/// </summary>
43-
private readonly Func<Regex> _pattern;
51+
private readonly Func<Regex> _pattern = pattern;
4452

4553
/// <summary>
4654
/// The regular expression pattern of the entity.
4755
/// </summary>
48-
private Regex? _validator;
49-
50-
/// <summary>
51-
/// Initializes a new instance of the <see cref="EntityDescriptor" /> class.
52-
/// </summary>
53-
/// <param name="dataTitle">
54-
/// The data title.
55-
/// </param>
56-
/// <param name="description">
57-
/// The description.
58-
/// </param>
59-
/// <param name="pattern">
60-
/// The pattern.
61-
/// </param>
62-
public EntityDescriptor(string? dataTitle, string? description, Func<Regex> pattern) {
63-
DataTitle = dataTitle;
64-
Description = description;
65-
_pattern = pattern;
66-
_validator = null;
67-
}
56+
private Regex? _validator = null;
6857

6958
/// <summary>
7059
/// Gets the data title of the entity.
7160
/// </summary>
7261
// ReSharper disable once MemberCanBePrivate.Global
7362
// ReSharper disable once UnusedAutoPropertyAccessor.Global
74-
public string? DataTitle { get; }
63+
public string? DataTitle { get; } = dataTitle;
7564

7665
/// <summary>
7766
/// Gets the description of the entity.
7867
/// </summary>
7968
// ReSharper disable once MemberCanBePrivate.Global
8069
// ReSharper disable once UnusedAutoPropertyAccessor.Global
81-
public string? Description { get; }
70+
public string? Description { get; } = description;
8271

8372
/// <summary>
8473
/// Gets the compiled regular expression object for validating the entity.
@@ -92,14 +81,14 @@ public EntityDescriptor(string? dataTitle, string? description, Func<Regex> patt
9281
/// <param name="value">The data to be validated.</param>
9382
/// <param name="validationErrors">A list of validation errors.</param>
9483
/// <returns>True, if valid. Otherwise, false.</returns>
95-
public virtual bool IsValid(string? value, out IList<ParserException> validationErrors)
96-
{
84+
public virtual bool IsValid(string? value, out IList<ParserException> validationErrors) {
85+
#pragma warning disable IDE0028 // Simplify collection initialization
9786
validationErrors = new List<ParserException>();
87+
#pragma warning restore IDE0028 // Simplify collection initialization
9888

9989
var result = Pattern.IsMatch(value ?? string.Empty);
10090

101-
if (result)
102-
{
91+
if (result) {
10392
return true;
10493
}
10594

0 commit comments

Comments
 (0)