Code generation
(Adding message template to the top of the page)
No edit summary
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{message|Write the content here to display this box}}
<message>Write the content here to display this box</message>
Also referred to as '''Codegen'''.
 
MDriven can generate C# code for projects in Visual Studio.
MDriven can generate C# code for projects in Visual Studio.


If you have several [[:Category:Packages|Package]]<nowiki/>s, you probably need them to use code access package boundaries. Then, add the name of the other packages in the [[Property inspector|Property Inspector]] for the [[:Category:Packages|Package.]]
If you have several [[:Category:Packages|Package]]<nowiki/>s, you probably need them to use code access package boundaries. Then, add the name of the other packages in the [[Documentation:Property inspector|Property Inspector]] for the Package.
 
==== Why do you have to CodeGen and when to upload model to MDrivenServer ====
There are 3-4 places with a model - and they should be the same for things to work.
 
# Your model - this place is used when pressing play in the designer
# MDrivenServer - this is used for all PS calls coming to the server, and from the webui in the server
# Your compiled code (it is reflected back to model when you start the ecospace in runtime)
# If you utilize codedress - the model assemblies are uploaded to the MDrivenServer and reflected in order to use the c# code for model methods.
We will assume that Your model is the latest and correct. Now refresh your code with the C# button - and possibly right click c# and generate all - then Build. The assemblies now has the correct model.
 
Then "Upload model" -  if you use CodeDress - your assemblies are sent to the server now - that is why it is good practice to have compiled your generated code - so you don't risk sending old assemblies with old model to MDrivenServer.
 
Now start you local App, or your turnkey server,


==== Troubleshooting: [[Code generation not working]] ====
==== Troubleshooting: [[Documentation:Code generation not working|Code generation not working]] ====
[[Category:MDriven Framework]]
[[Category:MDriven Framework]]
[[Category:C-Sharp]]
[[Category:C-Sharp]]
[[Category:Visual Studio]]
[[Category:Visual Studio]]
{{Edited|July|12|2024}}
{{Edited|July|12|2025}}

Latest revision as of 05:39, 21 March 2025

This page was created by Lars.olofsson@mdriven.net on 2017-12-20. Last edited by Stephanie@mdriven.net on 2025-03-21.

Also referred to as Codegen.

MDriven can generate C# code for projects in Visual Studio.

If you have several Packages, you probably need them to use code access package boundaries. Then, add the name of the other packages in the Property Inspector for the Package.

Why do you have to CodeGen and when to upload model to MDrivenServer

There are 3-4 places with a model - and they should be the same for things to work.

  1. Your model - this place is used when pressing play in the designer
  2. MDrivenServer - this is used for all PS calls coming to the server, and from the webui in the server
  3. Your compiled code (it is reflected back to model when you start the ecospace in runtime)
  4. If you utilize codedress - the model assemblies are uploaded to the MDrivenServer and reflected in order to use the c# code for model methods.

We will assume that Your model is the latest and correct. Now refresh your code with the C# button - and possibly right click c# and generate all - then Build. The assemblies now has the correct model.

Then "Upload model" - if you use CodeDress - your assemblies are sent to the server now - that is why it is good practice to have compiled your generated code - so you don't risk sending old assemblies with old model to MDrivenServer.

Now start you local App, or your turnkey server,

Troubleshooting: Code generation not working