-
Notifications
You must be signed in to change notification settings - Fork 10
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
Implemented method Slice in DataStream #150
Conversation
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.
Start to look good but we should do the substream instead of copies.
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.
Code looks perfect. Just one more adjustment to the test to ensure the behavior is what we expect in the design.
|
||
DataStream testSlice = stream.Slice(2); | ||
Assert.That( | ||
() => testSlice, |
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.
This is impossible to throw excepcion right? Do you want to check if the constructor throw or if the variable is null?
stream.WriteByte(0xCA); | ||
stream.WriteByte(0xFE); | ||
|
||
DataStream testSlice = stream.Slice(2); |
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.
Can you add just one more test for the base stream. Something like Assert.AreSame with testSlice.BaseStream and stream.BaseStream? so we know there isn't copies
This PR has been in WIP for 3 years. |
Description
Added a
Slice
method based on theSpan<T>
seen in C# 8.0 using the new methodWriteSegmentTo()
as a base.Using the method
Slice
will create a new DataStream based on a starting offset parameter or a starting offset parameter + length.Example
Closes #143