Open
Conversation
LinQingYuu
requested changes
Mar 15, 2026
Member
LinQingYuu
left a comment
There was a problem hiding this comment.
请把它丢到 PCL.Core.App,而不是新开一个命名空间
LinQingYuu
previously approved these changes
Mar 15, 2026
Pigeon0v0
reviewed
Mar 15, 2026
LinQingYuu
previously approved these changes
Mar 16, 2026
Contributor
Author
|
@sourcery-ai review |
审阅者指南引入了一个新的 DependencyCheckService,它会在应用程序启动时运行,通过 PowerShell 检查所需的 Microsoft Store 包(OpenGL 兼容包和 WebP 扩展),如果缺失则提示用户安装。 应用程序启动时依赖检查的时序图sequenceDiagram
participant AppLifecycle
participant DependencyCheckService
participant RuntimeInformation
participant PowerShell
participant MsgBoxWrapper
actor User
participant MsStore
AppLifecycle->>DependencyCheckService: _Start()
DependencyCheckService->>RuntimeInformation: OSArchitecture
alt OSArchitecture is Arm64
DependencyCheckService->>DependencyCheckService: _CheckAndAsk(Microsoft.D3DMappingLayers, OpenGL兼容包, 9nqpsl29bfff)
DependencyCheckService->>DependencyCheckService: _CheckPakcageAsync(Microsoft.D3DMappingLayers)
DependencyCheckService->>PowerShell: Start powershell.exe Get-AppxPackage
PowerShell-->>DependencyCheckService: JSON package list
alt package not found
DependencyCheckService->>MsgBoxWrapper: Show(缺失OpenGL兼容包)
MsgBoxWrapper-->>User: 显示对话框
User-->>MsgBoxWrapper: 选择确定
MsgBoxWrapper-->>DependencyCheckService: selection = 1
DependencyCheckService->>DependencyCheckService: _LaunchMsStore(9nqpsl29bfff)
DependencyCheckService->>MsStore: ms-windows-store://pdp?...productid=9nqpsl29bfff
else package found
DependencyCheckService-->>AppLifecycle: 继续启动
end
end
DependencyCheckService->>DependencyCheckService: _CheckAndAsk(Microsoft.WebpImageExtension, WebP组件包, 9pg2dk419drg)
DependencyCheckService->>DependencyCheckService: _CheckPakcageAsync(Microsoft.WebpImageExtension)
DependencyCheckService->>PowerShell: Start powershell.exe Get-AppxPackage
PowerShell-->>DependencyCheckService: JSON package list
alt WebP组件包缺失
DependencyCheckService->>MsgBoxWrapper: Show(缺失WebP组件包)
MsgBoxWrapper-->>User: 显示对话框
User-->>MsgBoxWrapper: 选择确定或稍后
MsgBoxWrapper-->>DependencyCheckService: selection
alt selection == 确定
DependencyCheckService->>DependencyCheckService: _LaunchMsStore(9pg2dk419drg)
DependencyCheckService->>MsStore: ms-windows-store://pdp?...productid=9pg2dk419drg
else selection == 稍后
DependencyCheckService-->>AppLifecycle: 不打开商店
end
else WebP组件包已安装
DependencyCheckService-->>AppLifecycle: 继续启动
end
新增 DependencyCheckService 的类图classDiagram
class DependencyCheckService {
<<sealed>>
+_Start() Task
+_CheckAndAsk(packageId string, packageName string, storeId string) Task
+_LaunchMsStore(id string) void
+_CheckPakcageAsync(id string) Task~bool~
+CheckPackSuit(jnode JsonNode, id string) bool
}
class MsgBoxWrapper {
+Show(message string, buttons string[]) int
}
class ProcessStartInfo {
+FileName string
+Arguments string
+UseShellExecute bool
+RedirectStandardOutput bool
+RedirectStandardError bool
+CreateNoWindow bool
}
class Process {
+StartInfo ProcessStartInfo
+Start() bool
}
class RuntimeInformation {
+OSArchitecture Architecture
}
class Context {
+Info(message string) void
}
DependencyCheckService ..> MsgBoxWrapper : uses
DependencyCheckService ..> ProcessStartInfo : creates
DependencyCheckService ..> Process : creates
DependencyCheckService ..> RuntimeInformation : reads
DependencyCheckService ..> Context : logs
文件级变更
与关联 issue 的对照评估
提示与命令与 Sourcery 交互
自定义你的体验访问你的 控制台 以:
获取帮助Original review guide in EnglishReviewer's GuideIntroduces a new DependencyCheckService that runs at application startup to check for required Microsoft Store packages (OpenGL compatibility and WebP extension) via PowerShell and prompts the user to install them if missing. Sequence diagram for dependency check at application startupsequenceDiagram
participant AppLifecycle
participant DependencyCheckService
participant RuntimeInformation
participant PowerShell
participant MsgBoxWrapper
actor User
participant MsStore
AppLifecycle->>DependencyCheckService: _Start()
DependencyCheckService->>RuntimeInformation: OSArchitecture
alt OSArchitecture is Arm64
DependencyCheckService->>DependencyCheckService: _CheckAndAsk(Microsoft.D3DMappingLayers, OpenGL兼容包, 9nqpsl29bfff)
DependencyCheckService->>DependencyCheckService: _CheckPakcageAsync(Microsoft.D3DMappingLayers)
DependencyCheckService->>PowerShell: Start powershell.exe Get-AppxPackage
PowerShell-->>DependencyCheckService: JSON package list
alt package not found
DependencyCheckService->>MsgBoxWrapper: Show(缺失OpenGL兼容包)
MsgBoxWrapper-->>User: 显示对话框
User-->>MsgBoxWrapper: 选择确定
MsgBoxWrapper-->>DependencyCheckService: selection = 1
DependencyCheckService->>DependencyCheckService: _LaunchMsStore(9nqpsl29bfff)
DependencyCheckService->>MsStore: ms-windows-store://pdp?...productid=9nqpsl29bfff
else package found
DependencyCheckService-->>AppLifecycle: 继续启动
end
end
DependencyCheckService->>DependencyCheckService: _CheckAndAsk(Microsoft.WebpImageExtension, WebP组件包, 9pg2dk419drg)
DependencyCheckService->>DependencyCheckService: _CheckPakcageAsync(Microsoft.WebpImageExtension)
DependencyCheckService->>PowerShell: Start powershell.exe Get-AppxPackage
PowerShell-->>DependencyCheckService: JSON package list
alt WebP组件包缺失
DependencyCheckService->>MsgBoxWrapper: Show(缺失WebP组件包)
MsgBoxWrapper-->>User: 显示对话框
User-->>MsgBoxWrapper: 选择确定或稍后
MsgBoxWrapper-->>DependencyCheckService: selection
alt selection == 确定
DependencyCheckService->>DependencyCheckService: _LaunchMsStore(9pg2dk419drg)
DependencyCheckService->>MsStore: ms-windows-store://pdp?...productid=9pg2dk419drg
else selection == 稍后
DependencyCheckService-->>AppLifecycle: 不打开商店
end
else WebP组件包已安装
DependencyCheckService-->>AppLifecycle: 继续启动
end
Class diagram for the new DependencyCheckServiceclassDiagram
class DependencyCheckService {
<<sealed>>
+_Start() Task
+_CheckAndAsk(packageId string, packageName string, storeId string) Task
+_LaunchMsStore(id string) void
+_CheckPakcageAsync(id string) Task~bool~
+CheckPackSuit(jnode JsonNode, id string) bool
}
class MsgBoxWrapper {
+Show(message string, buttons string[]) int
}
class ProcessStartInfo {
+FileName string
+Arguments string
+UseShellExecute bool
+RedirectStandardOutput bool
+RedirectStandardError bool
+CreateNoWindow bool
}
class Process {
+StartInfo ProcessStartInfo
+Start() bool
}
class RuntimeInformation {
+OSArchitecture Architecture
}
class Context {
+Info(message string) void
}
DependencyCheckService ..> MsgBoxWrapper : uses
DependencyCheckService ..> ProcessStartInfo : creates
DependencyCheckService ..> Process : creates
DependencyCheckService ..> RuntimeInformation : reads
DependencyCheckService ..> Context : logs
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - 我发现了两个问题,并给了一些总体反馈:
- 在
_CheckPakcageAsync方法中,foreach循环使用foreach (var node in jnode.AsArray())进行迭代,但仍然将jnode传入CheckPackSuit;这里很可能应该传入node,这样才能实际检查数组中的每个元素。 - 方法名
_CheckPakcageAsync有拼写错误,应重命名为_CheckPackageAsync(并更新所有调用处),以保持命名一致并避免混淆。 - 由于这段代码会调用
powershell.exe,建议对_CheckPakcageAsync和_Start增加仅限 Windows 的系统检查(例如RuntimeInformation.IsOSPlatform(OSPlatform.Windows)),以避免在非 Windows 平台上出现错误。
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the `_CheckPakcageAsync` method, the `foreach` loop iterates `foreach (var node in jnode.AsArray())` but still passes `jnode` into `CheckPackSuit`; this should likely pass `node` so each entry is actually inspected.
- The method name `_CheckPakcageAsync` contains a typo and should be renamed to `_CheckPackageAsync` (and all call sites updated) to keep naming consistent and avoid confusion.
- Since this code shells out to `powershell.exe`, consider guarding `_CheckPakcageAsync` and `_Start` with a Windows-only OS check (e.g., `RuntimeInformation.IsOSPlatform(OSPlatform.Windows)`) to avoid failures on non-Windows platforms.
## Individual Comments
### Comment 1
<location path="PCL.Core/App/Tools/DependencyCheckService.cs" line_range="85-87" />
<code_context>
+ if (jnode.GetValueKind().Equals(JsonValueKind.Array))
+ {
+ var hasPack = false;
+ foreach (var node in jnode.AsArray())
+ {
+ if (CheckPackSuit(jnode, id))
+ {
+ hasPack = true;
</code_context>
<issue_to_address>
**issue (bug_risk):** Array iteration likely checks the wrong JsonNode instance, leading to incorrect detection.
Inside the `foreach (var node in jnode.AsArray())` loop, `CheckPackSuit` is called with `jnode` instead of `node`, so the same array node is checked on every iteration instead of each element. This will produce the same result for every pass and likely never detect the intended match. Use `CheckPackSuit(node, id)` to evaluate each array item correctly.
</issue_to_address>
### Comment 2
<location path="PCL.Core/App/Tools/DependencyCheckService.cs" line_range="53" />
<code_context>
+ ps.Start();
+ }
+
+ private static async Task<bool> _CheckPakcageAsync(string id)
+ {
+ var command = $"Get-AppxPackage -Name *{id}* | ConvertTo-Json";
</code_context>
<issue_to_address>
**nitpick (typo):** Method name contains a typo that could hurt readability and discoverability.
`_CheckPakcageAsync` seems to misspell `Package`. Please rename it to `_CheckPackageAsync` for consistency and easier searchability.
Suggested implementation:
```csharp
private static async Task<bool> _CheckPackageAsync(string id)
```
Search the entire solution for `_CheckPakcageAsync` and update all call sites to `_CheckPackageAsync` to keep the code compiling and consistent.
</issue_to_address>帮我变得更有用!请对每条评论点选 👍 或 👎,我会根据你的反馈改进后续的代码审查。
Original comment in English
Hey - I've found 2 issues, and left some high level feedback:
- In the
_CheckPakcageAsyncmethod, theforeachloop iteratesforeach (var node in jnode.AsArray())but still passesjnodeintoCheckPackSuit; this should likely passnodeso each entry is actually inspected. - The method name
_CheckPakcageAsynccontains a typo and should be renamed to_CheckPackageAsync(and all call sites updated) to keep naming consistent and avoid confusion. - Since this code shells out to
powershell.exe, consider guarding_CheckPakcageAsyncand_Startwith a Windows-only OS check (e.g.,RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) to avoid failures on non-Windows platforms.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the `_CheckPakcageAsync` method, the `foreach` loop iterates `foreach (var node in jnode.AsArray())` but still passes `jnode` into `CheckPackSuit`; this should likely pass `node` so each entry is actually inspected.
- The method name `_CheckPakcageAsync` contains a typo and should be renamed to `_CheckPackageAsync` (and all call sites updated) to keep naming consistent and avoid confusion.
- Since this code shells out to `powershell.exe`, consider guarding `_CheckPakcageAsync` and `_Start` with a Windows-only OS check (e.g., `RuntimeInformation.IsOSPlatform(OSPlatform.Windows)`) to avoid failures on non-Windows platforms.
## Individual Comments
### Comment 1
<location path="PCL.Core/App/Tools/DependencyCheckService.cs" line_range="85-87" />
<code_context>
+ if (jnode.GetValueKind().Equals(JsonValueKind.Array))
+ {
+ var hasPack = false;
+ foreach (var node in jnode.AsArray())
+ {
+ if (CheckPackSuit(jnode, id))
+ {
+ hasPack = true;
</code_context>
<issue_to_address>
**issue (bug_risk):** Array iteration likely checks the wrong JsonNode instance, leading to incorrect detection.
Inside the `foreach (var node in jnode.AsArray())` loop, `CheckPackSuit` is called with `jnode` instead of `node`, so the same array node is checked on every iteration instead of each element. This will produce the same result for every pass and likely never detect the intended match. Use `CheckPackSuit(node, id)` to evaluate each array item correctly.
</issue_to_address>
### Comment 2
<location path="PCL.Core/App/Tools/DependencyCheckService.cs" line_range="53" />
<code_context>
+ ps.Start();
+ }
+
+ private static async Task<bool> _CheckPakcageAsync(string id)
+ {
+ var command = $"Get-AppxPackage -Name *{id}* | ConvertTo-Json";
</code_context>
<issue_to_address>
**nitpick (typo):** Method name contains a typo that could hurt readability and discoverability.
`_CheckPakcageAsync` seems to misspell `Package`. Please rename it to `_CheckPackageAsync` for consistency and easier searchability.
Suggested implementation:
```csharp
private static async Task<bool> _CheckPackageAsync(string id)
```
Search the entire solution for `_CheckPakcageAsync` and update all call sites to `_CheckPackageAsync` to keep the code compiling and consistent.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Big-Cake-jpg
approved these changes
Mar 16, 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.
Close #387
Summary by Sourcery
添加一个启动依赖检查服务,用于验证所需的 Windows 运行时组件是否已安装,并通过 Microsoft Store 提示引导用户安装缺失的包。
新功能:
Original summary in English
Summary by Sourcery
Add a startup dependency check service that verifies required Windows runtime components are installed and guides users to install missing packages via Microsoft Store prompts.
New Features: