Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Allow JsonSerializerOptions without TypeInfoResolver

Open
#1,150 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
csharp
Domain
api

Research direction

Start at the WithTools implementation mentioned in the issue and trace how the supplied JsonSerializerOptions are made read-only. Reproduce the behavior with a new System.Text.Json.JsonSerializerOptions that only adds converters and a naming policy; done means passing it to WithTools throws no exception.

Written by the indexing model from the issue text.

Description

enhancement needs confirmation P3

I have JsonSerializerOptions which only adds some converters and set the naming policy. I don't have a source generated JsonSerializerContext and therefore no TypeInfoResolver.

When passing these options to a WithTools function, I get the exception:

JsonSerializerOptions instance must specify a TypeInfoResolver setting before being marked as read-only.

I understand that making these options read only is a good thing, but I don't understand enough about the difference to the overload of MakeReadOnly(populateMissingResolver) on the options.

I can set TypeInfoResolver = new DefaultJsonTypeInfoResolver() on my options, but that seems a bit weird.

To Reproduce
Steps to reproduce the behavior:

  1. Pass a new System.Text.Json.JsonSerializerOptions() object to one of the WithTools functions.

Expected behavior
No exception should be thrown.

Dominant language
C#
Stars
4.5k
Forks
814
Avg merge
9d 19h
Merged PRs (30d)
4

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from modelcontextprotocol/csharp-sdk

All issues in modelcontextprotocol/csharp-sdk

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.