From cd3b955ad99de8c4cd501b6bfd7a7eb86f33deb1 Mon Sep 17 00:00:00 2001 From: abnanda Date: Mon, 29 Apr 2013 01:33:34 -0700 Subject: [PATCH] Made changes as per code review feedback #1908 --- .../MainPage.xaml.cs | 6 +++--- .../Infrastructure/ErrorExtensions.cs | 4 ++-- .../Infrastructure/StreamExtensions.cs | 1 - .../Microsoft.AspNet.SignalR.Client.csproj | 1 - .../Transports/AutoTransport.cs | 5 ++--- src/Microsoft.AspNet.SignalR.Client/app.config | 2 -- .../Http/DefaultHttpClient.cs | 12 ++++++------ .../Http/HttpResponseMessageWrapper.cs | 2 +- 8 files changed, 14 insertions(+), 19 deletions(-) delete mode 100644 src/Microsoft.AspNet.SignalR.Client/app.config diff --git a/samples/Microsoft.AspNet.SignalR.Client.Silverlight.Sample/MainPage.xaml.cs b/samples/Microsoft.AspNet.SignalR.Client.Silverlight.Sample/MainPage.xaml.cs index 0b60adca58..e099630748 100644 --- a/samples/Microsoft.AspNet.SignalR.Client.Silverlight.Sample/MainPage.xaml.cs +++ b/samples/Microsoft.AspNet.SignalR.Client.Silverlight.Sample/MainPage.xaml.cs @@ -47,7 +47,7 @@ public MainPage() }; var scheduler = TaskScheduler.FromCurrentSynchronizationContext(); - connection.TraceWriter = new Writer(val => + connection.TraceWriter = new ActionBasedWriter(val => { Dispatcher.BeginInvoke(() => { @@ -72,10 +72,10 @@ public MainPage() scheduler); } - private class Writer : TextWriter + private class ActionBasedWriter : TextWriter { private readonly Action _log; - public Writer(Action log) + public ActionBasedWriter(Action log) { _log = log; } diff --git a/src/Microsoft.AspNet.SignalR.Client/Infrastructure/ErrorExtensions.cs b/src/Microsoft.AspNet.SignalR.Client/Infrastructure/ErrorExtensions.cs index 3497b70310..6239b1f37e 100644 --- a/src/Microsoft.AspNet.SignalR.Client/Infrastructure/ErrorExtensions.cs +++ b/src/Microsoft.AspNet.SignalR.Client/Infrastructure/ErrorExtensions.cs @@ -21,10 +21,10 @@ public static SignalRError GetError(this Exception ex) { ex = ex.Unwrap(); - var customEx = ex as HttpClientException; + var httpClientException = ex as HttpClientException; SignalRError error; - if (customEx != null) + if (httpClientException != null) { error = GetHttpClientException(ex); } diff --git a/src/Microsoft.AspNet.SignalR.Client/Infrastructure/StreamExtensions.cs b/src/Microsoft.AspNet.SignalR.Client/Infrastructure/StreamExtensions.cs index 7eea59324f..a5263c5418 100644 --- a/src/Microsoft.AspNet.SignalR.Client/Infrastructure/StreamExtensions.cs +++ b/src/Microsoft.AspNet.SignalR.Client/Infrastructure/StreamExtensions.cs @@ -30,7 +30,6 @@ public static Task WriteAsync(this Stream stream, byte[] buffer) } #if !(NETFX_CORE || NET45) - [SuppressMessage("Microsoft.Performance", "CA1811:No upstream protected or public callers", Justification = "Keeping the method for future use")] private static Func WrapEndWrite(Stream stream) { return ar => diff --git a/src/Microsoft.AspNet.SignalR.Client/Microsoft.AspNet.SignalR.Client.csproj b/src/Microsoft.AspNet.SignalR.Client/Microsoft.AspNet.SignalR.Client.csproj index 8e11eb89ee..063ca99de5 100644 --- a/src/Microsoft.AspNet.SignalR.Client/Microsoft.AspNet.SignalR.Client.csproj +++ b/src/Microsoft.AspNet.SignalR.Client/Microsoft.AspNet.SignalR.Client.csproj @@ -135,7 +135,6 @@ - diff --git a/src/Microsoft.AspNet.SignalR.Client/Transports/AutoTransport.cs b/src/Microsoft.AspNet.SignalR.Client/Transports/AutoTransport.cs index cd9104d5e1..2e6e54d3c2 100644 --- a/src/Microsoft.AspNet.SignalR.Client/Transports/AutoTransport.cs +++ b/src/Microsoft.AspNet.SignalR.Client/Transports/AutoTransport.cs @@ -22,13 +22,13 @@ public class AutoTransport : IClientTransport // List of transports in fallback order private readonly IList _transports; - private static Type type = Type.GetType("System.Net.Browser.WebRequestCreator,System.Windows, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", false); + private static Type _typeWebRequestCreator = Type.GetType("System.Net.Browser.WebRequestCreator,System.Windows, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", false); public AutoTransport(IHttpClient httpClient) { _httpClient = httpClient; - if (type == null) + if (_typeWebRequestCreator == null) { _transports = new IClientTransport[] { #if NET45 @@ -38,7 +38,6 @@ public AutoTransport(IHttpClient httpClient) new LongPollingTransport(httpClient) }; } - else { _transports = new IClientTransport[] { diff --git a/src/Microsoft.AspNet.SignalR.Client/app.config b/src/Microsoft.AspNet.SignalR.Client/app.config deleted file mode 100644 index 6ff25ef973..0000000000 --- a/src/Microsoft.AspNet.SignalR.Client/app.config +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/Microsoft.AspNet.SignalR.Client45/Http/DefaultHttpClient.cs b/src/Microsoft.AspNet.SignalR.Client45/Http/DefaultHttpClient.cs index abaf23a3c1..b4981b0f27 100644 --- a/src/Microsoft.AspNet.SignalR.Client45/Http/DefaultHttpClient.cs +++ b/src/Microsoft.AspNet.SignalR.Client45/Http/DefaultHttpClient.cs @@ -24,13 +24,13 @@ public class DefaultHttpClient : IHttpClient [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Handler cannot be disposed before response is disposed")] public Task Get(string url, Action prepareRequest) { - var disposerResponse = new Disposer(); + var responseDisposer = new Disposer(); var cts = new CancellationTokenSource(); var handler = new DefaultHttpHandler(prepareRequest, () => { cts.Cancel(); - disposerResponse.Dispose(); + responseDisposer.Dispose(); }); var client = new HttpClient(handler); @@ -40,7 +40,7 @@ public Task Get(string url, Action prepareRequest) { if (responseMessage.IsSuccessStatusCode) { - disposerResponse.Set(responseMessage); + responseDisposer.Set(responseMessage); } else { @@ -61,13 +61,13 @@ public Task Get(string url, Action prepareRequest) [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Handler cannot be disposed before response is disposed")] public Task Post(string url, Action prepareRequest, IDictionary postData) { - var disposerResponse = new Disposer(); + var responseDisposer = new Disposer(); var cts = new CancellationTokenSource(); var handler = new DefaultHttpHandler(prepareRequest, () => { cts.Cancel(); - disposerResponse.Dispose(); + responseDisposer.Dispose(); }); var client = new HttpClient(handler); @@ -87,7 +87,7 @@ public Task Post(string url, Action prepareRequest, IDictio { if (responseMessage.IsSuccessStatusCode) { - disposerResponse.Set(responseMessage); + responseDisposer.Set(responseMessage); } else { diff --git a/src/Microsoft.AspNet.SignalR.Client45/Http/HttpResponseMessageWrapper.cs b/src/Microsoft.AspNet.SignalR.Client45/Http/HttpResponseMessageWrapper.cs index 10a514a5a2..9fcfba18e4 100644 --- a/src/Microsoft.AspNet.SignalR.Client45/Http/HttpResponseMessageWrapper.cs +++ b/src/Microsoft.AspNet.SignalR.Client45/Http/HttpResponseMessageWrapper.cs @@ -28,8 +28,8 @@ protected virtual void Dispose(bool disposing) { if (disposing) { - _httpResponseMessage.Dispose(); _httpResponseMessage.RequestMessage.Dispose(); + _httpResponseMessage.Dispose(); _client.Dispose(); } }