You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DEVELOPMENT.md
+66Lines changed: 66 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -137,6 +137,31 @@ cd Mutagen.Bethesda.Generator.All/bin/Debug/net8.0
137
137
138
138
The generators use relative paths like `../../../../Mutagen.Bethesda.{Game}/Records` to locate project files. Running from the build output directory ensures these relative paths resolve correctly to the repository structure.
139
139
140
+
## Project File Management
141
+
142
+
### Adding New Files to Projects
143
+
144
+
**Important**: Most projects in this repository use `<EnableDefaultCompileItems>False</EnableDefaultCompileItems>`, which means all source files must be explicitly listed in the `.csproj` file. This is necessary to properly nest generated code files under their corresponding XML definition files.
145
+
146
+
When adding new `.cs` files to a project:
147
+
148
+
1.**Find the correct location** in the `.csproj` file (files are typically grouped by directory/feature)
149
+
2.**Add a `<Compile Include="...">` element** with the file path
150
+
3.**For generated files only**: Add a `<DependentUpon>...</DependentUpon>` element to nest it under the XML file
-**NEVER use `sed` for bulk find/replace** - `sed` does not preserve Windows CRLF line endings, creating massive spurious diffs
190
+
- On Windows, `sed -i` converts CRLF to LF, causing every line to show as changed in git
191
+
- Use targeted edits with the Edit tool instead of global sed replacements
192
+
- If you must do bulk replacements, only use tools that preserve line endings (e.g., PowerShell with `-Raw` and explicit encoding)
193
+
- Example (incorrect): `find . -name "*.cs" -exec sed -i 's/OldName/NewName/g' {} \;` - creates CRLF→LF changes on every touched file
194
+
- Example (correct): Use Edit tool on each file individually, or ask user to use IDE refactoring tools
195
+
159
196
## Releases
160
197
161
198
### Packaging
@@ -189,6 +226,35 @@ Mutagen uses AutoFixture with custom builders to automatically generate properly
189
226
- If you want, you can use `[Theory, MutagenModAutoData]` which will allow injection of mods, and records that are added to the latest mod.
190
227
- AutoFixture will inject properly configured `SkyrimMod`, `ModKey`, `FormKey`, etc. as test parameters
191
228
229
+
## Coding Practices
230
+
231
+
### Avoid Using `dynamic`
232
+
233
+
Do not use `dynamic` when possible. The codebase provides proper interfaces and generic methods that should be used instead. Using `dynamic` bypasses compile-time type checking and can lead to runtime errors.
234
+
235
+
### Prefer ModPath Over DirectoryPath + ModKey
236
+
237
+
When working with paths to mod files, prefer using `ModPath` instead of separate `DirectoryPath` and `ModKey` parameters. `ModPath` is essentially a string path that is expected to point to a mod file, and includes the associated `ModKey`.
0 commit comments