diff --git a/src/lib/api/service_compiler/templates/c#/immutable.pb.cs b/src/lib/api/service_compiler/templates/c#/immutable.pb.cs index 0b1f818ec..53825bd5e 100644 --- a/src/lib/api/service_compiler/templates/c#/immutable.pb.cs +++ b/src/lib/api/service_compiler/templates/c#/immutable.pb.cs @@ -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 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}}