[C#] Remove null checks for C# value types#2933
Conversation
|
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
|
I will regenerate code if it looks OK |
There was a problem hiding this comment.
Question:
why is this line (some lines above) not covering all enums
for (CodegenProperty var : model.allVars) I had to add a separate one for this below
for (CodegenProperty var : model.vars) {There was a problem hiding this comment.
It should. That could be a bug with allVars.
I'll look into it in the coming week.
8250b07 to
4f05900
Compare
|
I think I need to add extra condition if it is a |
|
You mean something like |
|
Exactly. So if the value is nullable it will not be e.g. |
|
I think nullable is supported in the C# generators already: https://github.com/OpenAPITools/openapi-generator/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Amerged+nullable+csharp but you will need to use |
|
Thank you. I see that the simple type is already changed to nullable type. Then this will be covered. |
|
Ok, I verified it. the nullable types are having null checks. only value Types are skipped. |
|
Can you please update the C# netcore sample as well? |
6820342 to
1c8dbb3
Compare
1c8dbb3 to
261cee2
Compare
* 4.1.x: (56 commits) sync master Update compatibility table Ruby client: escape path parameters (OpenAPITools#3039) [gradle plugin] Release 4.0.1 fixes (OpenAPITools#3051) Update version to 4.0.2-SNAPSHOT (OpenAPITools#3047) Map number to double time since float is also parsed as double in Qt5 C++ (OpenAPITools#3046) Prepare 4.0.1 release (OpenAPITools#3041) [gradle] Reworking publishing pipeline (OpenAPITools#2886) [typescript-fetch] Fix uploading files (OpenAPITools#2900) Resolves OpenAPITools#2962 - Add properties config to Maven parameters (OpenAPITools#2963) fix(golang): Check error of xml Encode (OpenAPITools#3027) [C++][Restbed] Add handler callback methods (OpenAPITools#2911) Remove null checks for C# value types (OpenAPITools#2933) [python-server] Support python 3.7 for all server-generators (OpenAPITools#2884) Use golang's provided method names (gin) (OpenAPITools#2983) [python] Adding constructor parameters to Configuration and improving documentation (OpenAPITools#3002) Add new option to maven plugin's readme (OpenAPITools#3025) Engine param in maven plugin. (OpenAPITools#2881) Added support for patterns on model properties (OpenAPITools#2948) [csharp] Make API response headers dictionary case insensitive (OpenAPITools#2998) ...
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh,./bin/openapi3/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.master,4.1.x,5.0.x. Default:master.Description of the PR
Remove null checks on C# value types which throws a lot of warnings.
Null checks on enums which is a value type are already avoided. Combining simple types and enum as value types and avoiding null checks.
See here.
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/value-types
@wing328 @mandrean @jimschubert