[Compatibility issue] VB compiler generates tons of BC36954 errors when I upgrade .NET 6 projects to .NET 7
See original GitHub issueVersion Used: 4.4.0-3.22518.13+7856a68c109b22de70e07580018fec601e944f46
Steps to Reproduce:
The following code reports BC36954 error when I upgrade a .NET 6 project to .NET 7.
Dim s = "123".AsSpan()
Out commercial .NET 6 VB projects have a lot of “Ref Struct” consuming code like this, because many 3rd-party dependencies require it.
The migration to other languages is unacceptable. If we can’t migrate our .NET 6 projects to newer .NET versions smoothly, we have no choice but stop upgrading to newer .NET versions and begin porting these incompatible products to non-.NET platforms.
Diagnostic Id:
BC36954
Expected Behavior: No compilation errors.
Actual Behavior:
error BC36954: Overload resolution failed because no accessible 'AsSpan' can be called:
Extension method 'Public Function AsSpan() As ReadOnlySpan(Of Char)' defined in 'MemoryExtensions': 'ReadOnlySpan(Of T)' requires compiler feature 'RefStructs', which is not supported by this version of the Visual Basic compiler.
Extension method 'Public Function AsSpan(start As Integer) As ReadOnlySpan(Of Char)' defined in 'MemoryExtensions': 'ReadOnlySpan(Of T)' requires compiler feature 'RefStructs', which is not supported by this version of the Visual Basic compiler.
Extension method 'Public Function AsSpan(start As Integer, length As Integer) As ReadOnlySpan(Of Char)' defined in 'MemoryExtensions': 'ReadOnlySpan(Of T)' requires compiler feature 'RefStructs', which is not supported by this version of the Visual Basic compiler.
Issue Analytics
- State:
- Created 10 months ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Breaking changes in .NET 7
This article indicates whether each breaking change is binary compatible or source compatible: Binary compatible - Existing binaries will load ...
Read more >Errors after upgrading app from framework 6 to 7. #11217
NET Runtime from net6.0 to net 7.0 in the project file I get four times this error: NU1105 Unable to read project information...
Read more >Migrate from ASP.NET Core 6.0 to 7.0
This article explains how to update an existing ASP.NET Core 6.0 project to ASP.NET Core 7.0. Prerequisites. Visual Studio; Visual Studio Code ...
Read more >How to configure a Visual Studio 2022 solution to compile ...
I just would like to have a single .NET 7 solution on which I can compile the same code to generate dlls for...
Read more >.NET core vs .NET framework
Wondering about the difference between .NET Core & .NET Framework? Here's a quick guide on how to pick the right runtime environment for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Nukepayload2 From discussion with the team, this API pattern (passing ref structs through) was meant to be supported. I’ll get started to fix this regression. Sorry about that.
@Nukepayload2 These Span APIs should have been inaccessible from VB in .NET 6 already. A mechanism was in place (attribute
[Obsolete("Types with embedded references are not supported in this version of your compiler.")]
emitted on ref structs) to prevent compilers without ref sruct support from using types they didn’t understand/support.This mechanism was imperfect as the following example shows (compiled against .NET 6 TFM):
In .NET 7, this mechanism was strengthened, resulting in the message you’re seing: “… requires compiler feature ‘RefStructs’, which is not supported by this version of the Visual Basic compiler.”.
Tagging @333fred @jaredpar @AlekseyTs in case anything to add or if they can think of a possible mitigation.