We have a bunch of files that are auto-generated based on the database model. I have had some facepalm experiences because I modified some code, only to find out my modifications where overwritten because I'd not noticed that my changes were in those generated files.
So, I modified our generator to include a "do not modify" comment in the file header. This helps! Although, when tracing method calls, it's easy to end up in the middle of one of these files, and you wouldn't necessarily know unless you scrolled to the top to check for the header. That is awkward (and error-prone).
Is there any way to mark these files, in a similar way that "External Libraries" are marked, so it's clear from styling that these files should be read-only?
The .NET stack uses the naming convention *.designer.cs for C# files, for instance, in addition to putting a comment on the first line stating that the file is generated using an automated tool and any changes will be lost if the file is regenerated.
You could use *.generated.php as a file naming pattern, and include a comment header that states:
The file is generated by tool X, version Y
Don't edit the source code of this file
Any changes to the file will be lost the next time the tool is run
Point people to a file they can edit, if applicable
naming convention is best - if all generated files were prefixed with "GEN" or something, you'd notice far quicker.
Some environments will also let you colour the tab based on a regex, so this would allow you to make them all black or pink by detecting the prefix in the filename.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With