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
# Build without restoring (faster if dependencies haven't changed)
69
+
dotnet build --no-restore
70
+
```
71
+
72
+
### For changes under to native files:
73
+
74
+
```bash
75
+
# Build the native components to verify compilation works
76
+
./build.sh -skipmanaged
77
+
78
+
# Do a full test run:
79
+
./build -test
80
+
```
81
+
45
82
## Testing
46
83
47
-
### Running Tests
84
+
### Running All Tests
48
85
49
86
**Linux/macOS:**
50
87
```bash
@@ -56,12 +93,27 @@ Build.cmd
56
93
Test.cmd
57
94
```
58
95
59
-
The test script runs all tests in the repository. Test projects are located in the `src/tests` directory.
96
+
The test script runs all tests in the repository. **Important**: `test.sh` calls `eng/build.sh -test -skipmanaged -skipnative`, which means it only runs tests without rebuilding. Always build first if you've made code changes.
60
97
61
98
### Test Organization
62
-
- Unit tests are typically in `*.Tests` projects
63
-
- Integration tests may be in separate test projects
64
-
- Test helpers are in `Microsoft.Diagnostics.TestHelpers`
99
+
100
+
Test projects are usually located in `src/tests/` with the following structure:
101
+
102
+
-**Tool and libraries tests**: `*.UnitTests.csproj` or `*.Tests.csproj` under the appropriate tool's folder in `src/tests`.
103
+
- Changes with native dependencies (SOS, DBGShim, dotnet-sos, dotnet-dump) are better tested with the global test script.
104
+
105
+
### Running Specific Tests
106
+
107
+
```bash
108
+
# Run tests for a specific project
109
+
dotnet test src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/
110
+
111
+
# Run tests with detailed output
112
+
dotnet test --logger "console;verbosity=detailed"
113
+
114
+
# Run a specific test by name
115
+
dotnet test --filter "FullyQualifiedName~TestMethodName"
116
+
```
65
117
66
118
## Project Structure
67
119
@@ -91,17 +143,25 @@ The test script runs all tests in the repository. Test projects are located in t
91
143
The repository follows standard .NET coding conventions defined in the `.editorconfig` file at the root. This is a **must** for C# code. Ensure your changes conform to these settings:
92
144
93
145
1.**Indentation**: 4 spaces (no tabs)
94
-
2.**Line endings**: LF on Linux/macOS, CRLF on Windows
146
+
2.**Line endings**: LF on Linux/macOS, CRLF on Windows (EditorConfig enforces this)
95
147
3.**Braces**: Opening braces on new lines for types, methods, properties, control blocks
96
-
4.**Naming**:
97
-
- PascalCase for types, methods, properties, public fields
98
-
- camelCase for local variables, parameters, private fields
99
-
-`_camelCase` for private instance fields (with underscore prefix)
100
-
5.**File organization**: One type per file, filename matches type name
101
-
6.**Additional EditorConfig rules**:
148
+
4.**Naming conventions** (strictly enforced):
149
+
- PascalCase for types, methods, properties, public fields, constants
150
+
- camelCase for local variables and parameters
151
+
-`_camelCase` for private/internal instance fields (underscore prefix)
152
+
-`s_camelCase` for static private/internal fields (s_ prefix)
153
+
5.**File headers**: All C# files must include the MIT license header:
154
+
```csharp
155
+
// Licensed to the .NET Foundation under one or more agreements.
156
+
// The .NET Foundation licenses this file to you under the MIT license.
157
+
```
158
+
6.**Using directives**: Must be placed **outside** the namespace declaration
159
+
7.**Var keyword**: Avoid using `var` - use explicit types (configured as error when type is apparent)
160
+
8.**File organization**: One type per file, filename matches type name
161
+
9.**Additional rules**:
102
162
- Trim trailing whitespace
103
163
- Insert final newline
104
-
-Follow C# new line and indentation preferences
164
+
-Prefer braces even for single-line blocks
105
165
106
166
### Native Code (C/C++)
107
167
@@ -111,6 +171,14 @@ Native code follows similar conventions:
111
171
- Use clear, descriptive names
112
172
- Follow existing patterns in the codebase
113
173
174
+
### Platform-Specific Line Endings
175
+
176
+
**Critical**: Line endings must match the platform to avoid breaking scripts:
177
+
- Shell scripts (`.sh`): **LF only** (will break on Linux/macOS if CRLF)
178
+
- Batch files (`.cmd`, `.bat`): **CRLF only**
179
+
- C# files: LF on Linux/macOS, CRLF on Windows
180
+
- The `.editorconfig` file enforces these rules automatically
181
+
114
182
## Making Changes
115
183
116
184
### General Guidelines
@@ -141,10 +209,33 @@ Native code follows similar conventions:
141
209
### After Making Changes
142
210
143
211
1.**Build**: Ensure your changes compile without errors or new warnings
212
+
```bash
213
+
./build.sh # or Build.cmd on Windows
214
+
```
144
215
2.**Test**: Run relevant tests to verify functionality
216
+
```bash
217
+
./test.sh # or Test.cmd on Windows
218
+
```
145
219
3.**Code style**: Verify changes match the repository's coding standards
220
+
- Check file headers (.NET Foundation header)
221
+
- Verify naming conventions (especially field prefixes)
222
+
- Ensure using directives are outside namespace
223
+
- Confirm line endings are correct for file type
146
224
4.**Documentation**: Update if your changes affect public APIs or behavior
147
225
226
+
### Investigating Build or Test Failures
227
+
228
+
When builds or tests fail, follow this diagnostic process:
229
+
230
+
1.**Check build logs**: Look at `artifacts/log/Build.binlog` using the Binary Log Viewer
231
+
2.**Review terminal output**: MSBuild errors will show the failing project and error code
232
+
3.**Check test results**: Detailed test logs are in `artifacts/TestResults/`
233
+
4.**For native builds**: Review CMake output for missing dependencies or configuration issues
234
+
5.**Clean and rebuild**: Sometimes required after changing build configuration files:
235
+
```bash
236
+
./build.sh -rebuild
237
+
```
238
+
148
239
## Development Workflow
149
240
150
241
### Typical Workflow
@@ -178,16 +269,43 @@ Native code follows similar conventions:
178
269
179
270
### Solution Files
180
271
181
-
The main solution file is `build.sln` at the root. This file is generated from `build.proj` and can be regenerated using:
182
-
```bash
183
-
./eng/generate-sln.sh
184
-
```
272
+
The main solution file is `build.sln` at the root. **Important**: This file is auto-generated from `build.proj`.
273
+
274
+
-**Do NOT manually edit**`build.sln`
275
+
- Regenerate after adding/removing projects:
276
+
- Linux/macOS: `./eng/generate-sln.sh`
277
+
- Windows: `.\eng\generate-sln.ps1`
278
+
- The solution is regenerated automatically during builds when needed
- Handled through machine-wide installation or container installation
308
+
- See `documentation/building/` for platform-specific prerequisites
191
309
192
310
### Platform-Specific Code
193
311
@@ -212,15 +330,24 @@ start-vs.cmd
212
330
213
331
### Common Issues
214
332
215
-
1.**Build failures**: Ensure all prerequisites are installed (see documentation/building/)
216
-
2.**Test failures**: Some tests may require specific runtime versions or configurations
217
-
3.**Native component issues**: Check CMake output for missing dependencies
333
+
1.**Build failures**:
334
+
- Ensure all prerequisites are installed (see `documentation/building/`)
335
+
- Check `artifacts/log/Build.binlog` for detailed error information
336
+
2.**Test failures**:
337
+
- Some tests require specific runtime versions or configurations
338
+
- Check test output in `artifacts/TestResults/` if using global test script
339
+
- Verify you built before testing (test scripts don't rebuild)
340
+
3.**Native component issues**:
341
+
- Check terminal output for cl/clang/cmake error output.
342
+
4.**Line ending issues**:
343
+
- Shell scripts fail on Linux/macOS: Check for CRLF line endings
344
+
- Ensure `.editorconfig` settings are being respected by your editor
218
345
219
346
## Dependencies and Security
220
347
221
348
### Adding Dependencies
222
349
223
-
1.**NuGet packages**: Add to `eng/Versions.props` with appropriate version
350
+
1.**NuGet packages**: Add to `eng/Versions.props` with appropriate version and never modify `NuGet.config` to add a source feed unless asked to do so specifically. Particularly, *never* add `nuget.org` as a source to `NuGet.config`. Use the `nuget` MCP as needed to query and solve for assembly version conflicts.
224
351
2.**Security**: Be mindful of security implications when adding dependencies
225
352
3.**Licensing**: Ensure new dependencies are compatible with MIT license
226
353
4.**Minimize dependencies**: Only add when necessary
@@ -279,6 +406,7 @@ start-vs.cmd
279
406
## Questions and Support
280
407
281
408
If you encounter issues or have questions:
409
+
282
410
1. Check existing documentation in `/documentation`
283
411
2. Review closed issues and pull requests for similar problems
0 commit comments