diff --git a/binding/csharp/.editorconfig b/binding/csharp/.editorconfig index b53f6cb..9ff4bca 100644 --- a/binding/csharp/.editorconfig +++ b/binding/csharp/.editorconfig @@ -19,8 +19,7 @@ indent_size = 2 end_of_line = lf [*.cs] -dotnet_analyzer_diagnostic.category-Style.severity = none csharp_style_namespace_declarations = file_scoped:silent [*.cs] -file_header_template = Copyright 2023 The Ip2Region Authors. All rights reserved.\nUse of this source code is governed by a Apache2.0-style\nlicense that can be found in the LICENSE file.\n@Author Alan \n@Date 2023/07/25\nUpdated by Argo Zhang at 2025/11/21 +file_header_template = Copyright 2025 The Ip2Region Authors. All rights reserved.\nUse of this source code is governed by a Apache2.0-style\nlicense that can be found in the LICENSE file.\n@Author Alan \n@Date 2023/07/25\nUpdated by Argo Zhang at 2025/11/21 diff --git a/binding/csharp/IP2Region.Net.BenchMark/Benmarks.cs b/binding/csharp/IP2Region.Net.BenchMark/Benmarks.cs index 66dcb85..f5eb2fd 100644 --- a/binding/csharp/IP2Region.Net.BenchMark/Benmarks.cs +++ b/binding/csharp/IP2Region.Net.BenchMark/Benmarks.cs @@ -1,4 +1,4 @@ -// Copyright 2023 The Ip2Region Authors. All rights reserved. +// Copyright 2025 The Ip2Region Authors. All rights reserved. // Use of this source code is governed by a Apache2.0-style // license that can be found in the LICENSE file. // @Author Alan diff --git a/binding/csharp/IP2Region.Net.BenchMark/Program.cs b/binding/csharp/IP2Region.Net.BenchMark/Program.cs index 5ca00ae..49bae6f 100644 --- a/binding/csharp/IP2Region.Net.BenchMark/Program.cs +++ b/binding/csharp/IP2Region.Net.BenchMark/Program.cs @@ -1,3 +1,10 @@ +// Copyright 2025 The Ip2Region Authors. All rights reserved. +// Use of this source code is governed by a Apache2.0-style +// license that can be found in the LICENSE file. +// @Author Alan +// @Date 2023/07/25 +// Updated by Argo Zhang at 2025/11/21 + using BenchmarkDotNet.Running; using IP2Region.Net.BenchMark; diff --git a/binding/csharp/IP2Region.Net.Test/SearcherTest.cs b/binding/csharp/IP2Region.Net.Test/SearcherTest.cs index b9b4e22..ce10a11 100644 --- a/binding/csharp/IP2Region.Net.Test/SearcherTest.cs +++ b/binding/csharp/IP2Region.Net.Test/SearcherTest.cs @@ -1,3 +1,10 @@ +// Copyright 2025 The Ip2Region Authors. All rights reserved. +// Use of this source code is governed by a Apache2.0-style +// license that can be found in the LICENSE file. +// @Author Alan +// @Date 2023/07/25 +// Updated by Argo Zhang at 2025/11/21 + using IP2Region.Net.Abstractions; using IP2Region.Net.XDB; using Microsoft.Extensions.DependencyInjection; diff --git a/binding/csharp/IP2Region.Net.Test/UtilTest.cs b/binding/csharp/IP2Region.Net.Test/UtilTest.cs index 8d6eb3d..8a4d38b 100644 --- a/binding/csharp/IP2Region.Net.Test/UtilTest.cs +++ b/binding/csharp/IP2Region.Net.Test/UtilTest.cs @@ -1,3 +1,10 @@ +// Copyright 2025 The Ip2Region Authors. All rights reserved. +// Use of this source code is governed by a Apache2.0-style +// license that can be found in the LICENSE file. +// @Author Alan +// @Date 2023/07/25 +// Updated by Argo Zhang at 2025/11/21 + using Xunit; namespace IP2Region.Net.Test; diff --git a/binding/csharp/IP2Region.Net.Test/XdbTest.cs b/binding/csharp/IP2Region.Net.Test/XdbTest.cs index 2e4a75f..8b92da8 100644 --- a/binding/csharp/IP2Region.Net.Test/XdbTest.cs +++ b/binding/csharp/IP2Region.Net.Test/XdbTest.cs @@ -1,3 +1,10 @@ +// Copyright 2025 The Ip2Region Authors. All rights reserved. +// Use of this source code is governed by a Apache2.0-style +// license that can be found in the LICENSE file. +// @Author Alan +// @Date 2023/07/25 +// Updated by Argo Zhang at 2025/11/21 + using Xunit; namespace IP2Region.Net.Test; diff --git a/binding/csharp/IP2Region.Net/Abstractions/ISearcher.cs b/binding/csharp/IP2Region.Net/Abstractions/ISearcher.cs index d270e4e..89cd5e5 100644 --- a/binding/csharp/IP2Region.Net/Abstractions/ISearcher.cs +++ b/binding/csharp/IP2Region.Net/Abstractions/ISearcher.cs @@ -1,8 +1,9 @@ -// Copyright 2023 The Ip2Region Authors. All rights reserved. +// Copyright 2025 The Ip2Region Authors. All rights reserved. // Use of this source code is governed by a Apache2.0-style // license that can be found in the LICENSE file. // @Author Alan // @Date 2023/07/25 +// Updated by Argo Zhang at 2025/11/21 using System.Net; diff --git a/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs b/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs index ace55ad..16fbf05 100644 --- a/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs +++ b/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs @@ -1,8 +1,9 @@ -// Copyright 2023 The Ip2Region Authors. All rights reserved. +// Copyright 2025 The Ip2Region Authors. All rights reserved. // Use of this source code is governed by a Apache2.0-style // license that can be found in the LICENSE file. // @Author Alan // @Date 2023/07/25 +// Updated by Argo Zhang at 2025/11/21 using IP2Region.Net.Abstractions; using IP2Region.Net.XDB; diff --git a/binding/csharp/IP2Region.Net/Internal/Abstractions/AbstractCacheStrategy.cs b/binding/csharp/IP2Region.Net/Internal/Abstractions/AbstractCacheStrategy.cs index e277dde..a716382 100644 --- a/binding/csharp/IP2Region.Net/Internal/Abstractions/AbstractCacheStrategy.cs +++ b/binding/csharp/IP2Region.Net/Internal/Abstractions/AbstractCacheStrategy.cs @@ -1,8 +1,9 @@ -// Copyright 2023 The Ip2Region Authors. All rights reserved. +// Copyright 2025 The Ip2Region Authors. All rights reserved. // Use of this source code is governed by a Apache2.0-style // license that can be found in the LICENSE file. // @Author Alan // @Date 2023/07/25 +// Updated by Argo Zhang at 2025/11/21 using System.Buffers; diff --git a/binding/csharp/IP2Region.Net/Internal/CacheStrategyFactory.cs b/binding/csharp/IP2Region.Net/Internal/CacheStrategyFactory.cs index 0deb198..e71f5bd 100644 --- a/binding/csharp/IP2Region.Net/Internal/CacheStrategyFactory.cs +++ b/binding/csharp/IP2Region.Net/Internal/CacheStrategyFactory.cs @@ -1,8 +1,9 @@ -// Copyright 2023 The Ip2Region Authors. All rights reserved. +// Copyright 2025 The Ip2Region Authors. All rights reserved. // Use of this source code is governed by a Apache2.0-style // license that can be found in the LICENSE file. // @Author Alan // @Date 2023/07/25 +// Updated by Argo Zhang at 2025/11/21 using IP2Region.Net.Internal.Abstractions; using IP2Region.Net.XDB; diff --git a/binding/csharp/IP2Region.Net/Internal/ContentCacheStrategy.cs b/binding/csharp/IP2Region.Net/Internal/ContentCacheStrategy.cs index ad3e2ba..fad002b 100644 --- a/binding/csharp/IP2Region.Net/Internal/ContentCacheStrategy.cs +++ b/binding/csharp/IP2Region.Net/Internal/ContentCacheStrategy.cs @@ -1,8 +1,9 @@ -// Copyright 2023 The Ip2Region Authors. All rights reserved. +// Copyright 2025 The Ip2Region Authors. All rights reserved. // Use of this source code is governed by a Apache2.0-style // license that can be found in the LICENSE file. // @Author Alan // @Date 2023/07/25 +// Updated by Argo Zhang at 2025/11/21 using IP2Region.Net.Internal.Abstractions; @@ -10,7 +11,7 @@ namespace IP2Region.Net.Internal; class ContentCacheStrategy : AbstractCacheStrategy { - ReadOnlyMemory _cacheData = default; + readonly ReadOnlyMemory _cacheData = default; public ContentCacheStrategy(string xdbPath) : base(xdbPath) { diff --git a/binding/csharp/IP2Region.Net/Internal/FileCacheStrategy.cs b/binding/csharp/IP2Region.Net/Internal/FileCacheStrategy.cs index 3a597b0..2a69364 100644 --- a/binding/csharp/IP2Region.Net/Internal/FileCacheStrategy.cs +++ b/binding/csharp/IP2Region.Net/Internal/FileCacheStrategy.cs @@ -1,8 +1,9 @@ -// Copyright 2023 The Ip2Region Authors. All rights reserved. +// Copyright 2025 The Ip2Region Authors. All rights reserved. // Use of this source code is governed by a Apache2.0-style // license that can be found in the LICENSE file. // @Author Alan // @Date 2023/07/25 +// Updated by Argo Zhang at 2025/11/21 using IP2Region.Net.Internal.Abstractions; diff --git a/binding/csharp/IP2Region.Net/Internal/VectorIndexCacheStrategy.cs b/binding/csharp/IP2Region.Net/Internal/VectorIndexCacheStrategy.cs index f34b1b2..89ff83e 100644 --- a/binding/csharp/IP2Region.Net/Internal/VectorIndexCacheStrategy.cs +++ b/binding/csharp/IP2Region.Net/Internal/VectorIndexCacheStrategy.cs @@ -1,8 +1,9 @@ -// Copyright 2023 The Ip2Region Authors. All rights reserved. +// Copyright 2025 The Ip2Region Authors. All rights reserved. // Use of this source code is governed by a Apache2.0-style // license that can be found in the LICENSE file. // @Author Alan // @Date 2023/07/25 +// Updated by Argo Zhang at 2025/11/21 using IP2Region.Net.Internal.Abstractions; @@ -10,12 +11,12 @@ namespace IP2Region.Net.Internal; internal class VectorIndexCacheStrategy : AbstractCacheStrategy { - ReadOnlyMemory _vectorCahe = default; + readonly ReadOnlyMemory _vectorCache = default; public VectorIndexCacheStrategy(string xdbPath) : base(xdbPath) { - _vectorCahe = base.GetData(256, 256 * 256 * 8); + _vectorCache = base.GetData(256, 256 * 256 * 8); } - public override ReadOnlyMemory GetVectorIndexStartPos(int offset) => _vectorCahe.Slice(offset, 8); + public override ReadOnlyMemory GetVectorIndexStartPos(int offset) => _vectorCache.Slice(offset, 8); } diff --git a/binding/csharp/IP2Region.Net/XDB/CachePolicy.cs b/binding/csharp/IP2Region.Net/XDB/CachePolicy.cs index 9397ee0..59b6b29 100644 --- a/binding/csharp/IP2Region.Net/XDB/CachePolicy.cs +++ b/binding/csharp/IP2Region.Net/XDB/CachePolicy.cs @@ -1,3 +1,10 @@ +// Copyright 2025 The Ip2Region Authors. All rights reserved. +// Use of this source code is governed by a Apache2.0-style +// license that can be found in the LICENSE file. +// @Author Alan +// @Date 2023/07/25 +// Updated by Argo Zhang at 2025/11/21 + namespace IP2Region.Net.XDB; /// diff --git a/binding/csharp/IP2Region.Net/XDB/Searcher.cs b/binding/csharp/IP2Region.Net/XDB/Searcher.cs index 1aa7fc6..adb30d6 100644 --- a/binding/csharp/IP2Region.Net/XDB/Searcher.cs +++ b/binding/csharp/IP2Region.Net/XDB/Searcher.cs @@ -1,8 +1,9 @@ -// Copyright 2023 The Ip2Region Authors. All rights reserved. +// Copyright 2025 The Ip2Region Authors. All rights reserved. // Use of this source code is governed by a Apache2.0-style // license that can be found in the LICENSE file. -// @Author Alan Lee -// @Date 2023/07/23 +// @Author Alan +// @Date 2023/07/25 +// Updated by Argo Zhang at 2025/11/21 using IP2Region.Net.Abstractions; using IP2Region.Net.Internal; @@ -57,7 +58,7 @@ public class Searcher : ISearcher public string? Search(uint ipAddress) { var bytes = BitConverter.GetBytes(ipAddress); - bytes.Reverse(); + Array.Reverse(bytes); return SearchCore(bytes); } diff --git a/binding/csharp/IP2Region.Net/XDB/Util.cs b/binding/csharp/IP2Region.Net/XDB/Util.cs index 0510f40..54afc7a 100644 --- a/binding/csharp/IP2Region.Net/XDB/Util.cs +++ b/binding/csharp/IP2Region.Net/XDB/Util.cs @@ -1,3 +1,10 @@ +// Copyright 2025 The Ip2Region Authors. All rights reserved. +// Use of this source code is governed by a Apache2.0-style +// license that can be found in the LICENSE file. +// @Author Alan +// @Date 2023/07/25 +// Updated by Argo Zhang at 2025/11/21 + using System.Buffers; using System.Buffers.Binary; using System.Net; @@ -35,7 +42,7 @@ public static class Util if (!File.Exists(dbPath)) { - throw new FileNotFoundException("xdb file not fould.", dbPath); + throw new FileNotFoundException("xdb file not found.", dbPath); } using var reader = File.OpenRead(dbPath); diff --git a/binding/csharp/IP2Region.Net/XDB/XdbVersion.cs b/binding/csharp/IP2Region.Net/XDB/XdbVersion.cs index e93e9db..5630cf8 100644 --- a/binding/csharp/IP2Region.Net/XDB/XdbVersion.cs +++ b/binding/csharp/IP2Region.Net/XDB/XdbVersion.cs @@ -1,3 +1,10 @@ +// Copyright 2025 The Ip2Region Authors. All rights reserved. +// Use of this source code is governed by a Apache2.0-style +// license that can be found in the LICENSE file. +// @Author Alan +// @Date 2023/07/25 +// Updated by Argo Zhang at 2025/11/21 + namespace IP2Region.Net.XDB; ///