refactor: Clean up immutable.pb.cs code-gen template a bit more
So the generated code more closely follows our formatting practices
This commit is contained in:
1 parent
21051c9a0b
commit
ffb2245ae6
1 file changed
+13
-19
@@ -37,7 +37,6 @@ namespace {{package}} {
|
||||
x => x.{{key_name}};
|
||||
|
||||
{{/if}}
|
||||
|
||||
public static MessageDescriptor Descriptor =>
|
||||
{{name}}.Descriptor;
|
||||
|
||||
@@ -105,7 +104,6 @@ namespace {{package}} {
|
||||
{{name}}Immutable left, {{name}}Immutable right) =>
|
||||
!(left == right);
|
||||
|
||||
//
|
||||
// Immutable field wrappers
|
||||
{{#each field}}
|
||||
{{#if type.isdict}}
|
||||
@@ -124,7 +122,6 @@ namespace {{package}} {
|
||||
|
||||
public bool Has{{Name}} =>
|
||||
_impl.{{Name}} != null;
|
||||
|
||||
{{else}}
|
||||
public {{type.immutable}} {{Name}} => ({{type.immutable}})_impl.{{Name}};
|
||||
{{/if}}
|
||||
@@ -142,25 +139,22 @@ namespace {{package}} {
|
||||
|
||||
public {{name}}Immutable with(
|
||||
// Arguments
|
||||
{{#each field}}
|
||||
{{#each field}}
|
||||
{{#if type.isdict}}
|
||||
IReadOnlyDictionary<{{type.keytype.cstype}},{{type.cstype}}> {{name}} = null,
|
||||
IDictionary<{{type.keytype.cstype}},{{type.cstype}}> {{name}}_mut = null
|
||||
IDictionary<{{type.keytype.cstype}},{{type.cstype}}> {{name}}_mut = null{{#unless @last}},{{/unless}}
|
||||
{{else}}{{#if type.islist}}
|
||||
IEnumerable<{{type.cstype}}> {{name}} = null{{#unless @last}},{{/unless}}
|
||||
{{else}}{{#if type.ismessage}}
|
||||
{{{type.cstype}}} {{name}} = null{{#unless @last}},{{/unless}}
|
||||
{{else}}
|
||||
{{#if type.islist}}
|
||||
// Note: Should we generate an IEnumerable<immutabletype> here?
|
||||
IEnumerable<{{type.cstype}}> {{name}} = null
|
||||
{{else}}
|
||||
{{#if type.ismessage}}
|
||||
{{{type.cstype}}} {{name}}=null
|
||||
{{else}}
|
||||
{{{type.nullable_type}}} {{name}}=null
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{{type.nullable_type}}} {{name}} = null{{#unless @last}},{{/unless}}
|
||||
{{/if}}
|
||||
{{#unless @last}},{{/unless}}
|
||||
{{/each}}) {
|
||||
{{name}} temp = new {{name}}();
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
) {
|
||||
var temp = new {{name}}();
|
||||
// populate temp internal object
|
||||
{{#each field}}
|
||||
{{#if type.isdict}}
|
||||
@@ -182,7 +176,7 @@ namespace {{package}} {
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
return new {{name}}Immutable(temp, false);
|
||||
return new(temp, false);
|
||||
}
|
||||
{{#unless @last}}
|
||||
|
||||
|
||||
Reference in new issue
Block a user