Archive for the ‘Tools’ Category

Patch text files after code generation with CodeFluent Entities

CodeFluent Entities provides a large set of concepts and tools to generate code as custom as wanted. But, it may be a reason you need to modify the output produced by the CodeFluent Entities engine when there is not an option or a feature that allows you do that.
The Patch Producer is a producer that lets you “patch” text files using regular expressions. You can find the Patch Producer under the Utility Producers category.

Patch producer

Patch producer

Add a Patch

Add a Patch

Path: can be a directory path or a file path. If relative, it is based from the directory containing the project root part.
File Search Pattern: is a file filter expression. Only used if “path” is a directory.
Search Pattern: a regular expression matching groups.
Replace: a key=value pair list separated by the “Replace Separator Character”.

You can use the default namespace in the path attribute using the syntax {1:DefaultNameSpace}


Example 1

CodeFluent Entities provides a “tracking” feature.

Tracking User Name

Tracking User Name

In most of the cases the CodeFluentUser.Name is of the form “Domain\UserName” and let’s say we only want to store in the database the “UserName” without the “Domain” (ie. The CodeFluentUser.UserName).
In my case I have a CodeFluent Entities project with a Business Object Model (BOM) producer and a SQL Server persistence producer. The BOM generated files are stored in a class library project having as name the default namespace.
So, I need to search all files matching “ *.cs ” in my BOM project:
.cs Search Path

.cs Search Path

And make the replacement using the regular expression:
And replace the matched value in the group name “name” by “UserName”:
UserName replace

UserName replace

If I build my CodeFluent Entities, now I have:
UserName replaced

UserName replaced


Example 2

CodeFluent Entities adds some information on each generated file about the generation itself. For example, for SQL files:

Generation information

Generation information

Let’s say we want to add the name our company within this information, something like “CodeFluent Generated for SoftFluent […]
We add a new “Patch” producer.
Generation information Patch

Generation information Patch

As you can see, I store my SQL files in a folder named “SQL” in the same location as my BOM generated files (cf. example 1).
We build the CodeFluent Entities project and now we have:
Generation information Patched

Generation information Patched

Have fun.
Pablo Fernandez Duran

Using CodeFluent Entities x64 Tools

January 17, 2013 Leave a comment

In addition to the Visual Studio Integrated Modeler, CodeFluent Entities provides a set of tools in the form of executable files (.exe).

You can take a look in the installation directory of CodeFluent Entities to find these tools.

You will find:

For a more detailed description take a look at this blog post.

Well, these tools come in two versions: the x86 version and the x64 version.

The x86 version tools are located in \Program Files (x86)\SoftFluent\CodeFluent\Modeler while the x64 version in \Program Files (x86)\SoftFluent\CodeFluent\x64.

By Default, the CodeFluent Entities Modeler (integrated to Visual Studio) executes the x86 version tools, but maybe it would be interesting to use the x64 version (for instance, if you have a big model).

If you use the CodeFluent Entities Tools without its integration to Visual Studio you only need to look in to the wanted directory.

On the other hand, if you use the Visual Studio Integrated Modeler you can easily configure the Build Platform from the CodeFluent Entities Options. Check the “CodeFluent Entities Build – 32 Bits” option for a x86 platform or the “CodeFluent Entities Build – 64 Bits” option for a x64 platform.

CodeFluent Entities Options - Build Platform

CodeFluent Entities Options – Build Platform

Maybe you also noticed in the picture above that there is an option “CodeFluent Entities Build – CLR4”. Indeed, some tools are also built on the CLR4 (the rest is built on the CRL2) as:

  • The Builder (CodeFluent.Build4.exe)
  • The Service Host (CodeFluent.Runtime.ServiceHost4.exe)

Using a tool built on the CLR4 allows easier integration for custom assemblies (such as custom Aspects or Producers).

CLR2 tools can also be used with the CLR4 assemblies but it requires .config modifications.

The CLR4 tools exist in the x86 version, as well as in the x64 version.

Finally, using a x86 or a x64 tool has no impact when generating applications, as the product builds platform-agnostic code. You will be able to use “Any CPU”, X86, or X64 at your convenience.


Pablo Fernandez Duran