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
dotnet test tests/Microsoft.Agents.AI.<Package>.UnitTests
21
+
dotnet format src/Microsoft.Agents.AI.<Package>
22
+
23
+
# Run a single test
24
+
dotnet test --filter "FullyQualifiedName~Namespace.TestClassName.TestMethodName"
25
+
26
+
# Run unit tests only
27
+
dotnet test --filter FullyQualifiedName\~UnitTests
28
+
```
29
+
30
+
Use `--tl:off` when building to avoid flickering when running commands in the agent.
31
+
32
+
## Speeding Up Builds and Testing
12
33
13
34
The full solution is large. Use these shortcuts:
14
35
15
36
| Change type | What to do |
16
37
|-------------|------------|
17
-
| Internal logic | Build only the affected project and its `*.UnitTests` project. Fix issues, then build the full solution and run all unit tests. |
38
+
|Isolated/Internal logic | Build only the affected project and its `*.UnitTests` project. Fix issues, then build the full solution and run all unit tests. |
18
39
| Public API surface | Build the full solution and run all unit tests immediately. |
19
40
20
41
Example: Building a single code project for all target frameworks
Example: Running tests for a single project using .net 10.
55
+
Example: Running tests for a single project using .NET 10.
35
56
36
57
```bash
37
-
cd /workspaces/agent-framework/dotnet
38
-
dotnet test ./tests/Microsoft.Agents.AI.Abstractions.UnitTests/Microsoft.Agents.AI.Abstractions.UnitTests.csproj -f net10.0
58
+
# From dotnet/ directory
59
+
dotnet test ./tests/Microsoft.Agents.AI.Abstractions.UnitTests -f net10.0
60
+
```
61
+
62
+
Example: Running a single test in a specific project using .NET 10.
63
+
Provide the full namespace, class name, and method name for the test you want to run:
64
+
65
+
```bash
66
+
# From dotnet/ directory
67
+
dotnet test ./tests/Microsoft.Agents.AI.Abstractions.UnitTests -f net10.0 --filter "FullyQualifiedName~Microsoft.Agents.AI.Abstractions.UnitTests.AgentRunOptionsTests.CloningConstructorCopiesProperties"
39
68
```
40
69
41
70
### Multi-target framework tip
42
71
43
-
Most projects target multiple .NET frameworks. If the affected code does **not** use `#if` directives for framework-specific logic, pass `--framework net10.0` to speed up building and testing.
72
+
Most projects target multiple .NET frameworks. If the affected code does **not** use `#if` directives for framework-specific logic, pass `-f net10.0` to speed up building and testing.
73
+
74
+
### Package Restore tip
75
+
76
+
`dotnet build` will try and restore packages for all projects on each build, which can be slow.
77
+
Unless packages have been changed, or it's the first time building the solution, add `--no-restore` to the build command to skip this step and speed up builds.
78
+
79
+
Just remember to run `dotnet restore` after pulling changes, making changes to project references, or when building for the first time.
80
+
81
+
### Testing on Linux tip
82
+
83
+
Unit tests target both .NET Framework as well as .NET Core. When running on Linux, only the .NET Core tests can be run, as .NET Framework is not supported on Linux.
84
+
85
+
To run only the .NET Core tests, use the `-f net10.0` option with `dotnet test`.
Copy file name to clipboardExpand all lines: dotnet/AGENTS.md
+27-28Lines changed: 27 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,41 +4,28 @@ Instructions for AI coding agents working in the .NET codebase.
4
4
5
5
## Build, Test, and Lint Commands
6
6
7
-
```bash
8
-
# From dotnet/ directory
9
-
dotnet build # Build all projects
10
-
dotnet test# Run all tests
11
-
dotnet format # Auto-fix formatting
7
+
See `./.github/skills/build-and-test/SKILL.md` for detailed instructions on building, testing, and linting projects.
12
8
13
-
# Build/test a specific project (preferred for isolated changes)
14
-
dotnet build src/Microsoft.Agents.AI.<Package>
15
-
dotnet test tests/Microsoft.Agents.AI.<Package>.UnitTests
16
-
17
-
# Run a single test
18
-
dotnet test --filter "FullyQualifiedName~TestClassName.TestMethodName"
19
-
```
9
+
## Project Structure
20
10
21
-
**Note**: Changes to core packages (`Microsoft.Agents.AI`, `Microsoft.Agents.AI.Abstractions`) affect dependent projects - run checks across the entire solution. For isolated changes, build/test only the affected project to save time.
11
+
See `./.github/skills/project-structure/SKILL.md` for an overview of the project structure.
22
12
23
-
##Project Structure
13
+
### Core types
24
14
25
-
```
26
-
dotnet/
27
-
├── src/
28
-
│ ├── Microsoft.Agents.AI/ # Core AI agent abstractions
29
-
│ ├── Microsoft.Agents.AI.Abstractions/ # Shared abstractions and interfaces
-`AIAgent`: The abstract base class that all agents derive from, providing common methods for interacting with an agent.
16
+
-`AgentSession`: The abstract base class that all agent sessions derive from, representing a conversation with an agent.
17
+
-`ChatClientAgent`: An `AIAgent` implementation that uses an `IChatClient` to send messages to an AI provider and receive responses.
18
+
-`IChatClient`: Interface for sending messages to an AI provider and receiving responses. Used by `ChatClientAgent` and implemented by provider-specific packages.
19
+
-`FunctionInvokingChatClient`: Decorator for `IChatClient` that adds function invocation capabilities.
20
+
-`AITool`: Represents a tool that an agent/AI provider can use, with metadata and an execution delegate.
21
+
-`AIFunction`: A specific type of `AITool` that represents a local function the agent/AI provider can call, with parameters and return types defined.
22
+
-`ChatMessage`: Represents a message in a conversation.
23
+
-`AIContent`: Represents content in a message, which can be text, a function call, tool output and more.
38
24
39
25
### External Dependencies
40
26
41
-
The framework integrates with `Microsoft.Extensions.AI` and `Microsoft.Extensions.AI.Abstractions` (external NuGet packages) using types like `IChatClient`, `FunctionInvokingChatClient`, `AITool`, and `AIContent`.
27
+
The framework integrates with `Microsoft.Extensions.AI` and `Microsoft.Extensions.AI.Abstractions` (external NuGet packages)
28
+
using types like `IChatClient`, `FunctionInvokingChatClient`, `AITool`, `AIFunction`, `ChatMessage`, and `AIContent`.
42
29
43
30
## Key Conventions
44
31
@@ -49,8 +36,19 @@ The framework integrates with `Microsoft.Extensions.AI` and `Microsoft.Extension
49
36
-**Config**: Read from environment variables with `UPPER_SNAKE_CASE` naming
50
37
-**Tests**: Add Arrange/Act/Assert comments; use Moq for mocking
51
38
39
+
## Key Design Principles
40
+
41
+
When developing or reviewing code, verify adherence to these key design principles:
42
+
43
+
-**DRY**: Avoid code duplication by moving common logic into helper methods or helper classes.
44
+
-**Single Responsibility**: Each class should have one clear responsibility.
45
+
-**Encapsulation**: Keep implementation details private and expose only necessary public APIs.
46
+
-**Strong Typing**: Use strong typing to ensure that code is self-documenting and to catch errors at compile time.
47
+
52
48
## Sample Structure
53
49
50
+
Samples (in `./samples/` folder) should follow this structure:
51
+
54
52
1. Copyright header: `// Copyright (c) Microsoft. All rights reserved.`
55
53
2. Description comment explaining what the sample demonstrates
56
54
3. Using statements
@@ -60,6 +58,7 @@ The framework integrates with `Microsoft.Extensions.AI` and `Microsoft.Extension
60
58
Configuration via environment variables (never hardcode secrets). Keep samples simple and focused.
61
59
62
60
When adding a new sample:
61
+
63
62
- Create a standalone project in `samples/` with matching directory and project names
64
63
- Include a README.md explaining what the sample does and how to run it
0 commit comments