Skip to content

Commit eeefcf7

Browse files
author
Qiming Yuan
committed
Optimize memory usage.
1 parent 5bbef76 commit eeefcf7

File tree

247 files changed

+272
-9
lines changed

Some content is hidden

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

247 files changed

+272
-9
lines changed

Dropbox.Api.Tests/DropboxApiTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,22 @@ public async Task TestNoAuth()
249249
Assert.IsTrue(response.Changes);
250250
}
251251

252+
/// Test APM flow.
253+
/// </summary>
254+
[TestMethod]
255+
public void TaskAPM()
256+
{
257+
var result = Client.Users.BeginGetCurrentAccount(null);
258+
var account = Client.Users.EndGetCurrentAccount(result);
259+
var accountId = account.AccountId;
260+
261+
result = Client.Users.BeginGetAccountBatch(new string[] { accountId }, null);
262+
var accounts = Client.Users.EndGetAccountBatch(result);
263+
264+
Assert.AreEqual(accounts.Count, 1);
265+
Assert.AreEqual(accounts[0].AccountId, accountId);
266+
}
267+
252268
/// <summary>
253269
/// Converts string to a memory stream.
254270
/// </summary>

Dropbox.Api/Async/PollArg.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public PollArg(string asyncJobId)
5151
/// </summary>
5252
/// <remarks>This is to construct an instance of the object when
5353
/// deserializing.</remarks>
54+
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
5455
public PollArg()
5556
{
5657
}

Dropbox.Api/Auth/RateLimitError.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public RateLimitError(RateLimitReason reason,
5050
/// </summary>
5151
/// <remarks>This is to construct an instance of the object when
5252
/// deserializing.</remarks>
53+
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
5354
public RateLimitError()
5455
{
5556
this.RetryAfter = 1;

Dropbox.Api/Auth/TokenFromOAuth1Arg.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public TokenFromOAuth1Arg(string oauth1Token,
6565
/// </summary>
6666
/// <remarks>This is to construct an instance of the object when
6767
/// deserializing.</remarks>
68+
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
6869
public TokenFromOAuth1Arg()
6970
{
7071
}

Dropbox.Api/Auth/TokenFromOAuth1Result.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public TokenFromOAuth1Result(string oauth2Token)
5353
/// </summary>
5454
/// <remarks>This is to construct an instance of the object when
5555
/// deserializing.</remarks>
56+
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
5657
public TokenFromOAuth1Result()
5758
{
5859
}

Dropbox.Api/DropboxRequestHandler.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,21 @@ private async Task<Result> RequestJsonStringWithRetry(
243243

244244
if (routeStyle == RouteStyle.Upload)
245245
{
246+
if (body == null)
247+
{
248+
throw new ArgumentNullException("body");
249+
}
250+
246251
// to support retry logic, the body stream must be seekable
247252
// if it isn't we won't retry
248253
if (!body.CanSeek)
249254
{
250255
maxRetries = 0;
251256
}
257+
else if (maxRetries == 0)
258+
{
259+
// Do not copy the stream
260+
}
252261
else if (body is MemoryStream)
253262
{
254263
cachedStreamStart = body.Position;
@@ -565,7 +574,6 @@ private class Result
565574
/// </summary>
566575
/// <typeparam name="TResponse">The type of the response.</typeparam>
567576
private class DownloadResponse<TResponse> : IDownloadResponse<TResponse>
568-
where TResponse : new()
569577
{
570578
/// <summary>
571579
/// The HTTP response containing the body content.

Dropbox.Api/Files/AlphaGetMetadataArg.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public AlphaGetMetadataArg(string path,
6363
/// </summary>
6464
/// <remarks>This is to construct an instance of the object when
6565
/// deserializing.</remarks>
66+
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
6667
public AlphaGetMetadataArg()
6768
{
6869
}

Dropbox.Api/Files/CommitInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public CommitInfo(string path,
7777
/// </summary>
7878
/// <remarks>This is to construct an instance of the object when
7979
/// deserializing.</remarks>
80+
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
8081
public CommitInfo()
8182
{
8283
this.Mode = Dropbox.Api.Files.WriteMode.Add.Instance;

Dropbox.Api/Files/CommitInfoWithProperties.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public CommitInfoWithProperties(string path,
6666
/// </summary>
6767
/// <remarks>This is to construct an instance of the object when
6868
/// deserializing.</remarks>
69+
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
6970
public CommitInfoWithProperties()
7071
{
7172
}

Dropbox.Api/Files/CreateFolderArg.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public CreateFolderArg(string path,
5656
/// </summary>
5757
/// <remarks>This is to construct an instance of the object when
5858
/// deserializing.</remarks>
59+
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
5960
public CreateFolderArg()
6061
{
6162
this.Autorename = false;

0 commit comments

Comments
 (0)