Skip to content

Conversation

@anandmeg
Copy link
Contributor

@anandmeg anandmeg commented Nov 14, 2025

Update the document to improve the section on using AI for serialization. Added details on handling nested and polymorphic types.


Internal previews

📄 File 🔗 Preview link
docs/standard/serialization/system-text-json/how-to.md How to write .NET objects as JSON (serialize)

Update the document to improve the section on using AI for serialization. Added details on handling nested and polymorphic types.
Copilot AI review requested due to automatic review settings November 14, 2025 18:37
@anandmeg anandmeg requested review from a team and gewarren as code owners November 14, 2025 18:37
@dotnetrepoman dotnetrepoman bot added this to the November 2025 milestone Nov 14, 2025
@dotnet-policy-service dotnet-policy-service bot added dotnet-fundamentals/svc community-contribution Indicates PR is created by someone from the .NET community. labels Nov 14, 2025
Copilot finished reviewing on behalf of anandmeg November 14, 2025 18:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR revises the AI section of the serialization documentation to better explain how to use AI tools for generating code that handles nested and polymorphic types. The changes update the section heading and provide a more detailed example prompt for GitHub Copilot.

Key Changes

  • Updated the heading to clarify focus on nested and polymorphic types
  • Expanded the example Copilot prompt to demonstrate generating code for hierarchical object structures with custom JsonConverter
  • Improved the link text for Visual Studio Code in the "See also" section

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.

I had a couple small comments, but this is good.

I'll let @gewarren review and approve.


> [!TIP]
> You can use AI assistance to [serialize to JSON](#use-ai-to-serialize-to-json).
> You can use AI assistance to [serialize to JSON](#use-ai-to-serialize-nested-and-polymorphic-types).
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that the focus of the example has changed, seems like this belongs more in https://github.com/dotnet/docs/blob/main/docs/standard/serialization/system-text-json/polymorphism.md.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're revising these examples per community & cloud advocate feedback to show extended use cases which demonstrate the true value add of Copilot. In the other doc, this could come across as a simpler example use case given the doc's topic. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @gewarren. While the example should be expanded to be good, the true value add isn't going to be demonstrated in this article. However, I'm going to give that feedback down below inline with the copilot prompt.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gewarren, @adegeo - thanks! thoughts/suggestions on a good example scenario for this doc which is more than basic? Most folks know basic prompting at this point, so the previous example could be thought of as a bit basic.
cc: @BillWagner

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, is the proposed example a good one for https://github.com/dotnet/docs/blob/main/docs/standard/serialization/system-text-json/polymorphism.md, or would it need to be revised?

Copy link
Member

Choose a reason for hiding this comment

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

I agree that this example belongs where we go deeper on the polymorphism capabilities of System.Text.Json. Andy's suggestion would really help readers see more value from Copilot.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, and having that polymorphism AI example should be pretty comprehensive. More introduction in the copilot suggestion, setting up the scenario copilot is going to fix, maybe provide example code, etc, and then demonstrate it. Let's make Copilot work for our users, not make our users fight with copilot for something useable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks all for your input & feedback. I'll revise the example in this article using one of your suggestions below.
I’ll leave the advanced polymorphic example for the polymorphism article (I can draft the example and move it there, but I’ll let the SMEs review and finalize it).

Updated prompt to simplify serialization instructions and ensure proper formatting.
Copy link
Contributor

@adegeo adegeo 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 looking much better. Here are some suggestions to push this through to the finish line. Thanks!

Comment on lines 123 to 125
Review Copilot's suggestions before applying them.

For more information about GitHub Copilot, see GitHub's [FAQs](https://github.com/features/copilot#faq).
Copy link
Contributor

Choose a reason for hiding this comment

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

We really only need a small disclaimer at the end of these Copilot suggestions.

Suggested change
*Copilot is powered by AI, so surprises and mistakes are possible. For more information, see [Copilot general use FAQs](https://aka.ms/copilot-general-use-faqs).*

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We used to have this disclaimer before. It was revised in the doc based on feedback we've seen to just add the current "Review Copilot's suggestions before applying them." This disclaimer is present in Copilot.

You can use AI tools, such as GitHub Copilot, to generate code that uses `System.Text.Json` to serialize to JSON. You can customize the prompt to fit your object fields and serialization needs.

The following text shows an example prompt for Copilot Chat:
Here's an example prompt you can use in Visual Studio Code Copilot Chat to generate serialization code.
Copy link
Contributor

Choose a reason for hiding this comment

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

Considering this isn't specific to VSCode, it should be generic:

Suggested change
Here's an example prompt you can use in Visual Studio Code Copilot Chat to generate serialization code.
Here's an example prompt you can use in Copilot to generate serialization code:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried it in Visual Studio Code. I wouldn't want to claim it'll give the same results everywhere. User is free to copy and try the prompt with any Copilot.

Comment on lines 129 to +130
- [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states)
- [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview)
- [GitHub Copilot in Visual Studio Code](https://code.visualstudio.com/docs/copilot/overview)
Copy link
Contributor

Choose a reason for hiding this comment

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

These don't make sense for the article. It should point to how to deserialize and maybe more complex serialization:

Suggested change
- [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states)
- [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview)
- [GitHub Copilot in Visual Studio Code](https://code.visualstudio.com/docs/copilot/overview)
- [How to read JSON as .NET objects (deserialize)](deserialization.md)
- [How to customize property names and values with System.Text.Json](customize-properties.md)

Copy link
Contributor Author

@anandmeg anandmeg Nov 15, 2025

Choose a reason for hiding this comment

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

We don't want to add links directly in the section, so we decided to add these links to the Related links. wrt the other links, I'll leave it to the author @gewarren to decide which ones to include.

Co-authored-by: Andy (Steve) De George <[email protected]>
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-fundamentals/svc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants