Skip to content

统一多语言显示名称返回类型为键值对列表#89

Merged
wzh425 merged 2 commits intomainfrom
feature/auth-permission-i18n-display-name
Mar 17, 2026
Merged

统一多语言显示名称返回类型为键值对列表#89
wzh425 merged 2 commits intomainfrom
feature/auth-permission-i18n-display-name

Conversation

@MayueCif
Copy link
Copy Markdown
Contributor

将 GetI18nDisplayNameAsync 方法返回类型由 Dictionary<string, string> 改为 List<KeyValuePair<string, string>>,同步修改接口、实现及测试代码,提升多语言数据处理一致性。

将 GetI18nDisplayNameAsync 方法返回类型由 Dictionary<string, string> 改为 List<KeyValuePair<string, string>>,同步修改接口、实现及测试代码,提升多语言数据处理一致性。
Copilot AI review requested due to automatic review settings March 17, 2026 07:16
Copy link
Copy Markdown

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

本 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 wzh425 merged commit 622f3f4 into main Mar 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants