dotnet-repl icon indicating copy to clipboard operation
dotnet-repl copied to clipboard

[EXTERNAL] Creating variable of Span<> type results in CS8345 error

Open ptasz3k opened this issue 3 years ago • 2 comments

Steps to duplicate:

var bytes = new byte[10];
Span<byte> span = bytes;

result:

(1,1): error CS8345: Field or auto-implemented property cannot be of type 'Span<byte>' unless it is an instance member of a ref struct.

ptasz3k avatar Jun 23 '21 07:06 ptasz3k

This happens because what appears to be a local variable in C# scripting is implemented as a field.

jonsequitur avatar Jun 24 '21 19:06 jonsequitur

Here's the related issue in Roslyn: https://github.com/dotnet/roslyn/issues/40213

jonsequitur avatar Jun 25 '21 14:06 jonsequitur