-
-
Notifications
You must be signed in to change notification settings - Fork 375
doc(IP2Region): support IPv6 format #7661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideConsolidates IP locator functionality onto BaiduIpLocatorProvider (removing the V2 variant), updates DI registration, tests, and sample UI defaults accordingly, and extends the locator sample/docs to surface an IPv6 example entry. Updated class diagram for IP locator providers and Locators componentclassDiagram
class LocatorsComponent {
- string Ip
- string Location
- string ProviderName
- List_SelectedItem providers
+ OnProviderNameChanged(string providerName)
+ LocateAsync()
}
class IIpLocatorProvider {
<<interface>>
+ Locate(string ip)
}
class BaiduIpLocatorProvider {
+ Locate(string ip)
}
class BaiduIpLocatorProviderV2 {
<<removed_in_this_PR>>
+ Locate(string ip)
}
class IIpLocatorFactory {
<<interface>>
+ Create(string providerName) IIpLocatorProvider
}
class DefaultIpLocatorFactory {
+ Create(string providerName) IIpLocatorProvider
}
LocatorsComponent --> IIpLocatorFactory
DefaultIpLocatorFactory ..|> IIpLocatorFactory
BaiduIpLocatorProvider ..|> IIpLocatorProvider
BaiduIpLocatorProviderV2 ..|> IIpLocatorProvider
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've left some high level feedback:
- Since
BaiduIpLocatorProviderV2is removed from DI registration and tests, do a repo-wide search to clean up any remaining references (e.g., configuration values, provider names, or comments) that still mentionBaiduIpLocatorProviderV2to avoid dangling configuration or runtime selection issues. - The PR changes the default provider from
BaiduIpLocatorProviderV2toBaiduIpLocatorProviderand adjusts service registrations, which is more than a doc-only change; consider updating the PR title/description to reflect the behavioral change in provider selection and DI wiring.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Since `BaiduIpLocatorProviderV2` is removed from DI registration and tests, do a repo-wide search to clean up any remaining references (e.g., configuration values, provider names, or comments) that still mention `BaiduIpLocatorProviderV2` to avoid dangling configuration or runtime selection issues.
- The PR changes the default provider from `BaiduIpLocatorProviderV2` to `BaiduIpLocatorProvider` and adjusts service registrations, which is more than a doc-only change; consider updating the PR title/description to reflect the behavioral change in provider selection and DI wiring.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7661 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 750 749 -1
Lines 33191 33183 -8
Branches 4605 4604 -1
=========================================
- Hits 33191 33183 -8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Updates IP locator documentation/samples to mention IPv6 support via IP2Region and bumps the server sample’s IP2Region package version, while also removing the BaiduIpLocatorProviderV2 provider from DI registration and tests.
Changes:
- Bump
BootstrapBlazor.IP2Regionpackage reference to10.0.1in the Server project. - Update Locators sample/docs and localized strings to include an IPv6 example and describe IPv6 support.
- Remove
BaiduIpLocatorProviderV2provider registration and related unit tests/mocks (and delete the provider implementation file).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/UnitTest/Services/IpLocatorTest.cs | Removes V2-related tests and updates ProviderName usage to BaiduIpLocatorProvider. |
| src/BootstrapBlazor/Services/IPLocator/BaiduIpLocatorProviderV2.cs | Deletes the V2 provider implementation. |
| src/BootstrapBlazor/Extensions/BootstrapBlazorServiceCollectionExtensions.cs | Stops registering V2 provider (singleton + keyed). |
| src/BootstrapBlazor.Server/Locales/zh-CN.json | Updates locator description + adds an IPv6 example string (currently with malformed HTML). |
| src/BootstrapBlazor.Server/Locales/en-US.json | Updates locator description + adds an IPv6 example string (minor grammar issues). |
| src/BootstrapBlazor.Server/Components/Samples/Locators.razor.cs | Changes default provider to BaiduIpLocatorProvider. |
| src/BootstrapBlazor.Server/Components/Samples/Locators.razor | Adds an IPv6 sample IP and minor formatting change. |
| src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj | Bumps BootstrapBlazor.IP2Region to 10.0.1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "LocatorsNormalTipsTitle": "某些地理位置查询接口返回字符集可能是其他字符集如 <code>gbk</code>,程序会报错;", | ||
| "LocatorsNormalTitle": "普通用法", | ||
| "LocatorsProviderDesc": "<p>组件库内置两个免费在线地理位置定位器分别为 <code>BaiduIpLocatorProvider</code> <code>BaiduIpLocatorProviderV2</code><p><p>组件库内置一个收费在线地理位置定位器 <code>BootstrapBlazor.JuHeIpLocatorProvider</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.JuHeIpLocatorProvider\" target=\"_blank\">Nuget 包</a> <a href=\"https://juhe.cn\" target=\"_blank\">官网地址</a></p><p>组件库内置一个免费离线地理位置定位器 <code>BootstrapBlazor.IP2Region</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.IP2Region\" target=\"_blank\">Nuget 包</a></p>", | ||
| "LocatorsProviderDesc": "<p>组件库内置免费一个在线地理位置定位器 <code>BaiduIpLocatorProvider</code><p><p>组件库内置一个收费在线地理位置定位器 <code>BootstrapBlazor.JuHeIpLocatorProvider</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.JuHeIpLocatorProvider\" target=\"_blank\">Nuget 包</a> <a href=\"https://juhe.cn\" target=\"_blank\">官网地址</a></p><p>组件库内置一个免费离线地理位置定位器 <code>BootstrapBlazor.IP2Region</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.IP2Region\" target=\"_blank\">Nuget 包</a> 支持 <code>IPv6<code> 格式</p>", |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LocatorsProviderDesc has malformed HTML: 支持 <code>IPv6<code> 格式 is missing the closing </code> for the IPv6 code span, which will break rendering/formatting in the docs page.
| "LocatorsProviderDesc": "<p>组件库内置免费一个在线地理位置定位器 <code>BaiduIpLocatorProvider</code><p><p>组件库内置一个收费在线地理位置定位器 <code>BootstrapBlazor.JuHeIpLocatorProvider</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.JuHeIpLocatorProvider\" target=\"_blank\">Nuget 包</a> <a href=\"https://juhe.cn\" target=\"_blank\">官网地址</a></p><p>组件库内置一个免费离线地理位置定位器 <code>BootstrapBlazor.IP2Region</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.IP2Region\" target=\"_blank\">Nuget 包</a> 支持 <code>IPv6<code> 格式</p>", | |
| "LocatorsProviderDesc": "<p>组件库内置免费一个在线地理位置定位器 <code>BaiduIpLocatorProvider</code><p><p>组件库内置一个收费在线地理位置定位器 <code>BootstrapBlazor.JuHeIpLocatorProvider</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.JuHeIpLocatorProvider\" target=\"_blank\">Nuget 包</a> <a href=\"https://juhe.cn\" target=\"_blank\">官网地址</a></p><p>组件库内置一个免费离线地理位置定位器 <code>BootstrapBlazor.IP2Region</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.IP2Region\" target=\"_blank\">Nuget 包</a> 支持 <code>IPv6</code> 格式</p>", |
| "LocatorsNormalTipsTitle": "Some geographic location query interfaces may return character sets from other character sets such as<code>gbk</code>, and the program may report an error", | ||
| "LocatorsNormalTitle": "Basic usage", | ||
| "LocatorsProviderDesc": "<p>The component library has two built-in free online geolocation locators, <code>BaiduIpLocatorProvider</code> <code>BaiduIpLocatorProviderV2</code><p><p>The component library has a built-in paid online geolocation locator <code>BootstrapBlazor.JuHeIpLocatorProvider</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.JuHeIpLocatorProvider\" target=\"_blank\">Nuget package</a> <a href=\"https://juhe.cn\" target=\"_blank\">Official website address</a></p><p>The component library has a built-in free offline geolocation locator <code>BootstrapBlazor.IP2Region</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.IP2Region\" target=\"_blank\">Nuget package</a></p>", | ||
| "LocatorsProviderDesc": "<p>The component library built-in free online geolocation locators, <code>BaiduIpLocatorProvider</code><p><p>The component library has a built-in paid online geolocation locator <code>BootstrapBlazor.JuHeIpLocatorProvider</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.JuHeIpLocatorProvider\" target=\"_blank\">Nuget package</a> <a href=\"https://juhe.cn\" target=\"_blank\">Official website address</a></p><p>The component library has a built-in free offline geolocation locator <code>BootstrapBlazor.IP2Region</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.IP2Region\" target=\"_blank\">Nuget package</a>. Supports IPv6 format.</p>", |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LocatorsProviderDesc text is now grammatically inconsistent: "built-in free online geolocation locators" is plural but only a single provider is listed, and the sentence is missing a verb/article (e.g., "has a built-in free online geolocation locator"). This string shows up in the sample docs UI, so it’s worth correcting for clarity.
| "LocatorsProviderDesc": "<p>The component library built-in free online geolocation locators, <code>BaiduIpLocatorProvider</code><p><p>The component library has a built-in paid online geolocation locator <code>BootstrapBlazor.JuHeIpLocatorProvider</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.JuHeIpLocatorProvider\" target=\"_blank\">Nuget package</a> <a href=\"https://juhe.cn\" target=\"_blank\">Official website address</a></p><p>The component library has a built-in free offline geolocation locator <code>BootstrapBlazor.IP2Region</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.IP2Region\" target=\"_blank\">Nuget package</a>. Supports IPv6 format.</p>", | |
| "LocatorsProviderDesc": "<p>The component library has a built-in free online geolocation locator, <code>BaiduIpLocatorProvider</code>.</p><p>The component library has a built-in paid online geolocation locator <code>BootstrapBlazor.JuHeIpLocatorProvider</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.JuHeIpLocatorProvider\" target=\"_blank\">Nuget package</a> <a href=\"https://juhe.cn\" target=\"_blank\">Official website address</a></p><p>The component library has a built-in free offline geolocation locator <code>BootstrapBlazor.IP2Region</code> <a href=\"https://www.nuget.org/packages/BootstrapBlazor.IP2Region\" target=\"_blank\">Nuget package</a>. Supports IPv6 format.</p>", |
| services.AddSingleton<IIpLocatorProvider, BaiduIpLocatorProviderV2>(); | ||
|
|
||
| #if NET8_0_OR_GREATER | ||
| services.AddKeyedSingleton<IIpLocatorProvider, BaiduIpLocatorProvider>(nameof(BaiduIpLocatorProvider)); |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change removes the built-in BaiduIpLocatorProviderV2 registration (and the PR also deletes the type), which is a breaking change for any consumers that reference nameof(BaiduIpLocatorProviderV2) or configure IpLocatorOptions.ProviderName to BaiduIpLocatorProviderV2. Today DefaultIpLocatorFactory.Create indexes _providers[providerKey] and will throw KeyNotFoundException for an unknown key, so upgrades can fail at runtime. If the intent is to deprecate V2, consider keeping a compatibility shim (e.g., keep the type and mark [Obsolete], or map the old key to BaiduIpLocatorProvider / provide a safe fallback) and update all docs/samples that still mention V2 (e.g., ConnectionServices.razor, IpLocatorOptions XML docs).
| services.AddKeyedSingleton<IIpLocatorProvider, BaiduIpLocatorProvider>(nameof(BaiduIpLocatorProvider)); | |
| services.AddKeyedSingleton<IIpLocatorProvider, BaiduIpLocatorProvider>(nameof(BaiduIpLocatorProvider)); | |
| // Compatibility shim: map legacy BaiduIpLocatorProviderV2 key to current provider | |
| services.AddKeyedSingleton<IIpLocatorProvider, BaiduIpLocatorProvider>("BaiduIpLocatorProviderV2"); |
Link issues
fixes #7660
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Update IP locator configuration and samples to use the primary Baidu IP locator provider and demonstrate IPv6 usage.
New Features:
Enhancements:
Documentation: