You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
7 bugs found while reviewing the code (main @ cba5398)
#2250
While running a large static-analysis and test-writing experiment on main at commit 0de1831 (5 Oct 2026), we came across the bugs below. Each one was checked by hand, and the files involved are still unchanged on today's main, so the links and line numbers below point to commit cba5398. I'm posting them together here because they are code-level findings rather than user reports; happy to open separate issues or PRs for any you want to track.
Behavior a user can hit
The progress refresh thread can outlive the progress display.ProgressRefreshThread.cs#L25-L28: when the action given to Progress.Start/StartAsync completes before the new thread has run _running.Set() (line 39), Dispose sees _running unset and returns without setting _stopped or joining. The thread then starts and calls _context.Refresh() every refresh period for the rest of the process, after the renderer was completed, and the two ManualResetEvents are never disposed. I haven't checked whether this is behind NullReferenceException in Progress #1334, whose stack trace shows the refresh thread calling Refresh().
F# type names are never shortened in exception output.TypeNameHelper.cs#L79 and #L154 compare type.Assembly.GetName().Name with "FSharp.Core.dll", but an assembly name has no extension ("FSharp.Core"), so the FSharpTypeNames table (Option, Async, void) is never used.
JsonText accepts numbers with leading zeros.JsonTokenizer.cs#L150-L161 calls IsDigit(min: 1), and CharExtensions.cs#L22 compares with (char)min, i.e. '\u0001', not '1'. So '0' passes, 0123 is read as one number token, and the current == '0' branch on line 154 is dead.
AnsiConsole.ExportCustom reports the wrong export.AnsiConsole.Recording.cs#L56 throws "Cannot export HTML since a recording hasn't been started." (copied from ExportHtml). Cosmetic.
Type conversion: the trimming-friendly path cannot be turned on, and has two bugs
The feature switch name ends with a space.TypeConverterHelper.cs#L8 reads "Spectre.Console.TypeConverterHelper.IsGetConverterSupported ". Setting the switch under its name (AppContext.SetSwitch or RuntimeHostConfigurationOption) is not seen, so IsGetConverterSupported is always true and GetIntrinsicConverter is never reached. Fixing this exposes items 6 and 7.
Enums fail on that path. In GetIntrinsicConverter, lines 160-167, type is replaced by typeof(Enum) before factory(type), so the enum factory builds new EnumConverter(typeof(Enum)). Checked on .NET 10: its ConvertFromInvariantString("Red") throws FormatException ("Red is not a valid value for Enum") and ConvertToInvariantString(ConsoleColor.Red) throws ArgumentException ("Type provided must be an Enum"). Passing the original type to the factory fixes it.
Arrays never get ArrayConverter. On lines 150-158, arrays implement ICollection, so the typeof(Array) set on line 152 is overwritten on line 157 and the ArrayConverter entry (line 128) is dead: int[] gets CollectionConverter, which converts it to "(Collection)" instead of "Int32[] Array" (what TypeDescriptor.GetConverter gives).
For context: I work on NDepend, and these came out of experiments where the tool had a coding agent fix static-analysis issues and write tests on Spectre.Console. The agent flagged candidates and I verified the ones above by hand (item 5 came up while checking item 6). The last run fixed 967 issues, wrote 1,507 new tests, and took the code coverage from 71% to 98.5%. Its full report is here, in case any of it is useful (the bugs are in the Potential bugs row of the AI Assistant tab): https://www.ndepend.com/Sample-Reports/OnSpectreConsole/NDependReport.html?theme=light#ai-assistant
None of the code changes from those runs are proposed here, only the bugs.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Hi, and thanks for Spectre.Console.
While running a large static-analysis and test-writing experiment on
mainat commit0de1831(5 Oct 2026), we came across the bugs below. Each one was checked by hand, and the files involved are still unchanged on today'smain, so the links and line numbers below point to commitcba5398. I'm posting them together here because they are code-level findings rather than user reports; happy to open separate issues or PRs for any you want to track.Behavior a user can hit
The progress refresh thread can outlive the progress display.
ProgressRefreshThread.cs#L25-L28: when the action given toProgress.Start/StartAsynccompletes before the new thread has run_running.Set()(line 39),Disposesees_runningunset and returns without setting_stoppedor joining. The thread then starts and calls_context.Refresh()every refresh period for the rest of the process, after the renderer was completed, and the twoManualResetEvents are never disposed. I haven't checked whether this is behind NullReferenceException in Progress #1334, whose stack trace shows the refresh thread callingRefresh().F# type names are never shortened in exception output.
TypeNameHelper.cs#L79and#L154comparetype.Assembly.GetName().Namewith"FSharp.Core.dll", but an assembly name has no extension ("FSharp.Core"), so theFSharpTypeNamestable (Option,Async,void) is never used.JsonTextaccepts numbers with leading zeros.JsonTokenizer.cs#L150-L161callsIsDigit(min: 1), andCharExtensions.cs#L22compares with(char)min, i.e.'\u0001', not'1'. So'0'passes,0123is read as one number token, and thecurrent == '0'branch on line 154 is dead.AnsiConsole.ExportCustomreports the wrong export.AnsiConsole.Recording.cs#L56throws "Cannot export HTML since a recording hasn't been started." (copied fromExportHtml). Cosmetic.Type conversion: the trimming-friendly path cannot be turned on, and has two bugs
The feature switch name ends with a space.
TypeConverterHelper.cs#L8reads"Spectre.Console.TypeConverterHelper.IsGetConverterSupported ". Setting the switch under its name (AppContext.SetSwitchorRuntimeHostConfigurationOption) is not seen, soIsGetConverterSupportedis alwaystrueandGetIntrinsicConverteris never reached. Fixing this exposes items 6 and 7.Enums fail on that path. In
GetIntrinsicConverter, lines 160-167,typeis replaced bytypeof(Enum)beforefactory(type), so the enum factory buildsnew EnumConverter(typeof(Enum)). Checked on .NET 10: itsConvertFromInvariantString("Red")throwsFormatException("Red is not a valid value for Enum") andConvertToInvariantString(ConsoleColor.Red)throwsArgumentException("Type provided must be an Enum"). Passing the original type to the factory fixes it.Arrays never get
ArrayConverter. On lines 150-158, arrays implementICollection, so thetypeof(Array)set on line 152 is overwritten on line 157 and theArrayConverterentry (line 128) is dead:int[]getsCollectionConverter, which converts it to"(Collection)"instead of"Int32[] Array"(whatTypeDescriptor.GetConvertergives).For context: I work on NDepend, and these came out of experiments where the tool had a coding agent fix static-analysis issues and write tests on Spectre.Console. The agent flagged candidates and I verified the ones above by hand (item 5 came up while checking item 6). The last run fixed 967 issues, wrote 1,507 new tests, and took the code coverage from 71% to 98.5%. Its full report is here, in case any of it is useful (the bugs are in the Potential bugs row of the AI Assistant tab): https://www.ndepend.com/Sample-Reports/OnSpectreConsole/NDependReport.html?theme=light#ai-assistant
None of the code changes from those runs are proposed here, only the bugs.
All reactions