From efca915e94f3cfdc28a4d8c3c12704c9fc99595e Mon Sep 17 00:00:00 2001 From: Dieter Lunn Date: Sat, 29 Jun 2024 19:33:02 -0500 Subject: [PATCH] chore: update build and code for new language features --- .editorconfig | 7 ++ Ubiety.Stringprep.Core.sln | 5 +- build/Build.cs | 31 +++++---- build/_build.csproj | 4 +- .../Bidirectional/BidirectionalStep.cs | 27 +++----- .../BidirectionalFormatException.cs | 12 ---- .../Exceptions/ProhibitedValueException.cs | 12 ---- src/Ubiety.Stringprep.Core/MappingStep.cs | 17 +---- src/Ubiety.Stringprep.Core/MappingTable.cs | 4 +- .../MappingTableBuilder.cs | 38 +++++------ .../MappingTableCompiler.cs | 10 +-- .../NormalizationStep.cs | 19 ++---- .../PreparationProcessBuilder.cs | 2 +- .../ProhibitedValueStep.cs | 19 ++---- .../Ubiety.Stringprep.Core.xml | 64 +++++++++++++------ .../ValueRangeCompiler.cs | 11 ++-- .../ValueRangeTableBuilder.cs | 25 +++----- 17 files changed, 132 insertions(+), 175 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7da5088 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,7 @@ +[*.cs] + +# SA1010: Opening square brackets should be spaced correctly +dotnet_diagnostic.SA1010.severity = none + +# SA1009: Closing parenthesis should be spaced correctly +dotnet_diagnostic.SA1009.severity = none diff --git a/Ubiety.Stringprep.Core.sln b/Ubiety.Stringprep.Core.sln index 07b96bd..819ae43 100644 --- a/Ubiety.Stringprep.Core.sln +++ b/Ubiety.Stringprep.Core.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28315.86 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.35013.160 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{4B9462B8-7C12-4FF8-B198-420A37AD1C34}" EndProject @@ -9,6 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ubiety.Stringprep.Core", "s EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C669F553-ECC0-4C36-ACD2-35216BE7E292}" ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig .gitignore = .gitignore CHANGELOG.md = CHANGELOG.md README.md = README.md diff --git a/build/Build.cs b/build/Build.cs index 7eb71dd..4e95c25 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using JetBrains.Annotations; using Nuke.Common; using Nuke.Common.CI; @@ -11,36 +10,36 @@ using Nuke.Common.Tooling; using Nuke.Common.Tools.Coverlet; using Nuke.Common.Tools.DotNet; -using Nuke.Common.Tools.SonarScanner; using Nuke.Common.Tools.GitVersion; -using Nuke.Common.Utilities.Collections; +using Nuke.Common.Tools.SonarScanner; using Nuke.Common.Utilities; +using Nuke.Common.Utilities.Collections; +using System.Collections.Generic; using static Nuke.Common.ChangeLog.ChangelogTasks; -using static Nuke.Common.IO.FileSystemTasks; using static Nuke.Common.Tools.DotNet.DotNetTasks; using static Nuke.Common.Tools.SonarScanner.SonarScannerTasks; [GitHubActions( "release", GitHubActionsImage.WindowsLatest, - OnPushBranches = new[] { MasterBranch, ReleaseBranchPrefix + "/*"}, - InvokedTargets = new[] { nameof(Test), nameof(Publish) }, - ImportSecrets = new[] { nameof(NuGetKey) }, + OnPushBranches = [MasterBranch, ReleaseBranchPrefix + "/*"], + InvokedTargets = [nameof(Test), nameof(Publish)], + ImportSecrets = [nameof(NuGetKey)], EnableGitHubToken = true)] [GitHubActions( "continuous", GitHubActionsImage.WindowsLatest, GitHubActionsImage.UbuntuLatest, GitHubActionsImage.MacOsLatest, - OnPushBranchesIgnore = new[] { MasterBranch, ReleaseBranchPrefix + "/*"}, - OnPullRequestBranches = new[] { DevelopBranch }, + OnPushBranchesIgnore = [MasterBranch, ReleaseBranchPrefix + "/*"], + OnPullRequestBranches = [DevelopBranch], PublishArtifacts = false, - InvokedTargets = new[] { nameof(Test), nameof(Publish) }, + InvokedTargets = [nameof(Test), nameof(Publish)], EnableGitHubToken = true)] [AppVeyor( AppVeyorImage.UbuntuLatest, AppVeyorImage.VisualStudioLatest, - InvokedTargets = new[] { nameof(Test), nameof(SonarEnd)}, + InvokedTargets = [nameof(Test), nameof(SonarEnd)], SkipTags = true, AutoGenerate = true)] [UnsetVisualStudioEnvironmentVariables] @@ -70,9 +69,9 @@ class Build : NukeBuild .Before(Restore) .Executes(() => { - SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory); - TestsDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory); - EnsureCleanDirectory(ArtifactsDirectory); + SourceDirectory.GlobDirectories("**/bin", "**/obj").DeleteDirectories(); + TestsDirectory.GlobDirectories("**/bin", "**/obj").DeleteDirectories(); + ArtifactsDirectory.CreateOrCleanDirectory(); }); Target Restore => _ => _ @@ -108,7 +107,7 @@ class Build : NukeBuild .SetVersion(GitVersion.NuGetVersionV2) .SetOpenCoverPaths(ArtifactsDirectory / "coverage.opencover.xml") .SetProcessArgumentConfigurator(args => args.Add("/o:ubiety")) - .SetFramework("net5.0")); + .SetFramework("net8.0")); }); Target SonarEnd => _ => _ @@ -119,7 +118,7 @@ class Build : NukeBuild .Executes(() => { SonarScannerEnd(_ => _ - .SetFramework("net5.0")); + .SetFramework("net8.0")); }); [Parameter] readonly bool Cover = true; diff --git a/build/_build.csproj b/build/_build.csproj index 6e2f437..3ffb040 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -14,8 +14,8 @@ - - + + diff --git a/src/Ubiety.Stringprep.Core/Bidirectional/BidirectionalStep.cs b/src/Ubiety.Stringprep.Core/Bidirectional/BidirectionalStep.cs index 0c6d8c1..ed2a610 100644 --- a/src/Ubiety.Stringprep.Core/Bidirectional/BidirectionalStep.cs +++ b/src/Ubiety.Stringprep.Core/Bidirectional/BidirectionalStep.cs @@ -31,24 +31,17 @@ namespace Ubiety.Stringprep.Core.Bidirectional /// /// Bidirectional stringprep step. /// - public class BidirectionalStep : IPreparationProcess + /// + /// Initializes a new instance of the class. + /// + /// Prohibited character table. + /// RandAL character table. + /// L character table. + public class BidirectionalStep(IValueRangeTable prohibitedTable, IValueRangeTable ralTable, IValueRangeTable lTable) : IPreparationProcess { - private readonly IValueRangeTable _lTable; - private readonly IValueRangeTable _prohibitedTable; - private readonly IValueRangeTable _ralTable; - - /// - /// Initializes a new instance of the class. - /// - /// Prohibited character table. - /// RandAL character table. - /// L character table. - public BidirectionalStep(IValueRangeTable prohibitedTable, IValueRangeTable ralTable, IValueRangeTable lTable) - { - _prohibitedTable = prohibitedTable; - _ralTable = ralTable; - _lTable = lTable; - } + private readonly IValueRangeTable _lTable = lTable; + private readonly IValueRangeTable _prohibitedTable = prohibitedTable; + private readonly IValueRangeTable _ralTable = ralTable; /// /// Run the stringprep step. diff --git a/src/Ubiety.Stringprep.Core/Exceptions/BidirectionalFormatException.cs b/src/Ubiety.Stringprep.Core/Exceptions/BidirectionalFormatException.cs index 4840c34..17c4c30 100644 --- a/src/Ubiety.Stringprep.Core/Exceptions/BidirectionalFormatException.cs +++ b/src/Ubiety.Stringprep.Core/Exceptions/BidirectionalFormatException.cs @@ -25,14 +25,12 @@ */ using System; -using System.Runtime.Serialization; namespace Ubiety.Stringprep.Core.Exceptions { /// /// Bidirectional format exception. /// - [Serializable] public class BidirectionalFormatException : Exception { /// @@ -60,15 +58,5 @@ public BidirectionalFormatException(string message, Exception innerException) : base(message, innerException) { } - - /// - /// Initializes a new instance of the class. - /// - /// Serialization info. - /// Streaming context. - protected BidirectionalFormatException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } \ No newline at end of file diff --git a/src/Ubiety.Stringprep.Core/Exceptions/ProhibitedValueException.cs b/src/Ubiety.Stringprep.Core/Exceptions/ProhibitedValueException.cs index cfd320a..310a89e 100644 --- a/src/Ubiety.Stringprep.Core/Exceptions/ProhibitedValueException.cs +++ b/src/Ubiety.Stringprep.Core/Exceptions/ProhibitedValueException.cs @@ -25,7 +25,6 @@ */ using System; -using System.Runtime.Serialization; namespace Ubiety.Stringprep.Core.Exceptions { @@ -33,7 +32,6 @@ namespace Ubiety.Stringprep.Core.Exceptions /// Prohibited value exception. /// /// - [Serializable] public class ProhibitedValueException : Exception { /// @@ -70,15 +68,5 @@ public ProhibitedValueException(string message, Exception innerException) : base(message, innerException) { } - - /// - /// Initializes a new instance of the class. - /// - /// Serialization info. - /// Streaming context. - protected ProhibitedValueException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } \ No newline at end of file diff --git a/src/Ubiety.Stringprep.Core/MappingStep.cs b/src/Ubiety.Stringprep.Core/MappingStep.cs index e2c418b..e8d69af 100644 --- a/src/Ubiety.Stringprep.Core/MappingStep.cs +++ b/src/Ubiety.Stringprep.Core/MappingStep.cs @@ -32,19 +32,8 @@ namespace Ubiety.Stringprep.Core /// /// Mapping processing step. /// - public class MappingStep : IPreparationProcess + public class MappingStep(IMappingTable table) : IPreparationProcess { - private readonly IMappingTable _table; - - /// - /// Initializes a new instance of the class. - /// - /// Mapping table to use for processing. - public MappingStep(IMappingTable table) - { - _table = table; - } - /// /// Run the step. /// @@ -55,9 +44,9 @@ public string Run(string input) var sb = new StringBuilder(); foreach (var c in input) { - if (_table.HasReplacement(c)) + if (table.HasReplacement(c)) { - foreach (var r in _table.GetReplacement(c)) + foreach (var r in table.GetReplacement(c)) { sb.Append(Convert.ToChar(r)); } diff --git a/src/Ubiety.Stringprep.Core/MappingTable.cs b/src/Ubiety.Stringprep.Core/MappingTable.cs index 0c17baa..c5d4060 100644 --- a/src/Ubiety.Stringprep.Core/MappingTable.cs +++ b/src/Ubiety.Stringprep.Core/MappingTable.cs @@ -41,7 +41,7 @@ public abstract class MappingTable : IMappingTable /// Mapping table instance. public static IMappingTable Create(int[] valueTable, int replacement) { - return Create(valueTable, new[] { replacement }); + return Create(valueTable, [replacement]); } /// @@ -73,7 +73,7 @@ public static IMappingTable Create(params IDictionary[] baseTables) /// Mapping table builder instance. public static IMappingTableBuilder Build(int[] valueTable, int replacement) { - return Build(valueTable, new[] { replacement }); + return Build(valueTable, [replacement]); } /// diff --git a/src/Ubiety.Stringprep.Core/MappingTableBuilder.cs b/src/Ubiety.Stringprep.Core/MappingTableBuilder.cs index 2e06e6f..42c5cb5 100644 --- a/src/Ubiety.Stringprep.Core/MappingTableBuilder.cs +++ b/src/Ubiety.Stringprep.Core/MappingTableBuilder.cs @@ -33,24 +33,16 @@ namespace Ubiety.Stringprep.Core /// /// Mapping table builder. /// - internal class MappingTableBuilder : IMappingTableBuilder + /// + /// Initializes a new instance of the class. + /// + /// Base value tables. + internal class MappingTableBuilder(params IDictionary[] baseTables) : IMappingTableBuilder { - private readonly List> _baseTables; - private readonly List> _inclusions; - private readonly List _removals; - private readonly List<(List values, int[] replacements)> _valueRangeBaseTables; - - /// - /// Initializes a new instance of the class. - /// - /// Base value tables. - public MappingTableBuilder(params IDictionary[] baseTables) - { - _baseTables = baseTables.ToList(); - _valueRangeBaseTables = new List<(List, int[])>(); - _inclusions = new List>(); - _removals = new List(); - } + private readonly List> _baseTables = [.. baseTables]; + private readonly List> _inclusions = []; + private readonly List _removals = []; + private readonly List<(List values, int[] replacements)> _valueRangeBaseTables = []; /// /// Add value range table to mapping. @@ -60,7 +52,7 @@ public MappingTableBuilder(params IDictionary[] baseTables) /// Mapping table builder instance. public IMappingTableBuilder WithValueRangeTable(int[] values, int replacement) { - return WithValueRangeTable(values, new[] { replacement }); + return WithValueRangeTable(values, [replacement]); } /// @@ -115,7 +107,7 @@ public IMappingTableBuilder Remove(int removeValue) /// Thrown when no tables are provided. public IMappingTable Compile() { - if (!_baseTables.Any() && !_inclusions.Any() && !_valueRangeBaseTables.Any()) + if (_baseTables.Count == 0 && _inclusions.Count == 0 && _valueRangeBaseTables.Count == 0) { throw new InvalidOperationException("At least one table must be provided"); } @@ -123,14 +115,14 @@ public IMappingTable Compile() var mappingTables = new List { new DictionaryMappingTable(MappingTableCompiler.Compile( - _baseTables.ToArray(), - _inclusions.ToArray(), - _removals.ToArray())), + [.. _baseTables], + [.. _inclusions], + [.. _removals])), }; mappingTables.AddRange( from t in _valueRangeBaseTables - let valueRangeTable = ValueRangeCompiler.Compile(new[] { t.values }, Array.Empty().ToList(), _removals) + let valueRangeTable = ValueRangeCompiler.Compile([t.values], [], _removals) select new ValueRangeMappingTable(new ValueRangeTable(valueRangeTable), t.replacements)); return new CompositeMappingTable(mappingTables); diff --git a/src/Ubiety.Stringprep.Core/MappingTableCompiler.cs b/src/Ubiety.Stringprep.Core/MappingTableCompiler.cs index fcb0517..e507d97 100644 --- a/src/Ubiety.Stringprep.Core/MappingTableCompiler.cs +++ b/src/Ubiety.Stringprep.Core/MappingTableCompiler.cs @@ -48,7 +48,7 @@ public static IDictionary Compile( return DoRemove(DoInclude(DoCombine(baseTables), inclusions), removals); } - private static IDictionary DoRemove(IDictionary dict, IEnumerable removals) + private static SortedDictionary DoRemove(SortedDictionary dict, IEnumerable removals) { foreach (var key in removals) { @@ -63,8 +63,8 @@ private static IDictionary DoRemove(IDictionary dict, IE return dict; } - private static IDictionary DoInclude( - IDictionary dict, + private static SortedDictionary DoInclude( + SortedDictionary dict, IEnumerable> inclusions) { foreach (var t in inclusions) @@ -83,11 +83,11 @@ private static IDictionary DoInclude( return dict; } - private static IDictionary DoCombine(IReadOnlyList> baseTables) + private static SortedDictionary DoCombine(IReadOnlyList> baseTables) { if (baseTables.Count == 0) { - return new SortedDictionary(); + return []; } var combined = new SortedDictionary(baseTables[0]); diff --git a/src/Ubiety.Stringprep.Core/NormalizationStep.cs b/src/Ubiety.Stringprep.Core/NormalizationStep.cs index 89d16b8..b7b2133 100644 --- a/src/Ubiety.Stringprep.Core/NormalizationStep.cs +++ b/src/Ubiety.Stringprep.Core/NormalizationStep.cs @@ -31,19 +31,12 @@ namespace Ubiety.Stringprep.Core /// /// Normalization step. /// - internal class NormalizationStep : IPreparationProcess + /// + /// Initializes a new instance of the class. + /// + /// Normalization form to use. + internal class NormalizationStep(NormalizationForm normalizationForm) : IPreparationProcess { - private readonly NormalizationForm _normalizationForm; - - /// - /// Initializes a new instance of the class. - /// - /// Normalization form to use. - public NormalizationStep(NormalizationForm normalizationForm) - { - _normalizationForm = normalizationForm; - } - /// /// Run the step. /// @@ -51,7 +44,7 @@ public NormalizationStep(NormalizationForm normalizationForm) /// Normalized string. public string Run(string input) { - return input.Normalize(_normalizationForm); + return input.Normalize(normalizationForm); } } } \ No newline at end of file diff --git a/src/Ubiety.Stringprep.Core/PreparationProcessBuilder.cs b/src/Ubiety.Stringprep.Core/PreparationProcessBuilder.cs index c579608..8cbc0fb 100644 --- a/src/Ubiety.Stringprep.Core/PreparationProcessBuilder.cs +++ b/src/Ubiety.Stringprep.Core/PreparationProcessBuilder.cs @@ -35,7 +35,7 @@ namespace Ubiety.Stringprep.Core /// internal class PreparationProcessBuilder : IPreparationProcessBuilder { - private readonly IList _steps = new List(); + private readonly IList _steps = []; /// /// Add bidirectional step. diff --git a/src/Ubiety.Stringprep.Core/ProhibitedValueStep.cs b/src/Ubiety.Stringprep.Core/ProhibitedValueStep.cs index 2f3cbc2..3a77848 100644 --- a/src/Ubiety.Stringprep.Core/ProhibitedValueStep.cs +++ b/src/Ubiety.Stringprep.Core/ProhibitedValueStep.cs @@ -32,19 +32,12 @@ namespace Ubiety.Stringprep.Core /// /// Step that defines a prohibited value. /// - public class ProhibitedValueStep : IPreparationProcess + /// + /// Initializes a new instance of the class. + /// + /// Table of prohibited values. + public class ProhibitedValueStep(IValueRangeTable table) : IPreparationProcess { - private readonly IValueRangeTable _table; - - /// - /// Initializes a new instance of the class. - /// - /// Table of prohibited values. - public ProhibitedValueStep(IValueRangeTable table) - { - _table = table; - } - /// /// Executes the step. /// @@ -53,7 +46,7 @@ public ProhibitedValueStep(IValueRangeTable table) /// Thrown when input is prohibited. public string Run(string input) { - foreach (var value in input.Where(value => _table.Contains(value))) + foreach (var value in input.Where(value => table.Contains(value))) { throw new ProhibitedValueException(value); } diff --git a/src/Ubiety.Stringprep.Core/Ubiety.Stringprep.Core.xml b/src/Ubiety.Stringprep.Core/Ubiety.Stringprep.Core.xml index c7aba19..b61f882 100644 --- a/src/Ubiety.Stringprep.Core/Ubiety.Stringprep.Core.xml +++ b/src/Ubiety.Stringprep.Core/Ubiety.Stringprep.Core.xml @@ -8,11 +8,20 @@ Bidirectional stringprep step. + + Initializes a new instance of the class. + + Prohibited character table. + RandAL character table. + L character table. - Initializes a new instance of the class. + Bidirectional stringprep step. + + Initializes a new instance of the class. + Prohibited character table. RandAL character table. L character table. @@ -122,13 +131,6 @@ Exception message. Inner exception. - - - Initializes a new instance of the class. - - Serialization info. - Streaming context. - Prohibited value exception. @@ -159,13 +161,6 @@ Exception message. Inner exception. - - - Initializes a new instance of the class. - - Serialization info. - Streaming context. - Stringprep code tables. @@ -489,9 +484,8 @@ - Initializes a new instance of the class. + Mapping processing step. - Mapping table to use for processing. @@ -569,11 +563,18 @@ Mapping table builder. + + Initializes a new instance of the class. + + Base value tables. - Initializes a new instance of the class. + Mapping table builder. + + Initializes a new instance of the class. + Base value tables. @@ -638,11 +639,18 @@ Normalization step. + + Initializes a new instance of the class. + + Normalization form to use. - Initializes a new instance of the class. + Normalization step. + + Initializes a new instance of the class. + Normalization form to use. @@ -848,11 +856,18 @@ Step that defines a prohibited value. + + Initializes a new instance of the class. + + Table of prohibited values. - Initializes a new instance of the class. + Step that defines a prohibited value. + + Initializes a new instance of the class. + Table of prohibited values. @@ -955,11 +970,18 @@ Value range table builder. + + Initializes a new instance of the class. + + Value tables. - Initializes a new instance of the class. + Value range table builder. + + Initializes a new instance of the class. + Value tables. diff --git a/src/Ubiety.Stringprep.Core/ValueRangeCompiler.cs b/src/Ubiety.Stringprep.Core/ValueRangeCompiler.cs index e17607e..78313b6 100644 --- a/src/Ubiety.Stringprep.Core/ValueRangeCompiler.cs +++ b/src/Ubiety.Stringprep.Core/ValueRangeCompiler.cs @@ -26,7 +26,6 @@ using System; using System.Collections.Generic; -using System.Linq; namespace Ubiety.Stringprep.Core { @@ -52,7 +51,7 @@ public static int[] Compile(List[] baseTables, IList inclusions, IList Sort(inclusions); Sort(removals); - return DoRemove(DoReduce(DoInclude(DoCombine(baseTables), inclusions)), removals).ToArray(); + return [.. DoRemove(DoReduce(DoInclude(DoCombine(baseTables), inclusions)), removals)]; } private static void Sort(IList table) @@ -109,7 +108,7 @@ private static List DoCombine(IReadOnlyList> tables) { if (tables.Count == 1) { - return tables[0].ToList(); + return [.. tables[0]]; } var combined = new List(); @@ -155,7 +154,7 @@ private static List DoInclude(List list, IList inclusions) { if (inclusions[i] < list[0]) { - list.InsertRange(0, new[] { inclusions[i], inclusions[i + 1] }); + list.InsertRange(0, [inclusions[i], inclusions[i + 1]]); } else { @@ -167,7 +166,7 @@ private static List DoInclude(List list, IList inclusions) continue; } - list.InsertRange(j, new[] { inclusions[i], inclusions[i + 1] }); + list.InsertRange(j, [inclusions[i], inclusions[i + 1]]); break; } @@ -201,7 +200,7 @@ private static List DoRemove(List list, IList removals) return list; } - private static void CloseRemove(IList list, IList removals, ref int i, ref int j) + private static void CloseRemove(List list, IList removals, ref int i, ref int j) { for (i++; i < removals.Count; i += 2) { diff --git a/src/Ubiety.Stringprep.Core/ValueRangeTableBuilder.cs b/src/Ubiety.Stringprep.Core/ValueRangeTableBuilder.cs index 0d44ad8..f1167b4 100644 --- a/src/Ubiety.Stringprep.Core/ValueRangeTableBuilder.cs +++ b/src/Ubiety.Stringprep.Core/ValueRangeTableBuilder.cs @@ -33,22 +33,15 @@ namespace Ubiety.Stringprep.Core /// /// Value range table builder. /// - internal class ValueRangeTableBuilder : IValueRangeTableBuilder + /// + /// Initializes a new instance of the class. + /// + /// Value tables. + internal class ValueRangeTableBuilder(params List[] baseTables) : IValueRangeTableBuilder { - private readonly IList> _baseTables; - private readonly IList _inclusions; - private readonly IList _removals; - - /// - /// Initializes a new instance of the class. - /// - /// Value tables. - public ValueRangeTableBuilder(params List[] baseTables) - { - _baseTables = baseTables.ToList(); - _inclusions = new List(); - _removals = new List(); - } + private readonly IList> _baseTables = [.. baseTables]; + private readonly IList _inclusions = []; + private readonly IList _removals = []; /// /// Values to include in the tables. @@ -110,7 +103,7 @@ public IValueRangeTable Compile() throw new InvalidOperationException("At least one base table must be provided"); } - var ranges = ValueRangeCompiler.Compile(_baseTables.ToArray(), _inclusions, _removals.ToArray()); + var ranges = ValueRangeCompiler.Compile([.. _baseTables], _inclusions, [.. _removals]); return new ValueRangeTable(ranges); } }