Skip to content

[Bug]: Mark TestMetadataGenerator code with generated code attribute #4688

@dosolkowski-work

Description

@dosolkowski-work

Description

The code generated by TUnit.Core.SourceGenerator.Generators.TestMetadataGenerator is not marked with the [GeneratedCode] attribute, which makes it harder to exclude from code coverage reports.

Expected Behavior

All code generated by source generators would be marked with [GeneratedCode]. If appropriate, it could also be marked with [ExcludeFromCodeCoverage] as well.

Actual Behavior

The code, which is generated in the TUnit.Generated namespace, is not marked with any attributes to signify it is auto-generated.

Steps to Reproduce

Use <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles> in a project file to see the generated code and note it is not marked with attributes.

TUnit Version

1.13.0

.NET Version

.NET 10

Operating System

Windows

IDE / Test Runner

Other (please specify in additional context)

Error Output / Stack Trace

Additional Context

This happens during build, not during test execution, although the impact mostly affects code coverage reports.

IDE-Specific Issue?

  • I've confirmed this issue occurs when running via dotnet test or dotnet run, not just in my IDE

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions