Skip to content

Commit

Permalink
Optimize memory usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiming Yuan committed Jan 10, 2017
1 parent 5bbef76 commit eeefcf7
Show file tree
Hide file tree
Showing 247 changed files with 272 additions and 9 deletions.
16 changes: 16 additions & 0 deletions Dropbox.Api.Tests/DropboxApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,22 @@ public async Task TestNoAuth()
Assert.IsTrue(response.Changes);
}

/// Test APM flow.
/// </summary>
[TestMethod]
public void TaskAPM()
{
var result = Client.Users.BeginGetCurrentAccount(null);
var account = Client.Users.EndGetCurrentAccount(result);
var accountId = account.AccountId;

result = Client.Users.BeginGetAccountBatch(new string[] { accountId }, null);
var accounts = Client.Users.EndGetAccountBatch(result);

Assert.AreEqual(accounts.Count, 1);
Assert.AreEqual(accounts[0].AccountId, accountId);
}

/// <summary>
/// Converts string to a memory stream.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Async/PollArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public PollArg(string asyncJobId)
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public PollArg()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Auth/RateLimitError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public RateLimitError(RateLimitReason reason,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public RateLimitError()
{
this.RetryAfter = 1;
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Auth/TokenFromOAuth1Arg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public TokenFromOAuth1Arg(string oauth1Token,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public TokenFromOAuth1Arg()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Auth/TokenFromOAuth1Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public TokenFromOAuth1Result(string oauth2Token)
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public TokenFromOAuth1Result()
{
}
Expand Down
10 changes: 9 additions & 1 deletion Dropbox.Api/DropboxRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,21 @@ private async Task<Result> RequestJsonStringWithRetry(

if (routeStyle == RouteStyle.Upload)
{
if (body == null)
{
throw new ArgumentNullException("body");
}

// to support retry logic, the body stream must be seekable
// if it isn't we won't retry
if (!body.CanSeek)
{
maxRetries = 0;
}
else if (maxRetries == 0)
{
// Do not copy the stream
}
else if (body is MemoryStream)
{
cachedStreamStart = body.Position;
Expand Down Expand Up @@ -565,7 +574,6 @@ private class Result
/// </summary>
/// <typeparam name="TResponse">The type of the response.</typeparam>
private class DownloadResponse<TResponse> : IDownloadResponse<TResponse>
where TResponse : new()
{
/// <summary>
/// The HTTP response containing the body content.
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/AlphaGetMetadataArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public AlphaGetMetadataArg(string path,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public AlphaGetMetadataArg()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/CommitInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public CommitInfo(string path,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public CommitInfo()
{
this.Mode = Dropbox.Api.Files.WriteMode.Add.Instance;
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/CommitInfoWithProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public CommitInfoWithProperties(string path,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public CommitInfoWithProperties()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/CreateFolderArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public CreateFolderArg(string path,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public CreateFolderArg()
{
this.Autorename = false;
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/DeleteArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public DeleteArg(string path)
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public DeleteArg()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/DeleteBatchArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public DeleteBatchArg(col.IEnumerable<DeleteArg> entries)
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public DeleteBatchArg()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/DeleteBatchResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public DeleteBatchResult(col.IEnumerable<DeleteBatchResultEntry> entries)
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public DeleteBatchResult()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/DeleteResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public DeleteResult(Metadata metadata)
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public DeleteResult()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/DeletedMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public DeletedMetadata(string name,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public DeletedMetadata()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/Dimensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public Dimensions(ulong height,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public Dimensions()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/DownloadArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public DownloadArg(string path,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public DownloadArg()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/FileMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public FileMetadata(string name,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public FileMetadata()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/FileSharingInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public FileSharingInfo(bool readOnly,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public FileSharingInfo()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/FolderMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public FolderMetadata(string name,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public FolderMetadata()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/FolderSharingInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public FolderSharingInfo(bool readOnly,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public FolderSharingInfo()
{
this.TraverseOnly = false;
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/GetCopyReferenceArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public GetCopyReferenceArg(string path)
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public GetCopyReferenceArg()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/GetCopyReferenceResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public GetCopyReferenceResult(Metadata metadata,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public GetCopyReferenceResult()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/GetMetadataArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public GetMetadataArg(string path,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public GetMetadataArg()
{
this.IncludeMediaInfo = false;
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/GetTemporaryLinkArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public GetTemporaryLinkArg(string path)
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public GetTemporaryLinkArg()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/GetTemporaryLinkResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public GetTemporaryLinkResult(FileMetadata metadata,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public GetTemporaryLinkResult()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/GpsCoordinates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public GpsCoordinates(double latitude,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public GpsCoordinates()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/ListFolderArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public ListFolderArg(string path,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public ListFolderArg()
{
this.Recursive = false;
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/ListFolderContinueArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public ListFolderContinueArg(string cursor)
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public ListFolderContinueArg()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/ListFolderGetLatestCursorResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public ListFolderGetLatestCursorResult(string cursor)
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public ListFolderGetLatestCursorResult()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/ListFolderLongpollArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public ListFolderLongpollArg(string cursor,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public ListFolderLongpollArg()
{
this.Timeout = 30;
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/ListFolderLongpollResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public ListFolderLongpollResult(bool changes,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public ListFolderLongpollResult()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/ListFolderResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public ListFolderResult(col.IEnumerable<Metadata> entries,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public ListFolderResult()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/ListRevisionsArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public ListRevisionsArg(string path,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public ListRevisionsArg()
{
this.Limit = 10;
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/ListRevisionsResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public ListRevisionsResult(bool isDeleted,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public ListRevisionsResult()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/MediaMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ protected MediaMetadata(Dimensions dimensions = null,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public MediaMetadata()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/Metadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ protected Metadata(string name,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public Metadata()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/PathRootError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public PathRootError(string pathRoot = null)
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public PathRootError()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/PhotoMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public PhotoMetadata(Dimensions dimensions = null,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public PhotoMetadata()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/PreviewArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public PreviewArg(string path,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public PreviewArg()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/PropertyGroupUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public PropertyGroupUpdate(string templateId,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public PropertyGroupUpdate()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/PropertyGroupWithPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public PropertyGroupWithPath(string path,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public PropertyGroupWithPath()
{
}
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/RelocationArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public RelocationArg(string fromPath,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public RelocationArg()
{
this.AllowSharedFolder = false;
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/RelocationBatchArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public RelocationBatchArg(col.IEnumerable<RelocationPath> entries,
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public RelocationBatchArg()
{
this.AllowSharedFolder = false;
Expand Down
1 change: 1 addition & 0 deletions Dropbox.Api/Files/RelocationBatchResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public RelocationBatchResult(col.IEnumerable<RelocationResult> entries)
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public RelocationBatchResult()
{
}
Expand Down
Loading

0 comments on commit eeefcf7

Please sign in to comment.