Skip to content

Add console samples for Drivelution and Extension components#32

Merged
JusterZhu merged 4 commits intomainfrom
copilot/write-console-sample-programs
Feb 12, 2026
Merged

Add console samples for Drivelution and Extension components#32
JusterZhu merged 4 commits intomainfrom
copilot/write-console-sample-programs

Conversation

Copy link
Contributor

Copilot AI commented Feb 12, 2026

Creates comprehensive console samples for GeneralUpdate.Drivelution and GeneralUpdate.Extension components, demonstrating cross-platform driver updates and plugin extension management respectively.

Drivelution Sample (src/Drivelution/DrivelutionSample/)

Targets .NET 10.0 to match component. Demonstrates:

  • Platform detection (Windows/Linux/macOS) and capability checks
  • Driver validation, update strategies (retry, backup, rollback)
  • Directory scanning for driver discovery
  • Hash verification and signature validation flows

Extension Sample (src/Extension/ExtensionSample/)

Targets .NET 9.0 for broader compatibility with Extension's netstandard2.0. Demonstrates:

  • Extension host lifecycle and configuration
  • Package creation, installation with atomic rollback
  • Catalog operations (load, query by platform/ID, version compatibility)
  • Auto-update configuration (per-extension and global)
  • Server communication API (query/download endpoints)

Implementation Notes

  • References NuGet packages GeneralUpdate.Drivelution and GeneralUpdate.Extension version 10.2.1
  • Bilingual comments (Chinese/English) matching repository convention
  • Updated .gitignore to exclude generated extensions/ directories
  • Standard .sln files created via SDK 9.0 for IDE compatibility

Both samples provide comprehensive API coverage with realistic error handling patterns and are directly compilable and runnable.

Original prompt

This section details on the original issue you should resolve

<issue_title>Task Requirements: Write Console Sample Programs for the Drivelution and Extension Components of GeneralUpdate</issue_title>
<issue_description>Task Requirements: Write Console Sample Programs for the Drivelution and Extension Components of GeneralUpdate
Component Sources
GeneralUpdate.Drivelution: https://github.com/GeneralLibrary/GeneralUpdate/tree/master/src/c%23/GeneralUpdate.Drivelution
GeneralUpdate.Extension: https://github.com/GeneralLibrary/GeneralUpdate/tree/master/src/c%23/GeneralUpdate.Extension
Location for Sample WritingThe sample code must be written in the directory at https://github.com/GeneralLibrary/GeneralUpdate-Samples/tree/main/src.
Style/Idea ReferenceStrictly refer to the code style, project structure, comment specifications, calling logic, and other aspects of the completed Samples under the path https://github.com/GeneralLibrary/GeneralUpdate-Samples/tree/main/src.
Program Type and Function Coverage
Write independent Console App sample programs for the two components respectively;
The samples must fully cover the core functions of the corresponding components (need to reflect the main APIs, core scenarios, and key usage methods of the components);
The sample code must be directly compilable and runnable, including necessary comment explanations, input/output examples (if any), and dependency reference instructions.
Additional Requirements
The sample code must comply with C# coding standards, with a clear structure and no redundant code;
Ensure that the samples are compatible with the versions of the corresponding components, and the reference method is consistent with the existing Samples.</issue_description>

<agent_instructions>充分理解issue和代码上下文。</agent_instructions>

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 and others added 2 commits February 12, 2026 10:45
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
Copilot AI changed the title [WIP] Add console sample programs for Drivelution and Extension components Add console samples for Drivelution and Extension components Feb 12, 2026
Copilot AI requested a review from JusterZhu February 12, 2026 10:53
@JusterZhu
Copy link
Collaborator

@copilot You can reference the NuGet packages for Drivelution and Extension, as the corresponding version 10.2.1 is available on NuGet and provides the capabilities required in the sample.

Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 12, 2026

@copilot You can reference the NuGet packages for Drivelution and Extension, as the corresponding version 10.2.1 is available on NuGet and provides the capabilities required in the sample.

Updated both samples to reference the NuGet packages at version 10.2.1 instead of using project references. Both samples build and run successfully. (5c2bdb9)

Copilot AI requested a review from JusterZhu February 12, 2026 12:07
@JusterZhu JusterZhu marked this pull request as ready for review February 12, 2026 12:07
Copilot AI review requested due to automatic review settings February 12, 2026 12:07
@JusterZhu JusterZhu merged commit 5d5c051 into main Feb 12, 2026
1 check passed
@JusterZhu JusterZhu deleted the copilot/write-console-sample-programs branch February 12, 2026 12:08
Copy link

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

This PR adds comprehensive console sample programs for two GeneralUpdate components: GeneralUpdate.Drivelution (cross-platform driver update management) and GeneralUpdate.Extension (plugin extension management). The samples demonstrate comprehensive API coverage with bilingual (Chinese/English) comments matching repository conventions.

Changes:

  • Added DrivelutionSample demonstrating platform detection, driver validation, update strategies, backup/rollback operations
  • Added ExtensionSample demonstrating extension host lifecycle, package management, catalog operations, and auto-update configuration
  • Updated .gitignore to exclude generated extensions/ directories and .slnx files

Reviewed changes

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

Show a summary per file
File Description
src/Drivelution/DrivelutionSample/Program.cs Console sample demonstrating Drivelution driver update APIs with platform-specific examples
src/Drivelution/DrivelutionSample/DrivelutionSample.csproj Project file targeting .NET 10.0 with GeneralUpdate.Drivelution 10.2.1 dependency
src/Drivelution/DrivelutionSample/DrivelutionSample.sln Solution file for the Drivelution sample
src/Extension/ExtensionSample/Program.cs Console sample demonstrating Extension plugin management APIs with comprehensive feature coverage
src/Extension/ExtensionSample/ExtensionSample.csproj Project file targeting .NET 9.0 with GeneralUpdate.Extension 10.2.1 dependency
src/Extension/ExtensionSample/ExtensionSample.sln Solution file for the Extension sample
.gitignore Added patterns to exclude generated extensions directories and .slnx files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +43 to +44
var customUpdater = GeneralDrivelution.Create(options);
Console.WriteLine("✓ 自定义实例创建成功 / Custom instance created successfully");
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

The variable customUpdater is created to demonstrate custom configuration but is never used in the subsequent code. For better clarity in the sample, consider either using customUpdater in one of the later operations (such as in section 7 for backup/rollback) to demonstrate the custom configuration in action, or add a comment explaining that this is for demonstration purposes only.

Copilot uses AI. Check for mistakes.
Comment on lines +155 to +157
host.ExtensionCatalog.AddOrUpdateInstalledExtension(extensionMetadata);
Console.WriteLine("✓ 扩展已添加到目录 / Extension added to catalog");
Console.WriteLine(" (目录会自动保存 / Catalog is saved automatically)");
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

The extension metadata is added to the catalog unconditionally at line 155, even if the installation failed at line 126. This could lead to the catalog containing entries for extensions that aren't actually installed. The call to AddOrUpdateInstalledExtension should be moved inside the success block (after line 130) or wrapped in a conditional check for installSuccess.

Suggested change
host.ExtensionCatalog.AddOrUpdateInstalledExtension(extensionMetadata);
Console.WriteLine("✓ 扩展已添加到目录 / Extension added to catalog");
Console.WriteLine(" (目录会自动保存 / Catalog is saved automatically)");
if (installSuccess)
{
host.ExtensionCatalog.AddOrUpdateInstalledExtension(extensionMetadata);
Console.WriteLine("✓ 扩展已添加到目录 / Extension added to catalog");
Console.WriteLine(" (目录会自动保存 / Catalog is saved automatically)");
}
else
{
Console.WriteLine("✗ 扩展未安装,未更新扩展目录 / Extension not installed; catalog not updated");
}

Copilot uses AI. Check for mistakes.
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GeneralUpdate.Extension" Version="10.2.1" />
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

The code uses Newtonsoft.Json (line 5) for serialization in the CreateExtensionPackage method, but it's not explicitly listed as a package reference in the .csproj file. While it may be available as a transitive dependency through GeneralUpdate.Extension, it's a best practice to explicitly declare direct dependencies. Add a PackageReference for Newtonsoft.Json to make the dependency explicit and avoid potential issues if the transitive dependency is removed in future versions.

Suggested change
<PackageReference Include="GeneralUpdate.Extension" Version="10.2.1" />
<PackageReference Include="GeneralUpdate.Extension" Version="10.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +29
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5E892380-DB04-4680-8EB2-101A351EE9DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5E892380-DB04-4680-8EB2-101A351EE9DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E892380-DB04-4680-8EB2-101A351EE9DB}.Debug|x64.ActiveCfg = Debug|Any CPU
{5E892380-DB04-4680-8EB2-101A351EE9DB}.Debug|x64.Build.0 = Debug|Any CPU
{5E892380-DB04-4680-8EB2-101A351EE9DB}.Debug|x86.ActiveCfg = Debug|Any CPU
{5E892380-DB04-4680-8EB2-101A351EE9DB}.Debug|x86.Build.0 = Debug|Any CPU
{5E892380-DB04-4680-8EB2-101A351EE9DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5E892380-DB04-4680-8EB2-101A351EE9DB}.Release|Any CPU.Build.0 = Release|Any CPU
{5E892380-DB04-4680-8EB2-101A351EE9DB}.Release|x64.ActiveCfg = Release|Any CPU
{5E892380-DB04-4680-8EB2-101A351EE9DB}.Release|x64.Build.0 = Release|Any CPU
{5E892380-DB04-4680-8EB2-101A351EE9DB}.Release|x86.ActiveCfg = Release|Any CPU
{5E892380-DB04-4680-8EB2-101A351EE9DB}.Release|x86.Build.0 = Release|Any CPU
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

The solution file includes Debug|x64, Debug|x86, Release|x64, and Release|x86 platform configurations which are not present in other sample solution files in the repository. Existing samples use only "Any CPU" configurations. For consistency with the rest of the codebase, these extra platform-specific configurations should be removed to match the simpler structure used in other samples.

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +29
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8015E777-C917-47A3-A335-56EBFB7063F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8015E777-C917-47A3-A335-56EBFB7063F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8015E777-C917-47A3-A335-56EBFB7063F1}.Debug|x64.ActiveCfg = Debug|Any CPU
{8015E777-C917-47A3-A335-56EBFB7063F1}.Debug|x64.Build.0 = Debug|Any CPU
{8015E777-C917-47A3-A335-56EBFB7063F1}.Debug|x86.ActiveCfg = Debug|Any CPU
{8015E777-C917-47A3-A335-56EBFB7063F1}.Debug|x86.Build.0 = Debug|Any CPU
{8015E777-C917-47A3-A335-56EBFB7063F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8015E777-C917-47A3-A335-56EBFB7063F1}.Release|Any CPU.Build.0 = Release|Any CPU
{8015E777-C917-47A3-A335-56EBFB7063F1}.Release|x64.ActiveCfg = Release|Any CPU
{8015E777-C917-47A3-A335-56EBFB7063F1}.Release|x64.Build.0 = Release|Any CPU
{8015E777-C917-47A3-A335-56EBFB7063F1}.Release|x86.ActiveCfg = Release|Any CPU
{8015E777-C917-47A3-A335-56EBFB7063F1}.Release|x86.Build.0 = Release|Any CPU
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

The solution file includes Debug|x64, Debug|x86, Release|x64, and Release|x86 platform configurations which are not present in other sample solution files in the repository. Existing samples use only "Any CPU" configurations. For consistency with the rest of the codebase, these extra platform-specific configurations should be removed to match the simpler structure used in other samples.

Copilot uses AI. Check for mistakes.
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.

Task Requirements: Write Console Sample Programs for the Drivelution and Extension Components of GeneralUpdate

2 participants