forked from stryker-mutator/stryker-net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Instead, use System.Text.Json everywhere. ### JSON Configuration File Since there's [no equivalent][1] to `MissingMemberHandling` with `System.Text.Json`, the error messages in case of erroneous keys in the JSON configuration file have been improved. For example, if you have a typo in the `enabled` key you would get this error: > The allowed keys for the "stryker-config.since" object are { "enabled", "ignore-changes-in", "target" } but "enable" was found in the config file at "[…]/tests/stryker-config.json" Those better error messages also required to have a `JsonPropertyName` attribute on _all_ the properties. This is probably a good thing anyway since it makes the code more _greppable_. ### Newtonsoft.Json transitive dependency Unfortunately, `Newtonsoft.Json` is still there transitively (through Buildalyzer/3.2.2 → Microsoft.Extensions.DependencyModel/2.1.0 → Newtonsoft.Json/9.0.1) but there's nothing we can do about it for now, see microsoft/vstest#2488 (comment) for a full explanation. [1]: https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-migrate-from-newtonsoft-how-to#missingmemberhandling
- Loading branch information
Showing
21 changed files
with
625 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,155 @@ | ||
using Newtonsoft.Json; | ||
using Stryker.Core.Options; | ||
using System.Collections.Generic; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Stryker.CLI | ||
{ | ||
public class FileBasedInputOuter | ||
public interface IExtraData | ||
{ | ||
[JsonProperty(PropertyName = "stryker-config")] | ||
public FileBasedInput Input { get; set; } | ||
Dictionary<string, JsonElement> ExtraData { get; init; } | ||
} | ||
|
||
public class FileBasedInput | ||
public class FileBasedInputOuter : IExtraData | ||
{ | ||
[JsonProperty(PropertyName = "project-info")] | ||
public ProjectInfo ProjectInfo { get; set; } | ||
[JsonPropertyName("stryker-config")] | ||
public FileBasedInput Input { get; init; } | ||
|
||
public int? Concurrency { get; set; } | ||
[JsonExtensionData] | ||
public Dictionary<string, JsonElement> ExtraData { get; init; } | ||
} | ||
|
||
public class FileBasedInput : IExtraData | ||
{ | ||
[JsonPropertyName("project-info")] | ||
public ProjectInfo ProjectInfo { get; init; } | ||
|
||
[JsonPropertyName("concurrency")] | ||
public int? Concurrency { get; init; } | ||
|
||
[JsonPropertyName("mutation-level")] | ||
public string MutationLevel { get; init; } | ||
|
||
[JsonPropertyName("language-version")] | ||
public string LanguageVersion { get; init; } | ||
|
||
[JsonPropertyName("additional-timeout")] | ||
public int? AdditionalTimeout { get; init; } | ||
|
||
[JsonPropertyName("mutate")] | ||
public string[] Mutate { get; init; } | ||
|
||
[JsonProperty(PropertyName = "mutation-level")] | ||
public string MutationLevel { get; set; } | ||
[JsonPropertyName("solution")] | ||
public string Solution { get; init; } | ||
|
||
[JsonProperty(PropertyName = "language-version")] | ||
public string LanguageVersion { get; set; } | ||
[JsonPropertyName("target-framework")] | ||
public string TargetFramework { get; init; } | ||
|
||
[JsonProperty(PropertyName = "additional-timeout")] | ||
public int AdditionalTimeout { get; set; } | ||
[JsonPropertyName("project")] | ||
public string Project { get; init; } | ||
|
||
public string[] Mutate { get; set; } | ||
[JsonPropertyName("coverage-analysis")] | ||
public string CoverageAnalysis { get; init; } | ||
|
||
public string Solution { get; set; } | ||
[JsonPropertyName("disable-bail")] | ||
public bool? DisableBail { get; init; } | ||
|
||
[JsonProperty(PropertyName = "target-framework")] | ||
public string TargetFramework { get; set; } | ||
[JsonPropertyName("disable-mix-mutants")] | ||
public bool? DisableMixMutants { get; init; } | ||
|
||
public string Project { get; set; } | ||
[JsonPropertyName("thresholds")] | ||
public Thresholds Thresholds { get; init; } | ||
|
||
[JsonProperty(PropertyName = "coverage-analysis")] | ||
public string CoverageAnalysis { get; set; } | ||
[JsonPropertyName("verbosity")] | ||
public string Verbosity { get; init; } | ||
|
||
[JsonProperty(PropertyName = "disable-bail")] | ||
public bool DisableBail { get; set; } | ||
[JsonPropertyName("reporters")] | ||
public string[] Reporters { get; init; } | ||
|
||
[JsonProperty(PropertyName = "disable-mix-mutants")] | ||
public bool DisableMixMutants { get; set; } | ||
[JsonPropertyName("since")] | ||
public Since Since { get; init; } | ||
|
||
public Thresholds Thresholds { get; set; } | ||
[JsonPropertyName("baseline")] | ||
public Baseline Baseline { get; init; } | ||
|
||
public string Verbosity { get; set; } | ||
[JsonPropertyName("dashboard-url")] | ||
public string DashboardUrl { get; init; } | ||
|
||
public string[] Reporters { get; set; } | ||
[JsonPropertyName("test-projects")] | ||
public string[] TestProjects { get; init; } | ||
|
||
public Since Since { get; set; } | ||
[JsonPropertyName("test-case-filter")] | ||
public string TestCaseFilter { get; init; } | ||
|
||
public Baseline Baseline { get; set; } | ||
[JsonPropertyName("ignore-mutations")] | ||
public string[] IgnoreMutations { get; init; } | ||
|
||
[JsonProperty(PropertyName = "dashboard-url")] | ||
public string DashboardUrl { get; set; } | ||
[JsonPropertyName("ignore-methods")] | ||
public string[] IgnoreMethods { get; init; } | ||
|
||
[JsonProperty(PropertyName = "test-projects")] | ||
public string[] TestProjects { get; set; } | ||
[JsonExtensionData] | ||
public Dictionary<string, JsonElement> ExtraData { get; init; } | ||
} | ||
|
||
public class Since : IExtraData | ||
{ | ||
[JsonPropertyName("enabled")] | ||
public bool? Enabled { get; init; } | ||
|
||
[JsonProperty(PropertyName = "test-case-filter")] | ||
public string TestCaseFilter { get; set; } | ||
[JsonPropertyName("ignore-changes-in")] | ||
public string[] IgnoreChangesIn { get; init; } | ||
|
||
[JsonProperty(PropertyName = "ignore-mutations")] | ||
public string[] IgnoreMutations { get; set; } | ||
[JsonPropertyName("target")] | ||
public string Target { get; init; } | ||
|
||
[JsonProperty(PropertyName = "ignore-methods")] | ||
public string[] IgnoreMethods { get; set; } | ||
[JsonExtensionData] | ||
public Dictionary<string, JsonElement> ExtraData { get; init; } | ||
} | ||
|
||
public class Since | ||
public class Baseline : IExtraData | ||
{ | ||
public bool? Enabled { get; set; } | ||
[JsonPropertyName("enabled")] | ||
public bool? Enabled { get; init; } | ||
|
||
[JsonPropertyName("provider")] | ||
public string Provider { get; init; } | ||
|
||
[JsonProperty(PropertyName = "ignore-changes-in")] | ||
public string[] IgnoreChangesIn { get; set; } | ||
[JsonPropertyName("azure-fileshare-url")] | ||
public string AzureFileShareUrl { get; init; } | ||
|
||
[JsonProperty(PropertyName = "target")] | ||
public string Target { get; set; } | ||
[JsonPropertyName("fallback-version")] | ||
public string FallbackVersion { get; init; } | ||
|
||
[JsonExtensionData] | ||
public Dictionary<string, JsonElement> ExtraData { get; init; } | ||
} | ||
|
||
public class Baseline | ||
public class ProjectInfo : IExtraData | ||
{ | ||
public bool? Enabled { get; set; } | ||
[JsonPropertyName("name")] | ||
public string Name { get; init; } | ||
|
||
[JsonProperty(PropertyName = "provider")] | ||
public string Provider { get; set; } | ||
[JsonPropertyName("module")] | ||
public string Module { get; init; } | ||
|
||
[JsonProperty(PropertyName = "azure-fileshare-url")] | ||
public string AzureFileShareUrl { get; set; } | ||
[JsonPropertyName("version")] | ||
public string Version { get; init; } | ||
|
||
[JsonProperty(PropertyName = "fallback-version")] | ||
public string FallbackVersion { get; set; } | ||
[JsonExtensionData] | ||
public Dictionary<string, JsonElement> ExtraData { get; init; } | ||
} | ||
|
||
public class ProjectInfo | ||
public class Thresholds : IExtraData | ||
{ | ||
public string Name { get; set; } | ||
public string Module { get; set; } | ||
public string Version { get; set; } | ||
[JsonPropertyName("high")] | ||
public int? High { get; init; } | ||
|
||
[JsonPropertyName("low")] | ||
public int? Low { get; init; } | ||
|
||
[JsonPropertyName("break")] | ||
public int? Break { get; init; } | ||
|
||
[JsonExtensionData] | ||
public Dictionary<string, JsonElement> ExtraData { get; init; } | ||
} | ||
} |
Oops, something went wrong.