Skip to content

Commit f98073d

Browse files
authored
Refactor copy lambda (#19983)
* comment out broken tests * refactored copy lambda * added tests
1 parent b51b18e commit f98073d

File tree

9 files changed

+176
-66
lines changed

9 files changed

+176
-66
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import org.openapitools.codegen.model.OperationMap;
3434
import org.openapitools.codegen.model.OperationsMap;
3535
import org.openapitools.codegen.templating.mustache.*;
36+
import org.openapitools.codegen.templating.mustache.CopyLambda.CopyContent;
37+
import org.openapitools.codegen.templating.mustache.CopyLambda.WhiteSpaceStrategy;
3638
import org.openapitools.codegen.utils.ModelUtils;
3739
import org.slf4j.Logger;
3840
import org.slf4j.LoggerFactory;
@@ -427,7 +429,7 @@ public void execute(Template.Fragment fragment, Writer writer) throws IOExceptio
427429

428430
@Override
429431
protected ImmutableMap.Builder<String, Lambda> addMustacheLambdas() {
430-
CopyLambda copyLambda = new CopyLambda();
432+
final CopyContent copyContent = new CopyContent();
431433

432434
return super.addMustacheLambdas()
433435
.put("camelcase_sanitize_param", new CamelCaseAndSanitizeLambda().generator(this).escapeAsParamName(true))
@@ -443,12 +445,13 @@ protected ImmutableMap.Builder<String, Lambda> addMustacheLambdas() {
443445
.put("first", new FirstLambda(" "))
444446
.put("firstDot", new FirstLambda("\\."))
445447
.put("indent1", new IndentedLambda(4, " ", false, true))
448+
.put("indentAll1", new IndentedLambda(4, " ", true, true))
446449
.put("indent3", new IndentedLambda(12, " ", false, true))
447450
.put("indent4", new IndentedLambda(16, " ", false, true))
448-
.put("copy", copyLambda)
449-
.put("paste", new PasteLambda(copyLambda, true, true, true, false))
450-
.put("pasteOnce", new PasteLambda(copyLambda, true, true, true, true))
451-
.put("pasteLine", new PasteLambda(copyLambda, true, true, false, false))
451+
.put("copy", new CopyLambda(copyContent, WhiteSpaceStrategy.None, WhiteSpaceStrategy.None))
452+
.put("copyText", new CopyLambda(copyContent, WhiteSpaceStrategy.Strip, WhiteSpaceStrategy.StripLineBreakIfPresent))
453+
.put("paste", new PasteLambda(copyContent, false))
454+
.put("pasteOnce", new PasteLambda(copyContent, true))
452455
.put("uniqueLines", new UniqueLambda("\n", false))
453456
.put("unique", new UniqueLambda("\n", true))
454457
.put("camel_case", new CamelCaseLambda())

modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/CopyLambda.java

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
* Register:
2929
* <pre>
30-
* additionalProperties.put("copy", new CopyLambda());
30+
* additionalProperties.put("copy", new CopyLambda(new CopyContent()));
3131
* </pre>
3232
*
3333
* Use:
@@ -36,13 +36,55 @@
3636
* </pre>
3737
*/
3838
public class CopyLambda implements Mustache.Lambda {
39-
public String savedContent;
39+
public static class CopyContent {
40+
public String content;
41+
}
42+
43+
public CopyContent copyContent;
44+
private final WhiteSpaceStrategy leadingWhiteSpaceStrategy;
45+
private final WhiteSpaceStrategy trailingWhiteSpaceStrategy;
46+
47+
public enum WhiteSpaceStrategy {
48+
None,
49+
AppendLineBreakIfMissing,
50+
Strip,
51+
StripLineBreakIfPresent
52+
}
4053

41-
public CopyLambda() {
54+
public CopyLambda(CopyContent content, WhiteSpaceStrategy leadingWhiteSpaceStrategy, WhiteSpaceStrategy trailingWhiteSpaceStrategy) {
55+
this.copyContent = content;
56+
this.leadingWhiteSpaceStrategy = leadingWhiteSpaceStrategy;
57+
this.trailingWhiteSpaceStrategy = trailingWhiteSpaceStrategy;
4258
}
4359

4460
@Override
4561
public void execute(Fragment fragment, Writer writer) throws IOException {
46-
savedContent = fragment.execute().stripTrailing();
62+
String content = fragment.execute();
63+
64+
if (this.leadingWhiteSpaceStrategy == WhiteSpaceStrategy.AppendLineBreakIfMissing && !content.startsWith("\n")){
65+
content = "\n" + content;
66+
}
67+
68+
if (this.leadingWhiteSpaceStrategy == WhiteSpaceStrategy.Strip) {
69+
content = content.stripLeading();
70+
}
71+
72+
if (this.leadingWhiteSpaceStrategy == WhiteSpaceStrategy.StripLineBreakIfPresent && content.startsWith("\n")) {
73+
content = content.substring(1);
74+
}
75+
76+
if (this.trailingWhiteSpaceStrategy == WhiteSpaceStrategy.AppendLineBreakIfMissing && !content.endsWith("\n")){
77+
content = content + "\n";
78+
}
79+
80+
if (this.trailingWhiteSpaceStrategy == WhiteSpaceStrategy.Strip){
81+
content = content.stripTrailing();
82+
}
83+
84+
if (this.trailingWhiteSpaceStrategy == WhiteSpaceStrategy.StripLineBreakIfPresent && content.endsWith("\n")) {
85+
content = content.substring(0, content.length() - 1);
86+
}
87+
88+
this.copyContent.content = content;
4789
}
4890
}

modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/PasteLambda.java

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.io.IOException;
2020
import java.io.Writer;
2121

22+
import org.openapitools.codegen.templating.mustache.CopyLambda.CopyContent;
23+
2224
import com.samskivert.mustache.Mustache;
2325
import com.samskivert.mustache.Template.Fragment;
2426

@@ -27,7 +29,7 @@
2729
*
2830
* Register:
2931
* <pre>
30-
* additionalProperties.put("paste", new PasteLambda(copyLambda, true, true, true, false));
32+
* additionalProperties.put("paste", new PasteLambda(copyContent, false));
3133
* </pre>
3234
*
3335
* Use:
@@ -36,41 +38,26 @@
3638
* </pre>
3739
*/
3840
public class PasteLambda implements Mustache.Lambda {
39-
private final CopyLambda copyLambda;
40-
private final Boolean stripLeading;
41-
private final Boolean stripTrailing;
42-
private final Boolean endWithLineBreak;
41+
private final CopyContent copyContent;
4342
private final Boolean clear;
4443

45-
public PasteLambda(CopyLambda copyLambda, Boolean stripLeading, Boolean stripTrailing, Boolean endWithLineBreak, boolean clear) {
46-
this.copyLambda = copyLambda;
47-
this.stripLeading = stripLeading;
48-
this.stripTrailing = stripTrailing;
49-
this.endWithLineBreak = endWithLineBreak;
44+
public PasteLambda(CopyContent copyContent, boolean clear) {
45+
this.copyContent = copyContent;
5046
this.clear = clear;
5147
}
5248

5349
@Override
5450
public void execute(Fragment fragment, Writer writer) throws IOException {
55-
String content = this.copyLambda.savedContent;
51+
String content = this.copyContent.content;
5652

5753
if (content == null) {
5854
return;
5955
}
6056

61-
if (this.stripTrailing){
62-
content = content.stripTrailing();
63-
}
64-
if (this.stripLeading) {
65-
content = content.stripLeading();
66-
}
67-
if (this.endWithLineBreak && !content.endsWith("\n")){
68-
content = content + "\n";
69-
}
70-
writer.write(content);
71-
7257
if (this.clear) {
73-
this.copyLambda.savedContent = null;
58+
this.copyContent.content = null;
7459
}
60+
61+
writer.write(content);
7562
}
7663
}

modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,12 @@
342342
public override void Write(Utf8JsonWriter writer, {{classname}} {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}, JsonSerializerOptions jsonSerializerOptions)
343343
{
344344
{{#lambda.trimLineBreaks}}
345-
{{#lambda.copy}}
345+
{{#lambda.copyText}}
346346
{{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}
347-
{{/lambda.copy}}
347+
{{/lambda.copyText}}
348348
{{#discriminator}}
349349
{{#children}}
350-
if ({{#lambda.pasteLine}}{{/lambda.pasteLine}} is {{classname}} {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}){
350+
if ({{#lambda.paste}}{{/lambda.paste}} is {{classname}} {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}){
351351
JsonSerializer.Serialize<{{{name}}}>(writer, {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}, jsonSerializerOptions);
352352
return;
353353
}
@@ -449,9 +449,9 @@
449449
{{^isMap}}
450450
{{^isEnum}}
451451
{{^isUuid}}
452-
{{#lambda.copy}}
452+
{{#lambda.copyText}}
453453
writer.WriteString("{{baseName}}", {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}});
454-
{{/lambda.copy}}
454+
{{/lambda.copyText}}
455455
{{#lambda.indent3}}
456456
{{>WriteProperty}}
457457
{{/lambda.indent3}}
@@ -460,44 +460,44 @@
460460
{{/isMap}}
461461
{{/isString}}
462462
{{#isBoolean}}
463-
{{#lambda.copy}}
463+
{{#lambda.copyText}}
464464
writer.WriteBoolean("{{baseName}}", {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}.Value{{/isNullable}}{{/required}});
465-
{{/lambda.copy}}
465+
{{/lambda.copyText}}
466466
{{#lambda.indent3}}
467467
{{>WriteProperty}}
468468
{{/lambda.indent3}}
469469
{{/isBoolean}}
470470
{{^isEnum}}
471471
{{#isNumeric}}
472-
{{#lambda.copy}}
472+
{{#lambda.copyText}}
473473
writer.WriteNumber("{{baseName}}", {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}.Value{{/isNullable}}{{/required}});
474-
{{/lambda.copy}}
474+
{{/lambda.copyText}}
475475
{{#lambda.indent3}}
476476
{{>WriteProperty}}
477477
{{/lambda.indent3}}
478478
{{/isNumeric}}
479479
{{/isEnum}}
480480
{{#isDate}}
481-
{{#lambda.copy}}
481+
{{#lambda.copyText}}
482482
writer.WriteString("{{baseName}}", {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}.Value{{/isNullable}}{{/required}}.ToString({{name}}Format));
483-
{{/lambda.copy}}
483+
{{/lambda.copyText}}
484484
{{#lambda.indent3}}
485485
{{>WriteProperty}}
486486
{{/lambda.indent3}}
487487
{{/isDate}}
488488
{{#isDateTime}}
489-
{{#lambda.copy}}
489+
{{#lambda.copyText}}
490490
writer.WriteString("{{baseName}}", {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}.Value{{/isNullable}}{{/required}}.ToString({{name}}Format));
491-
{{/lambda.copy}}
491+
{{/lambda.copyText}}
492492
{{#lambda.indent3}}
493493
{{>WriteProperty}}
494494
{{/lambda.indent3}}
495495
{{/isDateTime}}
496496
{{#isEnum}}
497497
{{#isNumeric}}
498-
{{#lambda.copy}}
498+
{{#lambda.copyText}}
499499
writer.WriteNumber("{{baseName}}", {{#isInnerEnum}}{{classname}}.{{/isInnerEnum}}{{{datatypeWithEnum}}}ToJsonValue({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}.Value{{/isNullable}}{{/required}}));
500-
{{/lambda.copy}}
500+
{{/lambda.copyText}}
501501
{{#lambda.indent3}}
502502
{{>WriteProperty}}
503503
{{/lambda.indent3}}
@@ -519,9 +519,9 @@
519519
{{/isNullable}}
520520
{{/isInnerEnum}}
521521
{{^isInnerEnum}}
522-
{{#lambda.copy}}
522+
{{#lambda.copyText}}
523523
{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}
524-
{{/lambda.copy}}
524+
{{/lambda.copyText}}
525525
{{#required}}
526526
{{#isNullable}}
527527
if ({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}} == null)
@@ -533,7 +533,7 @@
533533
{{#enumVars}}
534534
{{#-first}}
535535
{{#isString}}
536-
if ({{#lambda.pasteLine}}{{/lambda.pasteLine}}RawValue != null){{! we cant use name here because enumVar also has a name property, so use the paste lambda instead }}
536+
if ({{#lambda.paste}}{{/lambda.paste}}RawValue != null){{! we cant use name here because enumVar also has a name property, so use the paste lambda instead }}
537537
writer.WriteString("{{baseName}}", {{#lambda.camelcase_sanitize_param}}{{nameInPascalCase}}{{/lambda.camelcase_sanitize_param}}RawValue);
538538
else
539539
writer.WriteNull("{{baseName}}");
@@ -552,10 +552,10 @@
552552
{{#enumVars}}
553553
{{#-first}}
554554
{{^isNumeric}}
555-
writer.WriteString("{{baseName}}", {{#lambda.pasteLine}}{{/lambda.pasteLine}}RawValue);
555+
writer.WriteString("{{baseName}}", {{#lambda.paste}}{{/lambda.paste}}RawValue);
556556
{{/isNumeric}}
557557
{{#isNumeric}}
558-
writer.WriteNumber("{{baseName}}", {{#lambda.camelcase_sanitize_param}}{{#lambda.pasteLine}}{{/lambda.pasteLine}}{{/lambda.camelcase_sanitize_param}}RawValue);
558+
writer.WriteNumber("{{baseName}}", {{#lambda.camelcase_sanitize_param}}{{#lambda.paste}}{{/lambda.paste}}{{/lambda.camelcase_sanitize_param}}RawValue);
559559
{{/isNumeric}}
560560
{{/-first}}
561561
{{/enumVars}}
@@ -568,16 +568,16 @@
568568
{{#isNullable}}
569569
if ({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option{{nrt!}}.Value != null)
570570
{
571-
var {{#lambda.pasteLine}}{{/lambda.pasteLine}}RawValue = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.Value{{nrt!}}.Value);
572-
writer.{{#lambda.first}}{{#allowableValues}}{{#enumVars}}{{^isNumeric}}WriteString {{/isNumeric}}{{#isNumeric}}WriteNumber {{/isNumeric}}{{/enumVars}}{{/allowableValues}}{{/lambda.first}}("{{baseName}}", {{#lambda.pasteLine}}{{/lambda.pasteLine}}RawValue);
571+
var {{#lambda.paste}}{{/lambda.paste}}RawValue = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.Value{{nrt!}}.Value);
572+
writer.{{#lambda.first}}{{#allowableValues}}{{#enumVars}}{{^isNumeric}}WriteString {{/isNumeric}}{{#isNumeric}}WriteNumber {{/isNumeric}}{{/enumVars}}{{/allowableValues}}{{/lambda.first}}("{{baseName}}", {{#lambda.paste}}{{/lambda.paste}}RawValue);
573573
}
574574
else
575575
writer.WriteNull("{{baseName}}");
576576
{{/isNullable}}
577577
{{^isNullable}}
578578
{
579-
var {{#lambda.pasteLine}}{{/lambda.pasteLine}}RawValue = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{nrt!}}.Value);
580-
writer.{{#lambda.first}}{{#allowableValues}}{{#enumVars}}{{^isNumeric}}WriteString {{/isNumeric}}{{#isNumeric}}WriteNumber {{/isNumeric}}{{/enumVars}}{{/allowableValues}}{{/lambda.first}}("{{baseName}}", {{#lambda.pasteLine}}{{/lambda.pasteLine}}RawValue);
579+
var {{#lambda.paste}}{{/lambda.paste}}RawValue = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{nrt!}}.Value);
580+
writer.{{#lambda.first}}{{#allowableValues}}{{#enumVars}}{{^isNumeric}}WriteString {{/isNumeric}}{{#isNumeric}}WriteNumber {{/isNumeric}}{{/enumVars}}{{/allowableValues}}{{/lambda.first}}("{{baseName}}", {{#lambda.paste}}{{/lambda.paste}}RawValue);
581581
}
582582
{{/isNullable}}
583583
{{/required}}
@@ -586,9 +586,9 @@
586586
{{/isMap}}
587587
{{/isEnum}}
588588
{{#isUuid}}
589-
{{#lambda.copy}}
589+
{{#lambda.copyText}}
590590
writer.WriteString("{{baseName}}", {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}.Value{{/isNullable}}{{/required}});
591-
{{/lambda.copy}}
591+
{{/lambda.copyText}}
592592
{{#lambda.indent3}}
593593
{{>WriteProperty}}
594594
{{/lambda.indent3}}

modules/openapi-generator/src/main/resources/csharp/libraries/generichost/RateLimitProvider`1.mustache

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,15 @@ namespace {{packageName}}.{{clientPackage}}
5353
}
5454
else
5555
{
56-
{{#lambda.indent1}}{{#lambda.pasteLine}}{{/lambda.pasteLine}}{{/lambda.indent1}}
56+
{{#lambda.indentAll1}}
57+
{{#lambda.paste}}
58+
{{/lambda.paste}}
59+
{{/lambda.indentAll1}}
5760
}
5861
{{/hasApiKeyMethods}}
5962
{{^hasApiKeyMethods}}
60-
{{#lambda.pasteLine}}{{/lambda.pasteLine}}
63+
{{#lambda.paste}}
64+
{{/lambda.paste}}
6165
{{/hasApiKeyMethods}}
6266

6367
foreach(Channel<TTokenBase> tokens in AvailableTokens.Values)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// {{{name}}} ({{{dataType}}}) pattern
22
Regex regex{{{name}}} = new Regex(@"{{{vendorExtensions.x-regex}}}"{{#vendorExtensions.x-modifiers}}{{#-first}}, {{/-first}}RegexOptions.{{{.}}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}});
33
{{#lambda.copy}}this.{{{name}}}{{#useGenericHost}}{{^required}}Option.Value{{/required}}{{/useGenericHost}} != null && {{/lambda.copy}}
4-
if ({{#lambda.first}}{{^required}}{{#lambda.pasteLine}}{{/lambda.pasteLine}} {{/required}}{{#isNullable}}{{#lambda.pasteLine}}{{/lambda.pasteLine}}{{/isNullable}}{{/lambda.first}}!regex{{{name}}}.Match(this.{{{name}}}{{#useGenericHost}}{{^required}}Option.Value{{/required}}{{/useGenericHost}}{{#isUuid}}.ToString(){{#lambda.first}}{{^required}}{{nrt!}} {{/required}}{{#isNullable}}! {{/isNullable}}{{/lambda.first}}{{/isUuid}}).Success)
4+
if ({{#lambda.first}}{{^required}}{{#lambda.paste}}{{/lambda.paste}} {{/required}}{{#isNullable}}{{#lambda.paste}}{{/lambda.paste}}{{/isNullable}}{{/lambda.first}}!regex{{{name}}}.Match(this.{{{name}}}{{#useGenericHost}}{{^required}}Option.Value{{/required}}{{/useGenericHost}}{{#isUuid}}.ToString(){{#lambda.first}}{{^required}}{{nrt!}} {{/required}}{{#isNullable}}! {{/isNullable}}{{/lambda.first}}{{/isUuid}}).Success)
55
{
66
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must match a pattern of " + regex{{{name}}}, new [] { "{{{name}}}" });
77
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{{#isNullable}}
22
if ({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{/required}} != null)
3-
{{#lambda.pasteLine}}{{/lambda.pasteLine}}
3+
{{#lambda.paste}}{{/lambda.paste}}
44
else
55
writer.WriteNull("{{baseName}}");
66
{{/isNullable}}
77
{{^isNullable}}
8-
{{#lambda.pasteLine}}{{/lambda.pasteLine}}
8+
{{#lambda.paste}}
9+
{{/lambda.paste}}
910
{{/isNullable}}

modules/openapi-generator/src/main/resources/csharp/libraries/generichost/modelGeneric.mustache

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,15 +345,17 @@
345345
{{/readOnlyVars}}
346346
{{#readOnlyVars}}
347347
{{#lambda.copy}}
348-
349348
if ({{name}} != null)
350349
hashCode = (hashCode * 59) + {{name}}.GetHashCode();
350+
351351
{{/lambda.copy}}
352352
{{#isNullable}}
353-
{{#lambda.pasteOnce}}{{/lambda.pasteOnce}}
353+
{{#lambda.pasteOnce}}
354+
{{/lambda.pasteOnce}}
354355
{{/isNullable}}
355356
{{^required}}
356-
{{#lambda.pasteOnce}}{{/lambda.pasteOnce}}
357+
{{#lambda.pasteOnce}}
358+
{{/lambda.pasteOnce}}
357359
{{/required}}
358360
{{/readOnlyVars}}
359361
{{#isAdditionalPropertiesTrue}}

0 commit comments

Comments
 (0)