Skip to content

Commit 3604e0c

Browse files
author
Michael Hallett
committed
Merge branch 'response-debug' of git://github.com/drusellers/RestSharp into work_in_progress
2 parents 2afed66 + 82cf122 commit 3604e0c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

RestSharp/RestResponse.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@
2020
using System.Collections.Generic;
2121
using System.Net;
2222
using RestSharp.Extensions;
23+
using System.Diagnostics;
2324

2425
namespace RestSharp
2526
{
27+
2628
/// <summary>
2729
/// Base class for common properties shared by RestResponse and RestResponse[[T]]
2830
/// </summary>
31+
[DebuggerDisplay("{DebuggerDisplay()}")]
2932
public abstract class RestResponseBase
3033
{
3134
private string content;
@@ -122,12 +125,23 @@ public string Content
122125
/// The exception thrown during the request, if any
123126
/// </summary>
124127
public Exception ErrorException { get; set; }
128+
129+
130+
/// <summary>
131+
/// Assists with debugging responses by displaying in the debugger output
132+
/// </summary>
133+
/// <returns></returns>
134+
protected string DebuggerDisplay()
135+
{
136+
return string.Format("{0}: {1} ({2})", StatusCode, ContentType, ContentLength);
137+
}
125138
}
126139

127140
/// <summary>
128141
/// Container for data sent back from API including deserialized data
129142
/// </summary>
130143
/// <typeparam name="T">Type of data to deserialize to</typeparam>
144+
[DebuggerDisplay("{DebuggerDisplay()}")]
131145
public class RestResponse<T> : RestResponseBase, IRestResponse<T>
132146
{
133147
/// <summary>
@@ -160,5 +174,6 @@ public static explicit operator RestResponse<T>(RestResponse response)
160174
/// <summary>
161175
/// Container for data sent back from API
162176
/// </summary>
177+
[DebuggerDisplay("{DebuggerDisplay()}")]
163178
public class RestResponse : RestResponseBase, IRestResponse { }
164179
}

0 commit comments

Comments
 (0)