-
-
Notifications
You must be signed in to change notification settings - Fork 33
Adding SpanByte to System #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi @Ellerbach, I'm nanoFramework bot. A human will be reviewing it shortly. 😉 |
@Ellerbach on your attempt to set the language version. According to the documentation as we are "kind of inline" with .NET Framework we should be supporting 7.3. I've added that to the nfproj file and the build went fine: So feel free to add that one above. |
@Ellerbach @krwq on a more high level look at this I was reading the documentation for the Span class and the remarks here got me thinking... I'm starting a conversation about this on Discord. |
The stackalloc part is removed, the pointer part as well, we are in a fully managed environment. In short, to "migrate" code from .NET Core to nanoFramework, a global replace of Span to SpanByte and from stackalloc to new will make the trick |
No doubts about that! My comments were more towards the overall implementation of this (. NET IoT included) and to point out these nuances that exist on smaller MCUs. |
@Ellerbach FYI I've just added |
All works for me :-) |
Build is now OK with the update targets. |
/// </exception> | ||
public void CopyTo(SpanByte destination) | ||
{ | ||
if (destination.Length < _length - _start) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be just < _length
Description
Adding SpanByte to System which is a simplified version of Span for byte. This will be used to replace byte[] in I2C, SPI and other low level operation manipulating byte buffers.
Motivation and Context
Today low level operation to transmit data to an I2C or SPI device is using raw byte buffer. This sometimes involve allocating and copying buffers. This concept of Span originally introduced with .NET Core is in short, a T[], int start and int end class. As nano Framework doesn't support generics, this is a simple implementation of Span named SpanByte.
This will be widely available and will allow to migrate native byte[] transfers to SpanByte.
How Has This Been Tested?
This has been tested with various sensors ported to nanoFramework from .NET IoT
Types of changes
Checklist: