Merged
Conversation
将 GetI18nDisplayNameAsync 方法返回类型由 Dictionary<string, string> 改为 List<KeyValuePair<string, string>>,同步修改接口、实现及测试代码,提升多语言数据处理一致性。
There was a problem hiding this comment.
Pull request overview
本 PR 将权限 SDK 的多语言显示名称查询 GetI18nDisplayNameAsync 返回类型从 Dictionary<string, string> 统一调整为 List<KeyValuePair<string, string>>,并同步更新接口、两端实现以及单元测试,以提升多语言数据处理的一致性与可控性(如保序、允许重复 key 等)。
Changes:
IPermissionService.GetI18nDisplayNameAsync返回类型改为List<KeyValuePair<string, string>>- Contrib 与 Wasm 端
PermissionService实现同步调整为按新类型反序列化返回 - Auth Tests 中对应测试用例同步调整(但当前实现存在类型不一致问题,见评论)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Contrib/Tests/Masa.Contrib.StackSdks.Auth.Tests/PermissionServiceTest.cs | 更新 I18n DisplayName 测试用例以适配新的返回类型(当前 mock/verify 泛型类型与生产代码不一致,会导致测试失败) |
| src/Contrib/Masa.Contrib.StackSdks.Auth/Service/PermissionService.cs | 将 GetI18nDisplayNameAsync 返回类型与 _caller.GetAsync<T> 泛型参数改为 List<KeyValuePair<string,string>> |
| src/Contrib.Wasm/Masa.Contrib.StackSdks.Auth.Wasm/Service/PermissionService.cs | Wasm 端同步调整 GetI18nDisplayNameAsync 返回类型与调用泛型参数 |
| src/BuildingBlocks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Service/IPermissionService.cs | 更新接口定义以匹配新的返回类型 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+47
to
+48
| caller.Verify(provider => provider.GetAsync<List<KeyValueModel>>(requestUri, default), Times.Once); | ||
| Assert.IsTrue(result.Count == 4); |
|
|
||
| [TestMethod] | ||
| public async Task TestGetI18nDisplayNameAsync() | ||
| public async Task TestGetI18nDisplayNameAsync_V2() |
Comment on lines
+31
to
42
| var data = new List<KeyValueModel> | ||
| { | ||
| ["en-us"] = "User" | ||
| new("en-us", "User"), | ||
| new("zh-cn", "用户"), | ||
| new("ru-ru", "User"), | ||
| new("ja-jp", "") | ||
| }; | ||
| var cultureName = string.Join(',', cultureNames); | ||
| var requestUri = $"api/permission/i18n-display-name?cultureName={Uri.EscapeDataString(cultureName)}&name={Uri.EscapeDataString(name)}"; | ||
| var caller = new Mock<ICaller>(); | ||
| caller.Setup(provider => provider.GetAsync<Dictionary<string, string>>(requestUri, default)).ReturnsAsync(data).Verifiable(); | ||
| caller.Setup(provider => provider.GetAsync<List<KeyValueModel>>(requestUri, default)).ReturnsAsync(data).Verifiable(); | ||
| var userContext = new Mock<IUserContext>(); |
wzh425
approved these changes
Mar 17, 2026
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.
将 GetI18nDisplayNameAsync 方法返回类型由 Dictionary<string, string> 改为 List<KeyValuePair<string, string>>,同步修改接口、实现及测试代码,提升多语言数据处理一致性。