Add console samples for Drivelution and Extension components#32
Add console samples for Drivelution and Extension components#32
Conversation
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
|
@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>
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) |
There was a problem hiding this comment.
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.
| var customUpdater = GeneralDrivelution.Create(options); | ||
| Console.WriteLine("✓ 自定义实例创建成功 / Custom instance created successfully"); |
There was a problem hiding this comment.
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.
| host.ExtensionCatalog.AddOrUpdateInstalledExtension(extensionMetadata); | ||
| Console.WriteLine("✓ 扩展已添加到目录 / Extension added to catalog"); | ||
| Console.WriteLine(" (目录会自动保存 / Catalog is saved automatically)"); |
There was a problem hiding this comment.
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.
| 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"); | |
| } |
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="GeneralUpdate.Extension" Version="10.2.1" /> |
There was a problem hiding this comment.
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.
| <PackageReference Include="GeneralUpdate.Extension" Version="10.2.1" /> | |
| <PackageReference Include="GeneralUpdate.Extension" Version="10.2.1" /> | |
| <PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> |
| 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 |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
Creates comprehensive console samples for
GeneralUpdate.DrivelutionandGeneralUpdate.Extensioncomponents, demonstrating cross-platform driver updates and plugin extension management respectively.Drivelution Sample (
src/Drivelution/DrivelutionSample/)Targets .NET 10.0 to match component. Demonstrates:
Extension Sample (
src/Extension/ExtensionSample/)Targets .NET 9.0 for broader compatibility with Extension's netstandard2.0. Demonstrates:
Implementation Notes
GeneralUpdate.DrivelutionandGeneralUpdate.Extensionversion 10.2.1.gitignoreto exclude generatedextensions/directories.slnfiles created via SDK 9.0 for IDE compatibilityBoth samples provide comprehensive API coverage with realistic error handling patterns and are directly compilable and runnable.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.