Add Adler32, Crc32, and Deflate APIs - #86
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## prime #86 +/- ##
==========================================
+ Coverage 85.45% 86.20% +0.75%
==========================================
Files 71 74 +3
Lines 1176 1240 +64
Branches 218 229 +11
==========================================
+ Hits 1005 1069 +64
Misses 121 121
Partials 50 50 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces three new utility APIs in PowerKit for common binary operations: Adler-32, CRC-32 (IEEE 802.3), and Deflate compression/decompression, alongside unit tests to validate expected behavior.
Changes:
- Added
Adler32andCrc32static classes withbyte[]andReadOnlySpan<byte>hashing overloads. - Added
Deflatestatic class withCompress/DecompressAPIs forbyte[]and (where available)ReadOnlySpan<byte>. - Added test coverage for the new checksum and compression utilities.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| PowerKit/Adler32.cs | Adds Adler-32 checksum API with Span + array overloads. |
| PowerKit/Crc32.cs | Adds CRC-32 checksum API with lookup table + Span + array overloads. |
| PowerKit/Deflate.cs | Adds Deflate compression/decompression helpers for arrays and spans (where supported). |
| PowerKit.Tests/Adler32Tests.cs | Validates Adler-32 known vectors and basic invariants. |
| PowerKit.Tests/Crc32Tests.cs | Validates CRC-32 known vectors and basic invariants. |
| PowerKit.Tests/DeflateTests.cs | Validates roundtrip compression/decompression and basic compression behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot do you think we could end |
Yes, done in commit
|
Adds three new static utility classes for checksum computation and Deflate compression.
New APIs
Adler32.Hash(Stream)/Adler32.Hash(byte[])/Adler32.Hash(ReadOnlySpan<byte>)→uintCrc32.Hash(Stream)/Crc32.Hash(byte[])/Crc32.Hash(ReadOnlySpan<byte>)→uint(IEEE 802.3 / 0xEDB88320 polynomial)Deflate.Compress(Stream, Stream)/Deflate.Compress(byte[])/Deflate.Compress(ReadOnlySpan<byte>)→void/byte[]Deflate.Decompress(Stream, Stream)/Deflate.Decompress(byte[])/Deflate.Decompress(ReadOnlySpan<byte>)→void/byte[]Implementation notes
Streamoverloads are the primary implementations for all three classes.byte[]overloads delegate to theStreamoverloads viaMemoryStream.ReadOnlySpan<byte>overloads are guarded with#if !NETFRAMEWORK || NET45_OR_GREATER(consistent with existing Span usage;System.Memoryis not available for net35). Adler32 and Crc32 span overloads compute directly over the span to avoid an intermediate array allocation; Deflate span overloads delegate via.ToArray().Crc32uses a pre-computed 256-entry lookup table initialized once at startup.