Repository: dotnet/runtime
File: src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs (C#)

Code before:
                            // Update mode, so we want to make sure _storedUncompressedData stays null so
                            // that later when we dispose the archive, this entry loads the compressedBytes, and
                            // copies them straight over
                            _storedUncompressedData.Dispose();
                            _storedUncompressedData = null;
                            _currentlyOpenForWrite = false;
                            _everOpenedForWrite = false;
                            throw;
                        }
                    }
                }

                // if they start modifying it and the compression method is not "store", we should make sure it will get deflated
                if (StoredCompressionMethodInternal != ZipCompressionMethod.Stored)
                {
                    StoredCompressionMethodInternal = ZipCompressionMethod.Deflate;
                }
            }

            return _storedUncompressedData;
        }

        private ZipCompressionMethod StoredCompressionMethodInternal
        {
            get { return _storedCompressionMethod; }
            set
            {
                if (value == ZipCompressionMethod.Deflate)
                    VersionToExtractAtLeast(ZipVersionNeededValues.Deflate);
                else if (value == ZipCompressionMethod.Deflate64)
                    VersionToExtractAtLeast(ZipVersionNeededValues.Deflate64);
                _storedCompressionMethod = value;
            }
        }
        // does almost everything you need to do to forget about this entry
        // writes the local header/data, gets rid of all the data,
        // closes all of the streams except for the very outermost one that
        // the user holds on to and is responsible for closing
        //
        // after calling this, and only after calling this can we be guaranteed
        // that we are reading to write the central directory
        //
        // should only throw an exception in extremely exceptional cases because it is called from dispose
        internal void WriteAndFinishLocalEntry(bool forceWrite)
        {
            CloseStreams();
            WriteLocalFileHeaderAndDataIfNeeded(forceWrite);
            UnloadStreams();
        }

        private bool WriteCentralDirectoryFileHeaderInitialize(bool forceWrite, out Zip64ExtraField? zip64ExtraField, out uint compressedSizeTruncated, out uint uncompressedSizeTruncated, out ushort extraFieldLength, out uint offsetOfLocalHeaderTruncated)

Review comment (suggestion):
This can be a public property with a private setter.

```suggestion
        public ZipCompressionMethod CompressionMethod
{
get { return _storedCompressionMethod; }
private set
```

Code after:
                        {
                            decompressor.CopyTo(_storedUncompressedData);
                        }
                        catch (InvalidDataException)
                        {
                            // this is the case where the archive say the entry is deflate, but deflateStream
                            // throws an InvalidDataException. This property should only be getting accessed in
                            // Update mode, so we want to make sure _storedUncompressedData stays null so
                            // that later when we dispose the archive, this entry loads the compressedBytes, and
                            // copies them straight over
                            _storedUncompressedData.Dispose();
                            _storedUncompressedData = null;
                            _currentlyOpenForWrite = false;
                            _everOpenedForWrite = false;
                            throw;
                        }
                    }
                }

                // if they start modifying it and the compression method is not "store", we should make sure it will get deflated
                if (CompressionMethod != ZipCompressionMethod.Stored)
                {
                    CompressionMethod = ZipCompressionMethod.Deflate;
                }
            }

            return _storedUncompressedData;
        }

        // does almost everything you need to do to forget about this entry
        // writes the local header/data, gets rid of all the data,
        // closes all of the streams except for the very outermost one that
        // the user holds on to and is responsible for closing
        //
        // after calling this, and only after calling this can we be guaranteed
        // that we are reading to write the central directory
        //
        // should only throw an exception in extremely exceptional cases because it is called from dispose
        internal void WriteAndFinishLocalEntry(bool forceWrite)
        {
            CloseStreams();
            WriteLocalFileHeaderAndDataIfNeeded(forceWrite);
            UnloadStreams();
        }

        private bool WriteCentralDirectoryFileHeaderInitialize(bool forceWrite, out Zip64ExtraField? zip64ExtraField, out uint compressedSizeTruncated, out uint uncompressedSizeTruncated, out ushort extraFieldLength, out uint offsetOfLocalHeaderTruncated)
        {
            // This part is simple, because we should definitely know the sizes by this time

            // _storedEntryNameBytes only gets set when we read in or call moveTo. MoveTo does a check, and
            // reading in should not be able to produce an entryname longer than ushort.MaxValue