Skip to content

Add comment line support on testconfig.json when targeting .NET Framework #10137

Description

@filzrev

Summary

JsonConfigurationFileParser support comment and trailing comma when targeting .NET.

JsonDocumentOptions jsonDocumentOptions = new()
{
CommentHandling = JsonCommentHandling.Skip,
AllowTrailingCommas = true,
};

But when using .NET Framework Jsonite library based implementation is used instead. (JsonConfigurationFileParser.netstandard.cs)
And comment is not supported because underling Jsonite don't support this feature.

StackTrace

Unhandled Exception: Jsonite.JsonException: Unexpected character '/' while parsing an object. Expecting a STRING or '}'
   at Jsonite.JsonReflectorDefault.OnDeserializeRaiseParsingError(Int32 offset, Int32 line, Int32 column, String message, Exception inner) in /_/src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Jsonite/JsonReflector.cs:line 353
   at Jsonite.Json.JsonReader.RaiseUnexpected(String message) in /_/src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Jsonite/JsonReader.cs:line 602
   at Jsonite.Json.JsonReader.ParseObject(Object obj, Type expectedType) in /_/src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Jsonite/JsonReader.cs:line 194
   at Jsonite.Json.JsonReader.Parse(Object existingObject, Type expectedType, Boolean expectValue) in /_/src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Jsonite/JsonReader.cs:line 95
   at Jsonite.Json.Deserialize(TextReader reader, JsonSettings settings) in /_/src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Jsonite/Json.cs:line 84
   at Jsonite.Json.Deserialize(String text, JsonSettings settings) in /_/src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Jsonite/Json.cs:line 69
   at Microsoft.Testing.Platform.Configurations.JsonConfigurationFileParser.ParseStream(Stream input) in /_/src/Platform/Microsoft.Testing.Platform/Configurations/JsonConfigurationFileParser.netstandard.cs:line 33
   at Microsoft.Testing.Platform.Configurations.JsonConfigurationSource.JsonConfigurationProvider.<LoadAsync>d__14.MoveNext() in /_/src/Platform/Microsoft.Testing.Platform/Configurations/JsonConfigurationProvider.cs:line 85

Background and Motivation

I want add comment on JSON configuration file. (e.g. add link to available options)
But currently it's not works if project contains .NET Framework target.

Proposed Feature

Add support for comment line on Jsonite custom implementation.
or preprocess comment lines before parsing JSON config file.

Activity

  1. added
    needs/triage
    on Jul 22, 2026
  2. added theissue type on Jul 22, 2026
  3. added
    area/mtp
    and removed
    needs/triage
    on Jul 22, 2026
  4. Evangelink commented on Jul 22, 2026

    @Evangelink
    Member

    Thanks for the report @filzev, this makes total sense to me so I'll work on fixing it. I have a bug fix release planned so depending on the effort to fix this, it might be included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area/mtp

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions