You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: fastbufferreader does not honor arraysegment configuration (#3320)
This PR resolves the issue where `FastBufferReader` did not provide
constructors that would automatically use an `ArraySegment`'s
configuration (Count and Offset) to define the `FastBufferReader`.
[MTTB-34](https://jira.unity3d.com/browse/MTTB-34)
fix: #2885
up-port: #3321
## Changelog
- Added `FastBufferReader(ArraySegment<byte> buffer, Allocator
copyAllocator)` constructor that uses the `ArraySegment.Offset` as the
`FastBufferReader` offset and the `ArraySegment.Count` as the
`FastBufferReader` length.
- Added `FastBufferReader(ArraySegment<byte> buffer, Allocator
copyAllocator, int length = -1)` constructor that uses the
`ArraySegment.Offset` as the `FastBufferReader` offset.
## Testing and Documentation
- Includes unit test.
- Includes public API documentation.
<!-- Uncomment and mark items off with a * if this PR deprecates any
API:
### Deprecated API
- [ ] An `[Obsolete]` attribute was added along with a `(RemovedAfter
yyyy-mm-dd)` entry.
- [ ] An [api updater] was added.
- [ ] Deprecation of the API is explained in the CHANGELOG.
- [ ] The users can understand why this API was removed and what they
should use instead.
-->
Copy file name to clipboardexpand all lines: com.unity.netcode.gameobjects/CHANGELOG.md
+2
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@ Additional documentation and release notes are available at [Multiplayer Documen
9
9
## [Unreleased]
10
10
11
11
### Added
12
+
- Added `FastBufferReader(ArraySegment<byte> buffer, Allocator copyAllocator)` constructor that uses the `ArraySegment.Offset` as the `FastBufferReader` offset and the `ArraySegment.Count` as the `FastBufferReader` length. (#3320)
13
+
- Added `FastBufferReader(ArraySegment<byte> buffer, Allocator copyAllocator, int length = -1)` constructor that uses the `ArraySegment.Offset` as the `FastBufferReader` offset. (#3320)
/// Create a FastBufferReader from an ArraySegment that uses the ArraySegment.Offset for the reader's offset.
146
+
///
147
+
/// A new buffer will be created using the given allocator and the value will be copied in.
148
+
/// FastBufferReader will then own the data.
149
+
///
150
+
/// Allocator.None is not supported for byte[]. If you need this functionality, use a fixed() block
151
+
/// and ensure the FastBufferReader isn't used outside that block.
152
+
/// </summary>
153
+
/// <param name="buffer">The buffer to copy from</param>
154
+
/// <param name="copyAllocator">The allocator type used for internal data when copying an existing buffer if other than Allocator.None is specified, that memory will be owned by this FastBufferReader instance</param>
155
+
/// <param name="length">The number of bytes to copy (all if this is -1)</param>
/// Create a FastBufferReader from an ArraySegment that uses the ArraySegment.Offset for the reader's offset and the ArraySegment.Count for the reader's length.
171
+
///
172
+
/// A new buffer will be created using the given allocator and the value will be copied in.
173
+
/// FastBufferReader will then own the data.
174
+
///
175
+
/// Allocator.None is not supported for byte[]. If you need this functionality, use a fixed() block
176
+
/// and ensure the FastBufferReader isn't used outside that block.
177
+
/// </summary>
178
+
/// <param name="buffer">The buffer to copy from</param>
179
+
/// <param name="copyAllocator">The allocator type used for internal data when copying an existing buffer if other than Allocator.None is specified, that memory will be owned by this FastBufferReader instance</param>
0 commit comments