Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !10333
An error occurred while fetching the assigned milestone of the selected merge_request.

[csharp-netcore] verbose null checking

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/aeneasr/close-dotnet-9442 into master 3 years ago
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 110

Created by: aeneasr

This patch addresses an issue where csharp-netcore failed to generate compilable code when required attributes were of complex types.

By using the non-shorthand syntax for checking if the value is set, and throwing an error in that case, the compile issues have been resolved.

Closes #9442 (closed) Closes #5442 (closed)

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    Commit all changed files. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (5.3.0), 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Compare
  • master (base)

and
  • latest version
    3a12d6e6
    1 commit, 2 years ago

110 files
+ 616
- 154

    Preferences

    File browser
    Compare changes
modules/…/…/…/…‎/csharp-netcore‎
modelGener‎ic.mustache‎ +8 -2
samples/client/pets‎tore/csharp-netcore‎
OpenAPIClient-http‎client/src/…/Model‎
Anim‎al.cs‎ +4 -1
Apple‎Req.cs‎ +4 -1
Basque‎Pig.cs‎ +4 -1
Categ‎ory.cs‎ +4 -1
ComplexQuad‎rilateral.cs‎ +8 -2
Danish‎Pig.cs‎ +4 -1
Equilateral‎Triangle.cs‎ +8 -2
Format‎Test.cs‎ +8 -2
Grandparen‎tAnimal.cs‎ +4 -1
IsoscelesT‎riangle.cs‎ +8 -2
Pet‎.cs‎ +8 -2
Quadrilatera‎lInterface.cs‎ +4 -1
ScaleneTr‎iangle.cs‎ +8 -2
ShapeInt‎erface.cs‎ +4 -1
SimpleQuadr‎ilateral.cs‎ +8 -2
TriangleIn‎terface.cs‎ +4 -1
Whal‎e.cs‎ +4 -1
Zebr‎a.cs‎ +4 -1
OpenAPIClient-n‎et47/src/…/Model‎
Anim‎al.cs‎ +4 -1
Apple‎Req.cs‎ +4 -1
Basque‎Pig.cs‎ +4 -1
Categ‎ory.cs‎ +4 -1
ComplexQuad‎rilateral.cs‎ +8 -2
Danish‎Pig.cs‎ +4 -1
Equilateral‎Triangle.cs‎ +8 -2
Format‎Test.cs‎ +8 -2
Grandparen‎tAnimal.cs‎ +4 -1
IsoscelesT‎riangle.cs‎ +8 -2
Pet‎.cs‎ +8 -2
Quadrilatera‎lInterface.cs‎ +4 -1
ScaleneTr‎iangle.cs‎ +8 -2
ShapeInt‎erface.cs‎ +4 -1
SimpleQuadr‎ilateral.cs‎ +8 -2
TriangleIn‎terface.cs‎ +4 -1
Whal‎e.cs‎ +4 -1
Zebr‎a.cs‎ +4 -1
OpenAPIClient-ne‎t5.0/src/…/Model‎
Anim‎al.cs‎ +4 -1
Apple‎Req.cs‎ +4 -1
Basque‎Pig.cs‎ +4 -1
Categ‎ory.cs‎ +4 -1
ComplexQuad‎rilateral.cs‎ +8 -2
Danish‎Pig.cs‎ +4 -1
Equilateral‎Triangle.cs‎ +8 -2
Format‎Test.cs‎ +8 -2
Grandparen‎tAnimal.cs‎ +4 -1
IsoscelesT‎riangle.cs‎ +8 -2
Pet‎.cs‎ +8 -2
Quadrilatera‎lInterface.cs‎ +4 -1
ScaleneTr‎iangle.cs‎ +8 -2
ShapeInt‎erface.cs‎ +4 -1
SimpleQuadr‎ilateral.cs‎ +8 -2
TriangleIn‎terface.cs‎ +4 -1
Whal‎e.cs‎ +4 -1
Zebr‎a.cs‎ +4 -1
OpenAPIClien‎t/src/…/Model‎
Anim‎al.cs‎ +4 -1
Apple‎Req.cs‎ +4 -1
Basque‎Pig.cs‎ +4 -1
Categ‎ory.cs‎ +4 -1
ComplexQuad‎rilateral.cs‎ +8 -2
Danish‎Pig.cs‎ +4 -1
Equilateral‎Triangle.cs‎ +8 -2
Format‎Test.cs‎ +8 -2
Grandparen‎tAnimal.cs‎ +4 -1
IsoscelesT‎riangle.cs‎ +8 -2
Pet‎.cs‎ +8 -2
Quadrilatera‎lInterface.cs‎ +4 -1
ScaleneTr‎iangle.cs‎ +8 -2
ShapeInt‎erface.cs‎ +4 -1
SimpleQuadr‎ilateral.cs‎ +8 -2
TriangleIn‎terface.cs‎ +4 -1
Whal‎e.cs‎ +4 -1
Zebr‎a.cs‎ +4 -1
OpenAPIClientC‎ore/src/…/Model‎
Anim‎al.cs‎ +4 -1
Apple‎Req.cs‎ +4 -1
Basque‎Pig.cs‎ +4 -1
Categ‎ory.cs‎ +4 -1
ComplexQuad‎rilateral.cs‎ +8 -2
Danish‎Pig.cs‎ +4 -1
Equilateral‎Triangle.cs‎ +8 -2
Format‎Test.cs‎ +8 -2
Grandparen‎tAnimal.cs‎ +4 -1
IsoscelesT‎riangle.cs‎ +8 -2
Pet‎.cs‎ +8 -2
Quadrilatera‎lInterface.cs‎ +4 -1
ScaleneTr‎iangle.cs‎ +8 -2
ShapeInt‎erface.cs‎ +4 -1
SimpleQuadr‎ilateral.cs‎ +8 -2
TriangleIn‎terface.cs‎ +4 -1
Whal‎e.cs‎ +4 -1
Zebr‎a.cs‎ +4 -1
OpenAPIClientCoreA‎ndNet47/src/…/Model‎
Pet‎.cs‎ +8 -2
…/…‎/…/…‎
Anim‎al.cs‎ +4 -1
Apple‎Req.cs‎ +4 -1
Basque‎Pig.cs‎ +4 -1
Categ‎ory.cs‎ +4 -1
ComplexQuad‎rilateral.cs‎ +8 -2
Danish‎Pig.cs‎ +4 -1
Equilateral‎Triangle.cs‎ +8 -2
Format‎Test.cs‎ +8 -2
Grandparen‎tAnimal.cs‎ +4 -1
IsoscelesT‎riangle.cs‎ +8 -2
Pet‎.cs‎ +8 -2
Quadrilatera‎lInterface.cs‎ +4 -1
ScaleneTr‎iangle.cs‎ +8 -2
ShapeInt‎erface.cs‎ +4 -1
SimpleQuadr‎ilateral.cs‎ +8 -2
TriangleIn‎terface.cs‎ +4 -1
Whal‎e.cs‎ +4 -1
Zebr‎a.cs‎ +4 -1
modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache
+ 8
- 2
  • View file @ 3a12d6e6

  • Edit in single-file editor

  • Open in Web IDE


@@ -132,7 +132,10 @@
{{^conditionalSerialization}}
{{^vendorExtensions.x-csharp-value-type}}
// to ensure "{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}" is required (not null)
this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} ?? throw new ArgumentNullException("{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} is a required property for {{classname}} and cannot be null");
if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} == null) {
throw new ArgumentNullException("{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} is a required property for {{classname}} and cannot be null");
}
this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
{{/vendorExtensions.x-csharp-value-type}}
{{#vendorExtensions.x-csharp-value-type}}
this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
@@ -141,7 +144,10 @@
{{#conditionalSerialization}}
{{^vendorExtensions.x-csharp-value-type}}
// to ensure "{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}" is required (not null)
this._{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} ?? throw new ArgumentNullException("{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} is a required property for {{classname}} and cannot be null");
if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} == null) {
throw new ArgumentNullException("{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} is a required property for {{classname}} and cannot be null");
}
this._{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
{{/vendorExtensions.x-csharp-value-type}}
{{#vendorExtensions.x-csharp-value-type}}
this._{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/Animal.cs
+ 4
- 1
  • View file @ 3a12d6e6

  • Edit in single-file editor

  • Open in Web IDE


@@ -52,7 +52,10 @@ namespace Org.OpenAPITools.Model
public Animal(string className = default(string), string color = "red")
{
// to ensure "className" is required (not null)
this.ClassName = className ?? throw new ArgumentNullException("className is a required property for Animal and cannot be null");
if (className == null) {
throw new ArgumentNullException("className is a required property for Animal and cannot be null");
}
this.ClassName = className;
// use default value if no "color" provided
this.Color = color ?? "red";
this.AdditionalProperties = new Dictionary<string, object>();
samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/AppleReq.cs
+ 4
- 1
  • View file @ 3a12d6e6

  • Edit in single-file editor

  • Open in Web IDE


@@ -45,7 +45,10 @@ namespace Org.OpenAPITools.Model
public AppleReq(string cultivar = default(string), bool mealy = default(bool))
{
// to ensure "cultivar" is required (not null)
this.Cultivar = cultivar ?? throw new ArgumentNullException("cultivar is a required property for AppleReq and cannot be null");
if (cultivar == null) {
throw new ArgumentNullException("cultivar is a required property for AppleReq and cannot be null");
}
this.Cultivar = cultivar;
this.Mealy = mealy;
}
samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/BasquePig.cs
+ 4
- 1
  • View file @ 3a12d6e6

  • Edit in single-file editor

  • Open in Web IDE


@@ -47,7 +47,10 @@ namespace Org.OpenAPITools.Model
public BasquePig(string className = default(string))
{
// to ensure "className" is required (not null)
this.ClassName = className ?? throw new ArgumentNullException("className is a required property for BasquePig and cannot be null");
if (className == null) {
throw new ArgumentNullException("className is a required property for BasquePig and cannot be null");
}
this.ClassName = className;
this.AdditionalProperties = new Dictionary<string, object>();
}
samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/Category.cs
+ 4
- 1
  • View file @ 3a12d6e6

  • Edit in single-file editor

  • Open in Web IDE


@@ -48,7 +48,10 @@ namespace Org.OpenAPITools.Model
public Category(long id = default(long), string name = "default-name")
{
// to ensure "name" is required (not null)
this.Name = name ?? throw new ArgumentNullException("name is a required property for Category and cannot be null");
if (name == null) {
throw new ArgumentNullException("name is a required property for Category and cannot be null");
}
this.Name = name;
this.Id = id;
this.AdditionalProperties = new Dictionary<string, object>();
}
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference:
Source branch: github/fork/aeneasr/close-dotnet-9442

Menu

Explore Projects Groups Snippets