"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CSharpTargetLanguage = exports.cSharpLanguageConfig = exports.systemTextJsonCSharpOptions = exports.newtonsoftCSharpOptions = exports.cSharpOptions = void 0;
const index_js_1 = require("../../RendererOptions/index.js");
const Support_js_1 = require("../../support/Support.js");
const TargetLanguage_js_1 = require("../../TargetLanguage.js");
const NewtonSoftCSharpRenderer_js_1 = require("./NewtonSoftCSharpRenderer.js");
const SystemTextJsonCSharpRenderer_js_1 = require("./SystemTextJsonCSharpRenderer.js");
const utils_js_1 = require("./utils.js");
exports.cSharpOptions = {
    framework: new index_js_1.EnumOption("framework", "Serialization framework", {
        NewtonSoft: "NewtonSoft",
        SystemTextJson: "SystemTextJson",
    }, "NewtonSoft"),
    useList: new index_js_1.EnumOption("array-type", "Use T[] or List<T>", {
        array: false,
        list: true,
    }, "array"),
    dense: new index_js_1.EnumOption("density", "Property density", {
        normal: false,
        dense: true,
    }, "normal", "secondary"),
    // FIXME: Do this via a configurable named eventually.
    namespace: new index_js_1.StringOption("namespace", "Generated namespace", "NAME", "QuickType"),
    version: new index_js_1.EnumOption("csharp-version", "C# version", {
        "5": 5,
        "6": 6,
    }, "6", "secondary"),
    virtual: new index_js_1.BooleanOption("virtual", "Generate virtual properties", false),
    typeForAny: new index_js_1.EnumOption("any-type", 'Type to use for "any"', {
        object: "object",
        dynamic: "dynamic",
    }, "object", "secondary"),
    useDecimal: new index_js_1.EnumOption("number-type", "Type to use for numbers", {
        double: false,
        decimal: true,
    }, "double", "secondary"),
    features: new index_js_1.EnumOption("features", "Output features", {
        complete: { namespaces: true, helpers: true, attributes: true },
        "attributes-only": {
            namespaces: true,
            helpers: false,
            attributes: true,
        },
        "just-types-and-namespace": {
            namespaces: true,
            helpers: false,
            attributes: false,
        },
        "just-types": {
            namespaces: true,
            helpers: false,
            attributes: false,
        },
    }, "complete"),
    baseclass: new index_js_1.EnumOption("base-class", "Base class", {
        EntityData: "EntityData",
        Object: undefined,
    }, "Object", "secondary"),
    checkRequired: new index_js_1.BooleanOption("check-required", "Fail if required properties are missing", false),
    keepPropertyName: new index_js_1.BooleanOption("keep-property-name", "Keep original field name generate", false),
};
exports.newtonsoftCSharpOptions = Object.assign({}, exports.cSharpOptions, {});
exports.systemTextJsonCSharpOptions = Object.assign({}, exports.cSharpOptions, {});
exports.cSharpLanguageConfig = {
    displayName: "C#",
    names: ["cs", "csharp"],
    extension: "cs",
};
class CSharpTargetLanguage extends TargetLanguage_js_1.TargetLanguage {
    constructor() {
        super(exports.cSharpLanguageConfig);
    }
    getOptions() {
        return exports.cSharpOptions;
    }
    get stringTypeMapping() {
        const mapping = new Map();
        mapping.set("date", "date-time");
        mapping.set("time", "date-time");
        mapping.set("date-time", "date-time");
        mapping.set("uuid", "uuid");
        mapping.set("uri", "uri");
        mapping.set("integer-string", "integer-string");
        mapping.set("bool-string", "bool-string");
        return mapping;
    }
    get supportsUnionsWithBothNumberTypes() {
        return true;
    }
    get supportsOptionalClassProperties() {
        return true;
    }
    needsTransformerForType(t) {
        const need = (0, utils_js_1.needTransformerForType)(t);
        return need !== "none" && need !== "nullable";
    }
    makeRenderer(renderContext, untypedOptionValues) {
        const options = (0, index_js_1.getOptionValues)(exports.cSharpOptions, untypedOptionValues);
        switch (options.framework) {
            case "NewtonSoft":
                return new NewtonSoftCSharpRenderer_js_1.NewtonsoftCSharpRenderer(this, renderContext, (0, index_js_1.getOptionValues)(exports.newtonsoftCSharpOptions, untypedOptionValues));
            case "SystemTextJson":
                return new SystemTextJsonCSharpRenderer_js_1.SystemTextJsonCSharpRenderer(this, renderContext, (0, index_js_1.getOptionValues)(exports.systemTextJsonCSharpOptions, untypedOptionValues));
            default:
                return (0, Support_js_1.assertNever)(options.framework);
        }
    }
}
exports.CSharpTargetLanguage = CSharpTargetLanguage;
