Skip to content

Updating EntityRequest.Base.template with code fix for response headers issue #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion Templates/CSharp/Base/EntityRequest.Base.template.tt
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,9 @@ public void AppendUpdateAsyncHeader(string entityName, string lowerCaseEntityNam
{
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append(" /// <param name=\"cancellationToken\">The <see cref=\"CancellationToken\"/> for the request.</param>");
}
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append(" /// <exception cref=\"ClientException\">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>");
}

stringBuilder.Append(Environment.NewLine);
stringBuilder.AppendFormat(" /// <returns>The updated {0}.</returns>", entityName);
Expand Down Expand Up @@ -390,6 +392,32 @@ public string GetEntityUpdateAsyncMethod(OdcmClass odcmClass, bool initializeCol
stringBuilder.AppendFormat(" public async System.Threading.Tasks.Task<{0}> UpdateAsync({0} {1}ToUpdate, CancellationToken cancellationToken)", entityName, lowerCaseEntityName);
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append(" {");
stringBuilder.Append(Environment.NewLine);
stringBuilder.AppendFormat(" if ({0}ToUpdate.AdditionalData != null)", lowerCaseEntityName);
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append(" {");
stringBuilder.Append(Environment.NewLine);
stringBuilder.AppendFormat(" if ({0}ToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||", lowerCaseEntityName);
stringBuilder.Append(Environment.NewLine);
stringBuilder.AppendFormat(" {0}ToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))", lowerCaseEntityName);
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append(" {");
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append(" throw new ClientException(");
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append(" new Error");
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append(" {");
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append(" Code = GeneratedErrorConstants.Codes.NotAllowed,");
stringBuilder.Append(Environment.NewLine);
stringBuilder.AppendFormat(" Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, {0}ToUpdate.GetType().Name)", lowerCaseEntityName);
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append(" });");
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append(" }");
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append(" }");
stringBuilder.Append(Environment.NewLine);
stringBuilder.AppendFormat(" this.ContentType = \"{0}\";", templateWriter.jsonContentType);
stringBuilder.Append(Environment.NewLine);
Expand Down
4 changes: 3 additions & 1 deletion Templates/CSharp/Base/IEntityRequest.Base.template.tt
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ public void AppendUpdateAsyncMethodHeader(string entityName, string lowerCaseEnt
{
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append(" /// <param name=\"cancellationToken\">The <see cref=\"CancellationToken\"/> for the request.</param>");
}
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append(" /// <exception cref=\"ClientException\">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>");
}

stringBuilder.Append(Environment.NewLine);
stringBuilder.AppendFormat(" /// <returns>The updated {0}.</returns>", entityName);
Expand Down