Skip to content

Consolidate NETFRAMEWORK/NETSTANDARD compile flags into LEGACY_DOTNET#1135

Merged
adamhathcock merged 5 commits intomasterfrom
copilot/consolidate-compile-flags
Jan 15, 2026
Merged

Consolidate NETFRAMEWORK/NETSTANDARD compile flags into LEGACY_DOTNET#1135
adamhathcock merged 5 commits intomasterfrom
copilot/consolidate-compile-flags

Conversation

Copy link
Contributor

Copilot AI commented Jan 15, 2026

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.

Copilot AI and others added 3 commits January 15, 2026 17:55
Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
… NETCOREAPP2_1 pattern

Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Copilot AI changed the title [WIP] Consolidate NETFRAMEWORK and NETSTANDARD compile flags Consolidate NETFRAMEWORK/NETSTANDARD compile flags into LEGACY_DOTNET Jan 15, 2026
Copilot AI requested a review from adamhathcock January 15, 2026 18:15
@adamhathcock adamhathcock marked this pull request as ready for review January 15, 2026 18:24
Copilot AI review requested due to automatic review settings January 15, 2026 18:24
@adamhathcock
Copy link
Owner

@copilot make the dotnet 6 or greater flag be dotnet 8 or greater

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR consolidates scattered compile-time conditional directives by introducing a unified LEGACY_DOTNET constant to distinguish between legacy frameworks (net48, netstandard20) and modern .NET (net8.0, net10.0). This refactoring improves code maintainability by replacing 45+ occurrences of complex flag combinations with a single, clearly-named constant.

Changes:

  • Added LEGACY_DOTNET compile constant in the project file for net48 and netstandard20 targets
  • Replaced complex combinations of NETFRAMEWORK/NETSTANDARD flags throughout the codebase with LEGACY_DOTNET or !LEGACY_DOTNET
  • Removed obsolete NETCF (NET Compact Framework) references
  • Fixed typo in compile constant: NET60_OR_GREATERNET6_0_OR_GREATER
  • Updated Microsoft.NET.ILLink.Tasks package from 10.0.0 to 10.0.1

Reviewed changes

Copilot reviewed 33 out of 33 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/SharpCompress/SharpCompress.csproj Defines LEGACY_DOTNET constant for net48 and netstandard20 targets
src/SharpCompress/packages.lock.json Updates ILLink.Tasks package version
src/SharpCompress/Utility.cs Fixes NET6_0_OR_GREATER typo
src/SharpCompress/Readers/AbstractReader.cs Replaces NETFRAMEWORK||NETSTANDARD2_0 with LEGACY_DOTNET
src/SharpCompress/Polyfills/StringExtensions.cs Replaces NETFRAMEWORK||NETSTANDARD2_0 with LEGACY_DOTNET
src/SharpCompress/NotNullExtensions.cs Replaces NETFRAMEWORK||NETSTANDARD with LEGACY_DOTNET
src/SharpCompress/IO/SourceStream.cs Replaces !NETFRAMEWORK&&!NETSTANDARD2_0 with !LEGACY_DOTNET
src/SharpCompress/IO/SharpCompressStream.cs Replaces !NETFRAMEWORK&&!NETSTANDARD2_0 with !LEGACY_DOTNET
src/SharpCompress/IO/ReadOnlySubStream.cs Replaces !NETFRAMEWORK&&!NETSTANDARD2_0 with !LEGACY_DOTNET
src/SharpCompress/IO/ProgressReportingStream.cs Replaces !NETFRAMEWORK&&!NETSTANDARD2_0 with !LEGACY_DOTNET
src/SharpCompress/IO/BufferedSubStream.cs Replaces !NETFRAMEWORK&&!NETSTANDARD2_0 with !LEGACY_DOTNET
src/SharpCompress/Crypto/Crc32Stream.cs Replaces !NETFRAMEWORK&&!NETSTANDARD2_0 with !LEGACY_DOTNET
src/SharpCompress/Compressors/ZStandard/DecompressionStream.cs Replaces !NETSTANDARD2_0&&!NETFRAMEWORK with !LEGACY_DOTNET
src/SharpCompress/Compressors/ZStandard/CompressionStream.cs Replaces !NETSTANDARD2_0&&!NETFRAMEWORK with !LEGACY_DOTNET
src/SharpCompress/Compressors/Rar/RarStream.cs Replaces NETCOREAPP2_1_OR_GREATER||NETSTANDARD2_1_OR_GREATER with !LEGACY_DOTNET
src/SharpCompress/Compressors/Rar/RarCrcStream.cs Replaces NETCOREAPP2_1_OR_GREATER||NETSTANDARD2_1_OR_GREATER with !LEGACY_DOTNET
src/SharpCompress/Compressors/Rar/RarBLAKE2spStream.cs Replaces NETCOREAPP2_1_OR_GREATER||NETSTANDARD2_1_OR_GREATER with !LEGACY_DOTNET
src/SharpCompress/Compressors/Rar/MultiVolumeReadOnlyStream.cs Replaces NETCOREAPP2_1_OR_GREATER||NETSTANDARD2_1_OR_GREATER with !LEGACY_DOTNET
src/SharpCompress/Compressors/LZMA/LzmaStream.cs Replaces !NETFRAMEWORK&&!NETSTANDARD2_0 with !LEGACY_DOTNET
src/SharpCompress/Compressors/LZMA/LzmaDecoder.cs Replaces !NETFRAMEWORK&&!NETSTANDARD2_0 with !LEGACY_DOTNET
src/SharpCompress/Compressors/LZMA/LZipStream.cs Replaces !NETFRAMEWORK&&!NETSTANDARD2_0 with !LEGACY_DOTNET
src/SharpCompress/Compressors/Deflate64/Deflate64Stream.cs Replaces !NETFRAMEWORK&&!NETSTANDARD2_0 with !LEGACY_DOTNET
src/SharpCompress/Compressors/Deflate/ZlibStream.cs Replaces !NETFRAMEWORK&&!NETSTANDARD2_0 with !LEGACY_DOTNET
src/SharpCompress/Compressors/Deflate/ZlibConstants.cs Removes obsolete NETCF conditional compilation and updates comment
src/SharpCompress/Compressors/Deflate/ZlibBaseStream.cs Replaces !NETFRAMEWORK&&!NETSTANDARD2_0 with !LEGACY_DOTNET
src/SharpCompress/Compressors/Deflate/GZipStream.cs Replaces !NETFRAMEWORK&&!NETSTANDARD2_0 with !LEGACY_DOTNET
src/SharpCompress/Compressors/Deflate/DeflateStream.cs Replaces !NETFRAMEWORK&&!NETSTANDARD2_0 with !LEGACY_DOTNET
src/SharpCompress/Compressors/BZip2/BZip2Stream.cs Replaces !NETFRAMEWORK&&!NETSTANDARD2_0 with !LEGACY_DOTNET
src/SharpCompress/Common/Zip/WinzipAesEncryptionData.cs Replaces NETFRAMEWORK||NETSTANDARD2_0 with LEGACY_DOTNET
src/SharpCompress/Common/Tar/TarReadOnlySubStream.cs Replaces !NETFRAMEWORK&&!NETSTANDARD2_0 with !LEGACY_DOTNET
src/SharpCompress/Common/EntryStream.cs Replaces !NETFRAMEWORK&&!NETSTANDARD2_0 with !LEGACY_DOTNET
src/SharpCompress/Archives/SevenZip/SevenZipArchive.cs Replaces !NETFRAMEWORK&&!NETSTANDARD2_0 with !LEGACY_DOTNET
src/SharpCompress/Algorithms/Adler32.cs Replaces !NETSTANDARD2_0&&!NETSTANDARD2_1&&!NETFRAMEWORK with !LEGACY_DOTNET

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 15, 2026

@copilot make the dotnet 6 or greater flag be dotnet 8 or greater

Changed all 5 occurrences of NET6_0_OR_GREATER to NET8_0_OR_GREATER in 3 files (Utility.cs, AsyncBinaryReader.cs, UnsafeHelper.cs). All targets build successfully and 984 tests pass. Commit: d2cb792

@adamhathcock adamhathcock merged commit f5d83c0 into master Jan 15, 2026
5 checks passed
@adamhathcock adamhathcock deleted the copilot/consolidate-compile-flags branch January 15, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidate compile flags

2 participants