Skip to content

Commit aa3333a

Browse files
committed
Add ConfigureAwait(false) to async tasks, Fix documentations.
1 parent 83abdcb commit aa3333a

File tree

87 files changed

+5448
-581
lines changed

Some content is hidden

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

87 files changed

+5448
-581
lines changed

Dropbox.Api/ApiException.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace Dropbox.Api
88
{
99
using System;
1010

11+
using Dropbox.Api.Babel;
12+
1113
/// <summary>
1214
/// The exception type that will be raised by an <see cref="ITransport" />
1315
/// implementation if there is an error processing the request which is caused by

Dropbox.Api/Async/LaunchEmptyResult.cs

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,28 @@ public Complete AsComplete
5959
}
6060
}
6161

62+
/// <summary>
63+
/// <para>Gets a value indicating whether this instance is AsyncJobId</para>
64+
/// </summary>
65+
public bool IsAsyncJobId
66+
{
67+
get
68+
{
69+
return this is AsyncJobId;
70+
}
71+
}
72+
73+
/// <summary>
74+
/// <para>Gets this instance as a AsyncJobId, or <c>null</c>.</para>
75+
/// </summary>
76+
public AsyncJobId AsAsyncJobId
77+
{
78+
get
79+
{
80+
return this as AsyncJobId;
81+
}
82+
}
83+
6284
#region Encoder class
6385

6486
/// <summary>
@@ -79,6 +101,12 @@ public override void EncodeFields(LaunchEmptyResult value, enc.IJsonWriter write
79101
Complete.Encoder.EncodeFields((Complete)value, writer);
80102
return;
81103
}
104+
if (value is AsyncJobId)
105+
{
106+
WriteProperty(".tag", "async_job_id", writer, enc.StringEncoder.Instance);
107+
AsyncJobId.Encoder.EncodeFields((AsyncJobId)value, writer);
108+
return;
109+
}
82110
throw new sys.InvalidOperationException();
83111
}
84112
}
@@ -113,6 +141,8 @@ protected override LaunchEmptyResult Decode(string tag, enc.IJsonReader reader)
113141
{
114142
case "complete":
115143
return Complete.Decoder.DecodeFields(reader);
144+
case "async_job_id":
145+
return AsyncJobId.Decoder.DecodeFields(reader);
116146
default:
117147
throw new sys.InvalidOperationException();
118148
}
@@ -198,5 +228,102 @@ public override Complete DecodeFields(enc.IJsonReader reader)
198228

199229
#endregion
200230
}
231+
232+
/// <summary>
233+
/// <para>This response indicates that the processing is asynchronous. The string is an
234+
/// id that can be used to obtain the status of the asynchronous job.</para>
235+
/// </summary>
236+
public sealed class AsyncJobId : LaunchEmptyResult
237+
{
238+
#pragma warning disable 108
239+
240+
/// <summary>
241+
/// <para>The encoder instance.</para>
242+
/// </summary>
243+
internal static enc.StructEncoder<AsyncJobId> Encoder = new AsyncJobIdEncoder();
244+
245+
/// <summary>
246+
/// <para>The decoder instance.</para>
247+
/// </summary>
248+
internal static enc.StructDecoder<AsyncJobId> Decoder = new AsyncJobIdDecoder();
249+
250+
/// <summary>
251+
/// <para>Initializes a new instance of the <see cref="AsyncJobId" /> class.</para>
252+
/// </summary>
253+
/// <param name="value">The value</param>
254+
public AsyncJobId(string value)
255+
{
256+
this.Value = value;
257+
}
258+
/// <summary>
259+
/// <para>Initializes a new instance of the <see cref="AsyncJobId" /> class.</para>
260+
/// </summary>
261+
private AsyncJobId()
262+
{
263+
}
264+
265+
/// <summary>
266+
/// <para>Gets the value of this instance.</para>
267+
/// </summary>
268+
public string Value { get; private set; }
269+
270+
#region Encoder class
271+
272+
/// <summary>
273+
/// <para>Encoder for <see cref="AsyncJobId" />.</para>
274+
/// </summary>
275+
private class AsyncJobIdEncoder : enc.StructEncoder<AsyncJobId>
276+
{
277+
/// <summary>
278+
/// <para>Encode fields of given value.</para>
279+
/// </summary>
280+
/// <param name="value">The value.</param>
281+
/// <param name="writer">The writer.</param>
282+
public override void EncodeFields(AsyncJobId value, enc.IJsonWriter writer)
283+
{
284+
WriteProperty("async_job_id", value.Value, writer, enc.StringEncoder.Instance);
285+
}
286+
}
287+
288+
#endregion
289+
290+
#region Decoder class
291+
292+
/// <summary>
293+
/// <para>Decoder for <see cref="AsyncJobId" />.</para>
294+
/// </summary>
295+
private class AsyncJobIdDecoder : enc.StructDecoder<AsyncJobId>
296+
{
297+
/// <summary>
298+
/// <para>Create a new instance of type <see cref="AsyncJobId" />.</para>
299+
/// </summary>
300+
/// <returns>The struct instance.</returns>
301+
protected override AsyncJobId Create()
302+
{
303+
return new AsyncJobId();
304+
}
305+
306+
/// <summary>
307+
/// <para>Set given field.</para>
308+
/// </summary>
309+
/// <param name="value">The field value.</param>
310+
/// <param name="fieldName">The field name.</param>
311+
/// <param name="reader">The json reader.</param>
312+
protected override void SetField(AsyncJobId value, string fieldName, enc.IJsonReader reader)
313+
{
314+
switch (fieldName)
315+
{
316+
case "async_job_id":
317+
value.Value = enc.StringDecoder.Instance.Decode(reader);
318+
break;
319+
default:
320+
reader.Skip();
321+
break;
322+
}
323+
}
324+
}
325+
326+
#endregion
327+
}
201328
}
202329
}

Dropbox.Api/Async/PollEmptyResult.cs

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,28 @@ public Complete AsComplete
5858
}
5959
}
6060

61+
/// <summary>
62+
/// <para>Gets a value indicating whether this instance is InProgress</para>
63+
/// </summary>
64+
public bool IsInProgress
65+
{
66+
get
67+
{
68+
return this is InProgress;
69+
}
70+
}
71+
72+
/// <summary>
73+
/// <para>Gets this instance as a InProgress, or <c>null</c>.</para>
74+
/// </summary>
75+
public InProgress AsInProgress
76+
{
77+
get
78+
{
79+
return this as InProgress;
80+
}
81+
}
82+
6183
#region Encoder class
6284

6385
/// <summary>
@@ -78,6 +100,12 @@ public override void EncodeFields(PollEmptyResult value, enc.IJsonWriter writer)
78100
Complete.Encoder.EncodeFields((Complete)value, writer);
79101
return;
80102
}
103+
if (value is InProgress)
104+
{
105+
WriteProperty(".tag", "in_progress", writer, enc.StringEncoder.Instance);
106+
InProgress.Encoder.EncodeFields((InProgress)value, writer);
107+
return;
108+
}
81109
throw new sys.InvalidOperationException();
82110
}
83111
}
@@ -112,6 +140,8 @@ protected override PollEmptyResult Decode(string tag, enc.IJsonReader reader)
112140
{
113141
case "complete":
114142
return Complete.Decoder.DecodeFields(reader);
143+
case "in_progress":
144+
return InProgress.Decoder.DecodeFields(reader);
115145
default:
116146
throw new sys.InvalidOperationException();
117147
}
@@ -197,5 +227,83 @@ public override Complete DecodeFields(enc.IJsonReader reader)
197227

198228
#endregion
199229
}
230+
231+
/// <summary>
232+
/// <para>The asynchronous job is still in progress.</para>
233+
/// </summary>
234+
public sealed class InProgress : PollEmptyResult
235+
{
236+
#pragma warning disable 108
237+
238+
/// <summary>
239+
/// <para>The encoder instance.</para>
240+
/// </summary>
241+
internal static enc.StructEncoder<InProgress> Encoder = new InProgressEncoder();
242+
243+
/// <summary>
244+
/// <para>The decoder instance.</para>
245+
/// </summary>
246+
internal static enc.StructDecoder<InProgress> Decoder = new InProgressDecoder();
247+
248+
/// <summary>
249+
/// <para>Initializes a new instance of the <see cref="InProgress" /> class.</para>
250+
/// </summary>
251+
private InProgress()
252+
{
253+
}
254+
255+
/// <summary>
256+
/// <para>A singleton instance of InProgress</para>
257+
/// </summary>
258+
public static readonly InProgress Instance = new InProgress();
259+
260+
#region Encoder class
261+
262+
/// <summary>
263+
/// <para>Encoder for <see cref="InProgress" />.</para>
264+
/// </summary>
265+
private class InProgressEncoder : enc.StructEncoder<InProgress>
266+
{
267+
/// <summary>
268+
/// <para>Encode fields of given value.</para>
269+
/// </summary>
270+
/// <param name="value">The value.</param>
271+
/// <param name="writer">The writer.</param>
272+
public override void EncodeFields(InProgress value, enc.IJsonWriter writer)
273+
{
274+
}
275+
}
276+
277+
#endregion
278+
279+
#region Decoder class
280+
281+
/// <summary>
282+
/// <para>Decoder for <see cref="InProgress" />.</para>
283+
/// </summary>
284+
private class InProgressDecoder : enc.StructDecoder<InProgress>
285+
{
286+
/// <summary>
287+
/// <para>Create a new instance of type <see cref="InProgress" />.</para>
288+
/// </summary>
289+
/// <returns>The struct instance.</returns>
290+
protected override InProgress Create()
291+
{
292+
return new InProgress();
293+
}
294+
295+
/// <summary>
296+
/// <para>Decode fields without ensuring start and end object.</para>
297+
/// </summary>
298+
/// <param name="reader">The json reader.</param>
299+
/// <returns>The decoded object.</returns>
300+
public override InProgress DecodeFields(enc.IJsonReader reader)
301+
{
302+
return InProgress.Instance;
303+
}
304+
}
305+
306+
#endregion
307+
}
200308
}
201309
}

Dropbox.Api/Babel/Decoder.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Copyright (c) Dropbox Inc. All rights reserved.
44
// </copyright>
55
//-----------------------------------------------------------------------------
6+
67
namespace Dropbox.Api.Babel
78
{
89
using System;
@@ -38,7 +39,7 @@ internal sealed class NullableDecoder<T> : IDecoder<T?> where T : struct
3839
private readonly IDecoder<T> decoder;
3940

4041
/// <summary>
41-
/// Initializes a new instance of the <see cref="NullableDecoder{T}"/>
42+
/// Initializes a new instance of the <see cref="NullableDecoder{T}"/> class.
4243
/// </summary>
4344
/// <param name="decoder">The decoder.</param>
4445
public NullableDecoder(IDecoder<T> decoder)
@@ -451,7 +452,7 @@ public override T DecodeFields(IJsonReader reader)
451452
{
452453
string fieldName;
453454

454-
if (!TryReadPropertyName(reader, out fieldName))
455+
if (!StructDecoder<T>.TryReadPropertyName(reader, out fieldName))
455456
{
456457
throw new InvalidOperationException("Not property found.");
457458
}
@@ -490,7 +491,8 @@ internal sealed class EmptyDecoder : IDecoder<Empty>
490491
/// <summary>
491492
/// Decoder for struct type.
492493
/// </summary>
493-
/// <typeparam name="T">The struct type.</typeparam>
494+
/// <param name="reader">The reader.</param>
495+
/// <returns>The empty instance.</returns>
494496
public Empty Decode(IJsonReader reader)
495497
{
496498
reader.Skip();

Dropbox.Api/Babel/JsonWriter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ private JsonWriter(JsonTextWriter writer)
3838
/// <typeparam name="T">The type of the object to write.</typeparam>
3939
/// <param name="encodable">The object to write.</param>
4040
/// <param name="encoder">The encoder.</param>
41+
/// <param name="escapeNonAscii">If escape non-ascii characters.</param>
4142
/// <returns>The encoded object as a JSON string.</returns>
4243
public static string Write<T>(T encodable, IEncoder<T> encoder, bool escapeNonAscii = false)
4344
{

Dropbox.Api/Babel/Util.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public static IAsyncResult ToApm(
113113
/// </summary>
114114
/// <typeparam name="T">The item type.</typeparam>
115115
/// <param name="items">The item.</param>
116-
/// <returns></returns>
116+
/// <returns>The list.</returns>
117117
public static IList<T> ToList<T>(IEnumerable<T> items)
118118
{
119119
return items != null ? new List<T>(items) : new List<T>();
@@ -124,7 +124,7 @@ public static IList<T> ToList<T>(IEnumerable<T> items)
124124
/// </summary>
125125
/// <typeparam name="T">The item type.</typeparam>
126126
/// <param name="items">The item.</param>
127-
/// <returns></returns>
127+
/// <returns>The list.</returns>
128128
public static IList<IList<T>> ToList<T>(IEnumerable<IEnumerable<T>> items)
129129
{
130130
var ret = new List<IList<T>>();

Dropbox.Api/Dropbox.Api.nuspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package >
33
<metadata>
44
<id>$id$</id>
5-
<version>2.3.3</version>
5+
<version>2.3.4</version>
66
<title>Dropbox v2 API Beta</title>
77
<authors>Dropbox Inc</authors>
88
<owners>Dropbox Inc</owners>
@@ -15,11 +15,11 @@
1515
<releaseNotes>Preview Release.
1616

1717
What's new:
18-
-Include Dropbox Business endpoints.
18+
- Assembly is now strongly named.
1919

2020
Bug fixes:
21-
-AuthException now has a deserialized ErrorResponse field.</releaseNotes>
22-
<copyright>Copyright (c) Dropbox Inc. 2015</copyright>
21+
- Add ConfigureAwait(false) to async tasks.</releaseNotes>
22+
<copyright>Copyright (c) Dropbox Inc. 2016</copyright>
2323
<tags>Dropbox Api</tags>
2424
</metadata>
2525
</package>

0 commit comments

Comments
 (0)