-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not nullable enum and object members. #43
Comments
Hi @kustanbruno |
Hi @moh-hassan Here is the xml file. Thank you for your quick response. |
Thanks for response.
All enum type or objects has no Nullable attribute It seems that the SAP XML file doesn't support nullable reference types of c# 8 OData2Poco apply nullable to only properties that have Nullable attribute with -b option. Can you try to add the next line at start of cs file:
If this is applicable, i can add a new feature to disable reference data types. Have a look to James Newton-King tweet What do you think to manage this nullable reference type objects? |
@kustanbruno What is special for your case that fire exception when deserialization of null objects? |
@moh-hassan Sorry for the slow reactions. I tried the adding the line you suggested to the poco file. The error still remains. We are using microsofts builtin System.Net.Http.HttpClient to make requests with the sap api. We get the following exception when trying to get from the api without the question marks.
We are using .net6, I think it uses C#10. I don't know if anything has changed in regards of nullable types. I think the fastest solution to our problem would be adding the feature to add ? to all reference data types, even if they don't have the Nullable attribute. Thanks for your help. |
@kustanbruno,
I agree with you and I'll add this feature in the next release. |
@kustanbruno |
The new feature works perfectly. I tried out the file and the generation too. Thank you for your quick and professional work. |
Hi @kustanbruno |
I am using odata2poco with SAP service layer. Some of the enum or object members are null from the api. I am using the -b, --nullable option. It works for C# primitives, but enums and objects from the api are not nullable. The newtonsoft JSON deserialization library can't deserialize the response object because there are fields with null value which are not nullable in the generated file.
If i put the "?" after the type definitions everything works. Is it possible to make every member variable nullable with the nullable option?
The text was updated successfully, but these errors were encountered: