Skip to content

Conversation

@jbrinkman
Copy link
Owner

This PR implements task 4.2 "Add namespace and type mapping capabilities" from the dotnet-api-diff spec.

Changes

  • Created the INameMapper interface for mapping namespaces and type names
  • Implemented the NameMapper class with support for:
    • One-to-many namespace mappings
    • Type name mappings
    • Auto-mapping of types with the same name but different namespaces
    • Case-sensitive or case-insensitive mapping options
  • Updated the ApiComparer class to use the NameMapper
  • Added comprehensive unit tests for the NameMapper
  • Added integration tests for the ApiComparer with NameMapper
  • Updated the Program.cs file to register the NameMapper in the DI container

Testing

All tests are passing, including the existing tests that were updated to include the NameMapper parameter.

Closes #4.2

- Add INameMapper interface for mapping namespaces and type names
- Implement NameMapper class with support for one-to-many mappings
- Integrate mapping logic into ApiComparer workflow
- Add unit tests for various mapping scenarios
- Update existing tests to work with the new NameMapper dependency

Resolves task 4.2
@jbrinkman jbrinkman requested a review from Copilot July 20, 2025 01:57
Copy link
Contributor

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 PR implements comprehensive namespace and type mapping capabilities for the dotnet-api-diff tool, enabling comparison of types across renamed namespaces and different organizational structures.

  • Adds INameMapper interface and NameMapper implementation supporting one-to-many mappings and auto-mapping
  • Integrates name mapping logic into ApiComparer to handle namespace transformations during comparisons
  • Updates dependency injection configuration to register the NameMapper service

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/DotNetApiDiff.Tests/ApiExtraction/NameMapperTests.cs Comprehensive unit tests for NameMapper functionality
tests/DotNetApiDiff.Tests/ApiExtraction/ApiComparerWithMappingTests.cs Integration tests for ApiComparer with mapping capabilities
tests/DotNetApiDiff.Tests/ApiExtraction/ApiComparerTests.cs Updated constructor to include INameMapper dependency
tests/DotNetApiDiff.Tests/ApiExtraction/ApiComparerManualTests.cs Added mock NameMapper to manual test setup
src/DotNetApiDiff/Program.cs Registered NameMapper in dependency injection container
src/DotNetApiDiff/Interfaces/INameMapper.cs Interface definition for namespace and type mapping operations
src/DotNetApiDiff/ApiExtraction/NameMapper.cs Core implementation of mapping logic with configuration support
src/DotNetApiDiff/ApiExtraction/ApiComparer.cs Integrated name mapping into type comparison workflow
.kiro/specs/dotnet-api-diff/tasks.md Updated task completion status

@jbrinkman
Copy link
Owner Author

I've addressed both code review comments:

  1. In NameMapper.cs, I extracted the string concatenation logic into a helper method CombineNamespaceParts and updated both places where it was used (in MapNamespace and MapFullTypeName methods).

  2. In ApiComparer.cs, I extracted the auto-mapping logic for finding types by simple name into a private helper method TryFindTypeBySimpleName and updated both places where it was used.

These changes improve code readability and reduce duplication while maintaining the same functionality.

Copy link
Owner Author

@jbrinkman jbrinkman left a comment

Choose a reason for hiding this comment

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

I've addressed all the code review comments by extracting helper methods to reduce code duplication. The changes maintain the same functionality while improving code readability and maintainability.

@jbrinkman jbrinkman merged commit ef0d118 into main Jul 20, 2025
9 checks passed
@jbrinkman jbrinkman deleted the feature/add-namespace-mapping branch July 20, 2025 12:26
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