Skip to content

Mark as IsAotCompatible#1180

Closed
mcraiha wants to merge 1 commit intoadamhathcock:masterfrom
mcraiha:IsAotCompatible
Closed

Mark as IsAotCompatible#1180
mcraiha wants to merge 1 commit intoadamhathcock:masterfrom
mcraiha:IsAotCompatible

Conversation

@mcraiha
Copy link

@mcraiha mcraiha commented Feb 2, 2026

For .NET 8 and .NET 10

I tested with dotnet build and dotnet pack from src folder. Also I ran dotnet test without issues. Tested with Ubuntu 24.04 + .NET 10 under WSL.

For .NET 8 and .NET 10
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 marks the SharpCompress library as AOT (Ahead-of-Time) compatible by adding the <IsAotCompatible>true</IsAotCompatible> property to the project file for .NET 8.0 and .NET 10.0 target frameworks. The author tested with standard build, pack, and test commands on Ubuntu 24.04 with .NET 10.

Changes:

  • Added IsAotCompatible property to the project configuration for .NET 8.0 and .NET 10.0 frameworks

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

</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net10.0' ">
<IsTrimmable>true</IsTrimmable>
<IsAotCompatible>true</IsAotCompatible>
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The library contains patterns that are problematic for Native AOT compilation. Specifically, in src/SharpCompress/Common/Zip/ZipEntry.cs line 27, the code uses header.GetType() == typeof(UnixTimeExtraField) for runtime type checking. This pattern is not AOT-friendly.

Other parts of the codebase use the proper pattern: u.Type == ExtraDataType.UnixTimeExtraField (see DirectoryEntryHeader.cs:93 and LocalEntryHeader.cs:72). The ZipEntry.cs code should be refactored to match this approach by using the Type property instead of GetType().

Additionally, the library uses Enum.IsDefined in several locations (TarArchive.Factory.cs, ZipArchive.Factory.cs, ArjHeader.cs, ZipFileEntry.cs). While Enum.IsDefined with typeof() is technically supported in .NET 8+ AOT, it does generate AOT analysis warnings in some scenarios.

Before marking this library as AOT compatible, these patterns should be addressed, and the library should be tested with PublishAot=true to ensure no AOT warnings are generated during compilation.

Suggested change
<IsAotCompatible>true</IsAotCompatible>
<IsAotCompatible>false</IsAotCompatible>

Copilot uses AI. Check for mistakes.
@adamhathcock
Copy link
Owner

Added to release, hope it works

@adamhathcock
Copy link
Owner

in master too

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.

3 participants