From ac95044f81d61aba8b160a7df1eb2581b7410aa2 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 3 Feb 2022 10:14:02 -0800 Subject: [PATCH 01/15] Drop .NET Standard 2.0/2.1. Add .NET 6.0 --- .github/workflows/test.yml | 10 +++++----- .../MaxMind.Db.Benchmark.csproj | 7 +++---- MaxMind.Db.Test/MaxMind.Db.Test.csproj | 7 +++---- MaxMind.Db/Buffer.cs | 6 ------ MaxMind.Db/MaxMind.Db.csproj | 7 +++---- MaxMind.Db/MemoryMapBuffer.cs | 20 ------------------- MaxMind.Db/Properties/AssemblyInfo.cs | 4 ++-- README.md | 4 ++-- releasenotes.md | 4 ++++ 9 files changed, 22 insertions(+), 47 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 61d1ec1..ba47938 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,11 +17,6 @@ jobs: with: submodules: true - - name: Setup dotnet 2.2 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 2.2 - - name: Setup dotnet 3.1 uses: actions/setup-dotnet@v1 with: @@ -32,6 +27,11 @@ jobs: with: dotnet-version: 5.0.* + - name: Setup .NET 6.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.* + - name: Build run: | dotnet build MaxMind.Db diff --git a/MaxMind.Db.Benchmark/MaxMind.Db.Benchmark.csproj b/MaxMind.Db.Benchmark/MaxMind.Db.Benchmark.csproj index 6404d87..35bbafe 100644 --- a/MaxMind.Db.Benchmark/MaxMind.Db.Benchmark.csproj +++ b/MaxMind.Db.Benchmark/MaxMind.Db.Benchmark.csproj @@ -2,9 +2,8 @@ Benchmark project to validate .NET reader for the MaxMind DB file format - 2.0.0 - net461;net5.0;netcoreapp2.1;netcoreapp3.1 - net5.0;netcoreapp2.1;netcoreapp3.1 + 4.0.0 + net6.0;net5.0;netcoreapp3.1 MaxMind.Db.Benchmark Exe MaxMind.Db.Benchmark @@ -18,7 +17,7 @@ false false false - 9.0 + 10.0 enable latest true diff --git a/MaxMind.Db.Test/MaxMind.Db.Test.csproj b/MaxMind.Db.Test/MaxMind.Db.Test.csproj index 7545b6e..8ed34d6 100644 --- a/MaxMind.Db.Test/MaxMind.Db.Test.csproj +++ b/MaxMind.Db.Test/MaxMind.Db.Test.csproj @@ -2,9 +2,8 @@ Test project to validate .NET reader for the MaxMind DB file format - 2.0.0 - net461;net5.0;netcoreapp2.1;netcoreapp3.1 - net5.0;netcoreapp2.1;netcoreapp3.1 + 4.0.0 + net6.0;net5.0;netcoreapp3.1 MaxMind.Db.Test ../MaxMind.snk true @@ -21,7 +20,7 @@ false false false - 9.0 + 10.0 enable latest true diff --git a/MaxMind.Db/Buffer.cs b/MaxMind.Db/Buffer.cs index 0deee6c..231ff28 100644 --- a/MaxMind.Db/Buffer.cs +++ b/MaxMind.Db/Buffer.cs @@ -52,13 +52,7 @@ internal double ReadDouble(long offset) /// internal float ReadFloat(long offset) { -#if NETSTANDARD2_0 || NET461 - var buffer = Read(offset, 4); - Array.Reverse(buffer); - return BitConverter.ToSingle(buffer, 0); -#else return BitConverter.Int32BitsToSingle(ReadInt(offset)); -#endif } /// diff --git a/MaxMind.Db/MaxMind.Db.csproj b/MaxMind.Db/MaxMind.Db.csproj index b4c2441..97a2a7d 100644 --- a/MaxMind.Db/MaxMind.Db.csproj +++ b/MaxMind.Db/MaxMind.Db.csproj @@ -2,9 +2,8 @@ .NET reader for the MaxMind DB file format - 3.0.0 - net461;net5.0;netstandard2.0;netstandard2.1 - net5.0;netstandard2.0;netstandard2.1 + 4.0.0 + net6.0;net5.0;netstandard2.1 true MaxMind.Db ../MaxMind.snk @@ -25,7 +24,7 @@ false false false - 9.0 + 10.0 true enable latest diff --git a/MaxMind.Db/MemoryMapBuffer.cs b/MaxMind.Db/MemoryMapBuffer.cs index 7fc8cf6..5df0dc3 100644 --- a/MaxMind.Db/MemoryMapBuffer.cs +++ b/MaxMind.Db/MemoryMapBuffer.cs @@ -36,36 +36,16 @@ private MemoryMapBuffer(string file, bool useGlobalNamespace, FileInfo fileInfo) { _memoryMappedFile = MemoryMappedFile.OpenExisting(mapName, MemoryMappedFileRights.Read); } -#if !NETSTANDARD2_0 && !NETSTANDARD2_1 && !NET5_0 - catch (Exception ex) when (ex is IOException || ex is NotImplementedException) -#else // Note that PNSE is only required by .NetStandard1.0, see the subsequent comment for more context catch (Exception ex) when (ex is IOException || ex is NotImplementedException || ex is PlatformNotSupportedException) -#endif { -#if !NETSTANDARD2_0 && !NETSTANDARD2_1 && !NET5_0 - var security = new MemoryMappedFileSecurity(); - security.AddAccessRule( - new System.Security.AccessControl.AccessRule( - new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, null), - MemoryMappedFileRights.Read, - System.Security.AccessControl.AccessControlType.Allow)); - - _memoryMappedFile = MemoryMappedFile.CreateFromFile(stream, mapName, Length, - MemoryMappedFileAccess.Read, security, HandleInheritability.None, false); -#else - // In .NET Core, named maps are not supported for Unices yet: https://github.com/dotnet/corefx/issues/1329 // When executed on unsupported platform, we get the PNSE. In which case, we consruct the memory map by // setting mapName to null. if (ex is PlatformNotSupportedException) mapName = null; - // In NetStandard1.0 (docs: http://bit.ly/1TOKXEw) and since .Net46 (https://msdn.microsoft.com/en-us/library/dn804422.aspx) - // CreateFromFile has a new overload with six arguments (modulo MemoryMappedFileSecurity). While the one with seven arguments - // is still available in .Net46, that has been removed from netstandard1.0. _memoryMappedFile = MemoryMappedFile.CreateFromFile(stream, mapName, Length, MemoryMappedFileAccess.Read, HandleInheritability.None, false); -#endif } } diff --git a/MaxMind.Db/Properties/AssemblyInfo.cs b/MaxMind.Db/Properties/AssemblyInfo.cs index b5846d7..405d148 100644 --- a/MaxMind.Db/Properties/AssemblyInfo.cs +++ b/MaxMind.Db/Properties/AssemblyInfo.cs @@ -42,8 +42,8 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.0")] -[assembly: AssemblyFileVersion("2.0.0")] +[assembly: AssemblyVersion("4.0.0")] +[assembly: AssemblyFileVersion("4.0.0")] [assembly: InternalsVisibleTo("MaxMind.Db.Test,PublicKey=" + "0024000004800000940000000602000000240000525341310004000001000100e30b6e4a9425b1" + "617ffc8bdf79801e67a371f9f650db860dc0dfff92cb63258765a0955c6fcde1da78dbaf5bf84d" + diff --git a/README.md b/README.md index 32d189b..246cbe9 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ format that stores data indexed by IP address subnets (IPv4 or IPv6). ## Requirements ## -This library works with .NET Framework version 4.6.1 and above and .NET Standard -2.0 or above. +This library works with .NET 5.0 and above and .NET Standard +3.1 or above. ## Installation ## diff --git a/releasenotes.md b/releasenotes.md index b35bba7..c3ced6a 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -1,5 +1,9 @@ # Release Notes # +## 4.0.0 + +* This library now requires .NET 5.0 or greater or .NET Standard 3.1. + ## 3.0.0 (2020-11-16) ## * This library now requires .NET Framework 4.6.1 or greater or .NET Standard From bf62056520d965875b55f0a90599bfcbe9f5079c Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 3 Feb 2022 10:15:22 -0800 Subject: [PATCH 02/15] Update suppressions --- MaxMind.Db.Test/ReaderTest.cs | 6 ++++-- MaxMind.Db/Metadata.cs | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/MaxMind.Db.Test/ReaderTest.cs b/MaxMind.Db.Test/ReaderTest.cs index 022411d..03108ea 100644 --- a/MaxMind.Db.Test/ReaderTest.cs +++ b/MaxMind.Db.Test/ReaderTest.cs @@ -177,12 +177,13 @@ public async Task TestNonSeekableStreamAsync() } } -#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type. #pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type. [Fact] public void NullStreamThrowsArgumentNullException() { +#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type. ((Action)(() => new Reader((Stream)null))) +#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type. .Should().Throw() .WithMessage("The database stream must not be null.*"); } @@ -190,12 +191,13 @@ public void NullStreamThrowsArgumentNullException() [Fact] public void NullStreamThrowsArgumentNullExceptionAsync() { +#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type. ((Func)(async () => { await Reader.CreateAsync((Stream)null).ConfigureAwait(false); })) +#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type. .Should().ThrowExactlyAsync() .WithMessage("The database stream must not be null.*"); } #pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type. -#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type. [Fact] public void TestEmptyStream() diff --git a/MaxMind.Db/Metadata.cs b/MaxMind.Db/Metadata.cs index f12c36a..fd73514 100644 --- a/MaxMind.Db/Metadata.cs +++ b/MaxMind.Db/Metadata.cs @@ -25,12 +25,11 @@ public sealed class Metadata /// /// [Constructor] + [CLSCompliant(false)] public Metadata( [Parameter("binary_format_major_version")] int binaryFormatMajorVersion, [Parameter("binary_format_minor_version")] int binaryFormatMinorVersion, -#pragma warning disable CS3001 // Argument type is not CLS-compliant [Parameter("build_epoch")] ulong buildEpoch, -#pragma warning restore CS3001 // Argument type is not CLS-compliant [Parameter("database_type")] string databaseType, IDictionary description, [Parameter("ip_version")] int ipVersion, From 30f81a1414f40d5316c9f7885b1b37cde484df4f Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 3 Feb 2022 10:21:04 -0800 Subject: [PATCH 03/15] Use implicit object creation in several spots --- MaxMind.Db.Benchmark/Program.cs | 6 +++--- MaxMind.Db.Test/Helper/TestUtils.cs | 2 +- MaxMind.Db.Test/ThreadingTest.cs | 2 +- MaxMind.Db/DictionaryActivatorCreator.cs | 2 +- MaxMind.Db/ListActivatorCreator.cs | 2 +- MaxMind.Db/MemoryMapBuffer.cs | 2 +- MaxMind.Db/TypeAcivatorCreator.cs | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/MaxMind.Db.Benchmark/Program.cs b/MaxMind.Db.Benchmark/Program.cs index ae9c0cc..88f2b62 100644 --- a/MaxMind.Db.Benchmark/Program.cs +++ b/MaxMind.Db.Benchmark/Program.cs @@ -48,7 +48,7 @@ private static void Main(string[] args) { if (!File.Exists(dbPath)) { - throw new Exception("Path provided by command-line argument does not exist!"); + throw new("Path provided by command-line argument does not exist!"); } } else @@ -60,7 +60,7 @@ private static void Main(string[] args) { if (!File.Exists(dbPath)) { - throw new Exception("Path set as environment variable MAXMIND_BENCHMARK_DB does not exist!"); + throw new("Path set as environment variable MAXMIND_BENCHMARK_DB does not exist!"); } } else @@ -70,7 +70,7 @@ private static void Main(string[] args) if (!File.Exists(dbPath)) { - throw new Exception($"{dbPath} does not exist in current directory ({Directory.GetCurrentDirectory()})!"); + throw new($"{dbPath} does not exist in current directory ({Directory.GetCurrentDirectory()})!"); } } } diff --git a/MaxMind.Db.Test/Helper/TestUtils.cs b/MaxMind.Db.Test/Helper/TestUtils.cs index 92c943a..6f81e37 100644 --- a/MaxMind.Db.Test/Helper/TestUtils.cs +++ b/MaxMind.Db.Test/Helper/TestUtils.cs @@ -17,7 +17,7 @@ private static string GetTestDirectory() { if (!Directory.Exists(dbPath)) { - throw new Exception("Path set as environment variable MAXMIND_TEST_BASE_DIR does not exist!"); + throw new("Path set as environment variable MAXMIND_TEST_BASE_DIR does not exist!"); } return dbPath; diff --git a/MaxMind.Db.Test/ThreadingTest.cs b/MaxMind.Db.Test/ThreadingTest.cs index 42d11ab..7eef4ee 100644 --- a/MaxMind.Db.Test/ThreadingTest.cs +++ b/MaxMind.Db.Test/ThreadingTest.cs @@ -47,7 +47,7 @@ public void TestParallelFor(FileAccessMode mode) var resultString = result.ToString(); var expectedString = ipsAndResults[ipAddress]; if (resultString != expectedString) - throw new Exception($"Non-matching result. Expected {expectedString}, found {resultString}"); + throw new($"Non-matching result. Expected {expectedString}, found {resultString}"); }); } diff --git a/MaxMind.Db/DictionaryActivatorCreator.cs b/MaxMind.Db/DictionaryActivatorCreator.cs index d64a88b..5e543e9 100644 --- a/MaxMind.Db/DictionaryActivatorCreator.cs +++ b/MaxMind.Db/DictionaryActivatorCreator.cs @@ -13,7 +13,7 @@ namespace MaxMind.Db internal sealed class DictionaryActivatorCreator { private readonly ConcurrentDictionary _dictActivators = - new ConcurrentDictionary(); + new(); internal ObjectActivator GetActivator(Type expectedType) => _dictActivators.GetOrAdd(expectedType, DictionaryActivator); diff --git a/MaxMind.Db/ListActivatorCreator.cs b/MaxMind.Db/ListActivatorCreator.cs index 8a0c7ff..685a075 100644 --- a/MaxMind.Db/ListActivatorCreator.cs +++ b/MaxMind.Db/ListActivatorCreator.cs @@ -12,7 +12,7 @@ namespace MaxMind.Db internal sealed class ListActivatorCreator { private readonly ConcurrentDictionary _listActivators = - new ConcurrentDictionary(); + new(); internal ObjectActivator GetActivator(Type expectedType) => _listActivators.GetOrAdd(expectedType, ListActivator); diff --git a/MaxMind.Db/MemoryMapBuffer.cs b/MaxMind.Db/MemoryMapBuffer.cs index 5df0dc3..2894af6 100644 --- a/MaxMind.Db/MemoryMapBuffer.cs +++ b/MaxMind.Db/MemoryMapBuffer.cs @@ -11,7 +11,7 @@ namespace MaxMind.Db { internal sealed class MemoryMapBuffer : Buffer { - private static readonly object FileLocker = new object(); + private static readonly object FileLocker = new(); private readonly MemoryMappedFile _memoryMappedFile; private readonly MemoryMappedViewAccessor _view; private bool _disposed; diff --git a/MaxMind.Db/TypeAcivatorCreator.cs b/MaxMind.Db/TypeAcivatorCreator.cs index d93e1e5..f4c6c72 100644 --- a/MaxMind.Db/TypeAcivatorCreator.cs +++ b/MaxMind.Db/TypeAcivatorCreator.cs @@ -55,7 +55,7 @@ List alwaysCreatedParameters internal sealed class TypeAcivatorCreator { private readonly ConcurrentDictionary _typeConstructors = - new ConcurrentDictionary(); + new(); internal TypeActivator GetActivator(Type expectedType) => _typeConstructors.GetOrAdd(expectedType, ClassActivator); From fbc1f3a029de520872aabbb39d47164e629f0e1c Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 3 Feb 2022 10:24:02 -0800 Subject: [PATCH 04/15] Remove stray blank lines --- MaxMind.Db.Test/ReaderTest.cs | 1 - MaxMind.Db/CachedDictionary.cs | 2 -- 2 files changed, 3 deletions(-) diff --git a/MaxMind.Db.Test/ReaderTest.cs b/MaxMind.Db.Test/ReaderTest.cs index 03108ea..0245519 100644 --- a/MaxMind.Db.Test/ReaderTest.cs +++ b/MaxMind.Db.Test/ReaderTest.cs @@ -247,7 +247,6 @@ public void NoIPV4SearchTree() [InlineData("ef00::", "MaxMind-DB-no-ipv4-search-tree.mmdb", 1, false)] public void TestFindPrefixLength(string ipStr, string dbFile, int expectedPrefixLength, bool expectedOK) { - using var reader = new Reader(Path.Combine(_testDataRoot, dbFile)); var ip = IPAddress.Parse(ipStr); var record = reader.Find(ip, out var prefixLength); diff --git a/MaxMind.Db/CachedDictionary.cs b/MaxMind.Db/CachedDictionary.cs index afdd494..945a700 100644 --- a/MaxMind.Db/CachedDictionary.cs +++ b/MaxMind.Db/CachedDictionary.cs @@ -71,7 +71,6 @@ private bool InternalRemove(TKey key) priorityList.Remove(node); dictionary.Remove(key); return true; - } #endregion Private methods @@ -241,7 +240,6 @@ public TValue this[TKey key] set => throw new NotSupportedException("Use Add instead"); } - /// /// Gets all the keys that are in memory /// From 65cfbe50e217dcc3b6309b3c91118f87e752d09e Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 3 Feb 2022 10:26:47 -0800 Subject: [PATCH 05/15] Add some braces for clarity --- MaxMind.Db.Test/ReaderTest.cs | 2 ++ MaxMind.Db/Decoder.cs | 13 +++++++++++++ MaxMind.Db/DictionaryActivatorCreator.cs | 3 +++ 3 files changed, 18 insertions(+) diff --git a/MaxMind.Db.Test/ReaderTest.cs b/MaxMind.Db.Test/ReaderTest.cs index 0245519..668703e 100644 --- a/MaxMind.Db.Test/ReaderTest.cs +++ b/MaxMind.Db.Test/ReaderTest.cs @@ -311,11 +311,13 @@ public void TestEnumerateCountryDatabase() { var count = 0; using (var reader = new Reader(Path.Combine(_testDataRoot, "GeoIP2-Country-Test.mmdb"))) + { foreach (var node in reader.FindAll>()) { TestNode(reader, node); count++; } + } count.Should().BeGreaterOrEqualTo(397); } diff --git a/MaxMind.Db/Decoder.cs b/MaxMind.Db/Decoder.cs index 0838981..4b0df12 100644 --- a/MaxMind.Db/Decoder.cs +++ b/MaxMind.Db/Decoder.cs @@ -88,8 +88,10 @@ private object Decode(Type expectedType, long offset, out long outOffset, Inject private ObjectType CtrlData(long offset, out int size, out long outOffset) { if (offset >= _database.Length) + { throw new InvalidDatabaseException("The MaxMind DB file's data section contains bad data: " + "pointer larger than the database."); + } var ctrlByte = _database.ReadOne(offset); offset++; @@ -101,10 +103,13 @@ private ObjectType CtrlData(long offset, out int size, out long outOffset) int nextByte = _database.ReadOne(offset); var typeNum = nextByte + 7; if (typeNum < 8) + { throw new InvalidDatabaseException( "Something went horribly wrong in the decoder. An extended type " + "resolved to a type number < 8 (" + typeNum + ")"); + } + type = (ObjectType)typeNum; offset++; } @@ -233,8 +238,11 @@ private double DecodeDouble(Type expectedType, long offset, int size) ReflectionUtil.CheckType(expectedType, typeof(double)); if (size != 8) + { throw new InvalidDatabaseException("The MaxMind DB file's data section contains bad data: " + "invalid size of double."); + } + return _database.ReadDouble(offset); } @@ -247,8 +255,11 @@ private float DecodeFloat(Type expectedType, long offset, int size) ReflectionUtil.CheckType(expectedType, typeof(float)); if (size != 4) + { throw new InvalidDatabaseException("The MaxMind DB file's data section contains bad data: " + "invalid size of float."); + } + return _database.ReadFloat(offset); } @@ -307,8 +318,10 @@ private object DecodeMapToDictionary(Type expectedType, long offset, int size, o { var genericArgs = expectedType.GetGenericArguments(); if (genericArgs.Length != 2) + { throw new DeserializationException( $"Unexpected number of Dictionary generic arguments: {genericArgs.Length}"); + } var obj = (IDictionary)_dictionaryActivatorCreator.GetActivator(expectedType)(size); diff --git a/MaxMind.Db/DictionaryActivatorCreator.cs b/MaxMind.Db/DictionaryActivatorCreator.cs index 5e543e9..91b1dd6 100644 --- a/MaxMind.Db/DictionaryActivatorCreator.cs +++ b/MaxMind.Db/DictionaryActivatorCreator.cs @@ -22,8 +22,11 @@ private static ObjectActivator DictionaryActivator(Type expectedType) { var genericArgs = expectedType.GetGenericArguments(); if (genericArgs.Length != 2) + { throw new DeserializationException( $"Unexpected number of Dictionary generic arguments: {genericArgs.Length}"); + } + ConstructorInfo? constructor; if (expectedType.GetTypeInfo().IsInterface) { From e6d267d6df75459285961ff5798b0d80030d3a18 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 3 Feb 2022 10:29:20 -0800 Subject: [PATCH 06/15] Simplify lambdas a bit --- MaxMind.Db.Test/ReaderTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MaxMind.Db.Test/ReaderTest.cs b/MaxMind.Db.Test/ReaderTest.cs index 668703e..9d358ce 100644 --- a/MaxMind.Db.Test/ReaderTest.cs +++ b/MaxMind.Db.Test/ReaderTest.cs @@ -192,7 +192,7 @@ public void NullStreamThrowsArgumentNullException() public void NullStreamThrowsArgumentNullExceptionAsync() { #pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type. - ((Func)(async () => { await Reader.CreateAsync((Stream)null).ConfigureAwait(false); })) + ((Func)(async () => await Reader.CreateAsync((Stream)null).ConfigureAwait(false))) #pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type. .Should().ThrowExactlyAsync() .WithMessage("The database stream must not be null.*"); @@ -212,7 +212,7 @@ public void TestEmptyStream() public void TestEmptyStreamAsync() { using var stream = new MemoryStream(); - ((Func)(async () => { await Reader.CreateAsync(stream).ConfigureAwait(false); })) + ((Func)(async () => await Reader.CreateAsync(stream).ConfigureAwait(false))) .Should().ThrowExactlyAsync() .WithMessage("*zero bytes left in the stream*"); } From 310b4c970599b40dd8ec2ba21863d6b5246aca78 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 3 Feb 2022 10:31:51 -0800 Subject: [PATCH 07/15] Fix up comment formatting --- MaxMind.Db/ConstructorAttribute.cs | 2 +- MaxMind.Db/InjectAttribute.cs | 4 ++-- MaxMind.Db/NetworkAttribute.cs | 4 ++-- MaxMind.Db/ParameterAttribute.cs | 4 ++-- MaxMind.Db/Reader.cs | 5 ++--- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/MaxMind.Db/ConstructorAttribute.cs b/MaxMind.Db/ConstructorAttribute.cs index 242803e..8574192 100644 --- a/MaxMind.Db/ConstructorAttribute.cs +++ b/MaxMind.Db/ConstructorAttribute.cs @@ -7,7 +7,7 @@ namespace MaxMind.Db { /// - /// Instruct Reader to use the constructor when deserializing. + /// Instruct Reader to use the constructor when deserializing. /// [AttributeUsage(AttributeTargets.Constructor)] public sealed class ConstructorAttribute : Attribute diff --git a/MaxMind.Db/InjectAttribute.cs b/MaxMind.Db/InjectAttribute.cs index 25b6920..78b0696 100644 --- a/MaxMind.Db/InjectAttribute.cs +++ b/MaxMind.Db/InjectAttribute.cs @@ -7,7 +7,7 @@ namespace MaxMind.Db { /// - /// Instruct Reader to map database key to constructor parameter. + /// Instruct Reader to map database key to constructor parameter. /// [AttributeUsage(AttributeTargets.Parameter)] public sealed class InjectAttribute : Attribute @@ -18,7 +18,7 @@ public sealed class InjectAttribute : Attribute public string ParameterName { get; } /// - /// Create a new instance of InjectAttribute. + /// Create a new instance of InjectAttribute. /// /// public InjectAttribute(string parameterName) diff --git a/MaxMind.Db/NetworkAttribute.cs b/MaxMind.Db/NetworkAttribute.cs index cfd8e01..4145e6c 100644 --- a/MaxMind.Db/NetworkAttribute.cs +++ b/MaxMind.Db/NetworkAttribute.cs @@ -7,13 +7,13 @@ namespace MaxMind.Db { /// - /// Instruct Reader to set the parameter to be the network in CIDR format. + /// Instruct Reader to set the parameter to be the network in CIDR format. /// [AttributeUsage(AttributeTargets.Parameter)] public sealed class NetworkAttribute : Attribute { /// - /// Create a new instance of NetworkAttribute. + /// Create a new instance of NetworkAttribute. /// public NetworkAttribute() { diff --git a/MaxMind.Db/ParameterAttribute.cs b/MaxMind.Db/ParameterAttribute.cs index 60ae1d1..001c645 100644 --- a/MaxMind.Db/ParameterAttribute.cs +++ b/MaxMind.Db/ParameterAttribute.cs @@ -7,7 +7,7 @@ namespace MaxMind.Db { /// - /// Instruct Reader to map database key to constructor parameter. + /// Instruct Reader to map database key to constructor parameter. /// [AttributeUsage(AttributeTargets.Parameter)] public sealed class ParameterAttribute : Attribute @@ -25,7 +25,7 @@ public sealed class ParameterAttribute : Attribute public bool AlwaysCreate { get; } /// - /// Create a new instance of ParameterAttribute. + /// Create a new instance of ParameterAttribute. /// /// The name of the parameter. /// diff --git a/MaxMind.Db/Reader.cs b/MaxMind.Db/Reader.cs index 09c8fed..ab299f2 100644 --- a/MaxMind.Db/Reader.cs +++ b/MaxMind.Db/Reader.cs @@ -246,9 +246,8 @@ private void Dispose(bool disposing) } /// - /// Get an enumerator that iterates all data nodes in the database. Do not modify the object as it may be cached. - /// - /// Note that due to caching, the Network attribute on constructor parameters will be ignored. + /// Get an enumerator that iterates all data nodes in the database. Do not modify the object as it may be cached. + /// Note that due to caching, the Network attribute on constructor parameters will be ignored. /// /// Value to inject during deserialization /// The size of the data cache. This can greatly speed enumeration at the cost of memory usage. From 54944050ab07f55eec030e17bbf6518649ead212 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 3 Feb 2022 10:35:32 -0800 Subject: [PATCH 08/15] Fix test to do what was intended, I think --- MaxMind.Db.Test/ReaderTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MaxMind.Db.Test/ReaderTest.cs b/MaxMind.Db.Test/ReaderTest.cs index 9d358ce..e5dfe78 100644 --- a/MaxMind.Db.Test/ReaderTest.cs +++ b/MaxMind.Db.Test/ReaderTest.cs @@ -503,7 +503,7 @@ private static void TestIPV4(Reader reader, string file) { TestAddresses(reader, file, - Enumerable.Range(0, 5).Select(i => "1.1.1." + (int)Math.Pow(2, 1)), + Enumerable.Range(0, 5).Select(i => "1.1.1." + (int)Math.Pow(2, i)), new Dictionary { {"1.1.1.3", "1.1.1.2"}, From 7bc869070abc99c9764c4351516119e86281b0f2 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 3 Feb 2022 10:43:35 -0800 Subject: [PATCH 09/15] Minor style changes --- MaxMind.Db.Test/DecoderTest.cs | 2 +- MaxMind.Db.Test/ThreadingTest.cs | 2 +- MaxMind.Db/Decoder.cs | 2 +- MaxMind.Db/DeserializationException.cs | 10 ++++++++-- MaxMind.Db/Network.cs | 6 +++--- MaxMind.Db/Reader.cs | 4 ++-- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/MaxMind.Db.Test/DecoderTest.cs b/MaxMind.Db.Test/DecoderTest.cs index a8822aa..eb81b25 100644 --- a/MaxMind.Db.Test/DecoderTest.cs +++ b/MaxMind.Db.Test/DecoderTest.cs @@ -11,7 +11,7 @@ namespace MaxMind.Db.Test { - public class DecoderTest + public static class DecoderTest { [Theory] [MemberData(nameof(TestUInt16))] diff --git a/MaxMind.Db.Test/ThreadingTest.cs b/MaxMind.Db.Test/ThreadingTest.cs index 7eef4ee..a07c27c 100644 --- a/MaxMind.Db.Test/ThreadingTest.cs +++ b/MaxMind.Db.Test/ThreadingTest.cs @@ -58,7 +58,7 @@ public void TestParallelFor(FileAccessMode mode) [Trait("Category", "BreaksMono")] public void TestManyOpens(FileAccessMode mode) { - Parallel.For(0, 50, i => + Parallel.For(0, 50, _ => { using var reader = new Reader(_testDatabase, mode); reader.Find(IPAddress.Parse("175.16.199.0")); diff --git a/MaxMind.Db/Decoder.cs b/MaxMind.Db/Decoder.cs index 4b0df12..8aa7a5d 100644 --- a/MaxMind.Db/Decoder.cs +++ b/MaxMind.Db/Decoder.cs @@ -468,7 +468,7 @@ private long NextValueOffset(long offset, int numberToSkip) break; } - numberToSkip -= 1; + numberToSkip--; } } diff --git a/MaxMind.Db/DeserializationException.cs b/MaxMind.Db/DeserializationException.cs index 54d98a4..724da75 100644 --- a/MaxMind.Db/DeserializationException.cs +++ b/MaxMind.Db/DeserializationException.cs @@ -10,10 +10,16 @@ namespace MaxMind.Db /// /// Thrown when there is an error deserializing to the provided type. /// - [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] [Serializable] public sealed class DeserializationException : Exception { + /// + /// Construct a DeserializationException + /// + public DeserializationException() : base() + { + } + /// /// Construct a DeserializationException /// @@ -34,7 +40,7 @@ public DeserializationException(string message, Exception innerException) } /// - /// Constructor for deserialization. + /// Construct a DeserializationException /// /// The SerializationInfo with data. /// The source for this deserialization. diff --git a/MaxMind.Db/Network.cs b/MaxMind.Db/Network.cs index 69f6807..836a94b 100644 --- a/MaxMind.Db/Network.cs +++ b/MaxMind.Db/Network.cs @@ -10,7 +10,7 @@ public sealed class Network private readonly IPAddress ip; /// - /// The prefix length is the number of leading 1 bits in the + /// The prefix length is the number of leading 1 bits in the /// subnet mask. Sometimes also known as netmask length. /// public int PrefixLength { get; } @@ -55,10 +55,10 @@ public Network(IPAddress ip, int prefixLength) PrefixLength = prefixLength; } - /// + /// /// A string representation of the network in CIDR notation, e.g., /// 1.2.3.0/24 or 2001::/8. - /// + /// public override string ToString() { return $"{NetworkAddress}/{PrefixLength}"; diff --git a/MaxMind.Db/Reader.cs b/MaxMind.Db/Reader.cs index ab299f2..42c0b85 100644 --- a/MaxMind.Db/Reader.cs +++ b/MaxMind.Db/Reader.cs @@ -402,7 +402,7 @@ private int ReadNode(int nodeNumber, int index) { case 24: { - var offset = baseOffset + index * 3; + var offset = baseOffset + (index * 3); return _database.ReadVarInt(offset, 3); } case 28: @@ -416,7 +416,7 @@ private int ReadNode(int nodeNumber, int index) } case 32: { - var offset = baseOffset + index * 4; + var offset = baseOffset + (index * 4); return _database.ReadInt(offset); } } From d6103edeca86c8f17e66539c880b5d4626f79386 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 3 Feb 2022 10:49:57 -0800 Subject: [PATCH 10/15] Run code cleanup on solution --- MaxMind.Db/DeserializationException.cs | 1 - MaxMind.Db/MemoryMapBuffer.cs | 12 ++++++++---- MaxMind.Db/Reader.cs | 5 +++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/MaxMind.Db/DeserializationException.cs b/MaxMind.Db/DeserializationException.cs index 724da75..aff7830 100644 --- a/MaxMind.Db/DeserializationException.cs +++ b/MaxMind.Db/DeserializationException.cs @@ -1,7 +1,6 @@ #region using System; -using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; #endregion diff --git a/MaxMind.Db/MemoryMapBuffer.cs b/MaxMind.Db/MemoryMapBuffer.cs index 2894af6..c4479f8 100644 --- a/MaxMind.Db/MemoryMapBuffer.cs +++ b/MaxMind.Db/MemoryMapBuffer.cs @@ -69,18 +69,22 @@ public override byte[] Read(long offset, int count) public override string ReadString(long offset, int count) { - if (offset + count > _view.Capacity) { + if (offset + count > _view.Capacity) + { throw new ArgumentOutOfRangeException( nameof(offset), "Attempt to read beyond the end of the MemoryMappedFile."); } unsafe { - byte* ptr = (byte*) 0; - try { + byte* ptr = (byte*)0; + try + { _view.SafeMemoryMappedViewHandle.AcquirePointer(ref ptr); return Encoding.UTF8.GetString(ptr + offset, count); - } finally { + } + finally + { _view.SafeMemoryMappedViewHandle.ReleasePointer(); } } diff --git a/MaxMind.Db/Reader.cs b/MaxMind.Db/Reader.cs index 42c0b85..c3a2ff4 100644 --- a/MaxMind.Db/Reader.cs +++ b/MaxMind.Db/Reader.cs @@ -371,9 +371,10 @@ private int StartNode(int bitLength) private long FindMetadataStart() { var dbLength = _database.Length; - var markerLength = (long) _metadataStartMarker.Length; + var markerLength = (long)_metadataStartMarker.Length; - for (var i = dbLength - markerLength; i > 0; i--) { + for (var i = dbLength - markerLength; i > 0; i--) + { int j = 0; for (; j < markerLength; j++) { From dbc84cd7aae18aaa51d5a606773059deb0c4c107 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 3 Feb 2022 10:51:52 -0800 Subject: [PATCH 11/15] Bump copyright year --- MaxMind.Db/Properties/AssemblyInfo.cs | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MaxMind.Db/Properties/AssemblyInfo.cs b/MaxMind.Db/Properties/AssemblyInfo.cs index 405d148..716f96b 100644 --- a/MaxMind.Db/Properties/AssemblyInfo.cs +++ b/MaxMind.Db/Properties/AssemblyInfo.cs @@ -16,7 +16,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("MaxMind, Inc.")] [assembly: AssemblyProduct("MaxMind.Db")] -[assembly: AssemblyCopyright("Copyright © 2013-2020 MaxMind, Inc.")] +[assembly: AssemblyCopyright("Copyright © 2013-2022 MaxMind, Inc.")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/README.md b/README.md index 246cbe9..26a12e7 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,6 @@ The MaxMind DB Reader API uses [Semantic Versioning](http://semver.org/). ## Copyright and License ## -This software is Copyright (c) 2013-2020 by MaxMind, Inc. +This software is Copyright (c) 2013-2022 by MaxMind, Inc. This is free software, licensed under the Apache License, Version 2.0. From 837ab482a18ec7b0ab54e63feb16aaeea2ad78ae Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 3 Feb 2022 10:54:22 -0800 Subject: [PATCH 12/15] Add .editorconfig --- .editorconfig | 302 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 302 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f52e632 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,302 @@ +# Remove the line below if you want to inherit .editorconfig settings from higher directories +root = true + +# C# files +[*.cs] + +#### Core EditorConfig Options #### + +# Indentation and spacing +indent_size = 4 +indent_style = space +tab_width = 4 + +# New line preferences +end_of_line = crlf +insert_final_newline = false + +#### .NET Coding Conventions #### + +# Organize usings +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = false +file_header_template = unset + +# this. and Me. preferences +dotnet_style_qualification_for_event = false +dotnet_style_qualification_for_field = false +dotnet_style_qualification_for_method = false +dotnet_style_qualification_for_property = false + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true +dotnet_style_predefined_type_for_member_access = true + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_operators = never_if_unnecessary +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members + +# Expression-level preferences +dotnet_style_coalesce_expression = true +dotnet_style_collection_initializer = true +dotnet_style_explicit_tuple_names = true +dotnet_style_namespace_match_folder = true +dotnet_style_null_propagation = true +dotnet_style_object_initializer = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true +dotnet_style_prefer_compound_assignment = true +dotnet_style_prefer_conditional_expression_over_assignment = true +dotnet_style_prefer_conditional_expression_over_return = true +dotnet_style_prefer_inferred_anonymous_type_member_names = true +dotnet_style_prefer_inferred_tuple_names = true +dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_simplified_boolean_expressions = true +dotnet_style_prefer_simplified_interpolation = true + +# Field preferences +dotnet_style_readonly_field = true + +# Parameter preferences +dotnet_code_quality_unused_parameters = all + +# Suppression preferences +dotnet_remove_unnecessary_suppression_exclusions = none + +# New line preferences +dotnet_style_allow_multiple_blank_lines_experimental = true +dotnet_style_allow_statement_immediately_after_block_experimental = true + +#### C# Coding Conventions #### + +# var preferences +csharp_style_var_elsewhere = true +csharp_style_var_for_built_in_types = true +csharp_style_var_when_type_is_apparent = true + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true +csharp_style_expression_bodied_constructors = false +csharp_style_expression_bodied_indexers = true +csharp_style_expression_bodied_lambdas = true +csharp_style_expression_bodied_local_functions = false +csharp_style_expression_bodied_methods = false +csharp_style_expression_bodied_operators = false +csharp_style_expression_bodied_properties = true + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true +csharp_style_pattern_matching_over_is_with_cast_check = true +csharp_style_prefer_not_pattern = true +csharp_style_prefer_pattern_matching = true +csharp_style_prefer_switch_expression = true + +# Null-checking preferences +csharp_style_conditional_delegate_call = true + +# Modifier preferences +csharp_prefer_static_local_function = true +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async + +# Code-block preferences +csharp_prefer_braces = true +csharp_prefer_simple_using_statement = true +csharp_style_namespace_declarations = block_scoped + +# Expression-level preferences +csharp_prefer_simple_default_expression = true +csharp_style_deconstructed_variable_declaration = true +csharp_style_implicit_object_creation_when_type_is_apparent = true +csharp_style_inlined_variable_declaration = true +csharp_style_pattern_local_over_anonymous_function = true +csharp_style_prefer_index_operator = true +csharp_style_prefer_null_check_over_type_check = true +csharp_style_prefer_range_operator = true +csharp_style_throw_expression = true +csharp_style_unused_value_assignment_preference = discard_variable +csharp_style_unused_value_expression_statement_preference = discard_variable + +# 'using' directive preferences +csharp_using_directive_placement = outside_namespace + +# New line preferences +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true +csharp_style_allow_embedded_statements_on_same_line_experimental = true + +#### C# Formatting Rules #### + +# New line preferences +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = no_change +csharp_indent_switch_labels = true + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Naming styles #### + +# Naming rules + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Symbol specifications + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case + +# Options + +roslynator_accessibility_modifiers = explicit +# Applicable to: rcs1018 + +roslynator_accessor_braces_style = multi_line +# Default: multi_line +# Applicable to: rcs0020 + +roslynator_array_creation_type_style = implicit +# Applicable to: rcs1014 + +roslynator_arrow_token_new_line = before +# Applicable to: rcs0032 + +roslynator_binary_operator_new_line = before +# Applicable to: rcs0027 + +roslynator_blank_line_between_closing_brace_and_switch_section = true +# Applicable to: rcs0014, rcs1036 + +roslynator_blank_line_between_single_line_accessors = true +# Applicable to: rcs0011 + +roslynator_blank_line_between_using_directives = separate_groups +# Applicable to: rcs0015 + +roslynator_body_style = expression +# Applicable to: rcs1016 + +roslynator_conditional_operator_condition_parentheses_style = omit_when_condition_is_single_token +# Applicable to: rcs1051 + +roslynator_conditional_operator_new_line = before +# Applicable to: rcs0028 + +roslynator_configure_await = true +# Applicable to: rcs1090 + +roslynator_empty_string_style = literal +# Applicable to: rcs1078 + +roslynator_enum_has_flag_style = operator +# Applicable to: rcs1096 + +roslynator_equals_token_new_line = before +# Applicable to: rcs0052 + +roslynator_new_line_at_end_of_file = true +# Applicable to: rcs0058 + +roslynator_new_line_before_while_in_do_statement = false +# Applicable to: rcs0051 + +roslynator_null_conditional_operator_new_line = before +# Applicable to: rcs0059 + +roslynator_null_check_style = pattern_matching +# Applicable to: rcs1248 + +roslynator_object_creation_parentheses_style = omit +# Applicable to: rcs1050 + +roslynator_object_creation_type_style = implicit_when_type_is_obvious +# Applicable to: rcs1250 + +roslynator_prefix_field_identifier_with_underscore = true + +roslynator_suppress_unity_script_methods = true +# Applicable to: rcs1213 + +roslynator_use_anonymous_function_or_method_group = anonymous_function +# Applicable to: rcs1207 + +roslynator_use_block_body_when_declaration_spans_over_multiple_lines = true +# Applicable to: rcs1016 + +roslynator_use_block_body_when_expression_spans_over_multiple_lines = true +# Applicable to: rcs1016 + +roslynator_use_var_instead_of_implicit_object_creation = true +# Applicable to: rcs1250 From 44edd04cba7bb6e78d48ebd9dcd18bad5013de09 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 3 Feb 2022 10:57:48 -0800 Subject: [PATCH 13/15] Set release date --- releasenotes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes.md b/releasenotes.md index c3ced6a..b902c90 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -1,6 +1,6 @@ # Release Notes # -## 4.0.0 +## 4.0.0 (2022-02-03) ## * This library now requires .NET 5.0 or greater or .NET Standard 3.1. From c9c09f6007688a6e6596519e2a5460188274cc53 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 3 Feb 2022 10:59:12 -0800 Subject: [PATCH 14/15] Enable new package validation --- MaxMind.Db/MaxMind.Db.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/MaxMind.Db/MaxMind.Db.csproj b/MaxMind.Db/MaxMind.Db.csproj index 97a2a7d..b89eaba 100644 --- a/MaxMind.Db/MaxMind.Db.csproj +++ b/MaxMind.Db/MaxMind.Db.csproj @@ -14,6 +14,7 @@ MaxMind-logo.png https://github.com/maxmind/MaxMind-DB-Reader-dotnet Apache-2.0 + true git https://github.com/maxmind/MaxMind-DB-Reader-dotnet false From 434bc05f981136b691871f4b49167ccfc9ac2783 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 3 Feb 2022 11:59:12 -0800 Subject: [PATCH 15/15] Disable CodeQL It is not working properly with .NET 6.0. We can reenable it later. --- .github/workflows/codeql-analysis.yml | 58 --------------------------- 1 file changed, 58 deletions(-) delete mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 23b09f2..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: "Code scanning - action" - -on: - push: - branches-ignore: - - 'dependabot/**' - pull_request: - schedule: - - cron: '0 14 * * 6' - -jobs: - CodeQL-Build: - - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} - - - name: Setup .NET 5.0 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 5.0.* - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - # Override language selection by uncommenting this and choosing your languages - # with: - # languages: go, javascript, csharp, python, cpp, java - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # ℹ️ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1