raml-dotnet-tools icon indicating copy to clipboard operation
raml-dotnet-tools copied to clipboard

Autogenerated C# code causes CS4072 warnings on compile

Open tb-wwparker opened this issue 7 years ago • 1 comments

With the addition of null-able types to C# and the use of them in the autogenerated code, some of the code generated from the RAML to .Net code build cause warning CS4072. One example is CS4072 The result of the expression is always 'false' since a value of type 'int' is never equal to 'null' of type 'int?'

url = url.Replace("{jobOrderId}", request.UriParameters.JobOrderId.ToString()); Where jobOrderId is defined as an integer (in the RAML and in the .cs file)

The schema looks like:

  uriParameters:
    jobOrderId:
      type: integer
      required: true

I changed the data type from string to integer so that I would not have to toString() the integers that I used as jobOrderIds. The code generate may have missed this as test case.

Could you fix the code or add a #pragma warning disable CS4072 to the code?

tb-wwparker avatar Mar 23 '17 22:03 tb-wwparker

Will check how to improve that. In the meantime that code is part of the templates. You can add the pragma directive or change the code there. Thanks for the feedback.

woodp avatar Mar 27 '17 18:03 woodp