Skip to content

Commit

Permalink
Respond to PR feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelcfanning committed Dec 1, 2023
1 parent 4a03e56 commit 677d01d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
18 changes: 3 additions & 15 deletions src/Sarif/EnumeratedArtifact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public EnumeratedArtifact(IFileSystem fileSystem)
internal byte[] bytes;
internal string contents;

private bool? isBinary;
private Encoding encoding;

public Uri Uri { get; set; }
Expand All @@ -28,22 +27,11 @@ public bool IsBinary
{
get
{
return this.isBinary ?? IsArtifactBinary();
GetArtifactData();
return this.contents == null;
}
}

internal bool IsArtifactBinary()
{
if (isBinary.HasValue)
{
return isBinary.Value;
}

GetArtifactData();
this.isBinary = this.contents == null;
return this.isBinary.Value;
}

public Stream Stream { get; set; }

public Encoding Encoding
Expand Down Expand Up @@ -151,7 +139,7 @@ private void RetrieveDataFromSeekableStream()
// Reset to beginning of stream in case caller neglected to do so.
this.Stream.Seek(0, SeekOrigin.Begin);

byte[] header = new byte[4096];
byte[] header = new byte[1024];
int length = this.Stream.Read(header, 0, header.Length);
isText = FileEncoding.CheckForTextualData(header, 0, length, out this.encoding);

Expand Down
4 changes: 2 additions & 2 deletions src/Sarif/MultithreadedZipArchiveArtifactProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class MultithreadedZipArchiveArtifactProvider : ArtifactProvider
private readonly ZipArchive zipArchive;
private ISet<string> binaryExtensions;

public ISet<string> BinaryExtensions
{
public ISet<string> BinaryExtensions
{
get
{
this.binaryExtensions ??= CreateDefaultBinaryExtensionsSet();
Expand Down
2 changes: 2 additions & 0 deletions src/Test.UnitTests.Sarif/EnumeratedArtifactTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ private void ValidateBinaryArtifact(EnumeratedArtifact artifact, int sizeInBytes
artifact.Bytes.Should().NotBeNull();
artifact.Bytes.Length.Should().Be(sizeInBytes);
artifact.SizeInBytes.Should().Be(sizeInBytes);
artifact.IsBinary.Should().BeTrue();

artifact.Contents.Should().BeNull();
}
Expand All @@ -230,6 +231,7 @@ private void ValidateTextArtifact(EnumeratedArtifact artifact, int sizeInBytes)
artifact.Contents.Should().NotBeNull();
artifact.Contents.Length.Should().Be(sizeInBytes);
artifact.SizeInBytes.Should().Be(sizeInBytes);
artifact.IsBinary.Should().BeFalse();

artifact.Bytes.Should().BeNull();
}
Expand Down

0 comments on commit 677d01d

Please sign in to comment.