| 111 | } |
| 112 | |
| 113 | class CSharpRenderer extends ConvenienceRenderer { |
| 114 | private _enumExtensionsNames = Map<Name, Name>(); |
| 115 | private readonly _needHelpers: boolean; |
| 116 | private readonly _needAttributes: boolean; |
| 117 | |
| 118 | constructor( |
| 119 | graph: TypeGraph, |
| 120 | private readonly _namespaceName: string, |
| 121 | private readonly _version: Version, |
| 122 | private readonly _dense: boolean, |
| 123 | private readonly _useList: boolean, |
| 124 | outputFeatures: OutputFeatures |
| 125 | ) { |
| 126 | super(graph); |
| 127 | this._needHelpers = outputFeatures.helpers; |
| 128 | this._needAttributes = outputFeatures.attributes; |
| 129 | } |
| 130 | |
| 131 | protected get forbiddenNamesForGlobalNamespace(): string[] { |
| 132 | return ["QuickType", "Converter", "JsonConverter", "Type", "Serialize"]; |
| 133 | } |
| 134 | |
| 135 | protected forbiddenForClassProperties(_: ClassType, classNamed: Name): { names: Name[]; namespaces: Namespace[] } { |
| 136 | return { names: [classNamed], namespaces: [] }; |
| 137 | } |
| 138 | |
| 139 | protected topLevelNameStyle(rawName: string): string { |
| 140 | return csNameStyle(rawName); |
| 141 | } |
| 142 | |
| 143 | protected get namedTypeNamer(): Namer { |
| 144 | return namingFunction; |
| 145 | } |
| 146 | |
| 147 | protected get classPropertyNamer(): Namer { |
| 148 | return namingFunction; |
| 149 | } |
| 150 | |
| 151 | protected get unionMemberNamer(): Namer { |
| 152 | return namingFunction; |
| 153 | } |
| 154 | |
| 155 | protected get enumCaseNamer(): Namer { |
| 156 | return namingFunction; |
| 157 | } |
| 158 | |
| 159 | protected unionNeedsName(u: UnionType): boolean { |
| 160 | return !nullableFromUnion(u); |
| 161 | } |
| 162 | |
| 163 | protected namedTypeToNameForTopLevel(type: Type): NamedType | null { |
| 164 | const definedTypes = type.directlyReachableTypes(t => { |
| 165 | if ((!(t instanceof UnionType) && t.isNamedType()) || (t instanceof UnionType && !nullableFromUnion(t))) { |
| 166 | return OrderedSet([t]); |
| 167 | } |
| 168 | return null; |
| 169 | }); |
| 170 | assert(definedTypes.size <= 1, "Cannot have more than one defined type per top-level"); |
nothing calls this directly
no test coverage detected
searching dependent graphs…