1. FIlippo Donà
  2. SnapDevelop
  3. Wednesday, 22 March 2023 11:12 AM UTC

Hello, I need information about converting datawindows to C# Model.

In SnapDevelop starting from a datawindow created with PowerBuilder I am able to create the relative C# Model using the "Convert DataWindow to C# Model" function however I find what I think is an issue.

Once the C# Model was generated and compiled, I noticed the following warnings regarding two non-nullable properties:

1> ------ Build started: Project: api.csproj, Configuration: Debug Any CPU ------
1> D_Righe_Documento.cs(22,23): Warning CS8618: L'elemento proprietà 'Descrizione' non nullable deve contenere un valore non Null all'uscita dal costruttore. Provare a dichiarare proprietà come nullable.
1> D_Righe_Documento.cs(35,23): Warning CS8618: L'elemento proprietà 'Totale_Riga' non nullable deve contenere un valore non Null all'uscita dal costruttore. Provare a dichiarare proprietà come nullable.

So I opened the settings of the DataWindow converter and I saw that the "Generate models with nullable property types" check was missing.

I checked the "Generate models with nullable property types" flag and tried to open the Preview of the C# Model I noticed that the preview is different from the code that was generated

Preview:

C# Model generated:

Any suggestions? 

Environment:
SnapDevelop 2022

Thank you all

Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Friday, 24 March 2023 21:12 PM UTC
  2. SnapDevelop
  3. # 1

Hi Filippo,

This is a warning that shows up when you have an reference-type field/property that cannot be ensured to have a value after constructing the class.
According to the error message, it's properties Descrizione and Totale_Riga that are triggering the warning. If you change these variable's type from string to string? (i.e. making them explicitly nullable), the warnings will disappear. Starting with .NET 6, projects are null-aware by default. You can read more about this here.

Hope this helps.

Regards,
Francisco

Comment
There are no comments made yet.
Mark Lee @Appeon Accepted Answer Pending Moderation
  1. Friday, 24 March 2023 09:47 AM UTC
  2. SnapDevelop
  3. # 2

Hi FIlippo,

 

Thanks for reporting this problem.
According to my writing case, this warnings message is not reproduced.
When modifying the "Generate models with nullable property types" global setting,
You need to exit the currently opened "Datawindow Converter" tab page. Re-open the "Convert Datawindow to C# Model" function to take effect.

In addition, is the column of the “Quantita” and “Prezzo” defined in the relevant table in your database allowed to be empty?

It is recommended that you provide a reproducible small case (including the datawindow DataSource and table SQL syntax) to us for more study.
And please report your SnapDevelop issue via our support ticketing system to ensure it is being properly received by our tech support and tracked : https://www.appeon.com/standardsupport/newbug

 

Regards,

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.