mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-22 23:15:20 +00:00
Fix build
This commit is contained in:
@@ -195,8 +195,6 @@ csharp_prefer_static_local_function = true:warning
|
||||
csharp_prefer_simple_using_statement = true:suggestion
|
||||
dotnet_diagnostic.IDE0063.severity = suggestion
|
||||
|
||||
csharp_style_namespace_declarations = file_scoped
|
||||
|
||||
##########################################
|
||||
# .NET Formatting Conventions
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-code-style-settings-reference#formatting-conventions
|
||||
@@ -251,6 +249,8 @@ csharp_space_between_square_brackets = false
|
||||
csharp_preserve_single_line_statements = false
|
||||
csharp_preserve_single_line_blocks = true
|
||||
|
||||
csharp_style_namespace_declarations = file_scoped
|
||||
|
||||
##########################################
|
||||
# .NET Naming Conventions
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-naming-conventions
|
||||
@@ -260,11 +260,13 @@ csharp_preserve_single_line_blocks = true
|
||||
dotnet_diagnostic.CA1000.severity = suggestion
|
||||
dotnet_diagnostic.CA1001.severity = error
|
||||
dotnet_diagnostic.CA1018.severity = error
|
||||
dotnet_diagnostic.CA1036.severity = silent
|
||||
dotnet_diagnostic.CA1051.severity = suggestion
|
||||
dotnet_diagnostic.CA1068.severity = error
|
||||
dotnet_diagnostic.CA1069.severity = error
|
||||
dotnet_diagnostic.CA1304.severity = error
|
||||
dotnet_diagnostic.CA1305.severity = suggestion
|
||||
dotnet_diagnostic.CA1307.severity = suggestion
|
||||
dotnet_diagnostic.CA1309.severity = suggestion
|
||||
dotnet_diagnostic.CA1310.severity = error
|
||||
dotnet_diagnostic.CA1707.severity = suggestion
|
||||
@@ -283,6 +285,7 @@ dotnet_diagnostic.CA1829.severity = suggestion
|
||||
dotnet_diagnostic.CA1834.severity = error
|
||||
dotnet_diagnostic.CA1845.severity = suggestion
|
||||
dotnet_diagnostic.CA1848.severity = suggestion
|
||||
dotnet_diagnostic.CA1852.severity = suggestion
|
||||
dotnet_diagnostic.CA2016.severity = suggestion
|
||||
dotnet_diagnostic.CA2201.severity = error
|
||||
dotnet_diagnostic.CA2206.severity = error
|
||||
@@ -295,6 +298,7 @@ dotnet_diagnostic.CA2254.severity = suggestion
|
||||
|
||||
dotnet_diagnostic.CS0169.severity = error
|
||||
dotnet_diagnostic.CS0219.severity = error
|
||||
dotnet_diagnostic.CS0649.severity = suggestion
|
||||
dotnet_diagnostic.CS1998.severity = error
|
||||
dotnet_diagnostic.CS8602.severity = error
|
||||
dotnet_diagnostic.CS8604.severity = error
|
||||
@@ -305,43 +309,53 @@ dotnet_diagnostic.CS4014.severity = error
|
||||
dotnet_diagnostic.CS8600.severity = error
|
||||
dotnet_diagnostic.CS8603.severity = error
|
||||
dotnet_diagnostic.CS8625.severity = error
|
||||
dotnet_diagnostic.CS8981.severity = suggestion
|
||||
|
||||
dotnet_diagnostic.BL0005.severity = suggestion
|
||||
|
||||
dotnet_diagnostic.MVC1000.severity = suggestion
|
||||
|
||||
dotnet_diagnostic.IDE0055.severity = suggestion # Fix formatting
|
||||
dotnet_diagnostic.IDE0023.severity = suggestion # use expression body for operators
|
||||
dotnet_diagnostic.IDE0025.severity = suggestion # use expression body for properties
|
||||
dotnet_diagnostic.IDE1006.severity = suggestion # Naming rule violation: These words cannot contain lower case characters
|
||||
dotnet_diagnostic.IDE0072.severity = suggestion # Populate switch - forces population of all cases even when default specified
|
||||
dotnet_diagnostic.IDE0027.severity = suggestion # Use expression body for accessors
|
||||
dotnet_diagnostic.IDE0032.severity = suggestion # Use auto property
|
||||
dotnet_diagnostic.IDE0007.severity = error # Use var
|
||||
dotnet_diagnostic.IDE0160.severity = suggestion # Use block scoped
|
||||
dotnet_diagnostic.IDE0011.severity = error # Use braces on if statements
|
||||
dotnet_diagnostic.IDE0057.severity = suggestion # substring can be simplified
|
||||
dotnet_diagnostic.RZ10012.severity = error
|
||||
|
||||
dotnet_diagnostic.IDE0004.severity = error # redundant cast
|
||||
dotnet_diagnostic.IDE0005.severity = error
|
||||
dotnet_diagnostic.IDE0007.severity = error # Use var
|
||||
dotnet_diagnostic.IDE0011.severity = error # Use braces on if statements
|
||||
dotnet_diagnostic.IDE0010.severity = silent # populate switch
|
||||
dotnet_diagnostic.IDE0017.severity = suggestion # initialization can be simplified
|
||||
dotnet_diagnostic.IDE0021.severity = silent # expression body for constructors
|
||||
dotnet_diagnostic.IDE0022.severity = silent # expression body for methods
|
||||
dotnet_diagnostic.IDE0023.severity = suggestion # use expression body for operators
|
||||
dotnet_diagnostic.IDE0024.severity = silent # expression body for operators
|
||||
dotnet_diagnostic.IDE0025.severity = suggestion # use expression body for properties
|
||||
dotnet_diagnostic.IDE0027.severity = suggestion # Use expression body for accessors
|
||||
dotnet_diagnostic.IDE0028.severity = silent
|
||||
dotnet_diagnostic.IDE0032.severity = suggestion # Use auto property
|
||||
dotnet_diagnostic.IDE0033.severity = error # prefer tuple name
|
||||
dotnet_diagnostic.IDE0037.severity = suggestion # simplify anonymous type
|
||||
dotnet_diagnostic.IDE0040.severity = error # modifiers required
|
||||
dotnet_diagnostic.IDE0041.severity = error # simplify null
|
||||
dotnet_diagnostic.IDE0042.severity = error # deconstruct variable
|
||||
dotnet_diagnostic.IDE0044.severity = error # make field only when possible
|
||||
dotnet_diagnostic.IDE0044.severity = suggestion # make field only when possible
|
||||
dotnet_diagnostic.IDE0047.severity = suggestion # paratemeter name
|
||||
dotnet_diagnostic.IDE0051.severity = error # unused field
|
||||
dotnet_diagnostic.IDE0052.severity = error # unused member
|
||||
dotnet_diagnostic.IDE0053.severity = suggestion # lambda not needed
|
||||
dotnet_diagnostic.IDE0055.severity = suggestion # Fix formatting
|
||||
dotnet_diagnostic.IDE0057.severity = suggestion # substring can be simplified
|
||||
dotnet_diagnostic.IDE0060.severity = suggestion # unused parameters
|
||||
dotnet_diagnostic.IDE0061.severity = suggestion # local expression body
|
||||
dotnet_diagnostic.IDE0062.severity = suggestion # local to static
|
||||
dotnet_diagnostic.IDE0063.severity = error # simplify using
|
||||
dotnet_diagnostic.IDE0066.severity = suggestion # switch expression
|
||||
dotnet_diagnostic.IDE0072.severity = suggestion # Populate switch - forces population of all cases even when default specified
|
||||
dotnet_diagnostic.IDE0078.severity = suggestion # use pattern matching
|
||||
dotnet_diagnostic.IDE0090.severity = suggestion # new can be simplified
|
||||
dotnet_diagnostic.IDE0130.severity = suggestion # namespace folder structure
|
||||
dotnet_diagnostic.IDE0160.severity = silent # Use block namespaces ARE NOT required
|
||||
dotnet_diagnostic.IDE0161.severity = suggestion # Please use file namespaces
|
||||
dotnet_diagnostic.IDE0161.severity = error # Please use file namespaces
|
||||
dotnet_diagnostic.IDE0200.severity = suggestion # lambda not needed
|
||||
dotnet_diagnostic.IDE1006.severity = suggestion # Naming rule violation: These words cannot contain lower case characters
|
||||
|
||||
##########################################
|
||||
# Styles
|
||||
|
||||
@@ -1,24 +1,3 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: AssemblyTitle("SharpCompress")]
|
||||
[assembly: AssemblyProduct("SharpCompress")]
|
||||
[assembly: InternalsVisibleTo("SharpCompress.Test" + SharpCompress.AssemblyInfo.PublicKeySuffix)]
|
||||
[assembly: CLSCompliant(true)]
|
||||
|
||||
namespace SharpCompress
|
||||
{
|
||||
/// <summary>
|
||||
/// Just a static class to house the public key, to avoid repetition.
|
||||
/// </summary>
|
||||
internal static class AssemblyInfo
|
||||
{
|
||||
internal const string PublicKeySuffix =
|
||||
",PublicKey=002400000480000094000000060200000024000052534131000400000100010059acfa17d26c44" +
|
||||
"7a4d03f16eaa72c9187c04f16e6569dd168b080e39a6f5c9fd00f28c768cd8e9a089d5a0e1b34c" +
|
||||
"cd971488e7afe030ce5ce8df2053cf12ec89f6d38065c434c09ee6af3ee284c5dc08f44774b679" +
|
||||
"bf39298e57efe30d4b00aecf9e4f6f8448b2cb0146d8956dfcab606cc64a0ac38c60a7d78b0d65" +
|
||||
"d3b98dc0";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
namespace SharpCompress.Common
|
||||
{
|
||||
internal interface IExtractionListener
|
||||
public interface IExtractionListener
|
||||
{
|
||||
void FireFilePartExtractionBegin(string name, long size, long compressedSize);
|
||||
void FireCompressedBytesRead(long currentPartCompressedBytes, long compressedReadBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace SharpCompress.Common.Rar.Headers
|
||||
{
|
||||
internal enum HeaderType : byte
|
||||
public enum HeaderType : byte
|
||||
{
|
||||
Null,
|
||||
Mark,
|
||||
@@ -146,4 +146,4 @@ namespace SharpCompress.Common.Rar.Headers
|
||||
{
|
||||
public const ushort HAS_NEXT_VOLUME = 0x0001;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace SharpCompress.Common.Rar.Headers
|
||||
{
|
||||
internal interface IRarHeader
|
||||
public interface IRarHeader
|
||||
{
|
||||
HeaderType HeaderType { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,21 +5,21 @@ using SharpCompress.Readers;
|
||||
|
||||
namespace SharpCompress.Common.Rar.Headers
|
||||
{
|
||||
internal class RarHeaderFactory
|
||||
public class RarHeaderFactory
|
||||
{
|
||||
private bool _isRar5;
|
||||
|
||||
internal RarHeaderFactory(StreamingMode mode, ReaderOptions options)
|
||||
public RarHeaderFactory(StreamingMode mode, ReaderOptions options)
|
||||
{
|
||||
StreamingMode = mode;
|
||||
Options = options;
|
||||
}
|
||||
|
||||
private ReaderOptions Options { get; }
|
||||
internal StreamingMode StreamingMode { get; }
|
||||
internal bool IsEncrypted { get; private set; }
|
||||
public ReaderOptions Options { get; }
|
||||
public StreamingMode StreamingMode { get; }
|
||||
public bool IsEncrypted { get; private set; }
|
||||
|
||||
internal IEnumerable<IRarHeader> ReadHeaders(Stream stream)
|
||||
public IEnumerable<IRarHeader> ReadHeaders(Stream stream)
|
||||
{
|
||||
var markHeader = MarkHeader.Read(stream, Options.LeaveStreamOpen, Options.LookForHeader);
|
||||
_isRar5 = markHeader.IsRar5;
|
||||
@@ -185,4 +185,4 @@ namespace SharpCompress.Common.Rar.Headers
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,11 @@ namespace SharpCompress.Common.Zip
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
#if NET7_0
|
||||
var rfc2898 = new Rfc2898DeriveBytes(_password, _salt, RFC2898_ITERATIONS, HashAlgorithmName.SHA1);
|
||||
#else
|
||||
var rfc2898 = new Rfc2898DeriveBytes(_password, _salt, RFC2898_ITERATIONS);
|
||||
#endif
|
||||
|
||||
KeyBytes = rfc2898.GetBytes(KeySizeInBytes); // 16 or 24 or 32 ???
|
||||
IvBytes = rfc2898.GetBytes(KeySizeInBytes);
|
||||
|
||||
@@ -43,7 +43,8 @@ namespace SharpCompress.Compressors.Deflate
|
||||
/// directly by applications wishing to create, read, or manipulate zip archive
|
||||
/// files.
|
||||
/// </summary>
|
||||
internal class CRC32
|
||||
[CLSCompliant(false)]
|
||||
public class CRC32
|
||||
{
|
||||
private const int BUFFER_SIZE = 8192;
|
||||
private static readonly UInt32[] crc32Table;
|
||||
@@ -290,4 +291,4 @@ namespace SharpCompress.Compressors.Deflate
|
||||
|
||||
// private member vars
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ using System.IO;
|
||||
|
||||
namespace SharpCompress.Compressors.LZMA.Utilites
|
||||
{
|
||||
internal class CrcCheckStream : Stream
|
||||
[CLSCompliant(false)]
|
||||
public class CrcCheckStream : Stream
|
||||
{
|
||||
private readonly uint _mExpectedCrc;
|
||||
private uint _mCurrentCrc;
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace SharpCompress.Compressors.Rar.UnpackV2017
|
||||
// Real size of DecodeNum table.
|
||||
public uint MaxNum;
|
||||
|
||||
// Left aligned start and upper limit codes defining code space
|
||||
// Left aligned start and upper limit codes defining code space
|
||||
// ranges for bit lengths. DecodeLen[BitLength-1] defines the start of
|
||||
// range for bit length and DecodeLen[BitLength] defines next code
|
||||
// after the end of range or in other words the upper limit code
|
||||
@@ -65,7 +65,7 @@ namespace SharpCompress.Compressors.Rar.UnpackV2017
|
||||
public readonly uint[] DecodeLen = new uint[16];
|
||||
|
||||
// Every item of this array contains the sum of all preceding items.
|
||||
// So it contains the start position in code list for every bit length.
|
||||
// So it contains the start position in code list for every bit length.
|
||||
public readonly uint[] DecodePos = new uint[16];
|
||||
|
||||
// Number of compressed bits processed in quick mode.
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.IO;
|
||||
|
||||
namespace SharpCompress.Compressors.Xz
|
||||
{
|
||||
[CLSCompliant(false)]
|
||||
public static class BinaryUtils
|
||||
{
|
||||
public static int ReadLittleEndianInt32(this BinaryReader reader)
|
||||
@@ -44,7 +45,7 @@ namespace SharpCompress.Compressors.Xz
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static byte[] ToLittleEndianBytes(this uint uint32)
|
||||
public static byte[] ToLittleEndianBytes(this uint uint32)
|
||||
{
|
||||
var result = BitConverter.GetBytes(uint32);
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@ using System;
|
||||
|
||||
namespace SharpCompress.Compressors.Xz
|
||||
{
|
||||
internal static class Crc32
|
||||
[CLSCompliant(false)]
|
||||
public static class Crc32
|
||||
{
|
||||
public const UInt32 DefaultPolynomial = 0xedb88320u;
|
||||
public const UInt32 DefaultSeed = 0xffffffffu;
|
||||
|
||||
@@ -5,7 +5,8 @@ using System.Collections.Generic;
|
||||
|
||||
namespace SharpCompress.Compressors.Xz
|
||||
{
|
||||
internal static class Crc64
|
||||
[CLSCompliant(false)]
|
||||
public static class Crc64
|
||||
{
|
||||
public const UInt64 DefaultSeed = 0x0;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ using SharpCompress.Compressors.Filters;
|
||||
|
||||
namespace SharpCompress.Compressors.Xz.Filters
|
||||
{
|
||||
internal class ArmFilter : BlockFilter
|
||||
public class ArmFilter : BlockFilter
|
||||
{
|
||||
public override bool AllowAsLast => false;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ using SharpCompress.Compressors.Filters;
|
||||
|
||||
namespace SharpCompress.Compressors.Xz.Filters
|
||||
{
|
||||
internal class ArmThumbFilter : BlockFilter
|
||||
public class ArmThumbFilter : BlockFilter
|
||||
{
|
||||
public override bool AllowAsLast => false;
|
||||
|
||||
|
||||
@@ -4,8 +4,9 @@ using System.IO;
|
||||
|
||||
namespace SharpCompress.Compressors.Xz.Filters
|
||||
{
|
||||
internal abstract class BlockFilter : ReadOnlyStream
|
||||
public abstract class BlockFilter : ReadOnlyStream
|
||||
{
|
||||
[CLSCompliant(false)]
|
||||
public enum FilterTypes : ulong
|
||||
{
|
||||
DELTA = 0x03,
|
||||
@@ -36,7 +37,6 @@ namespace SharpCompress.Compressors.Xz.Filters
|
||||
public abstract void Init(byte[] properties);
|
||||
public abstract void ValidateFilter();
|
||||
|
||||
public FilterTypes FilterType { get; set; }
|
||||
public static BlockFilter Read(BinaryReader reader)
|
||||
{
|
||||
var filterType = (FilterTypes)reader.ReadXZInteger();
|
||||
|
||||
@@ -14,7 +14,7 @@ using SharpCompress.Compressors.Filters;
|
||||
|
||||
namespace SharpCompress.Compressors.Xz.Filters
|
||||
{
|
||||
internal class IA64Filter : BlockFilter
|
||||
public class IA64Filter : BlockFilter
|
||||
{
|
||||
public override bool AllowAsLast => false;
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@ using SharpCompress.Compressors.LZMA;
|
||||
|
||||
namespace SharpCompress.Compressors.Xz.Filters
|
||||
{
|
||||
internal class Lzma2Filter : BlockFilter
|
||||
[CLSCompliant(false)]
|
||||
public class Lzma2Filter : BlockFilter
|
||||
{
|
||||
public override bool AllowAsLast => true;
|
||||
public override bool AllowAsNonLast => false;
|
||||
|
||||
@@ -14,7 +14,7 @@ using SharpCompress.Compressors.Filters;
|
||||
|
||||
namespace SharpCompress.Compressors.Xz.Filters
|
||||
{
|
||||
internal class PowerPCFilter : BlockFilter
|
||||
public class PowerPCFilter : BlockFilter
|
||||
{
|
||||
public override bool AllowAsLast => false;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ using SharpCompress.Compressors.Filters;
|
||||
|
||||
namespace SharpCompress.Compressors.Xz.Filters
|
||||
{
|
||||
internal class SparcFilter : BlockFilter
|
||||
public class SparcFilter : BlockFilter
|
||||
{
|
||||
public override bool AllowAsLast => false;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ using SharpCompress.Compressors.Filters;
|
||||
|
||||
namespace SharpCompress.Compressors.Xz.Filters
|
||||
{
|
||||
internal class X86Filter : BlockFilter
|
||||
public class X86Filter : BlockFilter
|
||||
{
|
||||
public override bool AllowAsLast => false;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -7,7 +8,8 @@ using SharpCompress.Compressors.Xz.Filters;
|
||||
|
||||
namespace SharpCompress.Compressors.Xz
|
||||
{
|
||||
internal sealed class XZBlock : XZReadOnlyStream
|
||||
[CLSCompliant(false)]
|
||||
public sealed class XZBlock : XZReadOnlyStream
|
||||
{
|
||||
public int BlockHeaderSize => (_blockHeaderSizeByte + 1) * 4;
|
||||
public ulong? CompressedSize { get; private set; }
|
||||
|
||||
@@ -5,7 +5,8 @@ using System.IO;
|
||||
|
||||
namespace SharpCompress.Crypto
|
||||
{
|
||||
internal sealed class Crc32Stream : Stream
|
||||
[CLSCompliant(false)]
|
||||
public sealed class Crc32Stream : Stream
|
||||
{
|
||||
public const uint DefaultPolynomial = 0xedb88320u;
|
||||
public const uint DefaultSeed = 0xffffffffu;
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.IO;
|
||||
|
||||
namespace SharpCompress.IO
|
||||
{
|
||||
internal class RewindableStream : Stream
|
||||
public class RewindableStream : Stream
|
||||
{
|
||||
private readonly Stream stream;
|
||||
private MemoryStream bufferStream = new MemoryStream();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
namespace SharpCompress.IO
|
||||
{
|
||||
internal enum StreamingMode
|
||||
public enum StreamingMode
|
||||
{
|
||||
Streaming,
|
||||
Seekable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace SharpCompress
|
||||
{
|
||||
internal class ReadOnlyCollection<T> : ICollection<T>
|
||||
public class ReadOnlyCollection<T> : ICollection<T>
|
||||
{
|
||||
private readonly ICollection<T> collection;
|
||||
|
||||
@@ -52,4 +52,4 @@ namespace SharpCompress
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace SharpCompress.Readers
|
||||
{
|
||||
internal interface IReaderExtractionListener : IExtractionListener
|
||||
public interface IReaderExtractionListener : IExtractionListener
|
||||
{
|
||||
void FireEntryExtractionProgress(Entry entry, long sizeTransferred, int iterations);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ using SharpCompress.Readers;
|
||||
|
||||
namespace SharpCompress
|
||||
{
|
||||
internal static class Utility
|
||||
[CLSCompliant(false)]
|
||||
public static class Utility
|
||||
{
|
||||
public static ReadOnlyCollection<T> ToReadOnly<T>(this ICollection<T> items)
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace SharpCompress.Test
|
||||
{
|
||||
byte[] compressed = new byte[cmpFs.Length];
|
||||
cmpFs.Read(compressed, 0, compressed.Length);
|
||||
byte[] test;
|
||||
byte[]? test;
|
||||
|
||||
ADCBase.Decompress(compressed, out test);
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace SharpCompress.Test
|
||||
|
||||
using (FileStream cmpFs = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "adc_compressed.bin")))
|
||||
{
|
||||
byte[] test;
|
||||
byte[]? test;
|
||||
|
||||
ADCBase.Decompress(cmpFs, out test);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace SharpCompress.Test
|
||||
protected void ArchiveStreamReadExtractAll(string testArchive, CompressionType compression)
|
||||
{
|
||||
testArchive = Path.Combine(TEST_ARCHIVES_PATH, testArchive);
|
||||
ArchiveStreamReadExtractAll(testArchive.AsEnumerable(), compression);
|
||||
ArchiveStreamReadExtractAll(new[] { testArchive }, compression);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,18 +73,18 @@ namespace SharpCompress.Test
|
||||
}
|
||||
}
|
||||
|
||||
protected void ArchiveStreamRead(string testArchive, ReaderOptions readerOptions = null)
|
||||
protected void ArchiveStreamRead(string testArchive, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
testArchive = Path.Combine(TEST_ARCHIVES_PATH, testArchive);
|
||||
ArchiveStreamRead(readerOptions, testArchive.AsEnumerable());
|
||||
ArchiveStreamRead(readerOptions, testArchive);
|
||||
}
|
||||
|
||||
protected void ArchiveStreamRead(ReaderOptions readerOptions = null, params string[] testArchives)
|
||||
protected void ArchiveStreamRead(ReaderOptions? readerOptions = null, params string[] testArchives)
|
||||
{
|
||||
ArchiveStreamRead(readerOptions, testArchives.Select(x => Path.Combine(TEST_ARCHIVES_PATH, x)));
|
||||
}
|
||||
|
||||
protected void ArchiveStreamRead(ReaderOptions readerOptions, IEnumerable<string> testArchives)
|
||||
protected void ArchiveStreamRead(ReaderOptions? readerOptions, IEnumerable<string> testArchives)
|
||||
{
|
||||
foreach (var path in testArchives)
|
||||
{
|
||||
@@ -115,12 +115,12 @@ namespace SharpCompress.Test
|
||||
}
|
||||
}
|
||||
|
||||
protected void ArchiveStreamMultiRead(ReaderOptions readerOptions = null, params string[] testArchives)
|
||||
protected void ArchiveStreamMultiRead(ReaderOptions? readerOptions = null, params string[] testArchives)
|
||||
{
|
||||
ArchiveStreamMultiRead(readerOptions, testArchives.Select(x => Path.Combine(TEST_ARCHIVES_PATH, x)));
|
||||
}
|
||||
|
||||
protected void ArchiveStreamMultiRead(ReaderOptions readerOptions, IEnumerable<string> testArchives)
|
||||
protected void ArchiveStreamMultiRead(ReaderOptions? readerOptions, IEnumerable<string> testArchives)
|
||||
{
|
||||
using (var archive = ArchiveFactory.Open(testArchives.Select(a => new FileInfo(a)), readerOptions))
|
||||
{
|
||||
@@ -144,14 +144,14 @@ namespace SharpCompress.Test
|
||||
VerifyFiles();
|
||||
}
|
||||
|
||||
protected void ArchiveOpenStreamRead(ReaderOptions readerOptions = null, params string[] testArchives)
|
||||
protected void ArchiveOpenStreamRead(ReaderOptions? readerOptions = null, params string[] testArchives)
|
||||
{
|
||||
ArchiveOpenStreamRead(readerOptions, testArchives.Select(x => Path.Combine(TEST_ARCHIVES_PATH, x)));
|
||||
}
|
||||
|
||||
protected void ArchiveOpenStreamRead(ReaderOptions readerOptions, IEnumerable<string> testArchives)
|
||||
protected void ArchiveOpenStreamRead(ReaderOptions? readerOptions, IEnumerable<string> testArchives)
|
||||
{
|
||||
using (var archive = ArchiveFactory.Open(testArchives.Select(f => new FileInfo(f)), null))
|
||||
using (var archive = ArchiveFactory.Open(testArchives.Select(f => new FileInfo(f)), readerOptions))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -173,16 +173,16 @@ namespace SharpCompress.Test
|
||||
VerifyFiles();
|
||||
}
|
||||
|
||||
protected void ArchiveOpenEntryVolumeIndexTest(int[][] results, ReaderOptions readerOptions = null, params string[] testArchives)
|
||||
protected void ArchiveOpenEntryVolumeIndexTest(int[][] results, ReaderOptions? readerOptions = null, params string[] testArchives)
|
||||
{
|
||||
ArchiveOpenEntryVolumeIndexTest(results, readerOptions, testArchives.Select(x => Path.Combine(TEST_ARCHIVES_PATH, x)));
|
||||
}
|
||||
|
||||
|
||||
protected void ArchiveOpenEntryVolumeIndexTest(int[][] results, ReaderOptions readerOptions, IEnumerable<string> testArchives)
|
||||
protected void ArchiveOpenEntryVolumeIndexTest(int[][] results, ReaderOptions? readerOptions, IEnumerable<string> testArchives)
|
||||
{
|
||||
string[] src = testArchives.ToArray();
|
||||
using (var archive = ArchiveFactory.Open(testArchives.Select(f => new FileInfo(f)), null))
|
||||
using (var archive = ArchiveFactory.Open(testArchives.Select(f => new FileInfo(f)), readerOptions))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -206,7 +206,7 @@ namespace SharpCompress.Test
|
||||
|
||||
|
||||
|
||||
protected void ArchiveFileRead(string testArchive, ReaderOptions readerOptions = null)
|
||||
protected void ArchiveFileRead(string testArchive, ReaderOptions? readerOptions = null)
|
||||
{
|
||||
testArchive = Path.Combine(TEST_ARCHIVES_PATH, testArchive);
|
||||
using (var archive = ArchiveFactory.Open(testArchive, readerOptions))
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace SharpCompress.Test.Rar
|
||||
ReadRarPassword("Rar5.encrypted_filesAndHeader.rar", "test");
|
||||
}*/
|
||||
|
||||
private void ReadRarPassword(string testArchive, string password)
|
||||
private void ReadRarPassword(string testArchive, string? password)
|
||||
{
|
||||
using (Stream stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, testArchive)))
|
||||
using (var archive = RarArchive.Open(stream, new ReaderOptions()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using SharpCompress.Common;
|
||||
using SharpCompress.Readers;
|
||||
@@ -232,7 +233,7 @@ namespace SharpCompress.Test.Rar
|
||||
using (var entryStream = reader.OpenEntryStream())
|
||||
{
|
||||
string file = Path.GetFileName(reader.Entry.Key);
|
||||
string folder = Path.GetDirectoryName(reader.Entry.Key);
|
||||
string folder = Path.GetDirectoryName(reader.Entry.Key) ?? throw new ArgumentNullException();
|
||||
string destdir = Path.Combine(SCRATCH_FILES_PATH, folder);
|
||||
if (!Directory.Exists(destdir))
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace SharpCompress.Test
|
||||
{
|
||||
public abstract class ReaderTests : TestBase
|
||||
{
|
||||
protected void Read(string testArchive, CompressionType expectedCompression, ReaderOptions options = null)
|
||||
protected void Read(string testArchive, CompressionType expectedCompression, ReaderOptions? options = null)
|
||||
{
|
||||
testArchive = Path.Combine(TEST_ARCHIVES_PATH, testArchive);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using SharpCompress.Common;
|
||||
using SharpCompress.Readers;
|
||||
@@ -85,7 +86,7 @@ namespace SharpCompress.Test.Tar
|
||||
using (var entryStream = reader.OpenEntryStream())
|
||||
{
|
||||
string file = Path.GetFileName(reader.Entry.Key);
|
||||
string folder = Path.GetDirectoryName(reader.Entry.Key);
|
||||
string folder = Path.GetDirectoryName(reader.Entry.Key) ?? throw new ArgumentNullException();
|
||||
string destdir = Path.Combine(SCRATCH_FILES_PATH, folder);
|
||||
if (!Directory.Exists(destdir))
|
||||
{
|
||||
|
||||
@@ -21,7 +21,8 @@ namespace SharpCompress.Test
|
||||
public TestBase()
|
||||
{
|
||||
var index = AppDomain.CurrentDomain.BaseDirectory.IndexOf("SharpCompress.Test", StringComparison.OrdinalIgnoreCase);
|
||||
SOLUTION_BASE_PATH = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory.Substring(0, index));
|
||||
var path = AppDomain.CurrentDomain.BaseDirectory.Substring(0, index);
|
||||
SOLUTION_BASE_PATH = Path.GetDirectoryName(path) ?? throw new ArgumentNullException();
|
||||
|
||||
TEST_ARCHIVES_PATH = Path.Combine(SOLUTION_BASE_PATH, "TestArchives", "Archives");
|
||||
ORIGINAL_FILES_PATH = Path.Combine(SOLUTION_BASE_PATH, "TestArchives", "Original");
|
||||
@@ -188,7 +189,7 @@ namespace SharpCompress.Test
|
||||
Assert.Equal(fi1.Attributes, fi2.Attributes);
|
||||
}
|
||||
|
||||
protected void CompareArchivesByPath(string file1, string file2, Encoding encoding = null)
|
||||
protected void CompareArchivesByPath(string file1, string file2, Encoding? encoding = null)
|
||||
{
|
||||
ReaderOptions readerOptions = new ReaderOptions { LeaveStreamOpen = false };
|
||||
readerOptions.ArchiveEncoding.Default = encoding ?? Encoding.Default;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace SharpCompress.Test
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
protected void Write(CompressionType compressionType, string archive, string archiveToVerifyAgainst, Encoding encoding = null)
|
||||
protected void Write(CompressionType compressionType, string archive, string archiveToVerifyAgainst, Encoding? encoding = null)
|
||||
{
|
||||
using (Stream stream = File.OpenWrite(Path.Combine(SCRATCH2_FILES_PATH, archive)))
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace SharpCompress.Test.Xz
|
||||
[Fact]
|
||||
public void CrcIncorrectThrows()
|
||||
{
|
||||
var bytes = Compressed.Clone() as byte[];
|
||||
var bytes = (byte[])Compressed.Clone();
|
||||
bytes[20]++;
|
||||
using (Stream badCrcStream = new MemoryStream(bytes))
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace SharpCompress.Test.Xz
|
||||
[Fact]
|
||||
public void ChecksMagicNumber()
|
||||
{
|
||||
var bytes = Compressed.Clone() as byte[];
|
||||
var bytes = (byte[])Compressed.Clone();
|
||||
bytes[3]++;
|
||||
using (Stream badMagicNumberStream = new MemoryStream(bytes))
|
||||
{
|
||||
@@ -23,7 +23,7 @@ namespace SharpCompress.Test.Xz
|
||||
[Fact]
|
||||
public void CorruptHeaderThrows()
|
||||
{
|
||||
var bytes = Compressed.Clone() as byte[];
|
||||
var bytes = (byte[])Compressed.Clone();
|
||||
bytes[8]++;
|
||||
using (Stream badCrcStream = new MemoryStream(bytes))
|
||||
{
|
||||
@@ -37,7 +37,7 @@ namespace SharpCompress.Test.Xz
|
||||
[Fact]
|
||||
public void BadVersionIfCrcOkButStreamFlagUnknown()
|
||||
{
|
||||
var bytes = Compressed.Clone() as byte[];
|
||||
var bytes = (byte[])Compressed.Clone();
|
||||
byte[] streamFlags = { 0x00, 0xF4 };
|
||||
byte[] crc = Crc32.Compute(streamFlags).ToLittleEndianBytes();
|
||||
streamFlags.CopyTo(bytes, 6);
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace SharpCompress.Test.Zip
|
||||
{
|
||||
long count = 0;
|
||||
long size = 0;
|
||||
Common.Zip.ZipEntry prev = null;
|
||||
Common.Zip.ZipEntry? prev = null;
|
||||
using (var fs = File.OpenRead(filename))
|
||||
using (var rd = ZipReader.Open(fs, new ReaderOptions() { LookForHeader = false }))
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -363,7 +363,7 @@ namespace SharpCompress.Test.Zip
|
||||
newFileName = newFileName.Substring(1);
|
||||
}
|
||||
newFileName = Path.Combine(SCRATCH_FILES_PATH, newFileName);
|
||||
var newDir = Path.GetDirectoryName(newFileName);
|
||||
var newDir = Path.GetDirectoryName(newFileName) ?? throw new ArgumentNullException();
|
||||
if (!Directory.Exists(newDir))
|
||||
{
|
||||
Directory.CreateDirectory(newDir);
|
||||
@@ -419,7 +419,7 @@ namespace SharpCompress.Test.Zip
|
||||
newFileName = newFileName.Substring(1);
|
||||
}
|
||||
newFileName = Path.Combine(SCRATCH_FILES_PATH, newFileName);
|
||||
var newDir = Path.GetDirectoryName(newFileName);
|
||||
var newDir = Path.GetDirectoryName(newFileName) ?? throw new ArgumentNullException();
|
||||
if (!Directory.Exists(newDir))
|
||||
{
|
||||
Directory.CreateDirectory(newDir);
|
||||
|
||||
Reference in New Issue
Block a user