Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove var usage
  • Loading branch information
jozkee authored and github-actions committed Sep 9, 2022
commit 63b91582f541b75e2c5e9dfe6914dde69701aa90
Original file line number Diff line number Diff line change
Expand Up @@ -323,27 +323,28 @@ private void WriteLongNameCore(TarEntryFormat format, string maxPathComponent)
{
Assert.Equal(255, maxPathComponent.Length);

var ms = new MemoryStream();
using (var writer = new TarWriter(ms, true))
TarEntry entry;
MemoryStream ms = new();
using (TarWriter writer = new(ms, true))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using (TarWriter writer = new(ms, true))
using (TarWriter writer = new(ms, leaveOpen: true))

{
TarEntryType entryType = format == TarEntryFormat.V7 ? TarEntryType.V7RegularFile : TarEntryType.RegularFile;
var entry1 = InvokeTarEntryCreationConstructor(format, entryType, maxPathComponent);
writer.WriteEntry(entry1);
entry = InvokeTarEntryCreationConstructor(format, entryType, maxPathComponent);
writer.WriteEntry(entry);

var entry2 = InvokeTarEntryCreationConstructor(format, entryType, Path.Join(maxPathComponent, maxPathComponent));
writer.WriteEntry(entry2);
entry = InvokeTarEntryCreationConstructor(format, entryType, Path.Join(maxPathComponent, maxPathComponent));
writer.WriteEntry(entry);
}

ms.Position = 0;
using var reader = new TarReader(ms);
using TarReader reader = new(ms);

TarEntry readEntry = reader.GetNextEntry();
entry = reader.GetNextEntry();
string expectedName = GetExpectedNameForFormat(format, maxPathComponent);
Assert.Equal(expectedName, readEntry.Name);
Assert.Equal(expectedName, entry.Name);

readEntry = reader.GetNextEntry();
entry = reader.GetNextEntry();
expectedName = GetExpectedNameForFormat(format, Path.Join(maxPathComponent, maxPathComponent));
Assert.Equal(expectedName, readEntry.Name);
Assert.Equal(expectedName, entry.Name);

Assert.Null(reader.GetNextEntry());

Expand Down