Repository navigation
Fix C# JSON request and response handling for integer collections #12295
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
Draft
Copilot
wants to merge
7
commits into
main
Choose a base branch
from
copilot/fix-json-serialization-for-collections
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
047c8b2
Initial plan
Copilot d3b5325
fix(http-client-csharp): complete integer collection JSON support
Copilot 833a350
test(http-client-csharp): replace integer collection fixtures with ge…
Copilot db18db6
test(http-client-csharp): cover nested integer JSON request serializa…
Copilot 580de7c
test(http-client-csharp): clarify integer collection baselines
Copilot 334085c
test(http-client-csharp): sync generated enumerable loop
Copilot 16f0c0e
test(http-client-csharp): render method signatures and reuse foreach …
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
144 changes: 144 additions & 0 deletions
144
...ta/ScmMethodProviderCollectionTests/IntegerCollectionResponsesUseUtf8JsonReader(Int16).cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| public virtual global::System.ClientModel.ClientResult<global::System.Collections.Generic.IReadOnlyList<short>> GetList(global::System.Threading.CancellationToken cancellationToken = default) | ||
| { | ||
| global::System.ClientModel.ClientResult result = this.GetList(cancellationToken.ToRequestOptions()); | ||
| global::System.Collections.Generic.List<short> value = new global::System.Collections.Generic.List<short>(); | ||
| global::System.BinaryData data = result.GetRawResponse().Content; | ||
| global::System.Text.Json.Utf8JsonReader jsonReader = new global::System.Text.Json.Utf8JsonReader(data.ToMemory().Span); | ||
| jsonReader.Read(); | ||
| while (jsonReader.Read()) | ||
| { | ||
| if ((jsonReader.TokenType == global::System.Text.Json.JsonTokenType.EndArray)) | ||
| { | ||
| break; | ||
| } | ||
| value.Add(jsonReader.GetInt16()); | ||
| } | ||
| return global::System.ClientModel.ClientResult.FromValue(((global::System.Collections.Generic.IReadOnlyList<short>)value), result.GetRawResponse()); | ||
| } | ||
| public virtual async global::System.Threading.Tasks.Task<global::System.ClientModel.ClientResult<global::System.Collections.Generic.IReadOnlyList<short>>> GetListAsync(global::System.Threading.CancellationToken cancellationToken = default) | ||
| { | ||
| global::System.ClientModel.ClientResult result = await this.GetListAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); | ||
| global::System.Collections.Generic.List<short> value = new global::System.Collections.Generic.List<short>(); | ||
| global::System.BinaryData data = result.GetRawResponse().Content; | ||
| global::System.Text.Json.Utf8JsonReader jsonReader = new global::System.Text.Json.Utf8JsonReader(data.ToMemory().Span); | ||
| jsonReader.Read(); | ||
| while (jsonReader.Read()) | ||
| { | ||
| if ((jsonReader.TokenType == global::System.Text.Json.JsonTokenType.EndArray)) | ||
| { | ||
| break; | ||
| } | ||
| value.Add(jsonReader.GetInt16()); | ||
| } | ||
| return global::System.ClientModel.ClientResult.FromValue(((global::System.Collections.Generic.IReadOnlyList<short>)value), result.GetRawResponse()); | ||
| } | ||
| public virtual global::System.ClientModel.ClientResult<global::System.Collections.Generic.IReadOnlyList<short?>> GetNullableList(global::System.Threading.CancellationToken cancellationToken = default) | ||
| { | ||
| global::System.ClientModel.ClientResult result = this.GetNullableList(cancellationToken.ToRequestOptions()); | ||
| global::System.Collections.Generic.List<short?> value = new global::System.Collections.Generic.List<short?>(); | ||
| global::System.BinaryData data = result.GetRawResponse().Content; | ||
| global::System.Text.Json.Utf8JsonReader jsonReader = new global::System.Text.Json.Utf8JsonReader(data.ToMemory().Span); | ||
| jsonReader.Read(); | ||
| while (jsonReader.Read()) | ||
| { | ||
| if ((jsonReader.TokenType == global::System.Text.Json.JsonTokenType.EndArray)) | ||
| { | ||
| break; | ||
| } | ||
| value.Add((jsonReader.TokenType == global::System.Text.Json.JsonTokenType.Null) ? null : jsonReader.GetInt16()); | ||
| } | ||
| return global::System.ClientModel.ClientResult.FromValue(((global::System.Collections.Generic.IReadOnlyList<short?>)value), result.GetRawResponse()); | ||
| } | ||
| public virtual async global::System.Threading.Tasks.Task<global::System.ClientModel.ClientResult<global::System.Collections.Generic.IReadOnlyList<short?>>> GetNullableListAsync(global::System.Threading.CancellationToken cancellationToken = default) | ||
| { | ||
| global::System.ClientModel.ClientResult result = await this.GetNullableListAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); | ||
| global::System.Collections.Generic.List<short?> value = new global::System.Collections.Generic.List<short?>(); | ||
| global::System.BinaryData data = result.GetRawResponse().Content; | ||
| global::System.Text.Json.Utf8JsonReader jsonReader = new global::System.Text.Json.Utf8JsonReader(data.ToMemory().Span); | ||
| jsonReader.Read(); | ||
| while (jsonReader.Read()) | ||
| { | ||
| if ((jsonReader.TokenType == global::System.Text.Json.JsonTokenType.EndArray)) | ||
| { | ||
| break; | ||
| } | ||
| value.Add((jsonReader.TokenType == global::System.Text.Json.JsonTokenType.Null) ? null : jsonReader.GetInt16()); | ||
| } | ||
| return global::System.ClientModel.ClientResult.FromValue(((global::System.Collections.Generic.IReadOnlyList<short?>)value), result.GetRawResponse()); | ||
| } | ||
| public virtual global::System.ClientModel.ClientResult<global::System.Collections.Generic.IReadOnlyDictionary<string, short>> GetDictionary(global::System.Threading.CancellationToken cancellationToken = default) | ||
| { | ||
| global::System.ClientModel.ClientResult result = this.GetDictionary(cancellationToken.ToRequestOptions()); | ||
| global::System.Collections.Generic.IDictionary<string, short> value = new global::System.Collections.Generic.Dictionary<string, short>(); | ||
| global::System.BinaryData data = result.GetRawResponse().Content; | ||
| global::System.Text.Json.Utf8JsonReader jsonReader = new global::System.Text.Json.Utf8JsonReader(data.ToMemory().Span); | ||
| jsonReader.Read(); | ||
| while (jsonReader.Read()) | ||
| { | ||
| if ((jsonReader.TokenType == global::System.Text.Json.JsonTokenType.EndObject)) | ||
| { | ||
| break; | ||
| } | ||
| string propertyName = jsonReader.GetString(); | ||
| jsonReader.Read(); | ||
| value.Add(propertyName, jsonReader.GetInt16()); | ||
| } | ||
| return global::System.ClientModel.ClientResult.FromValue(((global::System.Collections.Generic.IReadOnlyDictionary<string, short>)value), result.GetRawResponse()); | ||
| } | ||
| public virtual async global::System.Threading.Tasks.Task<global::System.ClientModel.ClientResult<global::System.Collections.Generic.IReadOnlyDictionary<string, short>>> GetDictionaryAsync(global::System.Threading.CancellationToken cancellationToken = default) | ||
| { | ||
| global::System.ClientModel.ClientResult result = await this.GetDictionaryAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); | ||
| global::System.Collections.Generic.IDictionary<string, short> value = new global::System.Collections.Generic.Dictionary<string, short>(); | ||
| global::System.BinaryData data = result.GetRawResponse().Content; | ||
| global::System.Text.Json.Utf8JsonReader jsonReader = new global::System.Text.Json.Utf8JsonReader(data.ToMemory().Span); | ||
| jsonReader.Read(); | ||
| while (jsonReader.Read()) | ||
| { | ||
| if ((jsonReader.TokenType == global::System.Text.Json.JsonTokenType.EndObject)) | ||
| { | ||
| break; | ||
| } | ||
| string propertyName = jsonReader.GetString(); | ||
| jsonReader.Read(); | ||
| value.Add(propertyName, jsonReader.GetInt16()); | ||
| } | ||
| return global::System.ClientModel.ClientResult.FromValue(((global::System.Collections.Generic.IReadOnlyDictionary<string, short>)value), result.GetRawResponse()); | ||
| } | ||
| public virtual global::System.ClientModel.ClientResult<global::System.Collections.Generic.IReadOnlyDictionary<string, short?>> GetNullableDictionary(global::System.Threading.CancellationToken cancellationToken = default) | ||
| { | ||
| global::System.ClientModel.ClientResult result = this.GetNullableDictionary(cancellationToken.ToRequestOptions()); | ||
| global::System.Collections.Generic.IDictionary<string, short?> value = new global::System.Collections.Generic.Dictionary<string, short?>(); | ||
| global::System.BinaryData data = result.GetRawResponse().Content; | ||
| global::System.Text.Json.Utf8JsonReader jsonReader = new global::System.Text.Json.Utf8JsonReader(data.ToMemory().Span); | ||
| jsonReader.Read(); | ||
| while (jsonReader.Read()) | ||
| { | ||
| if ((jsonReader.TokenType == global::System.Text.Json.JsonTokenType.EndObject)) | ||
| { | ||
| break; | ||
| } | ||
| string propertyName = jsonReader.GetString(); | ||
| jsonReader.Read(); | ||
| value.Add(propertyName, (jsonReader.TokenType == global::System.Text.Json.JsonTokenType.Null) ? null : jsonReader.GetInt16()); | ||
| } | ||
| return global::System.ClientModel.ClientResult.FromValue(((global::System.Collections.Generic.IReadOnlyDictionary<string, short?>)value), result.GetRawResponse()); | ||
| } | ||
| public virtual async global::System.Threading.Tasks.Task<global::System.ClientModel.ClientResult<global::System.Collections.Generic.IReadOnlyDictionary<string, short?>>> GetNullableDictionaryAsync(global::System.Threading.CancellationToken cancellationToken = default) | ||
| { | ||
| global::System.ClientModel.ClientResult result = await this.GetNullableDictionaryAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); | ||
| global::System.Collections.Generic.IDictionary<string, short?> value = new global::System.Collections.Generic.Dictionary<string, short?>(); | ||
| global::System.BinaryData data = result.GetRawResponse().Content; | ||
| global::System.Text.Json.Utf8JsonReader jsonReader = new global::System.Text.Json.Utf8JsonReader(data.ToMemory().Span); | ||
| jsonReader.Read(); | ||
| while (jsonReader.Read()) | ||
| { | ||
| if ((jsonReader.TokenType == global::System.Text.Json.JsonTokenType.EndObject)) | ||
| { | ||
| break; | ||
| } | ||
| string propertyName = jsonReader.GetString(); | ||
| jsonReader.Read(); | ||
| value.Add(propertyName, (jsonReader.TokenType == global::System.Text.Json.JsonTokenType.Null) ? null : jsonReader.GetInt16()); | ||
| } | ||
| return global::System.ClientModel.ClientResult.FromValue(((global::System.Collections.Generic.IReadOnlyDictionary<string, short?>)value), result.GetRawResponse()); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.