Generic AutoFixture test sources emit IL2091 during native publishing

Open Beginner friendly
#7,452 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
testing

Research direction

The warnings come from the generic data-source attributes in tests/TUnit.TestProject/Attributes/AutoFixtureSourceGeneratorAttribute.cs, at lines 3 and 11. Start by reading those attributes and the DataSourceGeneratorAttribute base classes they derive from, to see which type parameters need the DynamicallyAccessedMembers(PublicConstructors) annotation. Reproduce with the dotnet publish -p:Aot=true command from the issue. Done means IL2091 no longer appears in the native publish output for these attributes.

Written by the indexing model from the issue text.

Description

bug P3

Summary

Publishing the test application with Native AOT emits IL2091 warnings for the generic AutoFixture data-source attributes. Their type parameters do not carry the public-constructor annotations required by their DataSourceGeneratorAttribute base classes, making unrelated native validation noisy and potentially allowing fixture types to be trimmed incorrectly.

Reproduction

At commit 309ed46a59, run:

dotnet publish tests/TUnit.TestProject -c Release -f net10.0 -p:Aot=true --use-current-runtime

Expected and actual

The generic parameters in tests/TUnit.TestProject/Attributes/AutoFixtureSourceGeneratorAttribute.cs:3 and :11 should satisfy the base classes' trimming contracts. Instead, IL2091 reports missing DynamicallyAccessedMemberTypes.PublicConstructors on T and T1/T2/T3.

Environment

.NET SDK 10.0.403, .NET native compiler 10.0.14, macOS arm64.

Add the required annotations to these test fixture attributes and verify that these IL2091 warnings disappear during native publishing.

Dominant language
C#
Stars
4k
Forks
139
Avg merge
9h 6m
Merged PRs (30d)
282

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from thomhurst/TUnit

All issues in thomhurst/TUnit

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.