Merge pull request #505 from quicktype/csharp-liberal-properties

Don't forbid type names for properties in C#
This commit is contained in:
David Siegel 2018-02-08 19:45:00 -08:00 коммит произвёл GitHub
Родитель f44293cc6c 325f0725c7
Коммит 31056c59ab
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 17 добавлений и 3 удалений

Просмотреть файл

@ -159,7 +159,21 @@ class CSharpRenderer extends ConvenienceRenderer {
}
protected forbiddenForClassProperties(_: ClassType, classNamed: Name): ForbiddenWordsInfo {
return { names: [classNamed, "FromJson"], includeGlobalForbidden: true };
return {
names: [
classNamed,
"ToJson",
"FromJson",
"ToString",
"GetHashCode",
"Finalize",
"Equals",
"GetType",
"MemberwiseClone",
"ReferenceEquals"
],
includeGlobalForbidden: false
};
}
protected forbiddenForUnionMembers(_: UnionType, unionNamed: Name): ForbiddenWordsInfo {
@ -334,7 +348,7 @@ class CSharpRenderer extends ConvenienceRenderer {
// FIXME: Make FromJson a Named
this.emitExpressionMember(
["public static ", csType, " FromJson(string json)"],
["JsonConvert.DeserializeObject<", csType, ">(json, Converter.Settings)"]
["JsonConvert.DeserializeObject<", csType, ">(json, ", this._namespaceName, ".Converter.Settings)"]
);
});
};
@ -498,7 +512,7 @@ class CSharpRenderer extends ConvenienceRenderer {
// FIXME: Make ToJson a Named
this.emitExpressionMember(
["public static string ToJson(this ", this.csType(t), " self)"],
"JsonConvert.SerializeObject(self, Converter.Settings)"
["JsonConvert.SerializeObject(self, ", this._namespaceName, ".Converter.Settings)"]
);
});
});