Skip to content

Conversation

@thomhurst
Copy link
Owner

Summary

  • Updates NUnit migration code fixers to use the new inline properties on [Arguments] attribute (added in feat: add DisplayName, Skip, and Categories support for parameterized tests #4214)
  • Maps NUnit TestCase properties to TUnit inline properties instead of generating separate attributes:
    • TestNameDisplayName (inline on [Arguments])
    • CategoryCategories array (inline on [Arguments])
    • Ignore/IgnoreReasonSkip (inline on [Arguments])
  • Properties that don't have TUnit inline equivalents still generate separate attributes:
    • Description[Property("Description", "...")]
    • Author[Property("Author", "...")]
    • Explicit[Explicit]

Example Migration

Before (NUnit):

[TestCase(1, TestName = "Test One", Category = "Unit", Ignore = "WIP")]
[TestCase(2, TestName = "Test Two", Category = "Integration")]
public void MyTest(int value) { }

After (TUnit):

[Test]
[Arguments(1, DisplayName = "Test One", Skip = "WIP", Categories = ["Unit"])]
[Arguments(2, DisplayName = "Test Two", Categories = ["Integration"])]
public void MyTest(int value) { }

Test plan

  • All 44 NUnit migration analyzer tests pass
  • Added tests for Ignore → Skip inline conversion
  • Added tests for IgnoreReason → Skip inline conversion
  • Added comprehensive test with all inline properties (DisplayName, Skip, Categories)
  • Added test with all properties (inline + separate attributes)

🤖 Generated with Claude Code

thomhurst and others added 2 commits January 2, 2026 22:03
…attribute

- Update NUnitMigrationCodeFixProvider to map TestName → DisplayName inline on [Arguments]
- Update NUnitMigrationCodeFixProvider to map Category → Categories array inline on [Arguments]
- Update NUnitExpectedResultRewriter to use inline properties with correct argument ordering
- Remove separate [DisplayName] and [Category] attribute generation from NUnitTestCasePropertyRewriter
- Update tests to expect inline property format

This aligns the migration code fixers with the new inline property support added
in PR #4214 for ArgumentsAttribute.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add test for Ignore → Skip inline property conversion
- Add test for IgnoreReason → Skip inline property conversion
- Add test with all inline properties (DisplayName, Skip, Categories)
- Add comprehensive test with all properties (inline + separate attributes)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copilot AI review requested due to automatic review settings January 2, 2026 22:08
@thomhurst
Copy link
Owner Author

Summary

This PR enhances the NUnit migration code fixer to handle TestName, Category, and Ignore properties inline on the [Arguments] attribute instead of generating separate attributes.

Critical Issues

None found ✅

Suggestions

Consider argument ordering edge case

In NUnitExpectedResultRewriter.cs:442-525, the code ensures proper ordering: positional args → ExpectedResult → named properties. However, in NUnitMigrationCodeFixProvider.cs:84-136, there's no similar separation of positional vs named arguments before adding the Categories array at the end.

While this likely works in practice (since Categories is added last and C# allows named arguments after positional ones), for consistency with the NUnitExpectedResultRewriter approach, consider explicitly separating positional and named arguments in ConvertTestCaseArguments as well.

Test coverage is excellent

The new test cases comprehensively cover:

  • Individual properties (TestName, Category, Ignore, IgnoreReason)
  • Multiple properties combined
  • Comprehensive scenario with all properties

This demonstrates good testing discipline.

Verdict

APPROVE - No critical issues. The implementation correctly handles inline property conversion with comprehensive test coverage. The suggestion is a minor consistency improvement, not a blocking issue.

@thomhurst thomhurst enabled auto-merge (squash) January 2, 2026 22:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request enhances the NUnit to TUnit migration code fixers by utilizing the new inline properties on the [Arguments] attribute (added in #4214). Instead of generating separate attributes for DisplayName, Category, and Skip, these are now specified as inline named properties on each [Arguments] attribute, resulting in cleaner and more concise migrated code.

Key Changes:

  • TestCase property TestName is now converted to inline DisplayName property on [Arguments]
  • TestCase property Category is now converted to inline Categories array property on [Arguments]
  • TestCase properties Ignore and IgnoreReason are now converted to inline Skip property on [Arguments]

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
TUnit.Analyzers.Tests/NUnitMigrationAnalyzerTests.cs Updated existing tests to reflect inline property conversion and added comprehensive new tests for Ignore→Skip, IgnoreReason→Skip, and all inline properties combined
TUnit.Analyzers.CodeFixers/NUnitTestCasePropertyRewriter.cs Removed extraction and generation logic for TestName/Category properties, updated documentation to clarify these are now handled inline
TUnit.Analyzers.CodeFixers/NUnitMigrationCodeFixProvider.cs Implemented inline conversion of TestName→DisplayName, Category→Categories array, and Ignore/IgnoreReason→Skip within the Arguments attribute
TUnit.Analyzers.CodeFixers/NUnitExpectedResultRewriter.cs Implemented the same inline property conversions for TestCase attributes with ExpectedResult, maintaining proper argument ordering (positional → ExpectedResult → named properties)

@thomhurst thomhurst disabled auto-merge January 2, 2026 22:32
@thomhurst thomhurst merged commit 58474b8 into main Jan 2, 2026
18 of 19 checks passed
@thomhurst thomhurst deleted the fix/nunit-migration-inline-properties branch January 2, 2026 22:32
This was referenced Jan 5, 2026
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.

2 participants