Skip to content

Commit 370659d

Browse files
committed
Workaround for #911, possible breaking
1 parent c650cc0 commit 370659d

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/RestSharp/Parameter.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#endregion
1818

1919
using System;
20+
using JetBrains.Annotations;
2021
using RestSharp.Validation;
2122

2223
namespace RestSharp
@@ -32,7 +33,7 @@ public Parameter(string name, object value, ParameterType type)
3233
Ensure.NotEmpty(name, nameof(name));
3334

3435
Name = name;
35-
Value = value;
36+
Value = type != ParameterType.UrlSegment ? value : value.ToString().Replace("%2F", "/").Replace("%2f", "/");
3637
Type = type;
3738
}
3839

@@ -41,12 +42,12 @@ public Parameter(string name, object value, ParameterType type)
4142
/// <summary>
4243
/// Name of the parameter
4344
/// </summary>
44-
public string Name { get; set; }
45+
public string? Name { get; set; }
4546

4647
/// <summary>
4748
/// Value of the parameter
4849
/// </summary>
49-
public object Value { get; set; }
50+
public object? Value { get; set; }
5051

5152
/// <summary>
5253
/// Type of the parameter
@@ -61,7 +62,7 @@ public Parameter(string name, object value, ParameterType type)
6162
/// <summary>
6263
/// MIME content type of the parameter
6364
/// </summary>
64-
public string ContentType { get; set; }
65+
public string? ContentType { get; set; }
6566

6667
/// <summary>
6768
/// Return a human-readable representation of this parameter
@@ -85,6 +86,7 @@ public override bool Equals(object obj)
8586
=> !ReferenceEquals(null, obj)
8687
&& (ReferenceEquals(this, obj) || obj.GetType() == this.GetType() && Equals((Parameter) obj));
8788

89+
// ReSharper disable NonReadonlyMemberInGetHashCode
8890
public override int GetHashCode()
8991
{
9092
unchecked
@@ -98,18 +100,19 @@ public override int GetHashCode()
98100
return hashCode;
99101
}
100102
}
103+
// ReSharper enable NonReadonlyMemberInGetHashCode
101104
}
102105

103106
public class XmlParameter : Parameter
104107
{
105-
public XmlParameter(string name, object value, string xmlNamespace = null) : base(name, value, ParameterType.RequestBody)
108+
public XmlParameter(string name, object value, string? xmlNamespace = null) : base(name, value, ParameterType.RequestBody)
106109
{
107110
XmlNamespace = xmlNamespace;
108111
DataFormat = DataFormat.Xml;
109112
ContentType = Serialization.ContentType.Xml;
110113
}
111114

112-
public string XmlNamespace { get; }
115+
public string? XmlNamespace { get; }
113116
}
114117

115118
public class JsonParameter : Parameter

src/RestSharp/RestClientExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,9 @@ static void ThrowIfError(IRestResponse response)
431431
}
432432

433433
/// <summary>
434-
/// Sets the <see cref="RestClient"/> to only use JSON
434+
/// Sets the <see cref="RestClient"/> to only use JSON
435435
/// </summary>
436-
/// <param name="client"></param>
436+
/// <param name="client">The client instance</param>
437437
/// <returns></returns>
438438
public static RestClient UseJson(this RestClient client)
439439
{

src/RestSharp/RestSharp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<PropertyGroup>
33
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
44
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
5+
<Nullable>enable</Nullable>
56
</PropertyGroup>
67
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
78
<DefineConstants>$(DefineConstants);NETCORE</DefineConstants>

0 commit comments

Comments
 (0)