Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .nuget/RestSharp.Build.dll
Binary file not shown.
Binary file modified .nuget/Signed/RestSharp.Build.dll
Binary file not shown.
277 changes: 277 additions & 0 deletions RestSharp.2015.sln

Large diffs are not rendered by default.

451 changes: 451 additions & 0 deletions RestSharp.All.sln

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions RestSharp.Build/NuSpecUpdateTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace RestSharp.Build
{
public class NuSpecUpdateTask : Task
{
private Assembly _assembly;
private Assembly assembly;

public string Id { get; private set; }

Expand All @@ -27,7 +27,7 @@ public NuSpecUpdateTask() : this(null) { }

public NuSpecUpdateTask(Assembly assembly)
{
this._assembly = assembly;
this.assembly = assembly;
}

public override bool Execute()
Expand All @@ -36,18 +36,18 @@ public override bool Execute()
return false;

var path = Path.GetFullPath(this.SourceAssemblyFile);
this._assembly = this._assembly ?? Assembly.LoadFile(path);
this.assembly = this.assembly ?? Assembly.LoadFile(path);

var name = this._assembly.GetName();
var name = this.assembly.GetName();

#if SIGNED
this.Id = name.Name + "Signed";
#else
this.Id = name.Name;
#endif
this.Authors = this.GetAuthors(this._assembly);
this.Description = this.GetDescription(this._assembly);
this.Version = this.GetVersion(this._assembly);
this.Authors = GetAuthors(this.assembly);
this.Description = GetDescription(this.assembly);
this.Version = GetVersion(this.assembly);

this.GenerateComputedSpecFile();

Expand All @@ -59,16 +59,16 @@ private void GenerateComputedSpecFile()
var doc = XDocument.Load(this.SpecFile);
var metaNode = doc.Descendants("metadata").First();

this.ReplaceToken(metaNode, "id", this.Id);
this.ReplaceToken(metaNode, "authors", this.Authors);
this.ReplaceToken(metaNode, "owners", this.Authors);
this.ReplaceToken(metaNode, "description", this.Description);
this.ReplaceToken(metaNode, "version", this.Version);
ReplaceToken(metaNode, "id", this.Id);
ReplaceToken(metaNode, "authors", this.Authors);
ReplaceToken(metaNode, "owners", this.Authors);
ReplaceToken(metaNode, "description", this.Description);
ReplaceToken(metaNode, "version", this.Version);

doc.Save(this.SpecFile.Replace(".nuspec", "-computed.nuspec"));
}

private void ReplaceToken(XElement metaNode, XName name, string value)
private static void ReplaceToken(XContainer metaNode, XName name, string value)
{
var node = metaNode.Element(name);
var token = string.Format("${0}$", name.ToString().TrimEnd('s'));
Expand All @@ -78,26 +78,26 @@ private void ReplaceToken(XElement metaNode, XName name, string value)
token = "$author$";
}

if (node.Value.Equals(token, StringComparison.OrdinalIgnoreCase))
if (node != null && node.Value.Equals(token, StringComparison.OrdinalIgnoreCase))
{
node.SetValue(value);
}
}

private string GetDescription(Assembly asm)
private static string GetDescription(ICustomAttributeProvider asm)
{
return this.GetAttribute<AssemblyDescriptionAttribute>(asm).Description;
return GetAttribute<AssemblyDescriptionAttribute>(asm).Description;
}

private string GetAuthors(Assembly asm)
private static string GetAuthors(ICustomAttributeProvider asm)
{
return this.GetAttribute<AssemblyCompanyAttribute>(asm).Company;
return GetAttribute<AssemblyCompanyAttribute>(asm).Company;
}

private string GetVersion(Assembly asm)
private static string GetVersion(Assembly asm)
{
var version = asm.GetName().Version.ToString();
var attr = this.GetAttribute<AssemblyInformationalVersionAttribute>(asm);
var attr = GetAttribute<AssemblyInformationalVersionAttribute>(asm);

if (attr != null)
{
Expand All @@ -107,7 +107,7 @@ private string GetVersion(Assembly asm)
return version;
}

private TAttr GetAttribute<TAttr>(Assembly asm) where TAttr : Attribute
private static TAttr GetAttribute<TAttr>(ICustomAttributeProvider asm) where TAttr : Attribute
{
var attrs = asm.GetCustomAttributes(typeof(TAttr), false);

Expand Down
2 changes: 1 addition & 1 deletion RestSharp.Build/RestSharp.Build.Signed.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CCC30138-3D68-44D8-AF1A-D22F769EE8DC}</ProjectGuid>
<ProjectGuid>{60CF35B5-ABE3-47E4-BA0C-0ABAF1618475}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RestSharp.Build</RootNamespace>
Expand Down
20 changes: 0 additions & 20 deletions RestSharp.Compact.sln

This file was deleted.

12 changes: 6 additions & 6 deletions RestSharp.IntegrationTests/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
<sources>
<source name="System.Net" tracemode="includehex" maxdatasize="1024">
<listeners>
<add name="System.Net"/>
<add name="System.Net" />
</listeners>
</source>
</sources>
<switches>
<add name="System.Net" value="Verbose"/>
<add name="System.Net" value="Verbose" />
</switches>
<sharedListeners>
<add name="System.Net" type="System.Diagnostics.TextWriterTraceListener" initializeData="network.log"/>
<add name="System.Net" type="System.Diagnostics.TextWriterTraceListener" initializeData="network.log" />
</sharedListeners>
<trace autoflush="true"/>
<trace autoflush="true" />
</system.diagnostics>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
</configuration>
53 changes: 26 additions & 27 deletions RestSharp.IntegrationTests/AsyncRequestBodyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public void Can_Not_Be_Added_To_GET_Request()

using (SimpleServer.Create(BASE_URL, Handlers.Generic<RequestBodyCapturer>()))
{
var client = new RestClient(BASE_URL);
var request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
RestClient client = new RestClient(BASE_URL);
RestRequest request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);

const string contentType = "text/plain";
const string bodyData = "abc123 foo bar baz BING!";

request.AddParameter(contentType, bodyData, ParameterType.RequestBody);

var resetEvent = new ManualResetEvent(false);
ManualResetEvent resetEvent = new ManualResetEvent(false);

client.ExecuteAsync(request, response => resetEvent.Set());
resetEvent.WaitOne();
Expand All @@ -42,10 +42,9 @@ public void Can_Have_No_Body_Added_To_POST_Request()

using (SimpleServer.Create(BASE_URL, Handlers.Generic<RequestBodyCapturer>()))
{
var client = new RestClient(BASE_URL);
var request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);

var resetEvent = new ManualResetEvent(false);
RestClient client = new RestClient(BASE_URL);
RestRequest request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
ManualResetEvent resetEvent = new ManualResetEvent(false);

client.ExecuteAsync(request, response => resetEvent.Set());
resetEvent.WaitOne();
Expand All @@ -61,15 +60,15 @@ public void Can_Be_Added_To_POST_Request()

using (SimpleServer.Create(BASE_URL, Handlers.Generic<RequestBodyCapturer>()))
{
var client = new RestClient(BASE_URL);
var request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
RestClient client = new RestClient(BASE_URL);
RestRequest request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);

const string contentType = "text/plain";
const string bodyData = "abc123 foo bar baz BING!";

request.AddParameter(contentType, bodyData, ParameterType.RequestBody);

var resetEvent = new ManualResetEvent(false);
ManualResetEvent resetEvent = new ManualResetEvent(false);

client.ExecuteAsync(request, response => resetEvent.Set());
resetEvent.WaitOne();
Expand All @@ -85,15 +84,15 @@ public void Can_Be_Added_To_PUT_Request()

using (SimpleServer.Create(BASE_URL, Handlers.Generic<RequestBodyCapturer>()))
{
var client = new RestClient(BASE_URL);
var request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
RestClient client = new RestClient(BASE_URL);
RestRequest request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);

const string contentType = "text/plain";
const string bodyData = "abc123 foo bar baz BING!";

request.AddParameter(contentType, bodyData, ParameterType.RequestBody);

var resetEvent = new ManualResetEvent(false);
ManualResetEvent resetEvent = new ManualResetEvent(false);

client.ExecuteAsync(request, response => resetEvent.Set());
resetEvent.WaitOne();
Expand All @@ -109,15 +108,15 @@ public void Can_Be_Added_To_DELETE_Request()

using (SimpleServer.Create(BASE_URL, Handlers.Generic<RequestBodyCapturer>()))
{
var client = new RestClient(BASE_URL);
var request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
RestClient client = new RestClient(BASE_URL);
RestRequest request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);

const string contentType = "text/plain";
const string bodyData = "abc123 foo bar baz BING!";

request.AddParameter(contentType, bodyData, ParameterType.RequestBody);

var resetEvent = new ManualResetEvent(false);
ManualResetEvent resetEvent = new ManualResetEvent(false);

client.ExecuteAsync(request, response => resetEvent.Set());
resetEvent.WaitOne();
Expand All @@ -133,15 +132,15 @@ public void Can_Not_Be_Added_To_HEAD_Request()

using (SimpleServer.Create(BASE_URL, Handlers.Generic<RequestBodyCapturer>()))
{
var client = new RestClient(BASE_URL);
var request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
RestClient client = new RestClient(BASE_URL);
RestRequest request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);

const string contentType = "text/plain";
const string bodyData = "abc123 foo bar baz BING!";

request.AddParameter(contentType, bodyData, ParameterType.RequestBody);

var resetEvent = new ManualResetEvent(false);
ManualResetEvent resetEvent = new ManualResetEvent(false);

client.ExecuteAsync(request, response => resetEvent.Set());
resetEvent.WaitOne();
Expand All @@ -157,15 +156,15 @@ public void Can_Be_Added_To_OPTIONS_Request()

using (SimpleServer.Create(BASE_URL, Handlers.Generic<RequestBodyCapturer>()))
{
var client = new RestClient(BASE_URL);
var request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
RestClient client = new RestClient(BASE_URL);
RestRequest request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);

const string contentType = "text/plain";
const string bodyData = "abc123 foo bar baz BING!";

request.AddParameter(contentType, bodyData, ParameterType.RequestBody);

var resetEvent = new ManualResetEvent(false);
ManualResetEvent resetEvent = new ManualResetEvent(false);

client.ExecuteAsync(request, response => resetEvent.Set());
resetEvent.WaitOne();
Expand All @@ -181,15 +180,15 @@ public void Can_Be_Added_To_PATCH_Request()

using (SimpleServer.Create(BASE_URL, Handlers.Generic<RequestBodyCapturer>()))
{
var client = new RestClient(BASE_URL);
var request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
RestClient client = new RestClient(BASE_URL);
RestRequest request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);

const string contentType = "text/plain";
const string bodyData = "abc123 foo bar baz BING!";

request.AddParameter(contentType, bodyData, ParameterType.RequestBody);

var resetEvent = new ManualResetEvent(false);
ManualResetEvent resetEvent = new ManualResetEvent(false);

client.ExecuteAsync(request, response => resetEvent.Set());
resetEvent.WaitOne();
Expand Down Expand Up @@ -224,7 +223,7 @@ private class RequestBodyCapturer

public static void Capture(HttpListenerContext context)
{
var request = context.Request;
HttpListenerRequest request = context.Request;

CapturedContentType = request.ContentType;
CapturedHasEntityBody = request.HasEntityBody;
Expand All @@ -233,7 +232,7 @@ public static void Capture(HttpListenerContext context)

private static string StreamToString(Stream stream)
{
var streamReader = new StreamReader(stream);
StreamReader streamReader = new StreamReader(stream);
return streamReader.ReadToEnd();
}
}
Expand Down
Loading