Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Any change that affects generated output **must** be covered by a JSON or JSON S

- JSON inputs live in `test/inputs/json/`. `priority/` and `samples/` form the default input set; `misc/` is omitted under `QUICKTEST` and for languages with `skipMiscJSON`. Per-language `skipJSON` and `includeJSON` settings can further restrict inputs.
- JSON Schema inputs live in `test/inputs/schema/`. A `*.schema` can have a same-basename `.json` sample and numbered `.N.json` samples. Numbered `.N.fail.<feature>.json` files are expected failures for languages that declare that feature; `.N.fail.json` files apply regardless of features. An expected-failure sample must make the generated program exit nonzero.
- `test/inputs/json/priority/keywords.json`, `test/inputs/schema/keyword-enum.schema`, and `test/inputs/schema/keyword-unions.schema` are generated by `test/make-keyword-tests.sh` from `test/keywords.txt`. Never edit them directly: add the keyword to `test/keywords.txt`, optionally followed by a tab and a JSON value for the JSON sample, then regenerate.
- New schema fixture tests should have at least one positive and one negative test case unless there is a compelling reason not to.
- Per-language configuration鈥攊nput filters, renderer options, and `features`鈥攍ives in `test/languages.ts`.
- Fixtures and their filter names are registered in `test/fixtures.ts`; driver programs live in `test/fixtures/<language>/`.
Expand Down
23 changes: 15 additions & 8 deletions packages/quicktype-core/src/language/CSharp/CSharpRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ import {
noFollow,
} from "./utils.js";

const objectMemberNames = [
"ToString",
"GetHashCode",
"Finalize",
"Equals",
"GetType",
"MemberwiseClone",
"ReferenceEquals",
];

export class CSharpRenderer extends ConvenienceRenderer {
public constructor(
targetLanguage: TargetLanguage,
Expand Down Expand Up @@ -73,13 +83,7 @@ export class CSharpRenderer extends ConvenienceRenderer {
return {
names: [
classNamed,
"ToString",
"GetHashCode",
"Finalize",
"Equals",
"GetType",
"MemberwiseClone",
"ReferenceEquals",
...objectMemberNames,
...(this._csOptions.useRecords
? ["Clone", "EqualityContract", "PrintMembers"]
: []),
Expand All @@ -92,7 +96,10 @@ export class CSharpRenderer extends ConvenienceRenderer {
_: UnionType,
unionNamed: Name,
): ForbiddenWordsInfo {
return { names: [unionNamed], includeGlobalForbidden: true };
return {
names: [unionNamed, ...objectMemberNames],
includeGlobalForbidden: true,
};
}

protected makeNamedTypeNamer(): Namer {
Expand Down
64 changes: 32 additions & 32 deletions test/inputs/json/priority/keywords.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@
"CultureInfo": { "CultureInfo": 123 },
"date": { "date": 123 },
"date_parse_handling": { "date_parse_handling": 123 },
"DateFormatter": { "DateFormatter": 123 },
"DateOnly": { "DateOnly": 123 },
"DateOnlyConverter": { "DateOnlyConverter": 123 },
"dummy": 123
},
"obj2": {
"DateTime": { "DateTime": "2001-02-03T04:05:06Z" },
"DateFormatter": { "DateFormatter": 123 },
"DateTimeStyles": { "DateTimeStyles": 123 },
"debugger": { "debugger": 123 },
"decimal": { "decimal": 123 },
"declare": { "declare": 123 },
"decltype": { "decltype": 123 },
"decode_string": { "decode_string": 123 },
"dummy": 123
},
"obj2": {
"def": { "def": 123 },
"default": { "default": 123 },
"defer": { "defer": 123 },
Expand All @@ -89,11 +89,11 @@
"dynamic": { "dynamic": 123 },
"dynamic_cast": { "dynamic_cast": 123 },
"elif": { "elif": 123 },
"equalityContract": { "equalityContract": 123 },
"else": { "else": 123 },
"encode_quick_type": { "encode_quick_type": 123 },
"enum": { "enum": 123 },
"EnumValues": { "EnumValues": ["ready", "done", "ready", "done", "ready", "done", "ready", "done", "ready", "done"] },
"equalityContract": { "equalityContract": 123 },
"event": { "event": 123 },
"except": { "except": 123 },
"exception": { "exception": 123 },
Expand Down Expand Up @@ -131,6 +131,9 @@
"IMP": { "IMP": 123 },
"implements": { "implements": 123 },
"implicit": { "implicit": 123 },
"dummy": 123
},
"obj3": {
"import": { "import": 123 },
"in": { "in": 123 },
"indirect": { "indirect": 123 },
Expand All @@ -142,26 +145,26 @@
"int": { "int": 123 },
"interface": { "interface": 123 },
"internal": { "internal": 123 },
"dummy": 123
},
"obj3": {
"IsoDateTimeOffsetConverter": { "IsoDateTimeOffsetConverter": 123 },
"iterable": { "iterable": 123 },
"is": { "is": 123 },
"IsoDateTimeOffsetConverter": { "IsoDateTimeOffsetConverter": 123 },
"jdec": { "jdec": 123 },
"jenc": { "jenc": 123 },
"jpipe": { "jpipe": 123 },
"json": { "json": 123 },
"JSONAny": { "JSONAny": null },
"JSONCodingKey": { "JSONCodingKey": 123 },
"JSONDecoder": { "JSONDecoder": 123 },
"JSONEncoder": { "JSONEncoder": 123 },
"JSONNull": { "JSONNull": 123 },
"json_converter": { "json_converter": 123 },
"json_serializer": { "json_serializer": 123 },
"json_token": { "json_token": 123 },
"json_writer": { "json_writer": 123 },
"JSONAny": { "JSONAny": null },
"JSONCodingKey": { "JSONCodingKey": 123 },
"JSONDecoder": { "JSONDecoder": 123 },
"JSONEncoder": { "JSONEncoder": 123 },
"JsonException": { "JsonException": 123 },
"JsonGenerator": { "JsonGenerator": 123 },
"JsonNode": { "JsonNode": 123 },
"JSONNull": { "JSONNull": 123 },
"JsonParser": { "JsonParser": 123 },
"JsonReader": { "JsonReader": 123 },
"JsonTokenType": { "JsonTokenType": 123 },
"lambda": { "lambda": 123 },
Expand All @@ -180,7 +183,6 @@
"native": { "native": 123 },
"new": { "new": 123 },
"newtonsoft": { "newtonsoft": 123 },
"NSError": { "NSError": 123 },
"nil": { "nil": 123 },
"NO": { "NO": 123 },
"noexcept": { "noexcept": 123 },
Expand All @@ -192,20 +194,17 @@
"noSuchMethod": { "noSuchMethod": 123 },
"not": { "not": 123 },
"not_eq": { "not_eq": 123 },
"NSError": { "NSError": 123 },
"NSString": { "NSString": 123 },
"NULL": { "NULL": 123 },
"null": { "null": 123 },
"dummy": 123
},
"obj4": {
"nullptr": { "nullptr": 123 },
"number": { "number": 123 },
"object": { "object": 123 },
"JsonGenerator": { "JsonGenerator": 123 },
"JsonNode": { "JsonNode": 123 },
"JsonParser": { "JsonParser": 123 },
"ObjectMapper": { "ObjectMapper": 123 },
"SerializerProvider": { "SerializerProvider": 123 },
"SimpleModule": { "SimpleModule": 123 },
"StdDeserializer": { "StdDeserializer": 123 },
"StdSerializer": { "StdSerializer": 123 },
"of": { "of": 123 },
"oneway": { "oneway": 123 },
"open": { "open": 123 },
Expand All @@ -229,9 +228,6 @@
"protected": { "protected": 123 },
"Protocol": { "Protocol": 123 },
"protocol": { "protocol": 123 },
"dummy": 123
},
"obj4": {
"public": { "public": 123 },
"quicktype": { "quicktype": 123 },
"raise": { "raise": 123 },
Expand All @@ -251,23 +247,30 @@
"return": { "return": 123 },
"right": { "right": 123 },
"runtimeType": { "runtimeType": 123 },
"sbyte": { "sbyte": 123 },
"s": { "s": 123 },
"sbyte": { "sbyte": 123 },
"sealed": { "sealed": 123 },
"SEL": { "SEL": 123 },
"select": { "select": 123 },
"Self": { "Self": 123 },
"self": { "self": 123 },
"serialize": { "serialize": 123 },
"SerializerProvider": { "SerializerProvider": 123 },
"set": { "set": 123 },
"short": { "short": 123 },
"signed": { "signed": 123 },
"SimpleModule": { "SimpleModule": 123 },
"sizeof": { "sizeof": 123 },
"stackalloc": { "stackalloc": 123 },
"Standards": { "Standards": 123 },
"static": { "static": 123 },
"static_assert": { "static_assert": 123 },
"dummy": 123
},
"obj5": {
"static_cast": { "static_cast": 123 },
"StdDeserializer": { "StdDeserializer": 123 },
"StdSerializer": { "StdSerializer": 123 },
"strictfp": { "strictfp": 123 },
"string": { "string": 123 },
"struct": { "struct": 123 },
Expand All @@ -283,10 +286,10 @@
"thread_local": { "thread_local": 123 },
"throw": { "throw": 123 },
"throws": { "throws": 123 },
"to_json": { "to_json": 123 },
"top_level": { "top_level": 123 },
"TimeOnly": { "TimeOnly": 123 },
"TimeOnlyConverter": { "TimeOnlyConverter": 123 },
"to_json": { "to_json": 123 },
"top_level": { "top_level": 123 },
"toString": { "toString": 123 },
"transient": { "transient": 123 },
"True": { "True": 123 },
Expand All @@ -303,10 +306,6 @@
"ulong": { "ulong": 123 },
"unchecked": { "unchecked": 123 },
"undefined": { "undefined": 123 },
"dummy": 123
},
"obj5": {
"UUID": { "UUID": 123 },
"union": { "union": 123 },
"unowned": { "unowned": 123 },
"unsafe": { "unsafe": 123 },
Expand All @@ -315,6 +314,7 @@
"using": { "using": 123 },
"Utf8JsonReader": { "Utf8JsonReader": 123 },
"Utf8JsonWriter": { "Utf8JsonWriter": 123 },
"UUID": { "UUID": 123 },
"var": { "var": 123 },
"virtual": { "virtual": 123 },
"void": { "void": 123 },
Expand Down
Loading
Loading