nested using() and code rule CA2202

41 views Asked by At

I've the following code that warns the Code Quality rule CA2202

public void Deserialize(byte[] bytes, Encoding encoding)
    {
        using (var ms = new MemoryStream(bytes))
        using (var reader = new BinaryReader(ms))
        {
            this.ClientRequestId = reader.ReadUInt32();
            this.PayloadSize = reader.ReadUInt32();
            this.Payload = reader.ReadString((int)this.PayloadSize).TrimEnd('\0');
        }
    }

Why this happens and how can I fix it? Thanks

0

There are 0 answers