diff --git a/packages/quicktype-vscode/README.md b/packages/quicktype-vscode/README.md index 652fb05fa6..50879a20b8 100644 --- a/packages/quicktype-vscode/README.md +++ b/packages/quicktype-vscode/README.md @@ -23,6 +23,8 @@ This extension is available for free in the [Visual Studio Code Marketplace](htt - `quicktype.justTypes`: Generate only types, or also produce (de)serialization code when using "Open quicktype". When using "Paste", you can pick between the commands for "types" and "code", without having to set this option. +- `quicktype.csharp.framework`: Serialization framework for generated C#: `SystemTextJson` (default, built into .NET, no NuGet needed) or `NewtonSoft`. + - `quicktype.inferMaps`, `quicktype.inferEnums`, `quicktype.inferDateTimes`, `quicktype.inferUuids`, `quicktype.inferBoolStrings`, `quicktype.inferIntegerStrings`: Tell quicktype whether it should try to infer those types from the input JSON. This is not a precise science, so sometimes the guess will be wrong, which is why you can turn them off through these options. Also, quicktype doesn't support dates, UUIDs and stringified integers/booleans in all target languages yet. ## Contribute! diff --git a/packages/quicktype-vscode/package.json b/packages/quicktype-vscode/package.json index 05e2f6727c..23761d1821 100644 --- a/packages/quicktype-vscode/package.json +++ b/packages/quicktype-vscode/package.json @@ -46,6 +46,15 @@ "default": true, "description": "Produce only types; no (de-)serialization code" }, + "quicktype.csharp.framework": { + "type": "string", + "enum": [ + "NewtonSoft", + "SystemTextJson" + ], + "default": "SystemTextJson", + "description": "C# serialization framework: built-in System.Text.Json (default) or Newtonsoft.Json (NuGet)" + }, "quicktype.inferMaps": { "type": "boolean", "default": true, diff --git a/packages/quicktype-vscode/src/extension.ts b/packages/quicktype-vscode/src/extension.ts index 506efb9d97..78174d6295 100644 --- a/packages/quicktype-vscode/src/extension.ts +++ b/packages/quicktype-vscode/src/extension.ts @@ -112,6 +112,11 @@ async function runQuicktype( justTypes && lang.optionDefinitions.some((o) => o.name === "just-types") ? ({ "just-types": "true" } as RendererOptions) : {}; + // quicktype-core names the C# language "cs"; "csharp" is an alias. + if (lang.names.includes("csharp")) { + (rendererOptions as RendererOptions<"csharp">).framework = + configuration.get("csharp.framework", "SystemTextJson"); + } const inputData = new InputData(); switch (kind) {