AyCode.Core/AyCode.Core.Serializers.Con.../AyCode.Core.Serializers.Con...

54 lines
2.8 KiB
XML

<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\AyCode.Core\AyCode.Core.csproj" />
<ProjectReference Include="..\AyCode.Core.Tests\AyCode.Core.Tests.csproj" />
<ProjectReference Include="..\AyCode.Benchmark\AyCode.Benchmark.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MemoryPack" Version="1.21.4" />
<PackageReference Include="MessagePack" Version="3.1.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<StartupObject>AyCode.Core.Serializers.Console.Program</StartupObject>
</PropertyGroup>
<Import Project="..\AyCode.Core.targets" />
<!-- AOT-mode is publish-time only.
Why conditional on $(_IsPublishing): with .NET 8+, an unconditional <PublishAot>true</PublishAot>
forces the SDK to auto-set <IsDynamicCodeSupported>false</IsDynamicCodeSupported> as a runtime
host config option — meaning even regular `dotnet build` / `dotnet run` outputs report
RuntimeFeature.IsDynamicCodeSupported == false at runtime. That makes AcSerializerCommon's
Runtime path take the reflection fallback (ctor.Invoke / PropertyInfo.GetValue) instead of
Expression.Compile during JIT testing — Release benchmark numbers measure reflection, not
compiled expressions. Restricting PublishAot to actual publish keeps JIT semantics for
`dotnet build` / `dotnet run` while preserving full AOT analysis on `dotnet publish`.
AYCODE_NATIVEAOT define moved here too — it's the publish-time #if symbol that gates out
MessagePack benchmark + STJ-based DeepEqualsViaJson validation in Program.cs (both
incompatible with AOT trim/runtime constraints). Same conditioning ensures the symbol is
defined exactly when PublishAot is in effect. -->
<PropertyGroup Condition="'$(_IsPublishing)' == 'true'">
<PublishAot>true</PublishAot>
<InvariantGlobalization>true</InvariantGlobalization>
<DefineConstants>$(DefineConstants);AYCODE_NATIVEAOT</DefineConstants>
<!-- DAMs propagation chain landed across the public Deserialize<T>/Serialize<T> entry points down to
AcSerializerCommon factory methods. Remaining trim warnings concentrate on:
(a) serialize-side polymorphism via obj.GetType() — fundamental trimmer blind spot
(b) internal Type-flow through serialize helpers (ScanValueGenerated, WritePropertyOrSkip)
(c) external dependencies (MemoryPack/MessagePack/AutoMapper/MongoDB/STJ) — out of scope
Suppress for now so builds succeed; revisit if AOT runtime issues surface beyond ctor metadata. -->
<SuppressTrimAnalysisWarnings>true</SuppressTrimAnalysisWarnings>
<TrimmerSingleWarn>false</TrimmerSingleWarn>
<JsonSerializerIsReflectionEnabledByDefault>true</JsonSerializerIsReflectionEnabledByDefault>
</PropertyGroup>
</Project>