From 55f50866186f5ea76cbf18ba45b36c60eb2ada11 Mon Sep 17 00:00:00 2001 From: Trevor Pilley Date: Mon, 20 Nov 2023 11:24:35 +0000 Subject: [PATCH 01/13] Update devcontainer to 8.0 --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e35f5f485..8edc28088 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,7 +3,7 @@ { "name": "C# (.NET)", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/dotnet:7.0", + "image": "mcr.microsoft.com/devcontainers/dotnet:8.0", // Features to add to the dev container. More info: https://containers.dev/features. // "features": {}, From 7c9e7c41ecfa90c8c81a1cc0fa6462194ef2da9f Mon Sep 17 00:00:00 2001 From: Trevor Pilley Date: Mon, 20 Nov 2023 11:26:06 +0000 Subject: [PATCH 02/13] target .NET 8.0 --- src/PhoneNumbers/PhoneNumbers.csproj | 2 +- test/PhoneNumbers.Data.Tests/PhoneNumbers.Data.Tests.csproj | 2 +- test/PhoneNumbers.Tests/PhoneNumbers.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PhoneNumbers/PhoneNumbers.csproj b/src/PhoneNumbers/PhoneNumbers.csproj index 4c24d0c3b..65861b7c1 100644 --- a/src/PhoneNumbers/PhoneNumbers.csproj +++ b/src/PhoneNumbers/PhoneNumbers.csproj @@ -3,7 +3,7 @@ PhoneNumbers PhoneNumbers - net7.0;netstandard2.1;netstandard2.0 + net8.0;netstandard2.1;netstandard2.0 11.0 enable AllEnabledByDefault diff --git a/test/PhoneNumbers.Data.Tests/PhoneNumbers.Data.Tests.csproj b/test/PhoneNumbers.Data.Tests/PhoneNumbers.Data.Tests.csproj index 96b9dd3b7..268e6b924 100644 --- a/test/PhoneNumbers.Data.Tests/PhoneNumbers.Data.Tests.csproj +++ b/test/PhoneNumbers.Data.Tests/PhoneNumbers.Data.Tests.csproj @@ -3,7 +3,7 @@ PhoneNumbers.Data.Tests PhoneNumbers.Tests - net7.0 + net8.0 false true ..\..\PhoneNumbers.snk diff --git a/test/PhoneNumbers.Tests/PhoneNumbers.Tests.csproj b/test/PhoneNumbers.Tests/PhoneNumbers.Tests.csproj index 5179996fb..d84131e8e 100644 --- a/test/PhoneNumbers.Tests/PhoneNumbers.Tests.csproj +++ b/test/PhoneNumbers.Tests/PhoneNumbers.Tests.csproj @@ -3,7 +3,7 @@ PhoneNumbers.Tests PhoneNumbers.Tests - net7.0 + net8.0 false true ..\..\PhoneNumbers.snk From 6e7f3597e61658a8443dc219d604f4ed6e259930 Mon Sep 17 00:00:00 2001 From: Trevor Pilley Date: Mon, 20 Nov 2023 11:28:45 +0000 Subject: [PATCH 03/13] Sourcelink is included in .NET 8.0 SDK --- src/PhoneNumbers/PhoneNumbers.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/PhoneNumbers/PhoneNumbers.csproj b/src/PhoneNumbers/PhoneNumbers.csproj index 65861b7c1..5b9fdecb1 100644 --- a/src/PhoneNumbers/PhoneNumbers.csproj +++ b/src/PhoneNumbers/PhoneNumbers.csproj @@ -42,10 +42,6 @@ - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - runtime; build; native; contentfiles; analyzers; buildtransitive all From 237b1374ffdb0fee86e190130ae57aa0874af794 Mon Sep 17 00:00:00 2001 From: Trevor Pilley Date: Mon, 20 Nov 2023 11:41:51 +0000 Subject: [PATCH 04/13] CA1859 Use concrete types when possible for improved performance --- src/PhoneNumbers/Parsers/ResourceUtility.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PhoneNumbers/Parsers/ResourceUtility.cs b/src/PhoneNumbers/Parsers/ResourceUtility.cs index 26a9eb0be..ec5cf0da5 100644 --- a/src/PhoneNumbers/Parsers/ResourceUtility.cs +++ b/src/PhoneNumbers/Parsers/ResourceUtility.cs @@ -1,3 +1,4 @@ +using System.Collections.ObjectModel; using System.Reflection; namespace PhoneNumbers.Parsers; @@ -43,7 +44,7 @@ private static PhoneNumberKind ParseNumberKind(char value) => _ => throw new NotSupportedException(value.ToString()), }; - private static IReadOnlyList ParseNumberRanges(string value) => + private static ReadOnlyCollection ParseNumberRanges(string value) => value .Split(Chars.Comma) .Select(NumberRange.Create) From 359c2a37860ae2590d28365a363241287d3fa25a Mon Sep 17 00:00:00 2001 From: Trevor Pilley Date: Mon, 20 Nov 2023 11:45:08 +0000 Subject: [PATCH 05/13] Ignore CA1510, API not in NETSTANDARD --- .editorconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.editorconfig b/.editorconfig index e7131d02a..f9a65ecc0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -172,6 +172,9 @@ dotnet_diagnostic.CA1305.severity = error # CA1310: Specify StringComparison for correctness dotnet_diagnostic.CA1310.severity = error +# CA1510: Use ArgumentNullException throw helper +dotnet_diagnostic.CA1510.severity = none + # SA1101: Prefix local calls with this dotnet_diagnostic.SA1101.severity = none From 7d97e09e837b405053cd12de2b2e556c53b92475 Mon Sep 17 00:00:00 2001 From: Trevor Pilley Date: Mon, 20 Nov 2023 11:47:44 +0000 Subject: [PATCH 06/13] Remove obsolete constructor --- src/PhoneNumbers/ParseException.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/PhoneNumbers/ParseException.cs b/src/PhoneNumbers/ParseException.cs index c90b7f536..87513a67e 100644 --- a/src/PhoneNumbers/ParseException.cs +++ b/src/PhoneNumbers/ParseException.cs @@ -5,7 +5,6 @@ namespace PhoneNumbers; /// /// An exception thrown when there is an issue parsing a phone number. /// -[Serializable] [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public class ParseException : Exception { @@ -34,14 +33,4 @@ public ParseException(string? message, Exception? innerException) : base(message, innerException) { } - - /// - /// Initializes a new instance of the class. - /// - /// The that holds the serialized object data about the exception being thrown. - /// The that contains contextual information about the source or destination. - protected ParseException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } From abcf1bda236d10975f88dff2cd1ea0fd96ac4dab Mon Sep 17 00:00:00 2001 From: Trevor Pilley Date: Mon, 20 Nov 2023 12:04:24 +0000 Subject: [PATCH 07/13] Resolve possible NRE --- src/PhoneNumbers/ParseOptionsExtensions.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/PhoneNumbers/ParseOptionsExtensions.cs b/src/PhoneNumbers/ParseOptionsExtensions.cs index a824890b9..f8b90bbc5 100644 --- a/src/PhoneNumbers/ParseOptionsExtensions.cs +++ b/src/PhoneNumbers/ParseOptionsExtensions.cs @@ -89,9 +89,14 @@ public static ParseOptions AllowUnitedKingdomNumberingPlanCountries(this ParseOp private static ParseOptions Allow(ParseOptions parseOptions, Func predicate) { + if (parseOptions is null) + { + throw new ArgumentNullException(nameof(parseOptions)); + } + foreach (var countryInfo in CountryInfo.GetCountries(predicate)) { - parseOptions?.Countries.Add(countryInfo); + parseOptions.Countries.Add(countryInfo); } return parseOptions; From bf74b0c198b761c08e2ab70b261691e791829a67 Mon Sep 17 00:00:00 2001 From: Trevor Pilley Date: Mon, 20 Nov 2023 12:17:03 +0000 Subject: [PATCH 08/13] docs --- NuGet.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.md b/NuGet.md index 29bf7e24e..68bd17955 100644 --- a/NuGet.md +++ b/NuGet.md @@ -31,6 +31,6 @@ phoneNumber.ToString("RFC3966"); // tel:+44-114-272-644 (RFC3966 format) Builds for: -- .NET 7.0 +- .NET 8.0 - .NET Standard 2.1 - _supports .NET Core 3.0 or newer and .NET 5.0 or newer_ - .NET Standard 2.0 - _supports .NET Framework 4.6.2 or newer, however projects will need to be built with a minimum C# language version of 9.0 due to use of init only properties_ diff --git a/README.md b/README.md index 8d5c7c664..3cd685392 100644 --- a/README.md +++ b/README.md @@ -160,7 +160,7 @@ The library adheres to [Semantic Versioning](https://semver.org) and [release no Specific builds are included in the nuget package for: -- .NET 7.0 +- .NET 8.0 - .NET Standard 2.1 - _supports .NET Core 3.0 or newer and .NET 5.0 or newer_ - .NET Standard 2.0 - _supports .NET Framework 4.6.2 or newer, however projects will need to be built with a minimum C# language version of 9.0 due to use of init only properties_ From d1481990692b1fca324f9c5ffecaa14039b5fe2f Mon Sep 17 00:00:00 2001 From: Trevor Pilley Date: Mon, 20 Nov 2023 12:19:24 +0000 Subject: [PATCH 09/13] C# 12 --- src/PhoneNumbers/PhoneNumbers.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhoneNumbers/PhoneNumbers.csproj b/src/PhoneNumbers/PhoneNumbers.csproj index 5b9fdecb1..9fb82c3e4 100644 --- a/src/PhoneNumbers/PhoneNumbers.csproj +++ b/src/PhoneNumbers/PhoneNumbers.csproj @@ -4,7 +4,7 @@ PhoneNumbers PhoneNumbers net8.0;netstandard2.1;netstandard2.0 - 11.0 + 12.0 enable AllEnabledByDefault true From 5a7a83ed0a1a5cb586ee2875e13521daeb812257 Mon Sep 17 00:00:00 2001 From: Trevor Pilley Date: Mon, 20 Nov 2023 16:04:51 +0000 Subject: [PATCH 10/13] Update CI.yml --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index bc8710543..b6d354b16 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -55,7 +55,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name : dotnet restore run: dotnet restore From e031a381c0e9e703eed86b5bfa5a57c24a4c513c Mon Sep 17 00:00:00 2001 From: Trevor Pilley Date: Mon, 20 Nov 2023 16:05:15 +0000 Subject: [PATCH 11/13] Update publish.yml --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index eaa63d192..c1823264e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -46,7 +46,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Set release version if: github.ref_type == 'tag' From cdcf83ad025c303e9160c11b4c71cdf3bcedaa64 Mon Sep 17 00:00:00 2001 From: Trevor Pilley Date: Tue, 21 Nov 2023 10:42:05 +0000 Subject: [PATCH 12/13] Add test --- test/PhoneNumbers.Tests/ParseOptionsTests.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/PhoneNumbers.Tests/ParseOptionsTests.cs b/test/PhoneNumbers.Tests/ParseOptionsTests.cs index 5acbfc80c..7b69aea17 100644 --- a/test/PhoneNumbers.Tests/ParseOptionsTests.cs +++ b/test/PhoneNumbers.Tests/ParseOptionsTests.cs @@ -1,3 +1,4 @@ +using System; using System.Reflection; namespace PhoneNumbers.Tests; @@ -125,6 +126,18 @@ public void Default() Assert.Equal(countryInfos, ParseOptions.Default.Countries); } + [Fact] + public void Extensions_Throw_If_ParseOptions_Null() + { + var parseOptions = default(ParseOptions); + + typeof(ParseOptions) + .GetMethods(BindingFlags.Static | BindingFlags.Public) + .Where(x => x.GetParameters().Length == 1 && x.GetParameters()[0].ParameterType == typeof(ParseOptions)) + .ToList() + .ForEach(x => Assert.Throws(() => x.Invoke(null, [parseOptions]))); + } + [Fact] public void GetCountryInfo_Does_Not_Exist() => Assert.Null(ParseOptions.Default.GetCountryInfo("ZZ")); From b9da9692bbb41da2bb94cbc4aba4d1a7ca75ffe6 Mon Sep 17 00:00:00 2001 From: Trevor Pilley Date: Tue, 21 Nov 2023 11:06:40 +0000 Subject: [PATCH 13/13] Collection expressions --- CONTRIBUTING.md | 2 +- src/PhoneNumbers/CountryInfo.cs | 6 +- src/PhoneNumbers/CountryInfo_Africa.cs | 16 +- src/PhoneNumbers/CountryInfo_Asia.cs | 6 +- src/PhoneNumbers/CountryInfo_Europe.cs | 150 +++++++++---------- src/PhoneNumbers/CountryInfo_NorthAmerica.cs | 4 +- src/PhoneNumbers/CountryInfo_Oceania.cs | 8 +- src/PhoneNumbers/CountryInfo_SouthAmerica.cs | 4 +- 8 files changed, 98 insertions(+), 98 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4d1a44132..5fb2e7250 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,7 +33,7 @@ public static CountryInfo CountryName { get; } = new() Continent = Africa/Asia/Europe/Oceania/NorthAmerica/SouthAmerica, // as appropriate Iso3166Code = "ZZ", Name = "CountryName", - NsnLengths = new ReadOnlyCollection(new[] { N }), + NsnLengths = new ReadOnlyCollection([N]), }; ``` diff --git a/src/PhoneNumbers/CountryInfo.cs b/src/PhoneNumbers/CountryInfo.cs index a79022200..085a6f8ee 100644 --- a/src/PhoneNumbers/CountryInfo.cs +++ b/src/PhoneNumbers/CountryInfo.cs @@ -19,13 +19,13 @@ public sealed partial class CountryInfo internal const string Oceania = "Oceania"; internal const string SouthAmerica = "South America"; private static readonly ReadOnlyCollection s_emptyIntArray = new(Array.Empty()); - private static readonly ReadOnlyCollection s_formatters = new(new[] - { + private static readonly ReadOnlyCollection s_formatters = new( + [ E164PhoneNumberFormatter.Instance, E123PhoneNumberFormatter.Instance, NationalPhoneNumberFormatter.Instance, Rfc3966PhoneNumberFormatter.Instance, - }); + ]); /// /// Initialises a new instance of the class. diff --git a/src/PhoneNumbers/CountryInfo_Africa.cs b/src/PhoneNumbers/CountryInfo_Africa.cs index 6ba7e22c5..cc8297a1e 100644 --- a/src/PhoneNumbers/CountryInfo_Africa.cs +++ b/src/PhoneNumbers/CountryInfo_Africa.cs @@ -14,8 +14,8 @@ public partial class CountryInfo Continent = Africa, Iso3166Code = "EG", Name = "Egypt", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2, 1 }), - NsnLengths = new ReadOnlyCollection(new[] { 8, 9, 10, 11 }), + NdcLengths = new ReadOnlyCollection([3, 2, 1]), + NsnLengths = new ReadOnlyCollection([8, 9, 10, 11]), TrunkPrefix = "0", }; @@ -29,8 +29,8 @@ public partial class CountryInfo FormatProvider = SimplePhoneNumberFormatProvider.Default, Iso3166Code = "KE", Name = "Kenya", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 7, 8, 9, 12 }), + NdcLengths = new ReadOnlyCollection([3, 2]), + NsnLengths = new ReadOnlyCollection([7, 8, 9, 12]), TrunkPrefix = "0", }; @@ -44,8 +44,8 @@ public partial class CountryInfo Continent = Africa, Iso3166Code = "NG", Name = "Nigeria", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2, 1 }), - NsnLengths = new ReadOnlyCollection(new[] { 8, 10 }), + NdcLengths = new ReadOnlyCollection([3, 2, 1]), + NsnLengths = new ReadOnlyCollection([8, 10]), TrunkPrefix = "0", }; @@ -58,8 +58,8 @@ public partial class CountryInfo Continent = Africa, Iso3166Code = "ZA", Name = "South Africa", - NdcLengths = new ReadOnlyCollection(new[] { 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 9, 13 }), + NdcLengths = new ReadOnlyCollection([2]), + NsnLengths = new ReadOnlyCollection([9, 13]), TrunkPrefix = "0", }; } diff --git a/src/PhoneNumbers/CountryInfo_Asia.cs b/src/PhoneNumbers/CountryInfo_Asia.cs index 524a34816..c6276433f 100644 --- a/src/PhoneNumbers/CountryInfo_Asia.cs +++ b/src/PhoneNumbers/CountryInfo_Asia.cs @@ -13,7 +13,7 @@ public partial class CountryInfo Continent = Asia, Iso3166Code = "HK", Name = "Hong Kong", - NsnLengths = new ReadOnlyCollection(new[] { 8, 9, 12 }), + NsnLengths = new ReadOnlyCollection([8, 9, 12]), }; /// @@ -25,7 +25,7 @@ public partial class CountryInfo Continent = Asia, Iso3166Code = "MO", Name = "Macau", - NsnLengths = new ReadOnlyCollection(new[] { 8 }), + NsnLengths = new ReadOnlyCollection([8]), }; /// @@ -37,6 +37,6 @@ public partial class CountryInfo Continent = Asia, Iso3166Code = "SG", Name = "Singapore", - NsnLengths = new ReadOnlyCollection(new[] { 8, 10, 11 }), + NsnLengths = new ReadOnlyCollection([8, 10, 11]), }; } diff --git a/src/PhoneNumbers/CountryInfo_Europe.cs b/src/PhoneNumbers/CountryInfo_Europe.cs index 88e050348..21f01d3fa 100644 --- a/src/PhoneNumbers/CountryInfo_Europe.cs +++ b/src/PhoneNumbers/CountryInfo_Europe.cs @@ -15,8 +15,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "AT", Name = "Austria", - NdcLengths = new ReadOnlyCollection(new[] { 4, 3, 2, 1 }), - NsnLengths = new ReadOnlyCollection(new[] { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }), + NdcLengths = new ReadOnlyCollection([4, 3, 2, 1]), + NsnLengths = new ReadOnlyCollection([4, 5, 6, 7, 8, 9, 10, 11, 12, 13]), TrunkPrefix = "0", }; @@ -30,8 +30,8 @@ public partial class CountryInfo Iso3166Code = "BY", FormatProvider = SimplePhoneNumberFormatProvider.Default, Name = "Belarus", - NdcLengths = new ReadOnlyCollection(new[] { 4, 3, 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 6, 9, 10, 11 }), + NdcLengths = new ReadOnlyCollection([4, 3, 2]), + NsnLengths = new ReadOnlyCollection([6, 9, 10, 11]), TrunkPrefix = "8", }; @@ -46,8 +46,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "BE", Name = "Belgium", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2, 1 }), - NsnLengths = new ReadOnlyCollection(new[] { 8, 9 }), + NdcLengths = new ReadOnlyCollection([3, 2, 1]), + NsnLengths = new ReadOnlyCollection([8, 9]), TrunkPrefix = "0", }; @@ -62,8 +62,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "BG", Name = "Bulgaria", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2, 1 }), - NsnLengths = new ReadOnlyCollection(new[] { 8, 9, 12 }), + NdcLengths = new ReadOnlyCollection([3, 2, 1]), + NsnLengths = new ReadOnlyCollection([8, 9, 12]), TrunkPrefix = "0", }; @@ -78,8 +78,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "HR", Name = "Croatia", - NdcLengths = new ReadOnlyCollection(new[] { 5, 4, 3, 2, 1 }), - NsnLengths = new ReadOnlyCollection(new[] { 6, 7, 8, 9, 10 }), + NdcLengths = new ReadOnlyCollection([5, 4, 3, 2, 1]), + NsnLengths = new ReadOnlyCollection([6, 7, 8, 9, 10]), TrunkPrefix = "0", }; @@ -94,8 +94,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "CY", Name = "Cyprus", - NdcLengths = new ReadOnlyCollection(new[] { 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 8 }), + NdcLengths = new ReadOnlyCollection([2]), + NsnLengths = new ReadOnlyCollection([8]), }; /// @@ -109,8 +109,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "CZ", Name = "Czech Republic", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2, 1 }), - NsnLengths = new ReadOnlyCollection(new[] { 7, 9, 10, 11, 12 }), + NdcLengths = new ReadOnlyCollection([3, 2, 1]), + NsnLengths = new ReadOnlyCollection([7, 9, 10, 11, 12]), }; /// @@ -123,7 +123,7 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "DK", Name = "Denmark", - NsnLengths = new ReadOnlyCollection(new[] { 8 }), + NsnLengths = new ReadOnlyCollection([8]), }; /// @@ -137,8 +137,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "EE", Name = "Estonia", - NdcLengths = new ReadOnlyCollection(new[] { 4, 3, 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 7, 8, 10, 12 }), + NdcLengths = new ReadOnlyCollection([4, 3, 2]), + NsnLengths = new ReadOnlyCollection([7, 8, 10, 12]), }; /// @@ -152,8 +152,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "FI", Name = "Finland", - NdcLengths = new ReadOnlyCollection(new[] { 4, 3, 2, 1 }), - NsnLengths = new ReadOnlyCollection(new[] { 5, 6, 7, 8, 9, 10, 11, 12 }), + NdcLengths = new ReadOnlyCollection([4, 3, 2, 1]), + NsnLengths = new ReadOnlyCollection([5, 6, 7, 8, 9, 10, 11, 12]), TrunkPrefix = "0", }; @@ -168,7 +168,7 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "FR", Name = "France", - NsnLengths = new ReadOnlyCollection(new[] { 9, 13 }), + NsnLengths = new ReadOnlyCollection([9, 13]), TrunkPrefix = "0", }; @@ -183,8 +183,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "DE", Name = "Germany", - NdcLengths = new ReadOnlyCollection(new[] { 5, 4, 3, 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }), + NdcLengths = new ReadOnlyCollection([5, 4, 3, 2]), + NsnLengths = new ReadOnlyCollection([4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]), TrunkPrefix = "0", }; @@ -198,8 +198,8 @@ public partial class CountryInfo FormatProvider = BasicPhoneNumberFormatProvider.Instance, Iso3166Code = "GI", Name = "Gibraltar", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 4, 8 }), + NdcLengths = new ReadOnlyCollection([3, 2]), + NsnLengths = new ReadOnlyCollection([4, 8]), }; /// @@ -213,8 +213,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "GR", Name = "Greece", - NdcLengths = new ReadOnlyCollection(new[] { 4, 3, 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 10 }), + NdcLengths = new ReadOnlyCollection([4, 3, 2]), + NsnLengths = new ReadOnlyCollection([10]), }; /// @@ -228,8 +228,8 @@ public partial class CountryInfo FormatProvider = GBPhoneNumberFormatProvider.Instance, Iso3166Code = "GG", Name = "Guernsey", - NdcLengths = new ReadOnlyCollection(new[] { 4 }), - NsnLengths = new ReadOnlyCollection(new[] { 10 }), + NdcLengths = new ReadOnlyCollection([4]), + NsnLengths = new ReadOnlyCollection([10]), SharesCallingCode = true, TrunkPrefix = "0", }; @@ -245,8 +245,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "HU", Name = "Hungary", - NdcLengths = new ReadOnlyCollection(new[] { 2, 1 }), - NsnLengths = new ReadOnlyCollection(new[] { 8, 9, 12 }), + NdcLengths = new ReadOnlyCollection([2, 1]), + NsnLengths = new ReadOnlyCollection([8, 9, 12]), TrunkPrefix = "06", }; @@ -262,8 +262,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "IE", Name = "Ireland", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2, 1 }), - NsnLengths = new ReadOnlyCollection(new[] { 7, 8, 9, 12 }), + NdcLengths = new ReadOnlyCollection([3, 2, 1]), + NsnLengths = new ReadOnlyCollection([7, 8, 9, 12]), TrunkPrefix = "0", }; @@ -278,8 +278,8 @@ public partial class CountryInfo FormatProvider = GBPhoneNumberFormatProvider.Instance, Iso3166Code = "IM", Name = "Isle of Man", - NdcLengths = new ReadOnlyCollection(new[] { 4 }), - NsnLengths = new ReadOnlyCollection(new[] { 10 }), + NdcLengths = new ReadOnlyCollection([4]), + NsnLengths = new ReadOnlyCollection([10]), SharesCallingCode = true, TrunkPrefix = "0", }; @@ -296,8 +296,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "IT", Name = "Italy", - NdcLengths = new ReadOnlyCollection(new[] { 5, 4, 3, 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 5, 6, 7, 8, 9, 10, 11 }), + NdcLengths = new ReadOnlyCollection([5, 4, 3, 2]), + NsnLengths = new ReadOnlyCollection([5, 6, 7, 8, 9, 10, 11]), }; /// @@ -311,8 +311,8 @@ public partial class CountryInfo FormatProvider = GBPhoneNumberFormatProvider.Instance, Iso3166Code = "JE", Name = "Jersey", - NdcLengths = new ReadOnlyCollection(new[] { 4 }), - NsnLengths = new ReadOnlyCollection(new[] { 10 }), + NdcLengths = new ReadOnlyCollection([4]), + NsnLengths = new ReadOnlyCollection([10]), SharesCallingCode = true, TrunkPrefix = "0", }; @@ -327,8 +327,8 @@ public partial class CountryInfo Continent = Europe, Iso3166Code = "XK", Name = "Kosovo", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 8, 9 }), + NdcLengths = new ReadOnlyCollection([3, 2]), + NsnLengths = new ReadOnlyCollection([8, 9]), TrunkPrefix = "0", }; @@ -343,7 +343,7 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "LV", Name = "Latvia", - NsnLengths = new ReadOnlyCollection(new[] { 8 }), + NsnLengths = new ReadOnlyCollection([8]), }; /// @@ -357,8 +357,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "LT", Name = "Lithuania", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2, 1 }), - NsnLengths = new ReadOnlyCollection(new[] { 8 }), + NdcLengths = new ReadOnlyCollection([3, 2, 1]), + NsnLengths = new ReadOnlyCollection([8]), TrunkPrefix = "8", }; @@ -373,7 +373,7 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "LU", Name = "Luxembourg", - NsnLengths = new ReadOnlyCollection(new[] { 4, 5, 6, 7, 8, 9, 10, 11, 12 }), + NsnLengths = new ReadOnlyCollection([4, 5, 6, 7, 8, 9, 10, 11, 12]), }; /// @@ -387,8 +387,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "MT", Name = "Malta", - NdcLengths = new ReadOnlyCollection(new[] { 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 8, 10 }), + NdcLengths = new ReadOnlyCollection([2]), + NsnLengths = new ReadOnlyCollection([8, 10]), }; /// @@ -400,8 +400,8 @@ public partial class CountryInfo Continent = Europe, Iso3166Code = "MD", Name = "Moldova", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 5, 6, 7, 8 }), + NdcLengths = new ReadOnlyCollection([3, 2]), + NsnLengths = new ReadOnlyCollection([5, 6, 7, 8]), TrunkPrefix = "0", }; @@ -415,7 +415,7 @@ public partial class CountryInfo FormatProvider = MCPhoneNumberFormatProvider.Instance, Iso3166Code = "MC", Name = "Monaco", - NsnLengths = new ReadOnlyCollection(new[] { 8, 9, 12 }), + NsnLengths = new ReadOnlyCollection([8, 9, 12]), }; /// @@ -429,8 +429,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "NL", Name = "Netherlands", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 9 }), + NdcLengths = new ReadOnlyCollection([3, 2]), + NsnLengths = new ReadOnlyCollection([9]), TrunkPrefix = "0", }; @@ -444,7 +444,7 @@ public partial class CountryInfo FormatProvider = NOPhoneNumberFormatProvider.Instance, Iso3166Code = "NO", Name = "Norway", - NsnLengths = new ReadOnlyCollection(new[] { 8, 12 }), + NsnLengths = new ReadOnlyCollection([8, 12]), }; /// @@ -458,8 +458,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "PL", Name = "Poland", - NdcLengths = new ReadOnlyCollection(new[] { 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 6, 7, 8, 9 }), + NdcLengths = new ReadOnlyCollection([2]), + NsnLengths = new ReadOnlyCollection([6, 7, 8, 9]), }; /// @@ -472,8 +472,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "PT", Name = "Portugal", - NdcLengths = new ReadOnlyCollection(new[] { 3 }), - NsnLengths = new ReadOnlyCollection(new[] { 9 }), + NdcLengths = new ReadOnlyCollection([3]), + NsnLengths = new ReadOnlyCollection([9]), }; /// @@ -487,8 +487,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "RO", Name = "Romania", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 6, 7, 8, 9 }), + NdcLengths = new ReadOnlyCollection([3, 2]), + NsnLengths = new ReadOnlyCollection([6, 7, 8, 9]), TrunkPrefix = "0", }; @@ -502,7 +502,7 @@ public partial class CountryInfo FormatProvider = SimplePhoneNumberFormatProvider.Default, Iso3166Code = "SM", Name = "San Marino", - NsnLengths = new ReadOnlyCollection(new[] { 6, 7, 8, 9, 10 }), + NsnLengths = new ReadOnlyCollection([6, 7, 8, 9, 10]), }; /// @@ -515,8 +515,8 @@ public partial class CountryInfo Continent = Europe, Iso3166Code = "RS", Name = "Serbia", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 8, 9, 10, 11, 12 }), + NdcLengths = new ReadOnlyCollection([3, 2]), + NsnLengths = new ReadOnlyCollection([8, 9, 10, 11, 12]), TrunkPrefix = "0", }; @@ -530,8 +530,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "SK", Name = "Slovakia", - NdcLengths = new ReadOnlyCollection(new[] { 4, 3, 2, 1 }), - NsnLengths = new ReadOnlyCollection(new[] { 7, 9 }), + NdcLengths = new ReadOnlyCollection([4, 3, 2, 1]), + NsnLengths = new ReadOnlyCollection([7, 9]), TrunkPrefix = "0", }; @@ -547,8 +547,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "SL", Name = "Slovenia", - NdcLengths = new ReadOnlyCollection(new[] { 4, 3, 2, 1 }), - NsnLengths = new ReadOnlyCollection(new[] { 8, 12 }), + NdcLengths = new ReadOnlyCollection([4, 3, 2, 1]), + NsnLengths = new ReadOnlyCollection([8, 12]), TrunkPrefix = "0", }; @@ -563,8 +563,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "ES", Name = "Spain", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 9, 13 }), + NdcLengths = new ReadOnlyCollection([3, 2]), + NsnLengths = new ReadOnlyCollection([9, 13]), }; /// @@ -579,8 +579,8 @@ public partial class CountryInfo IsEuropeanUnionMember = true, Iso3166Code = "SE", Name = "Sweden", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2, 1 }), - NsnLengths = new ReadOnlyCollection(new[] { 6, 7, 8, 9, 10, 13 }), + NdcLengths = new ReadOnlyCollection([3, 2, 1]), + NsnLengths = new ReadOnlyCollection([6, 7, 8, 9, 10, 13]), TrunkPrefix = "0", }; @@ -594,8 +594,8 @@ public partial class CountryInfo FormatProvider = CHPhoneNumberFormatProvider.Instance, Iso3166Code = "CH", Name = "Switzerland", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 9 }), + NdcLengths = new ReadOnlyCollection([3, 2]), + NsnLengths = new ReadOnlyCollection([9]), TrunkPrefix = "0", }; @@ -610,8 +610,8 @@ public partial class CountryInfo FormatProvider = UAPhoneNumberFormatProvider.Instance, Iso3166Code = "UA", Name = "Ukraine", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 9, 10 }), + NdcLengths = new ReadOnlyCollection([3, 2]), + NsnLengths = new ReadOnlyCollection([9, 10]), TrunkPrefix = "0", }; @@ -627,8 +627,8 @@ public partial class CountryInfo FormatProvider = GBPhoneNumberFormatProvider.Instance, Iso3166Code = "GB", Name = "United Kingdom", - NdcLengths = new ReadOnlyCollection(new[] { 5, 4, 3, 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 7, 9, 10 }), + NdcLengths = new ReadOnlyCollection([5, 4, 3, 2]), + NsnLengths = new ReadOnlyCollection([7, 9, 10]), TrunkPrefix = "0", }; } diff --git a/src/PhoneNumbers/CountryInfo_NorthAmerica.cs b/src/PhoneNumbers/CountryInfo_NorthAmerica.cs index 901af0342..b04e27708 100644 --- a/src/PhoneNumbers/CountryInfo_NorthAmerica.cs +++ b/src/PhoneNumbers/CountryInfo_NorthAmerica.cs @@ -6,8 +6,8 @@ namespace PhoneNumbers; public partial class CountryInfo { internal const string NanpCallingCode = "1"; - private static readonly ReadOnlyCollection s_nanpNdcLengths = new(new[] { 3 }); - private static readonly ReadOnlyCollection s_nanpNsnLengths = new(new[] { 10 }); + private static readonly ReadOnlyCollection s_nanpNdcLengths = new([3]); + private static readonly ReadOnlyCollection s_nanpNsnLengths = new([10]); /// /// Gets the for Anguilla. diff --git a/src/PhoneNumbers/CountryInfo_Oceania.cs b/src/PhoneNumbers/CountryInfo_Oceania.cs index 4b2579e84..cda854c0b 100644 --- a/src/PhoneNumbers/CountryInfo_Oceania.cs +++ b/src/PhoneNumbers/CountryInfo_Oceania.cs @@ -32,8 +32,8 @@ public partial class CountryInfo FormatProvider = AUPhoneNumberFormatProvider.Instance, Iso3166Code = "AU", Name = "Australia", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2, 1 }), - NsnLengths = new ReadOnlyCollection(new[] { 5, 6, 7, 8, 9, 10 }), + NdcLengths = new ReadOnlyCollection([3, 2, 1]), + NsnLengths = new ReadOnlyCollection([5, 6, 7, 8, 9, 10]), TrunkPrefix = "0", }; @@ -62,7 +62,7 @@ public partial class CountryInfo Continent = Oceania, Iso3166Code = "PG", Name = "Papua New Guinea", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 7, 8 }), + NdcLengths = new ReadOnlyCollection([3, 2]), + NsnLengths = new ReadOnlyCollection([7, 8]), }; } diff --git a/src/PhoneNumbers/CountryInfo_SouthAmerica.cs b/src/PhoneNumbers/CountryInfo_SouthAmerica.cs index f38954d76..6e6a86000 100644 --- a/src/PhoneNumbers/CountryInfo_SouthAmerica.cs +++ b/src/PhoneNumbers/CountryInfo_SouthAmerica.cs @@ -16,8 +16,8 @@ public partial class CountryInfo FormatProvider = BRPhoneNumberFormatProvider.Instance, Iso3166Code = "BR", Name = "Brazil", - NdcLengths = new ReadOnlyCollection(new[] { 3, 2 }), - NsnLengths = new ReadOnlyCollection(new[] { 10, 11 }), + NdcLengths = new ReadOnlyCollection([3, 2]), + NsnLengths = new ReadOnlyCollection([10, 11]), TrunkPrefix = "0", }; }