Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/codegen/fromcto/csharp/csharpvisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions test/codegen/fromcto/csharp/csharpvisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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; \}/);
Expand Down
Loading