Skip to content

[Dev] Projects use LangVersion=latest but are not C# 14.0 compliant #217

@gman-comicdb

Description

@gman-comicdb

Describe the bug

Compiler throws errors and fails to build assemblies when trying to build ComicRackCE.
Related to C# 14.0 Enumerable.Reverse breaking change.

Exact Steps to Reproduce

VS 2022

  1. Have the latest VS 2022 installed (17.14.20)
    • MSBuild version: 17.14.23.0
  2. Clone and try to build any branch

VS 2026

  1. Have the latest VS 2026 installed (11206.111)
    • MSBuild version: 18.1.0.0
  2. Clone and try to build any branch

Screenshots

Image

cYo.Common.Windows and ComicRack project errors get raised once these are fixed. See end for relevant lines of code.

As text
Severity	Code	Description	Project	File	Line	Suppression State
Error (active)	CS1579	foreach statement cannot operate on variables of type 'void' because 'void' does not contain a public instance or extension definition for 'GetEnumerator'	cYo.Common	cYo.Common\Mathematics\Numeric.cs	261	
Error (active)	CS1936	Could not find an implementation of the query pattern for source type 'void'.  'Select' not found.	cYo.Common.Presentation	cYo.Common.Presentation\Panels\OverlayManager.cs	227	
Error (active)	CS1579	foreach statement cannot operate on variables of type 'void' because 'void' does not contain a public instance or extension definition for 'GetEnumerator'	cYo.Common.Presentation	cYo.Common.Presentation\Panels\OverlayPanel.cs	690	

Version

VS 2022 17.14.20 + MSBuild 17.14.23.0
VS 2026 11206.111 + MSBuild 18.1.0.0

Additional context

Enumerable.Reverse

When using C# 14 or newer and targeting a .NET older than net10.0 or .NET Framework with System.Memory reference, there is a breaking change with Enumerable.Reverse and arrays.

  • C# 14.0 has been out for a while; this only became a problem on upgrading to the latest VS 2022.

  • Bug might only impact those using VS 2022/2026 and with the .NET 10 SDK installed

Relevant lines of code

string[] array = message.Split('\n').Reverse().Take(messageLines)

foreach (ComicBook item in source.Reverse())

foreach (ComicBook item in source.Reverse())

foreach (bool item in flags.Reverse())

foreach (ToolStripMenuItem item in array2.Reverse())

return (from op in panels.ToArray().Reverse()

foreach (OverlayPanel item in panels.ToArray().Reverse())

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions