{"record":{"id":"c1e4f1e012df0927","repo":"stride3d/stride","slug":"operation-write-is-not-supported","errorCode":null,"errorMessage":"Operation 'Write' is not supported","messagePattern":"Operation 'Write' is not supported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Serialization/Serialization/LZ4/LZ4Stream.cs","lineNumber":466,"sourceCode":"        }\n        else\n        {\n            throw NotSupported(\"Seek\");\n        }\n\n        return Position;\n    }\n\n    /// <inheritdoc/>\n    public override void SetLength(long value)\n    {\n        throw NotSupported(\"SetLength\");\n    }\n\n    /// <inheritdoc/>\n    public override void WriteByte(byte value)\n    {\n        if (!CanWrite) throw NotSupported(\"Write\");\n\n        position++;\n\n        if (dataBuffer == null)\n        {\n            dataBuffer = new byte[blockSize];\n            bufferLength = blockSize;\n            bufferOffset = 0;\n        }\n\n        if (bufferOffset >= bufferLength)\n        {\n            FlushCurrentChunk();\n        }\n\n        dataBuffer[bufferOffset++] = value;\n    }\n","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Serialization/Serialization/LZ4/LZ4Stream.cs#L448-L484","documentation":"LZ4Stream.WriteByte checks CanWrite before appending the byte to the current compression block and throws NotSupportedException ('Write') when the stream was not opened for writing. Writing to a read/decompress-mode LZ4 stream is invalid by design.","triggerScenarios":"Calling WriteByte on an LZ4Stream created in read/decompress mode, or after Dispose.","commonSituations":"Passing a decompression stream to code that writes output (e.g. a serializer given the wrong end of a compress/decompress pair).","solutions":["Open the LZ4Stream in write/compress mode before writing","Check CanWrite before writes and route to the correct stream","Verify compress/decompress directions weren't swapped when constructing the pair"],"exampleFix":"// before\nvar s = new LZ4Stream(fs, CompressionMode.Decompress); s.WriteByte(b);\n// after\nvar s = new LZ4Stream(fs, CompressionMode.Compress); if (s.CanWrite) s.WriteByte(b);","handlingStrategy":"type-guard","validationCode":"if (!lz4Stream.CanWrite) throw new InvalidOperationException(\"LZ4Stream was not opened for writing; use Compress/write mode\");","typeGuard":"static bool IsWritable(Stream s) => s is { CanWrite: true };","tryCatchPattern":"try { lz4Stream.WriteByte(value); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"'Write' is not supported\")) { throw new InvalidOperationException(\"Stream is read-mode; open LZ4Stream in compress/write mode.\", ex); }","preventionTips":["Open compress-mode LZ4Stream for write paths","Check CanWrite before write calls","Verify compress/decompress arguments weren't swapped"],"tags":["csharp","stream","lz4","io"],"backgroundTag":"operation-not-supported","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}