Skip to content

Commit 1ffa419

Browse files
Improving test run (#1663)
* Improving test run * Use custom TaskFactory * Fixing warnings * Fixing more warnings * Moved XML serializer out * Use non-default XML serializer * Added a guard against using content type with no body * Use Xml serializer in tests where it should be used * Removed unused and breaking ref * Remove the Formatting assembly reference
1 parent f982e04 commit 1ffa419

File tree

95 files changed

+785
-900
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+785
-900
lines changed

RestSharp.sln

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestSharp.InteractiveTests"
2727
EndProject
2828
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestSharp.Serializers.Xml.Tests", "test\RestSharp.Serializers.Xml.Tests\RestSharp.Serializers.Xml.Tests.csproj", "{E6D94C12-9AD7-46E6-AB62-3676F25FDE51}"
2929
EndProject
30+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestSharp.Serializers.Xml", "src\RestSharp.Serializers.Xml\RestSharp.Serializers.Xml.csproj", "{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}"
31+
EndProject
3032
Global
3133
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3234
Debug.Appveyor|Any CPU = Debug.Appveyor|Any CPU
@@ -316,6 +318,36 @@ Global
316318
{E6D94C12-9AD7-46E6-AB62-3676F25FDE51}.Release|x64.Build.0 = Release|Any CPU
317319
{E6D94C12-9AD7-46E6-AB62-3676F25FDE51}.Release|x86.ActiveCfg = Release|Any CPU
318320
{E6D94C12-9AD7-46E6-AB62-3676F25FDE51}.Release|x86.Build.0 = Release|Any CPU
321+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug.Appveyor|Any CPU.ActiveCfg = Debug|Any CPU
322+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug.Appveyor|Any CPU.Build.0 = Debug|Any CPU
323+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug.Appveyor|ARM.ActiveCfg = Debug|Any CPU
324+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug.Appveyor|ARM.Build.0 = Debug|Any CPU
325+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug.Appveyor|Mixed Platforms.ActiveCfg = Debug|Any CPU
326+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug.Appveyor|Mixed Platforms.Build.0 = Debug|Any CPU
327+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug.Appveyor|x64.ActiveCfg = Debug|Any CPU
328+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug.Appveyor|x64.Build.0 = Debug|Any CPU
329+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug.Appveyor|x86.ActiveCfg = Debug|Any CPU
330+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug.Appveyor|x86.Build.0 = Debug|Any CPU
331+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
332+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug|Any CPU.Build.0 = Debug|Any CPU
333+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug|ARM.ActiveCfg = Debug|Any CPU
334+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug|ARM.Build.0 = Debug|Any CPU
335+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
336+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
337+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug|x64.ActiveCfg = Debug|Any CPU
338+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug|x64.Build.0 = Debug|Any CPU
339+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug|x86.ActiveCfg = Debug|Any CPU
340+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Debug|x86.Build.0 = Debug|Any CPU
341+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Release|Any CPU.ActiveCfg = Release|Any CPU
342+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Release|Any CPU.Build.0 = Release|Any CPU
343+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Release|ARM.ActiveCfg = Release|Any CPU
344+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Release|ARM.Build.0 = Release|Any CPU
345+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
346+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Release|Mixed Platforms.Build.0 = Release|Any CPU
347+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Release|x64.ActiveCfg = Release|Any CPU
348+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Release|x64.Build.0 = Release|Any CPU
349+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Release|x86.ActiveCfg = Release|Any CPU
350+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662}.Release|x86.Build.0 = Release|Any CPU
319351
EndGlobalSection
320352
GlobalSection(SolutionProperties) = preSolution
321353
HideSolutionNode = FALSE
@@ -332,5 +364,6 @@ Global
332364
{997AEFE5-D7D4-4033-A31A-07F476D6FE5D} = {1C42C435-8826-4044-8775-A1DA40EF4866}
333365
{6D7D1D60-4473-4C52-800C-9B892C6640A5} = {9051DDA0-E563-45D5-9504-085EBAACF469}
334366
{E6D94C12-9AD7-46E6-AB62-3676F25FDE51} = {9051DDA0-E563-45D5-9504-085EBAACF469}
367+
{4A35B1C5-520D-4267-BA70-2DCEAC0A5662} = {8C7B43EB-2F93-483C-B433-E28F9386AD67}
335368
EndGlobalSection
336369
EndGlobal

src/RestSharp.Serializers.NewtonsoftJson/JsonNetSerializer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public class JsonNetSerializer : IRestSerializer {
4848
public string? Serialize(Parameter bodyParameter) => Serialize(bodyParameter.Value);
4949

5050
public T? Deserialize<T>(RestResponse response) {
51+
if (response.Content == null)
52+
throw new DeserializationException(response, new InvalidOperationException("Response content is null"));
5153
using var reader = new JsonTextReader(new StringReader(response.Content)) { CloseInput = true };
5254

5355
return _serializer.Deserialize<T>(reader);

src/RestSharp.Serializers.NewtonsoftJson/RestSharp.Serializers.NewtonsoftJson.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<ItemGroup>
3-
<PackageReference Include="Newtonsoft.Json" Version="[12.0,)" />
3+
<PackageReference Include="Newtonsoft.Json" Version="[12.0.1,)" />
44
</ItemGroup>
55
<ItemGroup>
66
<ProjectReference Include="..\RestSharp\RestSharp.csproj" />

src/RestSharp/Serializers/DeserializeAsAttribute.cs renamed to src/RestSharp.Serializers.Xml/DeserializeAsAttribute.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
namespace RestSharp.Serializers;
1+
// ReSharper disable once CheckNamespace
2+
namespace RestSharp.Serializers;
23

34
/// <summary>
45
/// Allows control how class and property names and values are deserialized by XmlAttributeDeserializer
@@ -8,7 +9,7 @@ public sealed class DeserializeAsAttribute : Attribute {
89
/// <summary>
910
/// The name to use for the serialized element
1011
/// </summary>
11-
public string Name { get; set; }
12+
public string? Name { get; set; }
1213

1314
/// <summary>
1415
/// Sets if the property to Deserialize is an Attribute or Element (Default: false)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<RootNamespace>RestSharp.Serializers.Xml</RootNamespace>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<ProjectReference Include="..\RestSharp\RestSharp.csproj" />
9+
</ItemGroup>
10+
11+
</Project>

src/RestSharp/Serializers/SerializeAsAttribute.cs renamed to src/RestSharp.Serializers.Xml/SerializeAsAttribute.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Globalization;
22
using RestSharp.Extensions;
33

4+
// ReSharper disable once CheckNamespace
45
namespace RestSharp.Serializers;
56

67
/// <summary>

src/RestSharp/Serializers/Xml/XmlAttributeDeserializer.cs renamed to src/RestSharp.Serializers.Xml/XmlAttributeDeserializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace RestSharp.Serializers.Xml;
66

77
public class XmlAttributeDeserializer : XmlDeserializer {
8-
protected override object? GetValueFromXml(XElement root, XName name, PropertyInfo prop, bool useExactName) {
8+
protected override object? GetValueFromXml(XElement? root, XName? name, PropertyInfo prop, bool useExactName) {
99
var isAttribute = false;
1010

1111
//Check for the DeserializeAs attribute on the property
@@ -18,7 +18,7 @@ public class XmlAttributeDeserializer : XmlDeserializer {
1818

1919
if (!isAttribute) return base.GetValueFromXml(root, name, prop, useExactName);
2020

21-
var attributeVal = GetAttributeByName(root, name, useExactName);
21+
var attributeVal = GetAttributeByName(root!, name!, useExactName);
2222

2323
return attributeVal?.Value ?? base.GetValueFromXml(root, name, prop, useExactName);
2424
}

0 commit comments

Comments
 (0)