[PR #1135] [MERGED] Consolidate NETFRAMEWORK/NETSTANDARD compile flags into LEGACY_DOTNET #1564

Open
opened 2026-01-29 22:21:09 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/adamhathcock/sharpcompress/pull/1135
Author: @Copilot
Created: 1/15/2026
Status: Merged
Merged: 1/15/2026
Merged by: @adamhathcock

Base: masterHead: copilot/consolidate-compile-flags


📝 Commits (5)

  • 405dbb3 Initial plan
  • cab3e7d Initial analysis: Planning compile flags consolidation
  • a5300f3 Replace NETFRAMEWORK and NETSTANDARD2_0 with LEGACY_DOTNET compile flag
  • 52fef49 Additional simplifications: Remove NETCF, fix NET60 typo, consolidate NETCOREAPP2_1 pattern
  • d2cb792 Change NET6_0_OR_GREATER to NET8_0_OR_GREATER

📊 Changes

35 files changed (+58 additions, -59 deletions)

View changed files

📝 src/SharpCompress/Algorithms/Adler32.cs (+1 -1)
📝 src/SharpCompress/Archives/SevenZip/SevenZipArchive.cs (+1 -1)
📝 src/SharpCompress/Common/AsyncBinaryReader.cs (+1 -1)
📝 src/SharpCompress/Common/EntryStream.cs (+2 -2)
📝 src/SharpCompress/Common/Tar/TarReadOnlySubStream.cs (+2 -2)
📝 src/SharpCompress/Common/Zip/WinzipAesEncryptionData.cs (+1 -1)
📝 src/SharpCompress/Compressors/BZip2/BZip2Stream.cs (+1 -1)
📝 src/SharpCompress/Compressors/Deflate/DeflateStream.cs (+3 -3)
📝 src/SharpCompress/Compressors/Deflate/GZipStream.cs (+2 -2)
📝 src/SharpCompress/Compressors/Deflate/ZlibBaseStream.cs (+2 -2)
📝 src/SharpCompress/Compressors/Deflate/ZlibConstants.cs (+1 -5)
📝 src/SharpCompress/Compressors/Deflate/ZlibStream.cs (+3 -3)
📝 src/SharpCompress/Compressors/Deflate64/Deflate64Stream.cs (+1 -1)
📝 src/SharpCompress/Compressors/LZMA/LZipStream.cs (+1 -1)
📝 src/SharpCompress/Compressors/LZMA/LzmaDecoder.cs (+1 -1)
📝 src/SharpCompress/Compressors/LZMA/LzmaStream.cs (+1 -1)
📝 src/SharpCompress/Compressors/Rar/MultiVolumeReadOnlyStream.cs (+1 -1)
📝 src/SharpCompress/Compressors/Rar/RarBLAKE2spStream.cs (+1 -1)
📝 src/SharpCompress/Compressors/Rar/RarCrcStream.cs (+1 -1)
📝 src/SharpCompress/Compressors/Rar/RarStream.cs (+1 -1)

...and 15 more files

📄 Description

Consolidate compile flags for NETFRAMEWORK and NETSTANDARD

Summary of Changes

This PR consolidates scattered NETFRAMEWORK and NETSTANDARD2_0 compile flags into a single, clearer LEGACY_DOTNET constant.

What Changed

  1. Added LEGACY_DOTNET compile constant in SharpCompress.csproj

    • Defined for net48 and netstandard20 targets
    • Provides clear semantic meaning: code for legacy .NET platforms vs. modern .NET
  2. Replaced 41 occurrences across 25 files:

    • #if !NETFRAMEWORK && !NETSTANDARD2_0#if !LEGACY_DOTNET
    • #if NETFRAMEWORK || NETSTANDARD2_0#if LEGACY_DOTNET
    • #if !NETSTANDARD2_0 && !NETSTANDARD2_1 && !NETFRAMEWORK#if !LEGACY_DOTNET
    • #if NETFRAMEWORK || NETSTANDARD#if LEGACY_DOTNET
    • #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER#if !LEGACY_DOTNET
  3. Additional simplifications:

    • Removed obsolete NETCF (NET Compact Framework) flag - not a supported target
    • Fixed typo: NET60_OR_GREATERNET6_0_OR_GREATER
    • Changed NET6_0_OR_GREATERNET8_0_OR_GREATER (5 occurrences in 3 files)
    • Total: 6 additional simplifications

Benefits

  • Clearer intent: LEGACY_DOTNET communicates purpose better than framework checks
  • 🔧 Easier maintenance: Single source of truth for legacy vs. modern .NET
  • 📉 Reduced duplication: No need to repeat complex multi-framework conditions
  • 🐛 Fewer errors: Single constant reduces typos and inconsistent checks
  • 🎯 Better targeting: NET8_0_OR_GREATER aligns with actual project targets (net8.0, net10.0)

Verification

  • Analyze codebase and understand compile flag patterns
  • Add custom compile constant (LEGACY_DOTNET)
  • Replace all patterns with consolidated flag
  • Handle edge cases
  • Build all targets successfully (net48, netstandard20, net8.0, net10.0)
  • Run tests (984 tests pass on net10.0)
  • Apply additional simplifications
  • Change NET6_0_OR_GREATER to NET8_0_OR_GREATER per feedback
  • Format code with CSharpier
  • Code review (no issues)
  • Security scan (no issues)
Original prompt

This section details on the original issue you should resolve

<issue_title>Consolidate compile flags</issue_title>
<issue_description>NETFRAMEWORK and NETSTANDARD should be combined into a single compile flags to be used in code and replaced.

See if there are opportunities for other simplification</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/adamhathcock/sharpcompress/pull/1135 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 1/15/2026 **Status:** ✅ Merged **Merged:** 1/15/2026 **Merged by:** [@adamhathcock](https://github.com/adamhathcock) **Base:** `master` ← **Head:** `copilot/consolidate-compile-flags` --- ### 📝 Commits (5) - [`405dbb3`](https://github.com/adamhathcock/sharpcompress/commit/405dbb30cde5dfc488de4bb52d897f17a52c5495) Initial plan - [`cab3e7d`](https://github.com/adamhathcock/sharpcompress/commit/cab3e7d498127f779d27e42ce1f1c18c994f222c) Initial analysis: Planning compile flags consolidation - [`a5300f3`](https://github.com/adamhathcock/sharpcompress/commit/a5300f33836a25ce3a0b735acfe39a50b9027b9c) Replace NETFRAMEWORK and NETSTANDARD2_0 with LEGACY_DOTNET compile flag - [`52fef49`](https://github.com/adamhathcock/sharpcompress/commit/52fef492a5d7ab192c60075778f5b92e52dace5c) Additional simplifications: Remove NETCF, fix NET60 typo, consolidate NETCOREAPP2_1 pattern - [`d2cb792`](https://github.com/adamhathcock/sharpcompress/commit/d2cb792d91ca316080e8cfa97a0c843cf1ffa2b6) Change NET6_0_OR_GREATER to NET8_0_OR_GREATER ### 📊 Changes **35 files changed** (+58 additions, -59 deletions) <details> <summary>View changed files</summary> 📝 `src/SharpCompress/Algorithms/Adler32.cs` (+1 -1) 📝 `src/SharpCompress/Archives/SevenZip/SevenZipArchive.cs` (+1 -1) 📝 `src/SharpCompress/Common/AsyncBinaryReader.cs` (+1 -1) 📝 `src/SharpCompress/Common/EntryStream.cs` (+2 -2) 📝 `src/SharpCompress/Common/Tar/TarReadOnlySubStream.cs` (+2 -2) 📝 `src/SharpCompress/Common/Zip/WinzipAesEncryptionData.cs` (+1 -1) 📝 `src/SharpCompress/Compressors/BZip2/BZip2Stream.cs` (+1 -1) 📝 `src/SharpCompress/Compressors/Deflate/DeflateStream.cs` (+3 -3) 📝 `src/SharpCompress/Compressors/Deflate/GZipStream.cs` (+2 -2) 📝 `src/SharpCompress/Compressors/Deflate/ZlibBaseStream.cs` (+2 -2) 📝 `src/SharpCompress/Compressors/Deflate/ZlibConstants.cs` (+1 -5) 📝 `src/SharpCompress/Compressors/Deflate/ZlibStream.cs` (+3 -3) 📝 `src/SharpCompress/Compressors/Deflate64/Deflate64Stream.cs` (+1 -1) 📝 `src/SharpCompress/Compressors/LZMA/LZipStream.cs` (+1 -1) 📝 `src/SharpCompress/Compressors/LZMA/LzmaDecoder.cs` (+1 -1) 📝 `src/SharpCompress/Compressors/LZMA/LzmaStream.cs` (+1 -1) 📝 `src/SharpCompress/Compressors/Rar/MultiVolumeReadOnlyStream.cs` (+1 -1) 📝 `src/SharpCompress/Compressors/Rar/RarBLAKE2spStream.cs` (+1 -1) 📝 `src/SharpCompress/Compressors/Rar/RarCrcStream.cs` (+1 -1) 📝 `src/SharpCompress/Compressors/Rar/RarStream.cs` (+1 -1) _...and 15 more files_ </details> ### 📄 Description ## Consolidate compile flags for NETFRAMEWORK and NETSTANDARD ### Summary of Changes This PR consolidates scattered `NETFRAMEWORK` and `NETSTANDARD2_0` compile flags into a single, clearer `LEGACY_DOTNET` constant. ### What Changed 1. **Added `LEGACY_DOTNET` compile constant** in SharpCompress.csproj - Defined for `net48` and `netstandard20` targets - Provides clear semantic meaning: code for legacy .NET platforms vs. modern .NET 2. **Replaced 41 occurrences** across 25 files: - `#if !NETFRAMEWORK && !NETSTANDARD2_0` → `#if !LEGACY_DOTNET` - `#if NETFRAMEWORK || NETSTANDARD2_0` → `#if LEGACY_DOTNET` - `#if !NETSTANDARD2_0 && !NETSTANDARD2_1 && !NETFRAMEWORK` → `#if !LEGACY_DOTNET` - `#if NETFRAMEWORK || NETSTANDARD` → `#if LEGACY_DOTNET` - `#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER` → `#if !LEGACY_DOTNET` 3. **Additional simplifications**: - Removed obsolete `NETCF` (NET Compact Framework) flag - not a supported target - Fixed typo: `NET60_OR_GREATER` → `NET6_0_OR_GREATER` - **Changed `NET6_0_OR_GREATER` → `NET8_0_OR_GREATER`** (5 occurrences in 3 files) - Total: 6 additional simplifications ### Benefits - ✨ **Clearer intent**: `LEGACY_DOTNET` communicates purpose better than framework checks - 🔧 **Easier maintenance**: Single source of truth for legacy vs. modern .NET - 📉 **Reduced duplication**: No need to repeat complex multi-framework conditions - 🐛 **Fewer errors**: Single constant reduces typos and inconsistent checks - 🎯 **Better targeting**: `NET8_0_OR_GREATER` aligns with actual project targets (net8.0, net10.0) ### Verification ✅ - [x] Analyze codebase and understand compile flag patterns - [x] Add custom compile constant (`LEGACY_DOTNET`) - [x] Replace all patterns with consolidated flag - [x] Handle edge cases - [x] Build all targets successfully (net48, netstandard20, net8.0, net10.0) - [x] Run tests (984 tests pass on net10.0) - [x] Apply additional simplifications - [x] Change NET6_0_OR_GREATER to NET8_0_OR_GREATER per feedback - [x] Format code with CSharpier - [x] Code review (no issues) - [x] Security scan (no issues) <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Consolidate compile flags</issue_title> > <issue_description>NETFRAMEWORK and NETSTANDARD should be combined into a single compile flags to be used in code and replaced. > > See if there are opportunities for other simplification</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes adamhathcock/sharpcompress#1134 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 22:21:09 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1564