diff --git a/lib/codegen/fromcto/csharp/csharpvisitor.js b/lib/codegen/fromcto/csharp/csharpvisitor.js index 3e2c857..2180705 100644 --- a/lib/codegen/fromcto/csharp/csharpvisitor.js +++ b/lib/codegen/fromcto/csharp/csharpvisitor.js @@ -637,11 +637,12 @@ class CSharpVisitor { if (!parameters.useRequiredForNonOptionalReferenceTypes) {return false;} if (options.nullableType) {return false;} if (options.hasDefault) {return false;} + if (options.isArray) {return true;} // Scalar aliases are generated as record structs (value types), not reference types. if (options.isScalarAlias) {return false;} if (options.isEnum) {return false;} if (!options.csharpType) {return false;} - return this.isCSharpReferenceType(options.csharpType, !!options.isArray); + return this.isCSharpReferenceType(options.csharpType, false); } /** diff --git a/test/codegen/fromcto/csharp/csharpvisitor.js b/test/codegen/fromcto/csharp/csharpvisitor.js index 8575918..2a14af2 100644 --- a/test/codegen/fromcto/csharp/csharpvisitor.js +++ b/test/codegen/fromcto/csharp/csharpvisitor.js @@ -922,8 +922,10 @@ public class SampleModel : Concept { o Integer count o String nick optional o SSN ssn + o SSN[] ssns o Status status default="ACTIVE" o Status state + o Status[] states o Child child o Child[] children } @@ -935,8 +937,10 @@ public class SampleModel : Concept { file1.should.match(/public int count \{ get; set; \}/); file1.should.match(/public string\? nick \{ get; set; \}/); file1.should.match(/public SSN ssn \{ get; set; \}/); + file1.should.match(/public required SSN\[\] ssns \{ get; set; \}/); file1.should.match(/public Status status \{ get; set; \} = Status.Active;/); file1.should.match(/public Status state \{ get; set; \}/); + file1.should.match(/public required Status\[\] states \{ get; set; \}/); file1.should.match(/public required Child child \{ get; set; \}/); file1.should.match(/public required Child\[\] children \{ get; set; \}/); file1.should.not.match(/public required SSN ssn \{ get; set; \}/);