Support Native AOT#1857
Conversation
|
There may be non statically analyzable issues, but it should be good enough to annotate he project as AOT-safe. |
There was a problem hiding this comment.
Pull request overview
This PR updates FluentFTP to be compatible with Native AOT / trimming scenarios (per #1856) by removing or constraining reflection-heavy code paths and adding the necessary trimming annotations and package metadata.
Changes:
- Mark the NuGet package as AOT compatible and add trimming annotations for
CustomStreamto satisfyActivator.CreateInstance(Type)requirements. - Remove reflection-based argument printing to avoid trim/AOT warnings, and add a targeted
ToString()override to keep AutoDetect logging useful. - Restrict the
FtpSslStreamreflection-based close-notify hack tonet462/netstandard2.0, while usingSslStream.ShutdownAsyncon newer TFMs.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| FluentFTP/Streams/FtpSslStream.cs | Gates reflection-based SSL close-notify implementation to older TFMs for AOT/trimming compatibility. |
| FluentFTP/Model/Functions/FtpAutoDetectConfig.cs | Adds ToString() to improve log output without reflection. |
| FluentFTP/Model/FtpConfig.cs | Adds DynamicallyAccessedMembers annotation to support trimming-safe custom stream instantiation. |
| FluentFTP/Helpers/ValuePrinter.cs | Removes reflection-based object property printing to avoid AOT-related warnings. |
| FluentFTP/FluentFTP.csproj | Declares the package as AOT compatible. |
| FluentFTP/Client/BaseClient/Logger.cs | Removes MethodBase.GetCurrentMethod() usage to avoid trimming warnings. |
Comments suppressed due to low confidence (1)
FluentFTP/Streams/FtpSslStream.cs:103
- The XML doc comment for
SslDirectCallsays "Valid only on .NET Framework", but this code is now also compiled forNETSTANDARD2_0(and contains aNETSTANDARDbranch). Please update the comment to avoid misleading consumers/maintainers.
/// <summary>
/// Reflection hack to issue an SSL Close Notify Alert to cleanly shutdown an SSL session
/// Valid only on .NET Framework
/// </summary>
💡 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>
| // Do not use "None" - it can connect to TLS13, but Session Resume won't work, so a successful AutoDetect will be a false truth. | ||
| }; | ||
|
|
||
| public override string ToString() { |
| return "null"; | ||
| } | ||
|
|
||
| var type = obj.GetType(); |
There was a problem hiding this comment.
use #if AOT sections to keep older code for older platforms. dont delete.
|
Awaiting changes to be made before I can merge @0x5bfa |
Resolves #1856
These were the new AOT-related issues, just FYI: