Attribute substitution?

Posts   
 
    
AHenry
User
Posts: 17
Joined: 30-Jan-2013
# Posted on: 01-Mar-2022 17:34:18   

OK, this is a little tricky - it's not an LLBLGen problem, but it feels like there could be an LLBLGen solution.

I've got a single entity model, and I want to generate two+ LLBLGen Pro framework BL assemblies from it. The only major difference between them is the serialization libraries used, which use different Include/Exclude attributes. Unfortunately, two of the libraries are incompatible with each other, so I can't just tag the navigation element members with attributes for all of the libraries.

If I was writing in C++ instead of C#, I'd probably do something ugly with #defines and have multiple configurations of the BL project. C# doesn't have inheritance or composition of attributes so I think I have to do something on the code generation side.

The easiest way I can think of is to just use a single attribute ( [System.ServiceModel.DomainServices.Server.Include/Exclude] ) and then run a powershell script after code generation to copy the generated code to other project folders and perform mass-search-and-replace of the attributes at the same time. Alternatively, I could do the search and replace on the llblgen project file, and run two different code generation steps. I guess a custom pre-build event on the project could accomplish the same thing.

Are there any other obvious options? Does LLBLGen Designer have a command-line option to run code generation so I can automate this a little bit?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39747
Joined: 17-Aug-2003
# Posted on: 02-Mar-2022 08:31:04   

You can generate sourcecode on the command line using the cligenerator: https://www.llblgen.com/Documentation/5.9/Designer/Functionality%20Reference/CliGenerator.htm This generator is also distributed in source form in the sourcecode archive available under My Account -> Downloads, so you can adjust it to your liking. E.g. you could copy the llblgenproj file to a folder, generate the code from there, which should give you a codebase with the attributes, then remove all attribute definitions (assign them using rules in the project settings so you only have a few attribute definitions) from the project after the project has been loaded, in your version of the cligenerator, and then generate code again in a different folder, which should give you a code base without the attributes.

Frans Bouma | Lead developer LLBLGen Pro