Skip to content

Commit 7cc7056

Browse files
committed
Merge pull request restsharp#732 from restsharp/work_in_progress
.net 4.6 and code cleanup and standardization
2 parents 7350717 + 2257cf1 commit 7cc7056

File tree

156 files changed

+7119
-5386
lines changed

Some content is hidden

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

156 files changed

+7119
-5386
lines changed

.nuget/RestSharp.Build.dll

-512 Bytes
Binary file not shown.

.nuget/Signed/RestSharp.Build.dll

-512 Bytes
Binary file not shown.

RestSharp.2015.sln

Lines changed: 277 additions & 0 deletions
Large diffs are not rendered by default.

RestSharp.All.sln

Lines changed: 451 additions & 0 deletions
Large diffs are not rendered by default.

RestSharp.Build/NuSpecUpdateTask.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace RestSharp.Build
99
{
1010
public class NuSpecUpdateTask : Task
1111
{
12-
private Assembly _assembly;
12+
private Assembly assembly;
1313

1414
public string Id { get; private set; }
1515

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

2828
public NuSpecUpdateTask(Assembly assembly)
2929
{
30-
this._assembly = assembly;
30+
this.assembly = assembly;
3131
}
3232

3333
public override bool Execute()
@@ -36,18 +36,18 @@ public override bool Execute()
3636
return false;
3737

3838
var path = Path.GetFullPath(this.SourceAssemblyFile);
39-
this._assembly = this._assembly ?? Assembly.LoadFile(path);
39+
this.assembly = this.assembly ?? Assembly.LoadFile(path);
4040

41-
var name = this._assembly.GetName();
41+
var name = this.assembly.GetName();
4242

4343
#if SIGNED
4444
this.Id = name.Name + "Signed";
4545
#else
4646
this.Id = name.Name;
4747
#endif
48-
this.Authors = this.GetAuthors(this._assembly);
49-
this.Description = this.GetDescription(this._assembly);
50-
this.Version = this.GetVersion(this._assembly);
48+
this.Authors = GetAuthors(this.assembly);
49+
this.Description = GetDescription(this.assembly);
50+
this.Version = GetVersion(this.assembly);
5151

5252
this.GenerateComputedSpecFile();
5353

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

62-
this.ReplaceToken(metaNode, "id", this.Id);
63-
this.ReplaceToken(metaNode, "authors", this.Authors);
64-
this.ReplaceToken(metaNode, "owners", this.Authors);
65-
this.ReplaceToken(metaNode, "description", this.Description);
66-
this.ReplaceToken(metaNode, "version", this.Version);
62+
ReplaceToken(metaNode, "id", this.Id);
63+
ReplaceToken(metaNode, "authors", this.Authors);
64+
ReplaceToken(metaNode, "owners", this.Authors);
65+
ReplaceToken(metaNode, "description", this.Description);
66+
ReplaceToken(metaNode, "version", this.Version);
6767

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

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

81-
if (node.Value.Equals(token, StringComparison.OrdinalIgnoreCase))
81+
if (node != null && node.Value.Equals(token, StringComparison.OrdinalIgnoreCase))
8282
{
8383
node.SetValue(value);
8484
}
8585
}
8686

87-
private string GetDescription(Assembly asm)
87+
private static string GetDescription(ICustomAttributeProvider asm)
8888
{
89-
return this.GetAttribute<AssemblyDescriptionAttribute>(asm).Description;
89+
return GetAttribute<AssemblyDescriptionAttribute>(asm).Description;
9090
}
9191

92-
private string GetAuthors(Assembly asm)
92+
private static string GetAuthors(ICustomAttributeProvider asm)
9393
{
94-
return this.GetAttribute<AssemblyCompanyAttribute>(asm).Company;
94+
return GetAttribute<AssemblyCompanyAttribute>(asm).Company;
9595
}
9696

97-
private string GetVersion(Assembly asm)
97+
private static string GetVersion(Assembly asm)
9898
{
9999
var version = asm.GetName().Version.ToString();
100-
var attr = this.GetAttribute<AssemblyInformationalVersionAttribute>(asm);
100+
var attr = GetAttribute<AssemblyInformationalVersionAttribute>(asm);
101101

102102
if (attr != null)
103103
{
@@ -107,7 +107,7 @@ private string GetVersion(Assembly asm)
107107
return version;
108108
}
109109

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

RestSharp.Build/RestSharp.Build.Signed.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
66
<ProductVersion>8.0.30703</ProductVersion>
77
<SchemaVersion>2.0</SchemaVersion>
8-
<ProjectGuid>{CCC30138-3D68-44D8-AF1A-D22F769EE8DC}</ProjectGuid>
8+
<ProjectGuid>{60CF35B5-ABE3-47E4-BA0C-0ABAF1618475}</ProjectGuid>
99
<OutputType>Library</OutputType>
1010
<AppDesignerFolder>Properties</AppDesignerFolder>
1111
<RootNamespace>RestSharp.Build</RootNamespace>

RestSharp.Compact.sln

Lines changed: 0 additions & 20 deletions
This file was deleted.

RestSharp.IntegrationTests/App.config

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
<sources>
55
<source name="System.Net" tracemode="includehex" maxdatasize="1024">
66
<listeners>
7-
<add name="System.Net"/>
7+
<add name="System.Net" />
88
</listeners>
99
</source>
1010
</sources>
1111
<switches>
12-
<add name="System.Net" value="Verbose"/>
12+
<add name="System.Net" value="Verbose" />
1313
</switches>
1414
<sharedListeners>
15-
<add name="System.Net" type="System.Diagnostics.TextWriterTraceListener" initializeData="network.log"/>
15+
<add name="System.Net" type="System.Diagnostics.TextWriterTraceListener" initializeData="network.log" />
1616
</sharedListeners>
17-
<trace autoflush="true"/>
17+
<trace autoflush="true" />
1818
</system.diagnostics>
1919
<startup>
20-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
20+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
2121
</startup>
22-
</configuration>
22+
</configuration>

RestSharp.IntegrationTests/AsyncRequestBodyTests.cs

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ public void Can_Not_Be_Added_To_GET_Request()
1818

1919
using (SimpleServer.Create(BASE_URL, Handlers.Generic<RequestBodyCapturer>()))
2020
{
21-
var client = new RestClient(BASE_URL);
22-
var request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
21+
RestClient client = new RestClient(BASE_URL);
22+
RestRequest request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
2323

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

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

29-
var resetEvent = new ManualResetEvent(false);
29+
ManualResetEvent resetEvent = new ManualResetEvent(false);
3030

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

4343
using (SimpleServer.Create(BASE_URL, Handlers.Generic<RequestBodyCapturer>()))
4444
{
45-
var client = new RestClient(BASE_URL);
46-
var request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
47-
48-
var resetEvent = new ManualResetEvent(false);
45+
RestClient client = new RestClient(BASE_URL);
46+
RestRequest request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
47+
ManualResetEvent resetEvent = new ManualResetEvent(false);
4948

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

6261
using (SimpleServer.Create(BASE_URL, Handlers.Generic<RequestBodyCapturer>()))
6362
{
64-
var client = new RestClient(BASE_URL);
65-
var request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
63+
RestClient client = new RestClient(BASE_URL);
64+
RestRequest request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
6665

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

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

72-
var resetEvent = new ManualResetEvent(false);
71+
ManualResetEvent resetEvent = new ManualResetEvent(false);
7372

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

8685
using (SimpleServer.Create(BASE_URL, Handlers.Generic<RequestBodyCapturer>()))
8786
{
88-
var client = new RestClient(BASE_URL);
89-
var request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
87+
RestClient client = new RestClient(BASE_URL);
88+
RestRequest request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
9089

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

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

96-
var resetEvent = new ManualResetEvent(false);
95+
ManualResetEvent resetEvent = new ManualResetEvent(false);
9796

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

110109
using (SimpleServer.Create(BASE_URL, Handlers.Generic<RequestBodyCapturer>()))
111110
{
112-
var client = new RestClient(BASE_URL);
113-
var request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
111+
RestClient client = new RestClient(BASE_URL);
112+
RestRequest request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
114113

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

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

120-
var resetEvent = new ManualResetEvent(false);
119+
ManualResetEvent resetEvent = new ManualResetEvent(false);
121120

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

134133
using (SimpleServer.Create(BASE_URL, Handlers.Generic<RequestBodyCapturer>()))
135134
{
136-
var client = new RestClient(BASE_URL);
137-
var request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
135+
RestClient client = new RestClient(BASE_URL);
136+
RestRequest request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
138137

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

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

144-
var resetEvent = new ManualResetEvent(false);
143+
ManualResetEvent resetEvent = new ManualResetEvent(false);
145144

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

158157
using (SimpleServer.Create(BASE_URL, Handlers.Generic<RequestBodyCapturer>()))
159158
{
160-
var client = new RestClient(BASE_URL);
161-
var request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
159+
RestClient client = new RestClient(BASE_URL);
160+
RestRequest request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
162161

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

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

168-
var resetEvent = new ManualResetEvent(false);
167+
ManualResetEvent resetEvent = new ManualResetEvent(false);
169168

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

182181
using (SimpleServer.Create(BASE_URL, Handlers.Generic<RequestBodyCapturer>()))
183182
{
184-
var client = new RestClient(BASE_URL);
185-
var request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
183+
RestClient client = new RestClient(BASE_URL);
184+
RestRequest request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod);
186185

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

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

192-
var resetEvent = new ManualResetEvent(false);
191+
ManualResetEvent resetEvent = new ManualResetEvent(false);
193192

194193
client.ExecuteAsync(request, response => resetEvent.Set());
195194
resetEvent.WaitOne();
@@ -224,7 +223,7 @@ private class RequestBodyCapturer
224223

225224
public static void Capture(HttpListenerContext context)
226225
{
227-
var request = context.Request;
226+
HttpListenerRequest request = context.Request;
228227

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

234233
private static string StreamToString(Stream stream)
235234
{
236-
var streamReader = new StreamReader(stream);
235+
StreamReader streamReader = new StreamReader(stream);
237236
return streamReader.ReadToEnd();
238237
}
239238
}

0 commit comments

Comments
 (0)