Repository navigation
Closed
Copy link
Description
Summary
JsonConfigurationFileParser support comment and trailing comma when targeting .NET.
testfx/src/Platform/Microsoft.Testing.Platform/Configurations/JsonConfigurationFileParser.cs
Lines 31 to 35 in 75f70ec
| 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.
Metadata
Metadata
Assignees
Labels
area/mtpMicrosoft.Testing.Platform core library.
Activity
Evangelink commentedon Jul 22, 2026
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.