BinaryReader.ReadBytes() and ReadChars() methods and static checking RRS feed

  • Question

  • I use a lot of these BinaryReader methods, and while the static checker is an invaluable tool, it would be really great if these methods implicitly ensured the returned arrays were of the length requested.

    Right now code like this throws up a lot of warnings:

    using (BinaryReader reader = new BinaryReader(stream)) DoStuff(reader.ReadChars(4)); void DoStuff(char[] fourCC) { Contract.Requires(fourCC.Length == 4); }

    Saturday, July 5, 2014 3:07 PM


All replies