Skip to content

Commit

Permalink
fix(csharp):remove semicolon (;) from map property declaration (#60)
Browse files Browse the repository at this point in the history
fix(csharp):remove ; from map property declaration

Signed-off-by: [email protected] <[email protected]>
  • Loading branch information
ragi-dayananda authored Oct 11, 2023
1 parent be79293 commit a674726
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 28 deletions.
2 changes: 1 addition & 1 deletion lib/codegen/fromcto/csharp/csharpvisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ class CSharpVisitor {
// write Map field
if ( Object.keys(field).length > 0 && ModelUtil.isMap?.(field)) {
const decl = field.getModelFile().getAllDeclarations().find(d => d.name === field.ast.type.name);
parameters.fileWriter.writeLine(0, `public Dictionary<string, ${this.toCSharpType(decl.getValue().getType())}> ${field.getName()} { get; set; };\n`);
parameters.fileWriter.writeLine(1, `public Dictionary<string, ${this.toCSharpType(decl.getValue().getType())}> ${field.getName()} { get; set; }`);
return null;
}

Expand Down
36 changes: 12 additions & 24 deletions test/codegen/__snapshots__/codegen.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -327,18 +327,12 @@ public class Address : Concept {
public State? state { get; set; }
public string zipCode { get; set; }
public string country { get; set; }
public Dictionary<string, string> dictionary1 { get; set; };

public Dictionary<string, System.DateTime> dictionary2 { get; set; };

public Dictionary<string, SSN> dictionary3 { get; set; };

public Dictionary<string, Concept> dictionary4 { get; set; };

public Dictionary<string, string> dictionary5 { get; set; };

public Dictionary<string, Employee> dictionary6 { get; set; };

public Dictionary<string, string> dictionary1 { get; set; }
public Dictionary<string, System.DateTime> dictionary2 { get; set; }
public Dictionary<string, SSN> dictionary3 { get; set; }
public Dictionary<string, Concept> dictionary4 { get; set; }
public Dictionary<string, string> dictionary5 { get; set; }
public Dictionary<string, Employee> dictionary6 { get; set; }
}
//Dummy implementation of the scalar declaration to avoid compilation errors.
class Time_Dummy {}
Expand Down Expand Up @@ -5459,18 +5453,12 @@ public class Address : Concept {
public State? state { get; set; }
public string zipCode { get; set; }
public string country { get; set; }
public Dictionary<string, string> dictionary1 { get; set; };

public Dictionary<string, System.DateTime> dictionary2 { get; set; };

public Dictionary<string, SSN> dictionary3 { get; set; };

public Dictionary<string, Concept> dictionary4 { get; set; };

public Dictionary<string, string> dictionary5 { get; set; };

public Dictionary<string, Employee> dictionary6 { get; set; };

public Dictionary<string, string> dictionary1 { get; set; }
public Dictionary<string, System.DateTime> dictionary2 { get; set; }
public Dictionary<string, SSN> dictionary3 { get; set; }
public Dictionary<string, Concept> dictionary4 { get; set; }
public Dictionary<string, string> dictionary5 { get; set; }
public Dictionary<string, Employee> dictionary6 { get; set; }
}
//Dummy implementation of the scalar declaration to avoid compilation errors.
class Time_Dummy {}
Expand Down
6 changes: 3 additions & 3 deletions test/codegen/fromcto/csharp/csharpvisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@ public class SampleModel : Concept {
mockMapDeclaration.getValue.returns({ getType: getValueType });

csharpVisitor.visitField(mockField, param);
param.fileWriter.writeLine.withArgs(0, 'public Dictionary<string, string> Map1 { get; set; };\n').calledOnce.should.be.ok;
param.fileWriter.writeLine.withArgs(1, 'public Dictionary<string, string> Map1 { get; set; }').calledOnce.should.be.ok;
});

it('should write a line for field name and type thats a map of <String, Concept>', () => {
Expand All @@ -1551,7 +1551,7 @@ public class SampleModel : Concept {
mockMapDeclaration.getValue.returns({ getType: getValueType });

csharpVisitor.visitField(mockField, param);
param.fileWriter.writeLine.withArgs(0, 'public Dictionary<string, Concept> Map1 { get; set; };\n').calledOnce.should.be.ok;
param.fileWriter.writeLine.withArgs(1, 'public Dictionary<string, Concept> Map1 { get; set; }').calledOnce.should.be.ok;
});

it('should write a line for field name and type thats a map of <String, DateTime>', () => {
Expand All @@ -1577,7 +1577,7 @@ public class SampleModel : Concept {
mockMapDeclaration.getValue.returns({ getType: getValueType });

csharpVisitor.visitField(mockField, param);
param.fileWriter.writeLine.withArgs(0, 'public Dictionary<string, System.DateTime> Map1 { get; set; };\n').calledOnce.should.be.ok;
param.fileWriter.writeLine.withArgs(1, 'public Dictionary<string, System.DateTime> Map1 { get; set; }').calledOnce.should.be.ok;
});
});

Expand Down

0 comments on commit a674726

Please sign in to comment.