Skip to content

Update System.CommandLine dependency #776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

bagusnl
Copy link
Member

@bagusnl bagusnl commented Jun 27, 2025

Main Goal

Update System.CommandLine to beta 5

What works:

  • open, though it doesn't state the error or notice when the argument input is invalid.
  • tray
  • generatevelopackmetadata

PR Status :

  • Overall Status : Done
  • Commits : Done
  • Synced to base (Collapse:main) : Yes
  • Build status : OK
  • Crashing : Yes
  • Bug found caused by PR : 1
    • Suboption doesn't state the error or notice when the argument input is invalid.

Templates

Changelog Prefixes
  **[New]**
  **[Imp]**
  **[Fix]**
  **[Loc]**
  **[Doc]**

@bagusnl bagusnl requested review from gablm, a team and Copilot June 27, 2025 11:54
Copilot

This comment was marked as outdated.

Copy link

github-actions bot commented Jun 27, 2025

Qodana for .NET

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Detected 69 dependencies

Third-party software list

This page lists the third-party software dependencies used in CollapseLauncher

Dependency Version Licenses
CommunityToolkit.Common 8.4.0 MIT
CommunityToolkit.Mvvm 8.4.0 MIT
CommunityToolkit.WinUI.Animations 8.2.250402 MIT
CommunityToolkit.WinUI.Behaviors 8.2.250402 MIT
CommunityToolkit.WinUI.Controls.Primitives 8.2.250402 MIT
CommunityToolkit.WinUI.Controls.Sizers 8.2.250402 MIT
CommunityToolkit.WinUI.Converters 8.2.250402 MIT
CommunityToolkit.WinUI.Extensions 8.2.250402 MIT
CommunityToolkit.WinUI.Helpers 8.2.250402 MIT
CommunityToolkit.WinUI.Media 8.2.250402 MIT
CommunityToolkit.WinUI.Triggers 8.2.250402 MIT
Costura.Fody 6.0.0 MIT
DependencyPropertyGenerator 1.5.0 MIT
DotNet.ReproducibleBuilds 1.2.25 MIT
EventGenerator.Generator 0.13.1 MIT
Fody 6.9.2 MIT
GitInfo 3.5.0 MIT
Google.Protobuf.Tools 3.31.1 PROTOBUF
Google.Protobuf 3.31.1 BSD-3-Clause
Hi3Helper.ZstdNet 1.6.4 BSD-3-Clause
HtmlAgilityPack 1.12.1 MIT
Markdig.Signed 0.41.3 BSD-2-Clause
Microsoft.CSharp 4.7.0 MIT
Microsoft.Extensions.DependencyInjection.Abstractions 9.0.6 MIT
Microsoft.Extensions.DependencyInjection 9.0.6 MIT
Microsoft.Extensions.Logging.Abstractions 9.0.6 MIT
Microsoft.Extensions.Logging 9.0.6 MIT
Microsoft.Extensions.Options 9.0.6 MIT
Microsoft.Extensions.Primitives 9.0.6 MIT
Microsoft.NET.ILLink.Tasks 9.0.6 MIT
Microsoft.NETCore.Targets 6.0.0-preview.4.21253.7 MIT
Microsoft.Web.WebView2 1.0.3344-prerelease BSD-3-Clause
BSD-MYLEX
Microsoft.Win32.SystemEvents 9.0.6 MIT
Microsoft.Windows.CsWin32 0.3.183 Apache-2.0
Microsoft.Windows.CsWinRT 2.2.0 MIT
Microsoft.Windows.SDK.BuildTools.MSIX 1.7.20250508.1 MIT
Microsoft.Windows.SDK.BuildTools 10.0.26100.4188 PROPRIETARY-LICENSE
Microsoft.Windows.SDK.Win32Docs 0.1.42-alpha PROPRIETARY-LICENSE
Microsoft.Windows.SDK.Win32Metadata 63.0.31-preview MIT
Microsoft.Windows.WDK.Win32Metadata 0.13.25-experimental MIT
Microsoft.WindowsAppSDK.AI 1.8.135-experimental MS-DXSDK-D3DX-9.29.952.3
Microsoft.WindowsAppSDK.Base 1.8.250509001-experimental MIT
MS-DXSDK-D3DX-9.29.952.3
Microsoft.WindowsAppSDK.DWrite 1.8.25050910-experimental.2 MS-DXSDK-D3DX-9.29.952.3
Microsoft.WindowsAppSDK.Foundation 1.8.250507001-experimental MS-DXSDK-D3DX-9.29.952.3
Microsoft.WindowsAppSDK.InteractiveExperiences 1.8.250509002-experimental MS-DXSDK-D3DX-9.29.952.3
Microsoft.WindowsAppSDK.Packages 1.8.250515001-experimental2 MIT
MS-DXSDK-D3DX-9.29.952.3
Microsoft.WindowsAppSDK.Widgets 1.8.250505003-experimental MS-DXSDK-D3DX-9.29.952.3
Microsoft.WindowsAppSDK.WinUI 1.8.250507002-experimental MIT
MS-DXSDK-D3DX-9.29.952.3
Microsoft.WindowsAppSDK 1.8.250515001-experimental2 MIT
MS-DXSDK-D3DX-9.29.952.3
Microsoft.Xaml.Behaviors.WinUI.Managed 3.0.0 MIT
NuGet.Versioning 6.14.0 Apache-2.0
PhotoSauce.MagicScaler 0.15.0 MIT
PhotoSauce.NativeCodecs.Libwebp 1.4.0-preview1 MIT
Roman-Numerals 2.0.1 MIT
Sentry 5.11.2 MIT
SharpCompress 0.40.0 MIT
SharpHDiffPatch.Core 2.3.3 MIT
System.Buffers 4.6.0 MIT
System.Drawing.Common 9.0.6 MIT
System.IO.Hashing 9.0.6 MIT
System.Security.AccessControl 6.0.1 MIT
System.Security.Cryptography.ProtectedData 9.0.6 MIT
System.Text.Encoding.CodePages 9.0.6 MIT
System.Text.Json 9.0.6 MIT
System.Threading.Tasks.Extensions 4.5.4 MIT
TaskScheduler 2.12.1 MIT
ThisAssembly.Constants 2.0.6 MIT
Velopack 0.0.1297 MIT
ZstdSharp.Port 0.8.5 MIT
Contact Qodana team

Contact us at qodana-support@jetbrains.com

command.AddOption(oInput);
command.AddOption(oChannel);
command.Handler = CommandHandler.Create((string input, AppReleaseChannel channel) =>
var oChannel = new Option<AppReleaseChannel>("--channel", "-c")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this in Aliases style?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 3e15b13

Co-authored-by: Shatyuka <shatyuka@qq.com>
@bagusnl bagusnl requested a review from shatyuka June 27, 2025 16:01
Copy link
Member

@gablm gablm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine overall.
About the error/notice when the input is invalid, it never showed anything if either the game or region were wrong. Maybe it should, but I don't know how pertinent it would be to add a dialog or console warning.


var e = new ArgumentException("Argument to run this command is invalid! See the information above for more detail.");
Console.WriteLine(e);
m_appMode = AppMode.Launcher;
}

public static void ParseHi3CacheUpdaterArguments(params string[] args)
private static void ParseHi3CacheUpdaterArguments(params string[] _)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't the args parameter be removed in all of the Parse* functions as it's never used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented!
0160fbe

bagusnl added 4 commits June 28, 2025 06:40
1. Sentry
2. IconExtract
3. AppPreset
4. Velopack
5. Set CD
6. AppSettings
Co-authored-by: Gabriel Lima <44784408+gablm@users.noreply.github.com>
@bagusnl bagusnl requested review from gablm and Copilot June 27, 2025 23:54
Copy link
Contributor

@Copilot 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 the System.CommandLine packages to beta 5 and modernizes several components of the launcher.

  • Bumps System.CommandLine and NamingConventionBinder to 2.0.0-beta5
  • Refactors argument parsing to the new Option/CommandHandler API
  • Improves console allocation logic and skips redundant metadata writes

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Hi3Helper.Win32 Advanced submodule commit pointer
LoggerConsole.cs Added AttachConsole fallback, unified allocation and error handling
CollapseLauncher/packages.lock.json Updated System.CommandLine versions to beta 5
CollapseLauncher/Program.cs Relocated Sentry SDK initialization and updater hook
CollapseLauncher/CollapseLauncher.csproj Switched package versions and added Debug OutputType override
CollapseLauncher/Classes/Properties/ArgumentParser.cs Migrated to new System.CommandLine API and cleaned up parsing
CollapseLauncher/Classes/Extension/VelopackLocatorExtension.cs Skip writing metadata if unchanged
Comments suppressed due to low confidence (1)

CollapseLauncher/CollapseLauncher.csproj:95

  • Overriding OutputType to Exe in the Debug configuration will conflict with the main WinExe setting; consider removing this or aligning it with the intended output type.
        <OutputType>Exe</OutputType>


if (!isConsoleApp && !PInvoke.AllocConsole())
if (!isConsoleApp && !PInvoke.AttachConsole(0xFFFFFFFF))
Copy link
Preview

Copilot AI Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace the literal 0xFFFFFFFF with a named constant (e.g. ATTACH_PARENT_PROCESS) to clarify its meaning.

Suggested change
if (!isConsoleApp && !PInvoke.AttachConsole(0xFFFFFFFF))
const uint ATTACH_PARENT_PROCESS = 0xFFFFFFFF;
if (!isConsoleApp && !PInvoke.AttachConsole(ATTACH_PARENT_PROCESS))

Copilot uses AI. Check for mistakes.

Comment on lines +142 to +143
private static void AddHi3CacheUpdaterOptions() { }

Copy link
Preview

Copilot AI Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AddHi3CacheUpdaterOptions method is empty, so no options are added to the hi3cacheupdate command; it should register the required options and handler.

Suggested change
private static void AddHi3CacheUpdaterOptions() { }
private static void AddHi3CacheUpdaterOptions()
{
var oCachePath = new Option<string>("--cache-path")
{
Description = "Path to the cache directory",
Required = true
};
var oUpdateMode = new Option<string>("--update-mode")
{
Description = "Mode of cache update (e.g., 'full', 'incremental')",
Required = true
};
var hi3CacheUpdateCommand = _rootCommand.Children.OfType<Command>().FirstOrDefault(c => c.Name == "hi3cacheupdate");
if (hi3CacheUpdateCommand != null)
{
hi3CacheUpdateCommand.Options.Add(oCachePath);
hi3CacheUpdateCommand.Options.Add(oUpdateMode);
hi3CacheUpdateCommand.Action = CommandHandler.Create((string cachePath, string updateMode) =>
{
m_arguments.Hi3CacheUpdater = new ArgumentHi3CacheUpdater
{
CachePath = cachePath,
UpdateMode = updateMode
};
});
}
}

Copilot uses AI. Check for mistakes.

{
command.SetHandler(() =>
var oInput = new Option<string>("--output-path")
Copy link
Preview

Copilot AI Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updater option is declared as --output-path but the handler signature expects a parameter named input, causing a binding mismatch; rename the option or the handler parameter to match.

Copilot uses AI. Check for mistakes.

var command = new Command("takeownership", "Take ownership of the folder");
command.AddOption(inputOption);
command.Handler = CommandHandler.Create((string input) =>
var inputOption = new Option<string>("--input-path")
Copy link
Preview

Copilot AI Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The takeownership command defines --input-path but the handler expects input, leading to a name mismatch; align the option name with the handler parameter.

Suggested change
var inputOption = new Option<string>("--input-path")
var inputOption = new Option<string>("--input")

Copilot uses AI. Check for mistakes.

Copy link

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