Skip to content

Commit 934351a

Browse files
committed
merging
2 parents 800a390 + ea0b33a commit 934351a

File tree

22 files changed

+274
-59
lines changed

22 files changed

+274
-59
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@ Download/
3737
*.pidb
3838
*.userprefs
3939
restsharp-computed.nuspec
40+
Backup/
41+
*.htm

RestSharp.Build/RestSharp.Build.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<AssemblyName>RestSharp.Build</AssemblyName>
1313
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
1414
<FileAlignment>512</FileAlignment>
15+
<TargetFrameworkProfile />
1516
</PropertyGroup>
1617
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1718
<DebugSymbols>true</DebugSymbols>
@@ -21,6 +22,7 @@
2122
<DefineConstants>DEBUG;TRACE</DefineConstants>
2223
<ErrorReport>prompt</ErrorReport>
2324
<WarningLevel>4</WarningLevel>
25+
<Prefer32Bit>false</Prefer32Bit>
2426
</PropertyGroup>
2527
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2628
<DebugType>pdbonly</DebugType>
@@ -30,6 +32,7 @@
3032
<ErrorReport>prompt</ErrorReport>
3133
<WarningLevel>4</WarningLevel>
3234
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
35+
<Prefer32Bit>false</Prefer32Bit>
3336
</PropertyGroup>
3437
<ItemGroup>
3538
<Reference Include="Microsoft.Build.Framework" />

RestSharp.IntegrationTests/App.config

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<system.diagnostics>
44
<sources>
@@ -12,10 +12,8 @@
1212
<add name="System.Net" value="Verbose"/>
1313
</switches>
1414
<sharedListeners>
15-
<add name="System.Net"
16-
type="System.Diagnostics.TextWriterTraceListener"
17-
initializeData="network.log" />
15+
<add name="System.Net" type="System.Diagnostics.TextWriterTraceListener" initializeData="network.log"/>
1816
</sharedListeners>
1917
<trace autoflush="true"/>
2018
</system.diagnostics>
21-
</configuration>
19+
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

RestSharp.Net4/Extensions/RestClientExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static partial class RestClientExtensions
99
{
1010
public static RestResponse<dynamic> ExecuteDynamic(this IRestClient client, IRestRequest request)
1111
{
12-
var response = client.Execute(request);
12+
var response = client.Execute<dynamic>(request);
1313

1414
var generic = (RestResponse<dynamic>)response;
1515
dynamic content = SimpleJson.DeserializeObject(response.Content);

RestSharp.Net4/RestSharp.Net4.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<ErrorReport>prompt</ErrorReport>
2525
<WarningLevel>4</WarningLevel>
2626
<DocumentationFile>bin\Debug\RestSharp.xml</DocumentationFile>
27+
<NoWarn>1591</NoWarn>
2728
</PropertyGroup>
2829
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2930
<DebugType>pdbonly</DebugType>

RestSharp.Silverlight/RestSharp.Silverlight.csproj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@
1212
<RootNamespace>RestSharp.Silverlight</RootNamespace>
1313
<AssemblyName>RestSharp.Silverlight</AssemblyName>
1414
<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
15-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
15+
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
1616
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
1717
<SilverlightApplication>false</SilverlightApplication>
1818
<ValidateXaml>true</ValidateXaml>
1919
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
2020
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
2121
<RestorePackages>true</RestorePackages>
22+
<FileUpgradeFlags>
23+
</FileUpgradeFlags>
24+
<UpgradeBackupLocation>
25+
</UpgradeBackupLocation>
26+
<OldToolsVersion>4.0</OldToolsVersion>
2227
</PropertyGroup>
2328
<!-- This property group is only here to support building this project using the
2429
MSBuild 3.5 toolset. In order to work correctly with this older toolset, it needs
@@ -37,6 +42,7 @@
3742
<ErrorReport>prompt</ErrorReport>
3843
<WarningLevel>4</WarningLevel>
3944
<DocumentationFile>Bin\Debug\RestSharp.Silverlight.xml</DocumentationFile>
45+
<NoWarn>1591</NoWarn>
4046
</PropertyGroup>
4147
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
4248
<DebugType>pdbonly</DebugType>
@@ -61,8 +67,8 @@
6167
<Reference Include="System.Xml" />
6268
<Reference Include="System.Net" />
6369
<Reference Include="System.Windows.Browser" />
64-
<Reference Include="System.Xml.Linq, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
65-
<Reference Include="System.Xml.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
70+
<Reference Include="System.Xml.Linq, Version=5.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
71+
<Reference Include="System.Xml.Serialization, Version=5.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
6672
</ItemGroup>
6773
<ItemGroup>
6874
<Compile Include="..\RestSharp\Authenticators\HttpBasicAuthenticator.cs">

RestSharp.Tests/RestRequestTests.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.Runtime.InteropServices;
45
using System.Text;
56
using Xunit;
67
using System.Globalization;
8+
using Xunit.Extensions;
79

810
namespace RestSharp.Tests {
911
public class RestRequestTests {
@@ -17,5 +19,56 @@ public void Can_Add_Object_With_IntegerArray_property() {
1719
var request = new RestRequest();
1820
request.AddObject(new { Items = new int[] { 2, 3, 4 } });
1921
}
22+
23+
[Fact]
24+
public void Cannot_Set_Empty_Host_Header()
25+
{
26+
var request = new RestRequest();
27+
28+
var exception = Assert.Throws<ArgumentException>(() => request.AddHeader("Host", string.Empty));
29+
Assert.Equal("value", exception.ParamName);
30+
}
31+
32+
[Theory]
33+
[InlineData("http://localhost")]
34+
[InlineData("hostname 1234")]
35+
[InlineData("-leading.hyphen.not.allowed")]
36+
[InlineData("bad:port")]
37+
[InlineData(" no.leading.white-space")]
38+
[InlineData("no.trailing.white-space ")]
39+
[InlineData(".leading.dot.not.allowed")]
40+
[InlineData("double.dots..not.allowed")]
41+
[InlineData(".")]
42+
[InlineData(".:2345")]
43+
[InlineData(":5678")]
44+
[InlineData("")]
45+
[InlineData("foo:bar:baz")]
46+
public void Cannot_Set_Invalid_Host_Header(string value)
47+
{
48+
var request = new RestRequest();
49+
50+
var exception = Assert.Throws<ArgumentException>(() => request.AddHeader("Host", value));
51+
Assert.Equal("value", exception.ParamName);
52+
}
53+
54+
[Theory]
55+
[InlineData("localhost")]
56+
[InlineData("localhost:1234")]
57+
[InlineData("host.local")]
58+
[InlineData("anotherhost.local:2345")]
59+
[InlineData("www.w3.org")]
60+
[InlineData("www.w3.org:3456")]
61+
[InlineData("8.8.8.8")]
62+
[InlineData("a.1.b.2")]
63+
[InlineData("10.20.30.40:1234")]
64+
[InlineData("0host")]
65+
[InlineData("hypenated-hostname")]
66+
[InlineData("multi--hyphens")]
67+
public void Can_Set_Valid_Host_Header(string value)
68+
{
69+
var request = new RestRequest();
70+
71+
Assert.DoesNotThrow(() => request.AddHeader("Host", value));
72+
}
2073
}
2174
}

RestSharp.Tests/RestSharp.Tests.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
<ErrorReport>prompt</ErrorReport>
4545
<WarningLevel>4</WarningLevel>
4646
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
47+
<Prefer32Bit>false</Prefer32Bit>
4748
</PropertyGroup>
4849
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
4950
<DebugType>pdbonly</DebugType>
@@ -55,6 +56,7 @@
5556
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
5657
<DocumentationFile>
5758
</DocumentationFile>
59+
<Prefer32Bit>false</Prefer32Bit>
5860
</PropertyGroup>
5961
<ItemGroup>
6062
<Reference Include="Microsoft.Build.Framework" />
@@ -74,9 +76,8 @@
7476
<SpecificVersion>False</SpecificVersion>
7577
<HintPath>..\packages\xunit.extensions.1.9.2\lib\net20\xunit.extensions.dll</HintPath>
7678
</Reference>
77-
<Reference Include="xunit.runner.tdnet, Version=1.8.0.1545, Culture=neutral, PublicKeyToken=null">
78-
<SpecificVersion>False</SpecificVersion>
79-
<HintPath>..\packages\xunit.1.9.0.1566\lib\xunit.runner.tdnet.dll</HintPath>
79+
<Reference Include="xunit.runner.tdnet">
80+
<HintPath>..\packages\xunit.1.9.2\lib\net20\xunit.runner.tdnet.dll</HintPath>
8081
</Reference>
8182
</ItemGroup>
8283
<ItemGroup>

RestSharp.Tests/SampleClasses/misc.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public class PersonForXml
4848
public Order Order { get; set; }
4949

5050
public Disposition Disposition { get; set; }
51+
public Band FavoriteBand { get; set; }
52+
public class Band
53+
{
54+
public string Name { get; set; }
55+
}
5156

5257
}
5358

RestSharp.Tests/XmlAttributeDeserializerTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,18 @@ public void Can_Deserialize_Custom_Formatted_Date()
290290

291291
Assert.Equal(date, output.StartDate);
292292
}
293+
[Fact]
294+
public void Can_Deserialize_Nested_Class()
295+
{
296+
var doc = CreateElementsXml();
297+
var response = new RestResponse { Content = doc };
298+
299+
var d = new XmlAttributeDeserializer();
300+
var p = d.Deserialize<PersonForXml>(response);
293301

302+
Assert.NotNull(p.FavoriteBand);
303+
Assert.Equal("Goldfinger",p.FavoriteBand.Name);
304+
}
294305
[Fact]
295306
public void Can_Deserialize_Elements_On_Default_Root()
296307
{
@@ -839,6 +850,10 @@ private static string CreateElementsXml()
839850
}
840851
root.Add(friends);
841852

853+
root.Add(new XElement("FavoriteBand",
854+
new XElement("Name", "Goldfinger")
855+
));
856+
842857
doc.Add(root);
843858
return doc.ToString();
844859
}

0 commit comments

Comments
 (0)