dotnet / dotnet/roslyn

Using a JsonSchemaSegment with a json comment breaks visual studio auto complete and syntax highliting

Open
#82,066 0 comments 0 reactions 0 assignees View on GitHub
Area-IDE
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/Using-a-JsonSchemaSegment-with-a-json-co/11026128)._

---
[severity:Other]
**Description:**
There is a feature where you can append the schema for json files using the MSBuild attribute `JsonSchemaSegment`. You can include this schema within a NuGet package to help provide validation for users editing their appsettings. However if that schema is invalid, in any form it will break the inteilises and auto complete of the last two versions of visual studio. A simple way to break it is to add a comment in the json schema.

There is no errors, anywhere. Deleting bin, obj, .vs, visual studios internal cache still does not resolve the issue. I even looked in Structured Log Viewer to find any, not a single hint. This lead to me wasting wayyyy to much time trying to figure out why it was broken.

I have attached a demo project which will recreate the issue. Just build the `Poisioned.Package` and then build the `Source Project`. You will need to close visual studio and reopen. At that point you will notice syntax highlting will be gone on all nuget packages, in this case Newtonsoft.Json

![image.png](https://aka.ms/dc/image?name=B0aba22830b1c48df9733d4be3298d586639035253218852230_20260108-221521-image.png&tid=0aba22830b1c48df9733d4be3298d586639035253218852230)

**Effects:**
* Visual Studio 2022
* Visual Studio 2026

---
### Original Comments

#### Feedback Bot on 1/9/2026, 06:08 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

#### Feedback Bot on 1/12/2026, 05:21 AM:

This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.

Contributor guide

Open the contributing guide

Research direction

Build Poisioned.Package and then Source Project from the attached demo, using the MSBuild JsonSchemaSegment described in the issue. Reopen Visual Studio and verify the effect on Newtonsoft.Json syntax highlighting and autocomplete; done means an invalid schema, including one with a comment, no longer disables those features or produces an unexplained failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
json
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.