Closed
[WIP] Integrate C++ DataStream concept into C# codebase#5
Conversation
Copilot stopped work on behalf of
iMrShadow due to an error
April 21, 2026 10:38
iMrShadow
removed their request for review
April 28, 2026 10:23
Repository owner
locked and limited conversation to collaborators
Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DataStreambase +DataStreamMemory,DataStreamFile,DataStreamSubStream)MetaStreamand section storage to useDataStreamwhile preserving existing public API usageMetaStreamReader/MetaStreamWriterinternals to operate onDataStreaminstead of directBinaryReader/BinaryWriterOriginal prompt
Overview
Integrate the C++ DataStream concept into the C# codebase to provide a flexible, polymorphic stream abstraction layer. This refactoring will decouple MetaStream from direct System.IO.Stream usage and enable support for multiple stream types (file, memory, compressed, encrypted, sub-streams).
Current State
MetaStream(abstract base class) directly usesSystem.IO.StreaminUnderlyingStreamandSections[].StreamMetaStreamReaderandMetaStreamWriterhardcoded to work with .NET'sBinaryReader/BinaryWriterDesired Architecture
Create a DataStream abstraction layer inspired by the C++ reference provided:
1. Create DataStream Interface/Base Class
Create
src/TelltaleToolKit/Serialization/DataStream/DataStream.cs:System.IO.StreamSerialize(byte[] buffer, int offset, int count, bool write)- unified read/writeGetSize()- get total stream sizeGetPosition()- get current offsetSetPosition(long offset, SeekOrigin)- set positionTruncate(long newSize)- truncate streamGetSubStream(long offset, long size)- create read-only sub-stream viewCopy(DataStream dst, long dstOffset, long srcOffset, long size)- copy between streams2. Create Concrete DataStream Implementations
DataStreamFile (
src/TelltaleToolKit/Serialization/DataStream/DataStreamFile.cs)System.IO.FileStreamDataStreamMemory (
src/TelltaleToolKit/Serialization/DataStream/DataStreamMemory.cs)System.IO.MemoryStreamDataStreamSubStream (
src/TelltaleToolKit/Serialization/DataStream/DataStreamSubStream.cs)DataStreamContainer (
src/TelltaleToolKit/Serialization/DataStream/DataStreamContainer.cs)3. Refactor MetaStream to Use DataStream
Stream UnderlyingStreamwithDataStream UnderlyingStreamSections[].Stream(currentlySystem.IO.Stream) withDataStreamMetaStreamReaderandMetaStreamWriterto work withDataStreaminstead ofBinaryReader/BinaryWriter4. Benefits
Implementation Notes
MetaStream,MetaStreamReader, orMetaStreamWriterPriority
Start with the base
DataStreamclass andDataStreamMemoryimplementation. These are the most critical for supporting the core functionality.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: ```// This file was written by Lucas Saragosa. Im the author of this interpretation of
// the engine and require that if you use this code or library, you give credit to me and
// the amazing Telltale Games.
#pragma once
#include "../LibraryConfig.h"
#include "../Compression.h"
#include
#include
#include
#include
#ifndef _DATASTREAM
#define _DATASTREAM
#define DEFAULT_GROWTH_FACTOR 0x1000
#define READ DataStreamMode::eMode_Read
#define WRITE DataStreamMode::eMode_Write
//Returns a new instance as an object directly
#define OpenDataStreamFromDisc(file_path, mode) DataStreamFileDisc(
PlatformSpecOpenFile(file_path,
mode),
mode)
//Returns a new instance as a pointer which needs to be deleted. Most classes
//will delete it when done with it (consumers)
#define _OpenDataStreamFromDisc(file_path, mode)
new OpenDataStreamFromDisc(file_path, mode)
//With line terminator
#define OpenDataStreamFromDisc(file_path, mode)
_OpenDataStreamFromDisc(file_path, mode);
enum class DataStreamSeekType : unsigned char {
eSeekType_Begin = 0,
eSeekType_Current = 1,
eSeekType_End = 2
};
class DataStreamSubStream;
/*
A data stream. Abstract class which represents a stream of data (bytes) being read or written.
Class is not copyable but is moveable.
*/
class DataStream {
public:
DataStreamMode mMode;
int mSubStreams;
virtual bool Copy(DataStream* pDst, unsigned __i...
This pull request was created from Copilot chat.