autorest icon indicating copy to clipboard operation
autorest copied to clipboard

C# Code generator with empty models

Open henning-krause opened this issue 10 years ago • 1 comments

When you have an empty model, the C# generator creates an invalid model: It has two empty constructors.

This is because of a bug in the ModelTemplate.cshtml file (https://github.com/Azure/autorest/blob/master/AutoRest/Generators/CSharp/CSharp/Templates/ModelTemplate.cshtml).

The lines 37-47 need to be wrapped in an if-statement:

if (!string.IsNullOrEmpty(Model.ConstructorParameters) {
   ...
}

henning-krause avatar Dec 10 '15 12:12 henning-krause

This was fixed in the dev branch.

bitsforthought avatar Dec 10 '15 17:12 bitsforthought