markjprice / cs12dotnet8

Repository for the Packt Publishing book titled "C# 12 and .NET 8 - Modern Cross-Platform Development Fundamentals" by Mark J. Price
620 stars 188 forks source link

Missing "{}" in code for compressing streams files? #4

Closed DrAvriLev closed 10 months ago

DrAvriLev commented 11 months ago

Hello ,Mark. In the code refering to the "decompressor" section, you ommit the {} after using (decompressor) and after using (XmlReader reader = ...) Is that a delibarate action? I'm raising this issue because in the "compress" section above you did used those {} around the using statements... I think a clarification would be in order here. I undersatand the code, but missed the meaning for those missing {}... in the decompress section of this code.

 using (decompressor)
    // no curly braces? Why?
    using (XmlReader reader = XmlReader.Create(decompressor))

vs

using (compressor)
    {
      using (XmlWriter xml = XmlWriter.Create(compressor))
      {

By the way, when I added the curly braces on the using(decompressor), the output of the Reader missed the first entry... removing the {}, all came back to "normal".

markjprice commented 11 months ago

Thank you for bringing this issue to my attention. I have added an improvement item for the next edition: https://github.com/markjprice/cs12dotnet8/blob/main/docs/errata/improvements.md#page-484---compressing-streams