@@ -15,7 +15,7 @@ class RequestBuilderImplementation<TApi>(RefitSettings? refitSettings = null)
15
15
partial class RequestBuilderImplementation : IRequestBuilder
16
16
{
17
17
static readonly QueryAttribute DefaultQueryAttribute = new ( ) ;
18
- static readonly Uri BaseUri = new Uri ( "http://api" ) ;
18
+ static readonly Uri BaseUri = new ( "http://api" ) ;
19
19
readonly Dictionary < string , List < RestMethodInfoInternal > > interfaceHttpMethods ;
20
20
readonly ConcurrentDictionary <
21
21
CloseGenericMethodKey ,
@@ -641,7 +641,6 @@ bool paramsContainsCancellationToken
641
641
( basePath == "/" ? string . Empty : basePath ) + restMethod . RelativePath ;
642
642
var queryParamsToAdd = new List < KeyValuePair < string , string ? > > ( ) ;
643
643
var headersToAdd = new Dictionary < string , string ? > ( restMethod . Headers ) ;
644
- var propertiesToAdd = new Dictionary < string , object ? > ( ) ;
645
644
646
645
RestMethodParameterInfo ? parameterInfo = null ;
647
646
@@ -764,9 +763,8 @@ bool paramsContainsCancellationToken
764
763
}
765
764
766
765
//if property, add to populate into HttpRequestMessage.Properties
767
- if ( restMethod . PropertyParameterMap . TryGetValue ( i , out var propertyParameter ) )
766
+ if ( restMethod . PropertyParameterMap . ContainsKey ( i ) )
768
767
{
769
- propertiesToAdd [ propertyParameter ] = param ;
770
768
isParameterMappedToRequest = true ;
771
769
}
772
770
@@ -797,7 +795,7 @@ bool paramsContainsCancellationToken
797
795
798
796
AddHeadersToRequest ( headersToAdd , ret ) ;
799
797
800
- AddPropertiesToRequest ( restMethod , ret , propertiesToAdd ) ;
798
+ AddPropertiesToRequest ( restMethod , ret , paramList ) ;
801
799
802
800
// NB: The URI methods in .NET are dumb. Also, we do this
803
801
// UriBuilder business so that we preserve any hardcoded query
@@ -980,8 +978,7 @@ static void AddHeadersToRequest(Dictionary<string, string?> headersToAdd, HttpRe
980
978
}
981
979
}
982
980
983
- void AddPropertiesToRequest ( RestMethodInfoInternal restMethod , HttpRequestMessage ret ,
984
- Dictionary < string , object ? > propertiesToAdd )
981
+ void AddPropertiesToRequest ( RestMethodInfoInternal restMethod , HttpRequestMessage ret , object [ ] paramList )
985
982
{
986
983
// Add RefitSetting.HttpRequestMessageOptions to the HttpRequestMessage
987
984
if ( settings . HttpRequestMessageOptions != null )
@@ -996,16 +993,19 @@ void AddPropertiesToRequest(RestMethodInfoInternal restMethod, HttpRequestMessag
996
993
}
997
994
}
998
995
999
- foreach ( var property in propertiesToAdd )
996
+ for ( var i = 0 ; i < paramList . Length ; i ++ )
1000
997
{
998
+ if ( restMethod . PropertyParameterMap . TryGetValue ( i , out var propertyKey ) )
999
+ {
1001
1000
#if NET6_0_OR_GREATER
1002
1001
ret . Options . Set (
1003
- new HttpRequestOptionsKey < object ? > ( property . Key ) ,
1004
- property . Value
1002
+ new HttpRequestOptionsKey < object ? > ( propertyKey ) ,
1003
+ paramList [ i ]
1005
1004
) ;
1006
1005
#else
1007
- ret . Properties [ property . Key ] = property . Value ;
1006
+ ret . Properties [ propertyKey ] = paramList [ i ] ;
1008
1007
#endif
1008
+ }
1009
1009
}
1010
1010
1011
1011
// Always add the top-level type of the interface to the properties
0 commit comments