Skip to content

Conversation

Copy link

Copilot AI commented Jan 12, 2026

The ProcessInfo constructor required manually passing 19 individual parameters extracted from GlobalConfigInfo, making the code fragile when adding new fields. Each parameter had to be carefully extracted and passed in the correct order.

Changes

  • Added factory method to ProcessInfo: CreateFromConfig() centralizes parameter extraction from GlobalConfigInfo in a single location
  • Simplified instantiation in GeneralClientBootstrap: Replaced 19-parameter constructor call with 5-parameter factory method

Example

Before:

var processInfo = new ProcessInfo(_configInfo.MainAppName
    , _configInfo.InstallPath
    , _configInfo.ClientVersion
    , _configInfo.LastVersion
    , _configInfo.UpdateLogUrl
    , _configInfo.Encoding
    , _configInfo.Format
    , _configInfo.DownloadTimeOut
    , _configInfo.AppSecretKey
    , mainResp.Body
    , _configInfo.ReportUrl
    , _configInfo.BackupDirectory
    , _configInfo.Bowl
    , _configInfo.Scheme
    , _configInfo.Token
    , _configInfo.Script
    , BlackListManager.Instance.BlackFileFormats.ToList()
    , BlackListManager.Instance.BlackFiles.ToList()
    , BlackListManager.Instance.SkipDirectorys.ToList());

After:

var processInfo = ProcessInfo.CreateFromConfig(_configInfo, 
    mainResp.Body, 
    BlackListManager.Instance.BlackFileFormats.ToList(), 
    BlackListManager.Instance.BlackFiles.ToList(), 
    BlackListManager.Instance.SkipDirectorys.ToList());

The original constructor remains for backward compatibility. Adding new fields to GlobalConfigInfo now requires updating only the factory method.

Original prompt

This section details on the original issue you should resolve

<issue_title>[REFACTOR] Refactor the parameter initialization method in the bootstrap class GeneralClientBootstrap</issue_title>
<issue_description>### Target Module/File

GeneralUpdate.ClientCore/GeneralClientBootstrap.cs

Current Code Problems

In the SetConfig method of the bootstrap class GeneralClientBootstrap, every time a new field is added, corresponding modifications must be made to ProcessInfo, GlobalConfigInfo, and the places where process parameters are passed and written to files. This process is highly error-prone and cumbersome, requiring a refactoring.

Refactoring Objectives

The goal of the refactoring is to avoid missing parameter passing during maintenance and improve maintainability.

Refactoring Scope and Boundaries

Refactor the code only, while preserving the original intent of the code.

Risk Assessment

No response

Reference Materials

No response

Expected Completion Time

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Jan 12, 2026
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor parameter initialization method in GeneralClientBootstrap Refactor ProcessInfo initialization to use factory method Jan 12, 2026
Copilot AI requested a review from JusterZhu January 12, 2026 10:00
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.

[REFACTOR] Refactor the parameter initialization method in the bootstrap class GeneralClientBootstrap

2 participants