disable styling checks but fix build errors

This commit is contained in:
Adam Hathcock
2025-10-14 10:37:25 +01:00
parent 4ac74b61a3
commit 85c1e93183
10 changed files with 26 additions and 22 deletions

View File

@@ -11,11 +11,10 @@
<AnalysisLevel>latest-AllEnabledByDefault</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors>true</WarningsAsErrors>
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
<EnforceCodeStyleInBuild>false</EnforceCodeStyleInBuild>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn>
<!--Disabled by design-->

View File

@@ -9,6 +9,7 @@
using System;
using System.Runtime.CompilerServices;
#if SUPPORTS_RUNTIME_INTRINSICS
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
#endif

View File

@@ -1,6 +1,10 @@
using System;
using System.Collections.Generic;
using System.IO;
#if !NETFRAMEWORK && !NETSTANDARD2_0
using System.Diagnostics;
using System.Text;
#endif
namespace SharpCompress.IO;
@@ -230,6 +234,7 @@ internal static class StackStreamExtensions
return instanceId;
}
#if DEBUG_STREAMS
/// <summary>
/// Writes a debug message for stream construction.
/// </summary>
@@ -242,14 +247,15 @@ internal static class StackStreamExtensions
var frame = (new StackTrace()).GetFrame(3);
var parentInfo =
frame != null
#pragma warning disable IL2026
? $"{frame.GetMethod()?.DeclaringType?.Name}.{frame.GetMethod()?.Name}()"
#pragma warning restore IL2026
: "Unknown";
if (constructing.FullName == stream.GetType().FullName) //don't debug base IStackStream types
{
Debug.WriteLine($"{GetStreamStackString(stream, true)} : Constructed by [{parentInfo}]");
}
}
/// <summary>
/// Writes a debug message for stream disposal.
/// </summary>
@@ -260,13 +266,16 @@ internal static class StackStreamExtensions
var frame = (new StackTrace()).GetFrame(3);
var parentInfo =
frame != null
? $"{frame.GetMethod()?.DeclaringType?.Name}.{frame.GetMethod()?.Name}()"
: "Unknown";
#pragma warning disable IL2026
? $"{frame.GetMethod()?.DeclaringType?.Name}.{frame.GetMethod()?.Name}()"
#pragma warning restore IL2026
: "Unknown";
if (constructing.FullName == stream.GetType().FullName) //don't debug base IStackStream types
{
Debug.WriteLine($"{GetStreamStackString(stream, false)} : Disposed by [{parentInfo}]");
}
}
#endif
/// <summary>
/// Writes a debug trace message for the stream.

View File

@@ -16,6 +16,6 @@ public class BZip2ReaderTests : ReaderTests
Stream stream = new MemoryStream(
[0x42, 0x5a, 0x68, 0x34, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0x35]
);
Assert.Throws(typeof(InvalidOperationException), () => ReaderFactory.Open(stream));
Assert.Throws<InvalidOperationException>(() => ReaderFactory.Open(stream));
}
}

View File

@@ -122,6 +122,6 @@ public class GZipArchiveTests : ArchiveTests
{
using var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar.gz"));
using var archive = GZipArchive.Open(stream);
Assert.Equal(archive.Type, ArchiveType.GZip);
Assert.Equal(ArchiveType.GZip, archive.Type);
}
}

View File

@@ -17,8 +17,7 @@ public class RarArchiveTests : ArchiveTests
[Fact]
public void Rar_EncryptedFileAndHeader_NoPasswordExceptionTest() =>
Assert.Throws(
typeof(CryptographicException),
Assert.Throws<CryptographicException>(
() => ReadRarPassword("Rar.encrypted_filesAndHeader.rar", null)
);
@@ -28,15 +27,13 @@ public class RarArchiveTests : ArchiveTests
[Fact]
public void Rar5_EncryptedFileAndHeader_Archive_Err() =>
Assert.Throws(
typeof(CryptographicException),
Assert.Throws<CryptographicException>(
() => ReadRarPassword("Rar5.encrypted_filesAndHeader.rar", "failed")
);
[Fact]
public void Rar5_EncryptedFileAndHeader_NoPasswordExceptionTest() =>
Assert.Throws(
typeof(CryptographicException),
Assert.Throws<CryptographicException>(
() => ReadRarPassword("Rar5.encrypted_filesAndHeader.rar", null)
);
@@ -46,8 +43,7 @@ public class RarArchiveTests : ArchiveTests
[Fact]
public void Rar_EncryptedFileOnly_Archive_Err() =>
Assert.Throws(
typeof(CryptographicException),
Assert.Throws<CryptographicException>(
() => ReadRarPassword("Rar5.encrypted_filesOnly.rar", "failed")
);

View File

@@ -34,8 +34,7 @@ public class SevenZipArchiveTests : ArchiveTests
[Fact]
public void SevenZipArchive_LZMAAES_NoPasswordExceptionTest() =>
Assert.Throws(
typeof(CryptographicException),
Assert.Throws<CryptographicException>(
() => ArchiveFileRead("7Zip.LZMA.Aes.7z", new ReaderOptions { Password = null })
); //was failing with ArgumentNullException not CryptographicException like rar

View File

@@ -49,7 +49,7 @@ public class TarArchiveTests : ArchiveTests
var unmodified = Path.Combine(SCRATCH2_FILES_PATH, archive);
using (var archive2 = TarArchive.Open(unmodified))
{
Assert.Equal(1, archive2.Entries.Count);
Assert.Single(archive2.Entries);
Assert.Contains(filename, archive2.Entries.Select(entry => entry.Key));
foreach (var entry in archive2.Entries)
@@ -109,7 +109,7 @@ public class TarArchiveTests : ArchiveTests
var unmodified = Path.Combine(SCRATCH2_FILES_PATH, archive);
using (var archive2 = TarArchive.Open(unmodified))
{
Assert.Equal(1, archive2.Entries.Count);
Assert.Single(archive2.Entries);
Assert.Contains(longFilename, archive2.Entries.Select(entry => entry.Key));
foreach (var entry in archive2.Entries)

View File

@@ -256,7 +256,7 @@ public class TarReaderTests : ReaderTests
}
else
{
Assert.True(false, "Symlink has no target");
Assert.Fail("Symlink has no target");
}
}
}

View File

@@ -496,7 +496,7 @@ public class ZipArchiveTests : ArchiveTests
new ReaderOptions { Password = "test" }
);
var isComplete = reader.IsComplete;
Assert.Equal(1, reader.Volumes.Count);
Assert.Single(reader.Volumes);
var expectedComment =
"Encoding:utf-8 || Compression:Deflate levelDefault || Encrypt:None || ZIP64:Always\r\nCreated at 2017-Jan-23 14:10:43 || DotNetZip Tool v1.9.1.8\r\nTest zip64 archive";