Skip to content

Conversation

BartoszKlonowski
Copy link
Contributor

@BartoszKlonowski BartoszKlonowski commented Aug 30, 2025

This pull request closes #47386.

It uses the System.Net.Http.Json.HttpClientJsonExtensions.GetFromJsonAsync extension method to simplify the fetching and deserialization process in the tutorial to teach good practices from the beginning and use the latest available features.

To achieve the full compatibility with what was there in the tutorial and the new method usage, this PR:

  • Refactors the code of ProcessRepositoriesAsync function to make use of the GetFromJsonAsync method,
  • Refactors the Repository class so that it doesn't have to use the complicated JsonPropertyName of System.Text.Json.Serialization, but puts all the class fields that we want to deserialize right away into the class fields,
  • Changes the part of "Deserialize the JSON Result" so that the new method is described,
  • Removes completely the part deserialization configuration - it was just not needed anymore considering the simplified approach,
  • Updates snippets so that they match what is implemented step-by-step in the article,
  • Changes Write to WriteLine, so that at the beginning, when displaying only the repo name in the console we display it line by line, instead of all together (to slightly improve the readability).
  • Modifies the numeration of the points in the tutorials.
    I know this displays correctly already in the final page in docs, but it just confused me at first, so wanted to align that with what is displayed in page.

Note
This PR should also have the PR to samples repo merged: dotnet/samples#7067, to make sure that the full, final, project matches the tutorial implementation explained.


Internal previews

📄 File 🔗 Preview link
docs/csharp/tutorials/console-webapiclient.md Tutorial: Make HTTP requests in a .NET console app using C#

Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great @BartoszKlonowski

I had a few comments, and then it's ready to merge.

This is mentioned in two places - with the C# naming convention, where
it's worth to mention why we keep on having uppercase, and in the Repository
class defining, where we would normally had to make a conversion, but
now we don't because we have case-insensitive method as a tool.
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great @BartoszKlonowski

I'll :shipit: as soon as the build finishes.

@BillWagner BillWagner enabled auto-merge (squash) September 3, 2025 13:51
@BillWagner BillWagner merged commit aacf19b into dotnet:main Sep 3, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution Indicates PR is created by someone from the .NET community. dotnet-csharp/svc fundamentals/subsvc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The new dotnet version httpclient-json can be used.
2 participants