Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Feb 12, 2026

Link issues

fixes #7660

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Update IP locator configuration and samples to use the primary Baidu IP locator provider and demonstrate IPv6 usage.

New Features:

  • Expose an example IPv6 address in the locator sample UI to illustrate IPv6 lookup support.

Enhancements:

  • Simplify IP locator provider registration and usage by removing the BaiduIpLocatorProviderV2 implementation and associated test mocks.
  • Set BaiduIpLocatorProvider as the default provider in tests and the locator demo component.

Documentation:

  • Update locator sample content (and corresponding localized strings) to document and showcase IPv6 address lookup.

Copilot AI review requested due to automatic review settings February 12, 2026 05:52
@bb-auto bb-auto bot added the enhancement New feature or request label Feb 12, 2026
@bb-auto bb-auto bot added this to the v10.3.0 milestone Feb 12, 2026
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 12, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Consolidates 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 component

classDiagram
    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
Loading

File-Level Changes

Change Details Files
Make BaiduIpLocatorProvider the single/default implementation and remove BaiduIpLocatorProviderV2-related code and tests.
  • Switch test configuration to use BaiduIpLocatorProvider instead of BaiduIpLocatorProviderV2 in unit tests.
  • Remove BaiduIpLocatorProviderV2-specific tests, factory assertions, and mock provider subclasses.
  • Delete the BaiduIpLocatorProviderV2 implementation file and stop registering it in DI, including keyed registrations.
test/UnitTest/Services/IpLocatorTest.cs
src/BootstrapBlazor/Extensions/BootstrapBlazorServiceCollectionExtensions.cs
src/BootstrapBlazor/Services/IPLocator/BaiduIpLocatorProviderV2.cs
Update samples and defaults to use the remaining BaiduIpLocatorProvider and add an IPv6 example to the locator demo.
  • Change the default provider name in the Locators sample backing class from BaiduIpLocatorProviderV2 to BaiduIpLocatorProvider.
  • Add an IPv6 address example line to the Locators.razor sample and reformat the provider Select component attributes.
  • Update localization JSONs to provide text for the new IPv6-related sample string key.
src/BootstrapBlazor.Server/Components/Samples/Locators.razor
src/BootstrapBlazor.Server/Components/Samples/Locators.razor.cs
src/BootstrapBlazor.Server/Locales/en-US.json
src/BootstrapBlazor.Server/Locales/zh-CN.json
Minor cleanups in tests and sample markup.
  • Fix a typo in a test mock provider variable name used for cancellation/error testing.
  • Normalize file headers and remove a stray BOM in the Locators.razor.cs file.
  • Tidy whitespace in the Locators.razor page directive.
test/UnitTest/Services/IpLocatorTest.cs
src/BootstrapBlazor.Server/Components/Samples/Locators.razor
src/BootstrapBlazor.Server/Components/Samples/Locators.razor.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#7660 Update the IP locator/IP2Region documentation and samples to demonstrate and describe support for IPv6-format IP addresses.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (bec6064) to head (aa445fc).
⚠️ Report is 1 commits behind head on main.

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     
Flag Coverage Δ
BB 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a 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.IP2Region package reference to 10.0.1 in the Server project.
  • Update Locators sample/docs and localized strings to include an IPv6 example and describe IPv6 support.
  • Remove BaiduIpLocatorProviderV2 provider 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>",
Copy link

Copilot AI Feb 12, 2026

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.

Suggested change
"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>",

Copilot uses AI. Check for mistakes.
"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>",
Copy link

Copilot AI Feb 12, 2026

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.

Suggested change
"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>",

Copilot uses AI. Check for mistakes.
services.AddSingleton<IIpLocatorProvider, BaiduIpLocatorProviderV2>();

#if NET8_0_OR_GREATER
services.AddKeyedSingleton<IIpLocatorProvider, BaiduIpLocatorProvider>(nameof(BaiduIpLocatorProvider));
Copy link

Copilot AI Feb 12, 2026

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).

Suggested change
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");

Copilot uses AI. Check for mistakes.
@ArgoZhang ArgoZhang merged commit d49a9e8 into main Feb 12, 2026
12 checks passed
@ArgoZhang ArgoZhang deleted the refactor-ip branch February 12, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doc(IP2Region): support IPv6 format

1 participant