Files added to generated projects are deleted / moved to _OBSOLETE

Posts   
 
    
Stage
User
Posts: 1
Joined: 11-Oct-2020
# Posted on: 12-Oct-2020 03:37:16   

On the documentation page located at https://www.llblgen.com/Documentation/5.7/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/gencode_addingusercode.htm it states: "For example, consider an entity CustomerEntity being generated by LLBLGen Pro. You can then extend this class by adding a new file to the generated Visual Studio project and add the following code to that file"

But when I Generate Code the file that is added disappears. I went to Project / Settings / Code Generation / Delete Obsolete Files and unchecked this setting and now I get:

Obsolete file processing Moved obsolete file 'D:\SP.\CodeGen\DatabaseGeneric\EntityClasses\EmployeeEntityExt.cs' to 'D:\SP.\CodeGen\DatabaseGeneric\EntityClasses_OBSOLETE\EmployeeEntityExt.cs'

I am using version 5.7 (5.7.1) RTM Trial version. I also looked at the thread at https://www.llblgen.com/tinyforum/Thread/26835 but I am still left a little confused. Can you add files to the generated project and if you can, what do I need to do to stop the files that I add from being deleted. Or alternatively, should I add the partial classes in my own project that references the generated project and use the same namespace as the generated project?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 12-Oct-2020 07:13:18   

Hi Stage,

The setting Delete Obsolete Files is used to decide what to do with an obsolete file: delete it from or move it to an special folder. Your problem is that the file is marked as "obsolete" because it's in a folder that is explicitly assigned in code generation tasks. To avoid this you should put your custom files in a separate folder. This is explained in Automatic Cleanup of Outdated Files:

Automatic code clean up is only performed when the code generation task generates multiple files, e.g. 'all entities' or 'all typed views'. This also means that it will only clean up obsolete files in folders which are targeted by these tasks. If you place your custom classes in a separate folder, they're left untouched, as they're not in the target folder of one of these tasks.

Example: you have a couple of partial classes defined for a few entities. If you place these partial classes in the 'Entities' folder, which also contains all generated entity classes, these partial classes you created will be seen as obsolete as they're not overwritten by the code generator. To avoid this, place your partial classes in a different folder inside the same csproj/vbproj, e.g. 'Extensions'. As 'Extensions' isn't a folder targeted by a code generation task it won't be part of the code clean up process and files in there are left as-is. Files with a different extension are also left alone. E.g. if you have a file called 'specifics.txt' in the Entities folder, it's not deleted as it has a different extension as the entity classes files and therefore isn't a left-over from code generation.

David Elizondo | LLBLGen Support Team