Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 4, 2025

The TUnit.Core package was not automatically pulling in the Polyfill package for consuming test projects targeting netstandard2.0, requiring users to manually add the package or explicitly set EnableTUnitPolyfills=true.

Problem

When developers created test projects targeting netstandard2.0 and referenced TUnit.Core, they would encounter missing method exceptions or compilation errors because modern .NET APIs used by TUnit were not available in netstandard2.0 without the Polyfill package.

Solution

Modified the condition in TUnit.Core.targets from:

Condition="'$(EnableTUnitPolyfills)' == 'true' and '$(TargetFramework)' == 'netstandard2.0'"

To:

Condition="'$(EnableTUnitPolyfills)' != 'false' and '$(TargetFramework)' == 'netstandard2.0'"

This change makes the Polyfill package included by default for netstandard2.0 targets while preserving the ability to opt out by setting <EnableTUnitPolyfills>false</EnableTUnitPolyfills> in the project file.

Testing

  • Verified Polyfill package is automatically included for netstandard2.0 projects
  • Confirmed opt-out behavior works correctly when EnableTUnitPolyfills is set to false
  • Ensured net8.0+ projects don't get polyfills (existing correct behavior)
  • Validated no breaking changes to existing functionality

Fixes #2744.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Make sure the TUnit.Core package pulls in the Polyfill package to consuming test projects if using the netstandard2.0 variant Fix: Enable Polyfill package by default for netstandard2.0 in TUnit.Core Aug 4, 2025
Copilot AI requested a review from thomhurst August 4, 2025 11:32
Copilot finished work on behalf of thomhurst August 4, 2025 11:32
@thomhurst thomhurst marked this pull request as ready for review August 4, 2025 11:36
@thomhurst thomhurst merged commit c02e307 into main Aug 4, 2025
1 check passed
@thomhurst thomhurst deleted the copilot/fix-2744 branch August 4, 2025 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make sure the TUnit.Core package pulls in the Polyfill package to consuming test projects if using the netstandard2.0 variant

2 participants