Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Composite provider language tracking can retain the wrong fallback language, and the diagnostic test does not verify build failure.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Adds per-localization-class provider composition, enabling applications and plugins to override library translations by priority.
Changes:
- Generates provider registration, removal, priority, and notification support.
- Adds DLA006 validation for unsupported compiled mode.
- Adds integration tests, sample usage, and documentation.
| File | Description |
|---|---|
tests/TestProjectSet/ProviderPriority/zh-Hans.toml |
Adds priority-test resources. |
tests/TestProjectSet/ProviderPriority/ProviderPriority.csproj |
Configures priority test project. |
tests/TestProjectSet/ProviderPriority/Program.cs |
Exercises provider priorities and removal. |
tests/TestProjectSet/ProviderPriority/Lang.cs |
Enables provider composition. |
tests/TestProjectSet/ProviderPriority/en.toml |
Adds English test resources. |
tests/TestProjectSet/ProviderLanguageChange/Library/zh-Hans.toml |
Adds library Chinese resource. |
tests/TestProjectSet/ProviderLanguageChange/Library/ProviderLanguageChange.Library.csproj |
Configures test library. |
tests/TestProjectSet/ProviderLanguageChange/Library/LibraryLang.cs |
Enables provider notifications. |
tests/TestProjectSet/ProviderLanguageChange/Library/en.toml |
Adds library English resource. |
tests/TestProjectSet/ProviderLanguageChange/Application/zh-Hans.toml |
Adds application Chinese override. |
tests/TestProjectSet/ProviderLanguageChange/Application/ProviderLanguageChange.Application.csproj |
Configures test application. |
tests/TestProjectSet/ProviderLanguageChange/Application/Program.cs |
Tests language-change forwarding. |
tests/TestProjectSet/ProviderLanguageChange/Application/en.toml |
Adds application English override. |
tests/TestProjectSet/ProviderLanguageChange/Application/AppLang.cs |
Defines application localization source. |
tests/TestProjectSet/CompiledProviderError/zh-Hans.toml |
Adds diagnostic-test resource. |
tests/TestProjectSet/CompiledProviderError/Program.cs |
References generated localization API. |
tests/TestProjectSet/CompiledProviderError/Lang.cs |
Creates invalid compiled configuration. |
tests/TestProjectSet/CompiledProviderError/en.toml |
Adds English diagnostic resource. |
tests/TestProjectSet/CompiledProviderError/CompiledProviderError.csproj |
Configures diagnostic test project. |
tests/DotNetCampus.Localizations.Tests/TestProjectRunner.cs |
Builds and runs fixture projects. |
tests/DotNetCampus.Localizations.Tests/SourceGeneratorProjectTests.cs |
Adds source-generator integration tests. |
tests/DotNetCampus.Localizations.Tests/Properties/AssemblyInfo.cs |
Serializes test execution. |
tests/DotNetCampus.Localizations.Tests/LocalizedStringProviderCollectionTests.cs |
Contains no reviewable content. |
src/DotNetCampus.Localizations/LocalizedConfigurationAttribute.cs |
Adds provider-generation option. |
src/DotNetCampus.Localizations.Analyzer/Utils/CodeAnalysis/DiagnosticExtensions.cs |
Reports DLA006. |
src/DotNetCampus.Localizations.Analyzer/Properties/Localizations.zh-hant.resx |
Localizes DLA006 in Traditional Chinese. |
src/DotNetCampus.Localizations.Analyzer/Properties/Localizations.zh-hans.resx |
Localizes DLA006 in Simplified Chinese. |
src/DotNetCampus.Localizations.Analyzer/Properties/Localizations.resx |
Adds default DLA006 text. |
src/DotNetCampus.Localizations.Analyzer/Generators/ModelProviding/LocalizationGeneratingModelExtensions.cs |
Reads the new configuration option. |
src/DotNetCampus.Localizations.Analyzer/Generators/ModelProviding/LocalizationGeneratingModel.cs |
Stores provider-support metadata. |
src/DotNetCampus.Localizations.Analyzer/Generators/LocalizationMainClassGenerator.cs |
Generates provider composition APIs. |
src/DotNetCampus.Localizations.Analyzer/Generators/CodeTransforming/InterfaceCodeGenerator.cs |
Exposes dictionary values as providers. |
src/DotNetCampus.Localizations.Analyzer/Generators/CodeTransforming/DictionaryValuesCodeGenerator.cs |
Adds root change notifications. |
src/DotNetCampus.Localizations.Analyzer/Diagnostics.cs |
Defines DLA006. |
samples/LocalizationSample/Program.cs |
Demonstrates provider overrides. |
README.md |
Documents provider composition. |
DotNetCampus.SourceLocalizations.sln.DotSettings |
Adds formatting settings. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+482
to
+485
| var entries = registry._entries; | ||
| return entries.Length > 0 && entries[0].Priority > 0 | ||
| ? entries[0].Provider.IetfLanguageTag | ||
| : provider.IetfLanguageTag; |
|
|
||
| var result = await TestProjectRunner.BuildAsync(projectPath); | ||
|
|
||
| StringAssert.Contains(result.Output, "DLA006"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


需求:
解决方法:
提供 AddProvider 的方法,用于提供多个多语言源头
对于库来说,直接用自己的源代码生成器的 LibLang 类;只是要求采用字典的方式才能被注入
对于插件来说,提供的是 Provider 可以主动加入到主项目中
边界处理:
要求采用字典的方式,否则构建异常
带通知的方式加入,自动加事件