Skip to content

Commit

Permalink
update csharpier
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Hathcock committed Mar 14, 2024
1 parent 8072eb1 commit 93e181c
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.26.7",
"version": "0.27.3",
"commands": [
"dotnet-csharpier"
]
Expand Down
8 changes: 5 additions & 3 deletions src/SharpCompress/Archives/Rar/RarArchive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ protected override IEnumerable<RarVolume> LoadVolumes(SourceStream srcStream)
streams[1].Position = 0;
SrcStream.Position = 0;

return srcStream.Streams.Select(
a => new StreamRarArchiveVolume(a, ReaderOptions, idx++)
);
return srcStream.Streams.Select(a => new StreamRarArchiveVolume(
a,
ReaderOptions,
idx++
));
}
else //split mode or single file
{
Expand Down
4 changes: 2 additions & 2 deletions src/SharpCompress/Common/Zip/Headers/DirectoryEntryHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ internal override void Read(BinaryReader reader)

LoadExtra(extra);

var unicodePathExtra = Extra.FirstOrDefault(
u => u.Type == ExtraDataType.UnicodePathExtraField
var unicodePathExtra = Extra.FirstOrDefault(u =>
u.Type == ExtraDataType.UnicodePathExtraField
);
if (unicodePathExtra != null && ArchiveEncoding.Forced == null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/SharpCompress/Common/Zip/Headers/LocalEntryHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ internal override void Read(BinaryReader reader)

LoadExtra(extra);

var unicodePathExtra = Extra.FirstOrDefault(
u => u.Type == ExtraDataType.UnicodePathExtraField
var unicodePathExtra = Extra.FirstOrDefault(u =>
u.Type == ExtraDataType.UnicodePathExtraField
);
if (unicodePathExtra != null && ArchiveEncoding.Forced == null)
{
Expand Down
13 changes: 6 additions & 7 deletions src/SharpCompress/Common/Zip/StreamingZipHeaderFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,12 @@ ref rewindableStream
if (header.ZipHeaderType == ZipHeaderType.LocalEntry)
{
var local_header = ((LocalEntryHeader)header);
var dir_header = _entries?.FirstOrDefault(
entry =>
entry.Key == local_header.Name
&& local_header.CompressedSize == 0
&& local_header.UncompressedSize == 0
&& local_header.Crc == 0
&& local_header.IsDirectory == false
var dir_header = _entries?.FirstOrDefault(entry =>
entry.Key == local_header.Name
&& local_header.CompressedSize == 0
&& local_header.UncompressedSize == 0
&& local_header.Crc == 0
&& local_header.IsDirectory == false
);

if (dir_header != null)
Expand Down
4 changes: 2 additions & 2 deletions src/SharpCompress/Common/Zip/ZipHeaderFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ private void LoadHeader(ZipFileEntry entryHeader, Stream stream)

if (entryHeader.CompressionMethod == ZipCompressionMethod.WinzipAes)
{
var data = entryHeader.Extra.SingleOrDefault(
x => x.Type == ExtraDataType.WinZipAes
var data = entryHeader.Extra.SingleOrDefault(x =>
x.Type == ExtraDataType.WinZipAes
);
if (data != null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/SharpCompress/Compressors/Deflate64/InflaterManaged.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ bool deflate64

private void Reset() =>
_state = //_hasFormatReader ?
//InflaterState.ReadingHeader : // start by reading Header info
InflaterState.ReadingBFinal; // start by reading BFinal bit
//InflaterState.ReadingHeader : // start by reading Header info
InflaterState.ReadingBFinal; // start by reading BFinal bit

public void SetInput(byte[] inputBytes, int offset, int length) =>
_input.SetInput(inputBytes, offset, length); // append the bytes
Expand Down
8 changes: 4 additions & 4 deletions src/SharpCompress/Compressors/LZMA/LzmaDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,8 @@ internal bool Code(int dictionarySize, OutWindow outWindow, RangeCoder.Decoder r
{
var posState = (uint)outWindow._total & _posStateMask;
if (
_isMatchDecoders[
(_state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState
].Decode(rangeDecoder) == 0
_isMatchDecoders[(_state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState]
.Decode(rangeDecoder) == 0
)
{
byte b;
Expand Down Expand Up @@ -355,7 +354,8 @@ internal bool Code(int dictionarySize, OutWindow outWindow, RangeCoder.Decoder r
if (
_isRep0LongDecoders[
(_state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState
].Decode(rangeDecoder) == 0
]
.Decode(rangeDecoder) == 0
)
{
_state.UpdateShortRep();
Expand Down
39 changes: 18 additions & 21 deletions src/SharpCompress/Compressors/LZMA/LzmaEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,8 @@ private uint GetPureRepPrice(uint repIndex, Base.State state, uint posState)
if (repIndex == 0)
{
price = _isRepG0[state._index].GetPrice0();
price += _isRep0Long[
(state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState
].GetPrice1();
price += _isRep0Long[(state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState]
.GetPrice1();
}
else
{
Expand Down Expand Up @@ -713,9 +712,8 @@ private uint GetOptimum(uint position, out uint backRes)
.GetPrice(!_state.IsCharState(), matchByte, currentByte);
_optimum[1].MakeAsChar();

var matchPrice = _isMatch[
(_state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState
].GetPrice1();
var matchPrice = _isMatch[(_state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState]
.GetPrice1();
var repMatchPrice = matchPrice + _isRep[_state._index].GetPrice1();

if (matchByte == currentByte)
Expand Down Expand Up @@ -995,9 +993,8 @@ private uint GetOptimum(uint position, out uint backRes)
var posStateNext = (position + 1) & _posStateMask;
var nextRepMatchPrice =
curAnd1Price
+ _isMatch[
(state2._index << Base.K_NUM_POS_STATES_BITS_MAX) + posStateNext
].GetPrice1()
+ _isMatch[(state2._index << Base.K_NUM_POS_STATES_BITS_MAX) + posStateNext]
.GetPrice1()
+ _isRep[state2._index].GetPrice1();
{
var offset = cur + 1 + lenTest2;
Expand Down Expand Up @@ -1069,7 +1066,8 @@ private uint GetOptimum(uint position, out uint backRes)
+ GetRepPrice(repIndex, lenTest, state, posState)
+ _isMatch[
(state2._index << Base.K_NUM_POS_STATES_BITS_MAX) + posStateNext
].GetPrice0()
]
.GetPrice0()
+ _literalEncoder
.GetSubCoder(
position + lenTest,
Expand All @@ -1088,7 +1086,8 @@ private uint GetOptimum(uint position, out uint backRes)
curAndLenCharPrice
+ _isMatch[
(state2._index << Base.K_NUM_POS_STATES_BITS_MAX) + posStateNext
].GetPrice1();
]
.GetPrice1();
var nextRepMatchPrice = nextMatchPrice + _isRep[state2._index].GetPrice1();

// for(; lenTest2 >= 2; lenTest2--)
Expand Down Expand Up @@ -1174,7 +1173,8 @@ private uint GetOptimum(uint position, out uint backRes)
+ _isMatch[
(state2._index << Base.K_NUM_POS_STATES_BITS_MAX)
+ posStateNext
].GetPrice0()
]
.GetPrice0()
+ _literalEncoder
.GetSubCoder(
position + lenTest,
Expand All @@ -1194,7 +1194,8 @@ private uint GetOptimum(uint position, out uint backRes)
+ _isMatch[
(state2._index << Base.K_NUM_POS_STATES_BITS_MAX)
+ posStateNext
].GetPrice1();
]
.GetPrice1();
var nextRepMatchPrice =
nextMatchPrice + _isRep[state2._index].GetPrice1();

Expand Down Expand Up @@ -1243,10 +1244,8 @@ private void WriteEndMarker(uint posState)
return;
}

_isMatch[(_state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState].Encode(
_rangeEncoder,
1
);
_isMatch[(_state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState]
.Encode(_rangeEncoder, 1);
_isRep[_state._index].Encode(_rangeEncoder, 0);
_state.UpdateMatch();
var len = Base.K_MATCH_MIN_LEN;
Expand Down Expand Up @@ -1321,10 +1320,8 @@ public void CodeOneBlock(out long inSize, out long outSize, out bool finished)
// it's not used
ReadMatchDistances(out var len, out var numDistancePairs);
var posState = (uint)(_nowPos64) & _posStateMask;
_isMatch[(_state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState].Encode(
_rangeEncoder,
0
);
_isMatch[(_state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState]
.Encode(_rangeEncoder, 0);
_state.UpdateChar();
var curByte = _matchFinder.GetIndexByte((int)(0 - _additionalOffset));
_literalEncoder
Expand Down
15 changes: 7 additions & 8 deletions src/SharpCompress/Compressors/PPMd/I1/Allocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,8 @@ private void SplitBlock(Pointer pointer, uint oldIndex, uint newIndex)
unitCountDifference -= unitCount;
}

_memoryNodes[UNITS_TO_INDEX[unitCountDifference - 1]].Insert(
newPointer,
unitCountDifference
);
_memoryNodes[UNITS_TO_INDEX[unitCountDifference - 1]]
.Insert(newPointer, unitCountDifference);
}

private void GlueFreeBlocks()
Expand Down Expand Up @@ -457,10 +455,11 @@ private void GlueFreeBlocks()
if (INDEX_TO_UNITS[index] != unitCount)
{
var unitCountDifference = unitCount - INDEX_TO_UNITS[--index];
_memoryNodes[unitCountDifference - 1].Insert(
memoryNode0 + (unitCount - unitCountDifference),
unitCountDifference
);
_memoryNodes[unitCountDifference - 1]
.Insert(
memoryNode0 + (unitCount - unitCountDifference),
unitCountDifference
);
}

_memoryNodes[index].Insert(memoryNode0, INDEX_TO_UNITS[index]);
Expand Down
4 changes: 2 additions & 2 deletions tests/SharpCompress.Test/Tar/TarArchiveTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ public void Tar_Random_Write_Remove()

using (var archive = TarArchive.Open(unmodified))
{
var entry = archive.Entries.Single(
x => x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
var entry = archive.Entries.Single(x =>
x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
);
archive.RemoveEntry(entry);
archive.SaveTo(scratchPath, CompressionType.None);
Expand Down
24 changes: 12 additions & 12 deletions tests/SharpCompress.Test/Zip/ZipArchiveTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ public void Zip_Random_Write_Remove()

using (var archive = ZipArchive.Open(unmodified))
{
var entry = archive.Entries.Single(
x => x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
var entry = archive.Entries.Single(x =>
x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
);
archive.RemoveEntry(entry);

Expand Down Expand Up @@ -250,18 +250,18 @@ public void Zip_Removal_Poly()

using (ZipArchive vfs = (ZipArchive)ArchiveFactory.Open(scratchPath))
{
var e = vfs.Entries.First(
v => v.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
var e = vfs.Entries.First(v =>
v.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
);
vfs.RemoveEntry(e);
Assert.Null(
vfs.Entries.FirstOrDefault(
v => v.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
vfs.Entries.FirstOrDefault(v =>
v.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
)
);
Assert.Null(
((IArchive)vfs).Entries.FirstOrDefault(
v => v.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
((IArchive)vfs).Entries.FirstOrDefault(v =>
v.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
)
);
}
Expand Down Expand Up @@ -399,13 +399,13 @@ var file in Directory.EnumerateFiles(
{
archive.AddAllFromDirectory(SCRATCH_FILES_PATH);
archive.RemoveEntry(
archive.Entries.Single(
x => x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
archive.Entries.Single(x =>
x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
)
);
Assert.Null(
archive.Entries.FirstOrDefault(
x => x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
archive.Entries.FirstOrDefault(x =>
x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
)
);
}
Expand Down

0 comments on commit 93e181c

Please sign in to comment.