From 4d2433535fbf28d18a135554990780a8ea9f80d3 Mon Sep 17 00:00:00 2001 From: Vishrut Shah Date: Fri, 24 Jun 2016 11:21:23 -0700 Subject: [PATCH] Regenerating samples with gulp regenerate:expected:samples --- .../Azure.CSharp/StorageAccountsOperations.cs | 7 +- Samples/petstore/CSharp/SwaggerPetstore.cs | 154 +++++++++++++++--- 2 files changed, 138 insertions(+), 23 deletions(-) diff --git a/Samples/azure-storage/Azure.CSharp/StorageAccountsOperations.cs b/Samples/azure-storage/Azure.CSharp/StorageAccountsOperations.cs index a801a17ae3042..082b1d1bb6743 100644 --- a/Samples/azure-storage/Azure.CSharp/StorageAccountsOperations.cs +++ b/Samples/azure-storage/Azure.CSharp/StorageAccountsOperations.cs @@ -635,7 +635,12 @@ internal StorageAccountsOperations(StorageManagementClient client) if ((int)_statusCode != 200 && (int)_statusCode != 204) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_httpResponse.Headers.Contains("x-ms-request-id")) diff --git a/Samples/petstore/CSharp/SwaggerPetstore.cs b/Samples/petstore/CSharp/SwaggerPetstore.cs index b730bc16c6b7a..a4a8211b9e31c 100644 --- a/Samples/petstore/CSharp/SwaggerPetstore.cs +++ b/Samples/petstore/CSharp/SwaggerPetstore.cs @@ -226,7 +226,12 @@ private void Initialize() if ((int)_statusCode != 405) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -336,7 +341,12 @@ private void Initialize() if ((int)_statusCode != 405) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -442,7 +452,12 @@ private void Initialize() if ((int)_statusCode != 405 && (int)_statusCode != 404 && (int)_statusCode != 400) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -553,7 +568,12 @@ private void Initialize() if ((int)_statusCode != 200 && (int)_statusCode != 400) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -683,7 +703,12 @@ private void Initialize() if ((int)_statusCode != 200 && (int)_statusCode != 400) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -805,7 +830,12 @@ private void Initialize() if ((int)_statusCode != 404 && (int)_statusCode != 200 && (int)_statusCode != 400) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -927,7 +957,12 @@ private void Initialize() if ((int)_statusCode != 404 && (int)_statusCode != 200 && (int)_statusCode != 400) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -1069,7 +1104,12 @@ private void Initialize() if ((int)_statusCode != 405) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -1177,7 +1217,12 @@ private void Initialize() if ((int)_statusCode != 400) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -1303,7 +1348,12 @@ private void Initialize() if (!_httpResponse.IsSuccessStatusCode) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -1401,7 +1451,12 @@ private void Initialize() if ((int)_statusCode != 200) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -1524,7 +1579,12 @@ private void Initialize() if ((int)_statusCode != 200 && (int)_statusCode != 400) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -1653,7 +1713,12 @@ private void Initialize() if ((int)_statusCode != 404 && (int)_statusCode != 200 && (int)_statusCode != 400) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -1779,7 +1844,12 @@ private void Initialize() if ((int)_statusCode != 404 && (int)_statusCode != 400) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -1884,7 +1954,12 @@ private void Initialize() if (!_httpResponse.IsSuccessStatusCode) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -1986,7 +2061,12 @@ private void Initialize() if (!_httpResponse.IsSuccessStatusCode) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -2088,7 +2168,12 @@ private void Initialize() if (!_httpResponse.IsSuccessStatusCode) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -2204,7 +2289,12 @@ private void Initialize() if ((int)_statusCode != 200 && (int)_statusCode != 400) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -2314,7 +2404,12 @@ private void Initialize() if (!_httpResponse.IsSuccessStatusCode) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -2421,7 +2516,12 @@ private void Initialize() if ((int)_statusCode != 404 && (int)_statusCode != 200 && (int)_statusCode != 400) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -2556,7 +2656,12 @@ private void Initialize() if ((int)_statusCode != 404 && (int)_statusCode != 400) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) @@ -2663,7 +2768,12 @@ private void Initialize() if ((int)_statusCode != 404 && (int)_statusCode != 400) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace)