Skip to content

Conversation

@jbrinkman
Copy link
Owner

This PR resolves GitHub Issue #40 where type mappings weren't working correctly for generic parameters and equivalent signatures.

Problem

Type mappings like "RedisValue": "ValkeyValue" were configured but still showing as differences in the comparison results. The issue was that equivalent signatures should not appear as differences at all when types are properly mapped.

Root Cause

The issue had two parts:

  1. Modified types: Even when types were mapped equivalents, CalculateTypeChanges was comparing raw signatures without considering type mappings
  2. Added types: The logic for detecting "added" types was backwards - it tried to map new type names back to old types instead of checking if old types map TO new types

Solution

Key Changes

  • Enhanced ApiComparer: Fixed logic to properly check if old types map TO new types for added/removed detection
  • Modified DifferenceCalculator: Added optional signaturesEquivalent parameter to CalculateTypeChanges method
  • Signature Equivalence: When signatures are equivalent after applying type mappings, no difference is created
  • Comprehensive Testing: Added unit tests to validate type mapping scenarios

Interface Changes

  • IDifferenceCalculator.CalculateTypeChanges now accepts optional signaturesEquivalent parameter
  • Maintains backward compatibility with default value of false

Results

  • Eliminated false positives: Mapped types like RedisValue vs ValkeyValue no longer show as differences
  • Reduced noise: Differences reduced from 902 to 886 (16 fewer false positives)
  • Comprehensive coverage: Type mappings now work correctly for:
    • Basic type equivalence
    • Constructor signatures
    • Generic interface parameters
    • Method parameters and return types
  • All tests passing: 412/412 unit tests pass

Validation

Tested with real-world scenario comparing StackExchange.Redis vs Valkey.Glide assemblies:

  • Before: 902 differences (100 added, 791 removed, 11 modified)
  • After: 886 differences (95 added, 791 removed, 0 modified)

The mapped types (ValkeyValue, ValkeyKey, ValkeyResult, etc.) no longer appear anywhere in the differences report, confirming the fix works correctly.

Fixes #40

This commit resolves GitHub Issue #40 where type mappings weren't working
correctly for generic parameters and equivalent signatures.

Key changes:
- Enhanced ApiComparer to properly handle type mapping for added/removed types
- Modified DifferenceCalculator to accept signature equivalence parameter
- Fixed logic to check if old types map TO new types (not reverse)
- Added comprehensive unit tests for type mapping scenarios

Results:
- Eliminated false positives for mapped types (RedisValue vs ValkeyValue)
- Reduced differences from 902 to 886 (16 fewer false positives)
- Type mappings now work correctly for constructors and generic interfaces
- All 412 tests passing

Fixes #40
@jbrinkman jbrinkman self-assigned this Jul 30, 2025
Signed-off-by: jbrinkman <joe.brinkman@improving.com>
Signed-off-by: jbrinkman <joe.brinkman@improving.com>
Signed-off-by: jbrinkman <joe.brinkman@improving.com>
@jbrinkman jbrinkman merged commit 6bbeda1 into main Jul 31, 2025
7 of 8 checks passed
@jbrinkman jbrinkman deleted the fix/type-mapping-issue-40 branch July 31, 2025 01:38
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.

Type mapping not applied to generic type parameters in signatures

2 participants