Skip to content

AOT Compatibility Support | AOT 兼容性支持 #2

@natsurainko

Description

@natsurainko

AOT 兼容性支持

遇到的问题

使用 <PublishAot>true</PublishAot> 发布编译 ConnectX.ClientConsole 时遇到客户端无法正常连接,
表现为 Connect.Server 在连接后一段时间出现 Timeout,且 ConnectX.ClientConsole 输出中缺失部分连接信息

暂不确定 Connect.Server 的 AOT 兼容性

Image

可能的异常

Serilog 部分地方不兼容,例如 {@info}

8>C:\Users\Natsurainko\.nuget\packages\serilog.settings.configuration\9.0.0\lib\net9.0\Serilog.Settings.Configuration.dll(0,0): 警告 IL2104: Assembly 'Serilog.Settings.Configuration' produced trim warnings. For more information see https://aka.ms/il2104
8>C:\Users\Natsurainko\.nuget\packages\serilog.settings.configuration\9.0.0\lib\net9.0\Serilog.Settings.Configuration.dll(0,0): 警告 IL2104: Assembly 'Serilog.Settings.Configuration' produced trim warnings. For more information see https://aka.ms/il2104
8>C:\Users\Natsurainko\.nuget\packages\serilog\4.2.0\lib\net9.0\Serilog.dll(0,0): 警告 IL2104: Assembly 'Serilog' produced trim warnings. For more information see https://aka.ms/il2104
8>C:\Users\Natsurainko\.nuget\packages\serilog.settings.configuration\9.0.0\lib\net9.0\Serilog.Settings.Configuration.dll(0,0): 警告 IL3053: Assembly 'Serilog.Settings.Configuration' produced AOT analysis warnings.

其他编译器警告

8>D:\Git\ConnectX\ConnectX.ClientConsole\Program.cs(16,0): 警告 IL2026: ConnectX.ClientConsole.Program.GetSettings(IConfiguration): Using member 'Microsoft.Extensions.Configuration.ConfigurationBinder.GetValue<String>(IConfiguration,String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. In case the type is non-primitive, the trimmer cannot statically analyze the object's type so its members may be trimmed.
8>D:\Git\ConnectX\ConnectX.ClientConsole\Program.cs(17,0): 警告 IL2026: ConnectX.ClientConsole.Program.GetSettings(IConfiguration): Using member 'Microsoft.Extensions.Configuration.ConfigurationBinder.GetValue<UInt16>(IConfiguration,String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. In case the type is non-primitive, the trimmer cannot statically analyze the object's type so its members may be trimmed.
8>D:\Git\ConnectX\ConnectX.Client\Route\RouterPacketDispatcher.cs(96,0): 警告 IL3050: ConnectX.Client.Route.RouterPacketDispatcher.OnReceiveTransDatagram(P2PPacket): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.
8>ILC(0,0): 警告 IL3002: Serilog.Settings.Configuration.Assemblies.AssemblyFinder.Auto(): Using member 'Microsoft.Extensions.DependencyModel.DependencyContext.Default.get' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.
8>C:\Users\Natsurainko\.nuget\packages\memorypack.core\1.21.4\lib\net8.0\MemoryPack.Core.dll(0,0): 警告 IL2104: Assembly 'MemoryPack.Core' produced trim warnings. For more information see https://aka.ms/il2104
8>C:\Users\Natsurainko\.nuget\packages\memorypack.core\1.21.4\lib\net8.0\MemoryPack.Core.dll(0,0): 警告 IL3053: Assembly 'MemoryPack.Core' produced AOT analysis warnings.
8>D:\Git\ConnectX\Hive.Framework\Hive.Codec.Shared\DefaultPacketIdMapper.cs(91,0): 警告 IL2026: Hive.Codec.Shared.DefaultPacketIdMapper.Scan(Assembly): Using member 'System.Reflection.Assembly.GetTypes()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed.
8>ILC(0,0): 警告 IL3000: Serilog.Settings.Configuration.Assemblies.DllScanningAssemblyFinder.FindAssembliesContainingName(String): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.
8>ILC(0,0): 警告 IL3002: Microsoft.Extensions.DependencyModel.DependencyContext..cctor(): Using member 'Microsoft.Extensions.DependencyModel.DependencyContext.LoadDefault()' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions