-
-
Notifications
You must be signed in to change notification settings - Fork 95
Closed
Description
Repro steps:
Build this with dotnet publish --use-current-runtime -t:Rebuild:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<PublishAot>true</PublishAot>
<TrimmerSingleWarn>false</TrimmerSingleWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="TUnit" Version="0.66.13" />
</ItemGroup>
</Project>class Tests
{
[Test]
[Arguments(1)]
public async Task TestMethod(int i)
{
await Assert.That(i).IsEqualTo(1);
}
}Results in these warnings:
Trim analysis warning IL2026: [...] Using member 'TUnit.Core.Helpers.CastHelper.Cast<Int32>(Object)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Type conversion uses reflection for custom conversions.
AOT analysis warning IL3050: [...] Using member 'TUnit.Core.Helpers.CastHelper.Cast<Int32>(Object)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. Dynamic type conversion may require runtime code generation.
Comes from this generated code:
InvokeTypedTest = async (instance, args, cancellationToken) =>
{
switch (args.Length)
{
case 1:
await instance.TestMethod(TUnit.Core.Helpers.CastHelper.Cast<int>(args[0]));
break;
default:
throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}");
}
},Metadata
Metadata
Assignees
Labels
No labels