Skip to content

Simplify IParamConverterManager to single two-parameter GetConverter method#94

Merged
twogood merged 5 commits intomainfrom
copilot/fix-93
Aug 8, 2025
Merged

Simplify IParamConverterManager to single two-parameter GetConverter method#94
twogood merged 5 commits intomainfrom
copilot/fix-93

Conversation

Copy link
Contributor

Copilot AI commented Aug 6, 2025

This PR simplifies the IParamConverterManager interface by removing the single-parameter GetConverter overloads and keeping only the two-parameter method that requires both Type and ParameterInfo.

Background

Following feedback on the previous implementation, the interface has been streamlined to eliminate confusion and ensure consistency. The IParamConverter.CanConvert method now requires both parameters (non-nullable), so having single-parameter overloads in the manager was creating unnecessary complexity.

Changes

The IParamConverterManager interface has been simplified from:

public interface IParamConverterManager
{
    IParamConverter GetConverter(ParameterInfo parameterInfo);
    IParamConverter GetConverter(Type type);
    IParamConverter GetConverter(Type type, ParameterInfo parameterInfo);
}

to:

public interface IParamConverterManager
{
    IParamConverter GetConverter(Type type, ParameterInfo parameterInfo);
}

Key Improvements

  • Single consistent API: Only one GetConverter method that requires both type and parameter information
  • Eliminates confusion: No ambiguity about which overload to use
  • Cleaner implementation: Removed SyntheticParameterInfo class that was only used for backward compatibility
  • Updated usages: All calling code now explicitly provides both type and parameter information

Updated Usage

All code that previously used single-parameter overloads has been updated:

// Before (removed)
var converter = manager.GetConverter(parameterInfo);
var converter = manager.GetConverter(typeof(DateTime));

// After (unified approach)
var converter = manager.GetConverter(parameterInfo.ParameterType, parameterInfo);
var converter = manager.GetConverter(typeof(DateTime), parameterInfo);

This change ensures that parameter converters always have access to complete context information while maintaining a clean, simple API.

Fixes #93.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: twogood <189982+twogood@users.noreply.github.com>
Copilot AI changed the title [WIP] Add back support for ParameterInfo in IParamConverter Add back support for ParameterInfo in IParamConverter Aug 6, 2025
Copilot AI requested a review from twogood August 6, 2025 11:14
Co-authored-by: twogood <189982+twogood@users.noreply.github.com>
Copilot AI changed the title Add back support for ParameterInfo in IParamConverter Update IParamConverter to require non-nullable ParameterInfo Aug 6, 2025
Copilot AI requested a review from twogood August 6, 2025 11:33
@twogood
Copy link
Owner

twogood commented Aug 6, 2025

@copilot remove the existing GetConverter(Type type) and GetConverter(ParameterInfo parameterInfo) and only have the new method with two parameters.

Co-authored-by: twogood <189982+twogood@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 6, 2025

@copilot remove the existing GetConverter(Type type) and GetConverter(ParameterInfo parameterInfo) and only have the new method with two parameters.

Removed the single-parameter GetConverter(Type type) and GetConverter(ParameterInfo parameterInfo) methods from IParamConverterManager, keeping only the two-parameter version. Also removed the SyntheticParameterInfo class since it's no longer needed. Updated all usages in RequestHandler and tests. Commit 8e8b5f4.

Copilot AI changed the title Update IParamConverter to require non-nullable ParameterInfo Simplify IParamConverterManager to single two-parameter GetConverter method Aug 6, 2025
@twogood twogood marked this pull request as ready for review August 8, 2025 06:17
@twogood twogood merged commit 6520970 into main Aug 8, 2025
8 checks passed
@twogood twogood deleted the copilot/fix-93 branch August 8, 2025 06:17
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.

Add back support for ParameterInfo in IParamConverter

2 participants