tuyoogame / huatuo

huatuo是一个特性完整、零成本、高性能、低内存的近乎完美的Unity全平台原生c#热更方案。 Huatuo is a fully featured, zero-cost, high-performance, low-memory solution for Unity's all-platform native c# hotfix
MIT License
2.31k stars 377 forks source link

使用Stream的Write方法有问题 #18

Closed wumiao1990 closed 2 years ago

wumiao1990 commented 2 years ago

public class CircularBufferTest : Stream {

    public override bool CanRead { get; }
    public override bool CanSeek { get; }
    public override bool CanWrite { get; }
    public override long Length { get; }
    public override long Position { get; set; }

    public override void Flush()
    {
        throw new NotImplementedException();
    }

    public override int Read(byte[] buffer, int offset, int count)
    {
        throw new NotImplementedException();
    }

    public override long Seek(long offset, SeekOrigin origin)
    {
        throw new NotImplementedException();
    }

    public override void SetLength(long value)
    {
        throw new NotImplementedException();
    }
    public override void Write(byte[] buffer, int offset, int count)
    {

    }

    public void Write(int l)
    {
        byte[] s_Cached = new byte[4];
        s_Cached[0] = (byte)(l >> 0);
        s_Cached[1] = (byte)(l >> 8);
        s_Cached[2] = (byte)(l >> 16);
        s_Cached[3] = (byte)(l >> 24);
        Write(s_Cached, 0, 4);
    }
}

public static void CircularBufferTest()
{
    var capacity = 1024 * 512;
    CircularBufferTest m_SendBuffer = new CircularBufferTest();
    var msgLen = 1;
    m_SendBuffer.Write(msgLen);
}

属性字段在最上面定义时,调用write方法时会卡死 但是将上面定义的属性字段放到Plush()方法下面时,会报NotImplementedException:The method or operation is not implemented

pirunxi commented 2 years ago

确认bug。已修复。