Merge pull request #505 from quicktype/csharp-liberal-properties
Don't forbid type names for properties in C#
This commit is contained in:
Коммит
31056c59ab
|
@ -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)"]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче