Skip to content

Abstract core logic from MainViewModel into CoreLib; add Console sub-project - #5

Merged
jindongjie merged 5 commits into
masterfrom
copilot/abstract-core-logic-to-corelib
Mar 23, 2026
Merged

jindongjie merged 5 commits into
masterfrom
copilot/abstract-core-logic-to-corelib

Conversation

Copilot AI commented Mar 23, 2026 •

Copy link
Copy Markdown
Contributor

All business logic (file scanning, DOCX/TXT export, line counting) was embedded directly in MainViewModel.cs, making it unusable outside the Avalonia GUI.

New: SoftwareCopyrightSourceCodeCollector.CoreLib

Platform-agnostic class library. No UI framework dependencies.

  • FileItem — POCO for scanned source files
  • SoftwareInfo — POCO for all software metadata; ComboBox-driven fields are plain string
  • Core (static) — extracted business logic:
    • GetCodeCount(file) — binary detection + line count
    • ScanFilesAsync(folder, extensions, excludePatterns?) — parallel recursive scan with optional glob-based path exclusion via Microsoft.Extensions.FileSystemGlobbing → List<FileItem>
    • ExportToDocxAsync(stream, info, files, maxPage) — full DOCX generation with page trimming; throws ArgumentException on bad input, returns per-file warning list
    • BuildTxtLines(info) — assembles copyright registration TXT lines
    • ExportToTxtAsync(outputPath, info) — writes TXT to disk

New: SoftwareCopyrightSourceCodeCollector.Console

Interactive CLI referencing CoreLib only. Two workflows:

  1. Scan folder → export DOCX — prompts for folder, extensions, exclude patterns (glob), software metadata, output path
  2. Enter copyright info → export TXT — prompts for all registration fields including software-type flags

Updated: MainViewModel.cs

Delegates to Core; removes GetCodeCount, GetDocxPageCount, RemoveMiddlePages, IsExcluded, and the inline TXT-building block. ComboBoxItem fields are projected to string when constructing SoftwareInfo before passing to Core. The ExcludeFiles observable property is passed to Core.ScanFilesAsync as glob exclude patterns.

Merged from master

  • Exclude file by path feature — ExcludeFiles UI field in MainView.axaml and supporting IsExcluded logic (now in Core) using Microsoft.Extensions.FileSystemGlobbing
  • Updated package versions — Avalonia 11.3.12, CommunityToolkit.Mvvm 8.4.1, DocumentFormat.OpenXml 3.5.1, MessageBox.Avalonia 3.3.1.1, Semi.Avalonia 11.3.7.3
  • CoreLib/ stub project — empty CoreLib/core.cs skeleton added alongside the full SoftwareCopyrightSourceCodeCollector.CoreLib implementation
Original prompt

can you abstract core logic from MainViewModel.cs,to coreLib Core class,and implement the Console sub project in it Program.cs?


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Abstract core logic from MainViewModel to Core class Abstract core logic from MainViewModel into CoreLib; add Console sub-project Mar 23, 2026
Copilot AI requested a review from jindongjie March 23, 2026 06:41

@jindongjie jindongjie left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

please contain last commit edit in this pr

Copilot AI commented Mar 23, 2026 •

Copy link
Copy Markdown
Contributor Author

please contain last commit edit in this pr

Done in eda025b. Merged master into this PR, which brought in:

  • The "exclude file by path" feature (Microsoft.Extensions.FileSystemGlobbing) — the IsExcluded logic now lives in Core.ScanFilesAsync and the ExcludeFiles property is wired up in MainViewModel
  • Updated package versions (Avalonia 11.3.12, CommunityToolkit.Mvvm 8.4.1, DocumentFormat.OpenXml 3.5.1, etc.)
  • Your CoreLib/ stub project and MainView.axaml UI changes

The Console CLI also gained an exclude-patterns prompt matching the new GUI field.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • av-build-tel-api-v1.avaloniaui.net
    • Triggering command: /usr/share/dotnet/dotnet dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/avalonia.buildservices/11.3.2/tools/netstandard2.0/runtimeconfig.json /home/REDACTED/.nuget/packages/avalonia.buildservices/11.3.2/tools/netstandard2.0/Avalonia.BuildServices.Collector.dll (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from jindongjie March 23, 2026 07:00
@jindongjie jindongjie closed this Mar 23, 2026
@jindongjie jindongjie reopened this Mar 23, 2026
@sonarqubecloud

Copy link
Copy Markdown

@jindongjie
jindongjie marked this pull request as ready for review March 23, 2026 11:31
@jindongjie
jindongjie merged commit 9e421e6 into master Mar 23, 2026
9 checks passed
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.

2 participants