Fix compilation errors in C# 14 #142
Open
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.
After updating Visual Studio to version 17.13.5, C# 14.0 became available. However, this introduced a compilation issue in the project. As noted in dotnet/runtime#107723, C# 14.0 introduces first-class support for spans. As a result, when calling
Reverseon a byte[], the compiler now resolves it to the span-based methodvoid MemoryExtensions.Reverse<T>(this Span<T>)rather than the LINQ version,IEnumerable<T> Enumerable.Reverse<T>(this IEnumerable<T>). This change causes the project to fail to compile in the latest versions of Visual Studio, including 17.13.5 and 17.13.6.This PR resolves the issue by first calling
AsEnumerableto convert the array to anIEnumerable, ensuring that the correct version ofReverseis used. This should fix #140 .Alternatively, for this project, another fix would be to lower the C# language version by modifying
<LangVersion>preview</LangVersion>in WpfHexEditorCore.csproj to a version below C# 14.0.