Fix bugs, remove dead code, upgrade to net8.0, add unit tests#1
Draft
Copilot wants to merge 3 commits into
Draft
Fix bugs, remove dead code, upgrade to net8.0, add unit tests#1Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Co-authored-by: pieandcakes <17558378+pieandcakes@users.noreply.github.com>
Co-authored-by: pieandcakes <17558378+pieandcakes@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix bugs in assembly crawling code
Fix bugs, remove dead code, upgrade to net8.0, add unit tests
Feb 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Multiple bugs and code quality issues identified in code review across
Program.cs,Crawler.cs,Assembly.cs, andAssemblyExtension.cs. Also upgrades the project from EOL net6.0 to net8.0 and adds a unit test suite.Bugs
pathparam inInnerLoop()to auto-parse on startup; fixed"itemsfound"typo; removed dead"s"menu case and its no-opCreateSymLinkForAssembly()body; changedFileMode.OpenOrCreate→FileMode.Createto prevent stale file contentOrdinalIgnoreCasecomparer —new Dictionary<...>(sortedAssemblies_all, StringComparer.OrdinalIgnoreCase); addedbreakafterRemove(key)in inner loop to preventKeyNotFoundExceptionon continued iterationCode Quality
readonlytoFileSize,PublicKeyToken,FrameworkVersion,IsManaged; removed unusedusing System.Security.Cryptography; removed dead/* NOTES */C/C++ block; addedDebug.WriteLineto swallowed catch inGetAssemblyName(); removed deadIsReadyToRun()(alwaysfalse) and unreachableGetPublicKey()using System.Text/using System.Threading.Tasks; use.Countproperty on materializedList<T>instead of.Count()LINQ; removed all dead commented-outCreateSymlinks, constants, and helper methodsTargetFrameworkfromnet6.0→net8.0; bumpedSystem.Reflection.Metadatato8.0.0Unit Tests
Added
src/AssemblyCrawler.Tests(xUnit, net8.0) covering:StringExtension.GetStableHashCode()— stability and collision avoidanceAssemblyInfo— managed vs. non-managed construction,GetHashCode()consistencyAssemblyExtension—IsManagedAssembly(),SortByHashCode()groupingCrawler—Crawl()populates counts, double-crawl guard,Sort()before crawl,.resources.dllexclusionOriginal prompt
Code Review Fixes
Address the following issues found during code review of the assembly crawling code in
pieandcakes/AssemblyCrawler. The source code lives undersrc/AssemblyCrawler/.🔴 Bugs to Fix
Program.csline 16 — Inverted argument check:if (args.Length > 0)rejects all arguments. The program takes no arguments and uses an interactive loop, so the check is backwards — it should reject when arguments are passed unexpectedly. Actually, since the program is fully interactive (no args needed), the error message "Argument count not correct" is misleading. Fix: if the intent is to accept zero arguments, keep the> 0check but fix the error message to say something like"This program does not accept command-line arguments.". Alternatively, if a path argument should be supported, wire it up toInnerLoop.Program.csline 26 —pathparameter inInnerLoopis unused:InnerLoop(string? path = null)accepts a path but never uses it. Either remove the parameter or wire it up so that if a path is provided, it auto-parses that directory.Program.csline 253 — Missing space in output:$"{keyItemCount} itemsfound..."should be$"{keyItemCount} items found...".Program.csline 133 — Hidden menu option "s": The"s"case forCreateSymLinkForAssembly()is handled in the switch but is not listed in the printed menu options. SinceCreateSymLinkForAssembly()is entirely commented out (no-op), remove the dead"s"case from the switch.Crawler.csline 125 — Shallow copy of dictionary loses case-insensitive comparer:sortedAssemblies_managed = new Dictionary<...>(sortedAssemblies_all)creates a new dictionary using the default comparer instead ofStringComparer.OrdinalIgnoreCase. Fix: pass the comparer explicitly, e.g.new Dictionary<string, Dictionary<string, List<AssemblyInfo>>>(sortedAssemblies_all, StringComparer.OrdinalIgnoreCase).Crawler.cslines 130-136 — PotentialInvalidOperationException/KeyNotFoundException: When iteratingsortedAssemblies_managedinner keys, if the first entry'sIsManagedis false, the outer key is removed mid-iteration. But the innerforeachloop continues to accesssortedAssemblies_managed[key]which was just removed. Fix: add abreakaftersortedAssemblies_managed.Remove(key)to exit the inner loop after removing the outer key.🟡 Code Quality / Maintainability Fixes
Assembly.cslines 47-51 — Inconsistentreadonlyon Lazy fields:FName,AName,AssemblyVersion,FileVersionarereadonly, butFileSize,PublicKeyToken,FrameworkVersion,IsManagedare not, even though none are reassigned after construction. AddreadonlytoFileSize,PublicKeyToken,FrameworkVersion, andIsManaged.Assembly.csline 9 — Unusedusing: Removeusing System.Security.Cryptography;.Assembly.cslines 12-37 — Large dead block comment: Remove the/* NOTES ... */block of C/C++ pseudocode.Assembly.csline 95 — Emptycatchblock silently swallows exceptions: InGetAssemblyName(), add at minimum aDebug.WriteLineor similar so failures are not silently lost.Assembly.csline 186 —GetPublicKey()is never called: Remove the unusedGetPublicKey()method.Assembly.cslines 166-183 —IsReadyToRun()always returnsfalse: The body is entirely commented out. Remove this dead method.Crawler.cslines 61-62 — Unnecessary LINQ.Count()on materialized list:filesis already aList<T>, so use.Countproperty instead of.Count()LINQ extension. ForassemblyFiles, enumerate it once into a list first, then use.Count.Crawler.cslines 142-246 — Large blocks of commented-out code: Remove deadCreateSymlinksmethod, unusedAssemblyCacheFolderNameandPreCacheFileNameconstants, and unusedCreateDirectoryIfNotExistsandMakeSymLinkmethods (they are only used by the commented-out code).Program.csline 181 —FileMode.OpenOrCreatemay leave stale data: Change toFileMode.Createso old content is truncated.AssemblyExtension.cslines 7-8 — Unusedusingstatements: Removeusing System.Text;andusing System.Threading.Tasks;.Crawler.cslines 7-8 — Unusedusingstatements: Removeusing System.Text;andusing System.Threading.Tasks;.AssemblyCrawler.csproj— Targets outdatednet6.0: .NET 6 is end-of-life. UpdateTargetFrameworktonet8.0and updateSystem.Reflection.Metadatapackage to the latest stable version compatible with net8.0.🧪 Unit Tests
Add a new test project (e.g.
src/AssemblyCrawler.Tests/AssemblyCrawler.Tests.csproj) using xUnit or MSTest. Add it to the solution filesrc/AssemblyCrawler.sln. Write tests covering the following:Crawlerclass:Crawl()on a valid directory populatesAssemblyList,TotalFileCount, andTotalAssemblyCount.This pull request was created from Copilot chat.
💡 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.