Fix warnings and remove extra published artifacts · microsoft/VSConfigFinder@5f2acab (original) (raw)
`@@ -68,8 +68,7 @@ public static void CreateOutput(IFileSystem fileSystem, ILogger logger, VSConfig
`
68
68
`if (options.CreateFile)
`
69
69
`{
`
70
70
`// Create a file
`
71
``
`-
var serializerOptions = new JsonSerializerOptions { WriteIndented = true };
`
72
``
`-
var jsonString = JsonSerializer.Serialize(finalConfig, serializerOptions);
`
``
71
`+
var jsonString = JsonSerializer.Serialize(finalConfig, typeof(VSConfig), SourceGenerationContext.Default);
`
73
72
`var outputPath = Path.Combine(options.ConfigOutputPath!, ConfigExtension);
`
74
73
``
75
74
`fileSystem.WriteAllText(outputPath, jsonString);
`
`@@ -91,21 +90,30 @@ public static void CreateOutput(IFileSystem fileSystem, ILogger logger, VSConfig
`
91
90
`///
`
92
91
`public static string[] ReadComponents(IFileSystem fileSystem, CommandLineOptions options)
`
93
92
`{
`
94
``
`-
var pathsToVsConfigs = fileSystem.GetFileSystemEntries(options.FolderPath, "*" + ConfigExtension, recursive: true);
`
``
93
`+
var pathsToVsConfigs = fileSystem.GetFileSystemEntries(options.FolderPath!, "*" + ConfigExtension, recursive: true);
`
95
94
``
96
95
`var componentsSet = new HashSet(StringComparer.OrdinalIgnoreCase);
`
97
96
`var serializerOptions = new JsonSerializerOptions
`
98
97
`{
`
99
98
`PropertyNameCaseInsensitive = true,
`
100
99
`AllowTrailingCommas = true,
`
101
100
`};
`
``
101
`+
var context = new SourceGenerationContext(serializerOptions);
`
102
102
``
103
103
`foreach (var path in pathsToVsConfigs)
`
104
104
`{
`
105
105
`string[]? components;
`
106
106
`using (var stream = fileSystem.OpenFile(path))
`
107
107
`{
`
108
``
`-
components = JsonSerializer.Deserialize(stream, serializerOptions)?.Components;
`
``
108
`+
var config = JsonSerializer.Deserialize(stream, typeof(VSConfig), context);
`
``
109
`+
if (config is VSConfig vsconfig)
`
``
110
`+
{
`
``
111
`+
components = vsconfig.Components;
`
``
112
`+
}
`
``
113
`+
else
`
``
114
`+
{
`
``
115
`+
throw new ArgumentException("Failed to read components. Please make sure the .vsconfig file input is in the correct format.");
`
``
116
`+
}
`
109
117
`}
`
110
118
``
111
119
`if (components is not null)
`