Skip to content

Code Generation Settings

Daniel Svensson edited this page Sep 7, 2020 · 2 revisions

Code Generation Settings

The code generation for OpenRiaServives is based on some additional msbuild steps which are added to a client project by adding a single nuget package.If you have a client library for the code generation only that project will need a reference to the code generation package.
In order to enable code generation for a client project the project need to add a reference to any of the following nuget packages.

  • OpenRiaServices.Client.CodeGen
    • Non silverlight projects using unsiged versions OpenRiaServices.Client packages
  • OpenRiaServices.Signed.Client.CodeGen
    • Non silverlight projects using signed versions of OpenRiaServices.Client packages
    • Requires signed versions of server packages
  • OpenRiaServices.Silverlight.CodeGen
  • OpenRiaServices.Signed.Silverlight.CodeGen

MsBuild Properties

Below is a list of properties which can be set in a project in order to influence the code generation.

LinkedOpenRiaServerProject

Path (Relative or absolute) to the web project where the DomainServices and other server side logic resides.

Required This is a required property if code generation should occur at all.

OpenRiaGenerateApplicationContext

Determines if a WebContext class should be generated. The WebContext class is a singleton so only a single instance should be created.

Default: True for Silverlight Applications and when building exe files (when when $(OutputType) == exe)

OpenRiaClientUseFullTypeNames

Boolean where "true" means fully qualified type names should be generated.

Default: Not Set (false)

OpenRiaClientCodeGeneratorName

You can specify the full AssemblyQualifiedName of a CodeGenerator to use in case you want to use another code generatior than the default. Useful if your server project references the OpenRiaServices.T4 nuget package nad implements your own custom code generation logic.

Default: Not Set (no custom code generation)

OpenRiaSharedFilesMode

Introduced in 5.0 https://github.com/OpenRIAServices/OpenRiaServices/pull/229

Can be set to Link new behavior or Copy. Copy is the old approach used prior to version 5.0 and means that any shared file (file name ".shared.xx" in server project) is copied to the Generated_Code folder, marked as read-only and then referenced instead of compiling directly against the server copy.

Default: Link

MsBuild Items

OpenRiaClientCodeGenClientAssemblySearchPath

Msbuild Item Path to search for client assemblies.

Default: Includes $(TargetFrameworkDirectory) and $(TargetFrameworkSDKDirectory)

Extension Points

Below is a list of extensions points which can be set in a project in order to influence the code generation.

BeforeOpenRiaClientCodeGen

Redefine this target in your project in order to run tasks before RIA Services client proxy code generation occurs

Example

<Target Name="BeforeOpenRiaClientCodeGen">
  <Message Text="Before OpenRiaServices code generation"> 
</Target>

AfterOpenRiaClientCodeGen

Redefine this target in your project in order to run tasks after RIA Services client proxy code generation has been done

<Target Name="AfterOpenRiaClientCodeGen">
  <Message Text="After OpenRiaServices code generation"> 
</Target>

Actual Code generation Targets

CreateOpenRiaClientFiles

Target to invoke the CreateOpenRiaClientFilesTask after gathering information from $(LinkedOpenRiaServerProject). It is not executed unless $(LinkedOpenRiaServerProject) is non-empty and points to a valid project file.

CleanOpenRiaClientFiles

Task that deletes the RIA client files created by CreateOpenRiaClientFiles