Skip to content

Commit db37c0f

Browse files
patnikoCopilot
andcommitted
Quality fixes: C# in all verify.sh, fix stubs, consistent patterns
- Add C# build/run steps to all 26 verify.sh scripts that were missing them - Replace infinite-sessions TS stub with real implementation - Rework modes: remove filesystem-preset, rename cli-preset→default and minimal-preset→minimal with real implementations in all 4 languages - Fix C# patterns across all 33 scenarios: consistent await using, StartAsync/StopAsync, proper disposal 33 scenarios × 4 languages = 132 builds, all passing. 2 multi-user scenarios remain as stubs (require memory FS features). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3275b12 commit db37c0f

94 files changed

Lines changed: 757 additions & 438 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

test/scenarios/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ gh-app-go
4545
cli-preset-go
4646
filesystem-preset-go
4747
minimal-preset-go
48+
default-go
49+
minimal-go
4850

4951
# Python
5052
__pycache__/

test/scenarios/auth/byok-anthropic/csharp/Program.cs

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,45 @@
1010
return 1;
1111
}
1212

13-
await using var client = new CopilotClient(new CopilotClientOptions
13+
using var client = new CopilotClient(new CopilotClientOptions
1414
{
1515
CliPath = Environment.GetEnvironmentVariable("COPILOT_CLI_PATH"),
1616
});
1717

18-
await using var session = await client.CreateSessionAsync(new SessionConfig
18+
await client.StartAsync();
19+
20+
try
1921
{
20-
Model = model,
21-
Provider = new ProviderConfig
22-
{
23-
Type = "anthropic",
24-
BaseUrl = baseUrl,
25-
ApiKey = apiKey,
26-
},
27-
AvailableTools = [],
28-
SystemMessage = new SystemMessageConfig
22+
await using var session = await client.CreateSessionAsync(new SessionConfig
2923
{
30-
Mode = SystemMessageMode.Replace,
31-
Content = "You are a helpful assistant. Answer concisely.",
32-
},
33-
});
24+
Model = model,
25+
Provider = new ProviderConfig
26+
{
27+
Type = "anthropic",
28+
BaseUrl = baseUrl,
29+
ApiKey = apiKey,
30+
},
31+
AvailableTools = [],
32+
SystemMessage = new SystemMessageConfig
33+
{
34+
Mode = SystemMessageMode.Replace,
35+
Content = "You are a helpful assistant. Answer concisely.",
36+
},
37+
});
3438

35-
var response = await session.SendAndWaitAsync(new MessageOptions
36-
{
37-
Prompt = "What is the capital of France?",
38-
});
39+
var response = await session.SendAndWaitAsync(new MessageOptions
40+
{
41+
Prompt = "What is the capital of France?",
42+
});
3943

40-
if (response != null)
44+
if (response != null)
45+
{
46+
Console.WriteLine(response.Data?.Content);
47+
}
48+
}
49+
finally
4150
{
42-
Console.WriteLine(response.Data?.Content);
51+
await client.StopAsync();
4352
}
44-
4553
return 0;
54+

test/scenarios/auth/byok-anthropic/verify.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,12 @@ echo ""
6969
check "TypeScript (install)" bash -c "cd '$SCRIPT_DIR/typescript' && npm install --ignore-scripts 2>&1"
7070
check "TypeScript (build)" bash -c "cd '$SCRIPT_DIR/typescript' && npm run build 2>&1"
7171

72+
# C#: build
73+
check "C# (build)" bash -c "cd '$SCRIPT_DIR/csharp' && dotnet build --nologo -v q 2>&1"
74+
7275
if [ "${BYOK_SAMPLE_RUN_E2E:-}" = "1" ] && [ -n "${ANTHROPIC_API_KEY:-}" ]; then
7376
run_with_timeout "TypeScript (run)" bash -c "cd '$SCRIPT_DIR/typescript' && node dist/index.js"
77+
run_with_timeout "C# (run)" bash -c "cd '$SCRIPT_DIR/csharp' && dotnet run --no-build 2>&1"
7478
else
7579
echo "⚠️ WARNING: E2E run was SKIPPED — only build was verified, not runtime behavior."
7680
echo " To run fully: set BYOK_SAMPLE_RUN_E2E=1 and ANTHROPIC_API_KEY."

test/scenarios/auth/byok-azure/csharp/Program.cs

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,49 @@
1111
return 1;
1212
}
1313

14-
await using var client = new CopilotClient(new CopilotClientOptions
14+
using var client = new CopilotClient(new CopilotClientOptions
1515
{
1616
CliPath = Environment.GetEnvironmentVariable("COPILOT_CLI_PATH"),
1717
});
1818

19-
await using var session = await client.CreateSessionAsync(new SessionConfig
19+
await client.StartAsync();
20+
21+
try
2022
{
21-
Model = model,
22-
Provider = new ProviderConfig
23+
await using var session = await client.CreateSessionAsync(new SessionConfig
2324
{
24-
Type = "azure",
25-
BaseUrl = endpoint,
26-
ApiKey = apiKey,
27-
Azure = new AzureOptions
25+
Model = model,
26+
Provider = new ProviderConfig
2827
{
29-
ApiVersion = apiVersion,
28+
Type = "azure",
29+
BaseUrl = endpoint,
30+
ApiKey = apiKey,
31+
Azure = new AzureOptions
32+
{
33+
ApiVersion = apiVersion,
34+
},
3035
},
31-
},
32-
AvailableTools = [],
33-
SystemMessage = new SystemMessageConfig
34-
{
35-
Mode = SystemMessageMode.Replace,
36-
Content = "You are a helpful assistant. Answer concisely.",
37-
},
38-
});
36+
AvailableTools = [],
37+
SystemMessage = new SystemMessageConfig
38+
{
39+
Mode = SystemMessageMode.Replace,
40+
Content = "You are a helpful assistant. Answer concisely.",
41+
},
42+
});
3943

40-
var response = await session.SendAndWaitAsync(new MessageOptions
41-
{
42-
Prompt = "What is the capital of France?",
43-
});
44+
var response = await session.SendAndWaitAsync(new MessageOptions
45+
{
46+
Prompt = "What is the capital of France?",
47+
});
4448

45-
if (response != null)
49+
if (response != null)
50+
{
51+
Console.WriteLine(response.Data?.Content);
52+
}
53+
}
54+
finally
4655
{
47-
Console.WriteLine(response.Data?.Content);
56+
await client.StopAsync();
4857
}
49-
5058
return 0;
59+

test/scenarios/auth/byok-azure/verify.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,12 @@ echo ""
6969
check "TypeScript (install)" bash -c "cd '$SCRIPT_DIR/typescript' && npm install --ignore-scripts 2>&1"
7070
check "TypeScript (build)" bash -c "cd '$SCRIPT_DIR/typescript' && npm run build 2>&1"
7171

72+
# C#: build
73+
check "C# (build)" bash -c "cd '$SCRIPT_DIR/csharp' && dotnet build --nologo -v q 2>&1"
74+
7275
if [ -n "${AZURE_OPENAI_ENDPOINT:-}" ] && [ -n "${AZURE_OPENAI_API_KEY:-}" ]; then
7376
run_with_timeout "TypeScript (run)" bash -c "cd '$SCRIPT_DIR/typescript' && node dist/index.js"
77+
run_with_timeout "C# (run)" bash -c "cd '$SCRIPT_DIR/csharp' && dotnet run --no-build 2>&1"
7478
else
7579
echo "⚠️ WARNING: E2E run was SKIPPED — only build was verified, not runtime behavior."
7680
echo " To run fully: set AZURE_OPENAI_ENDPOINT and AZURE_OPENAI_API_KEY."

test/scenarios/auth/byok-ollama/csharp/Program.cs

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,42 @@
66
var compactSystemPrompt =
77
"You are a compact local assistant. Keep answers short, concrete, and under 80 words.";
88

9-
await using var client = new CopilotClient(new CopilotClientOptions
9+
using var client = new CopilotClient(new CopilotClientOptions
1010
{
1111
CliPath = Environment.GetEnvironmentVariable("COPILOT_CLI_PATH"),
1212
});
1313

14-
await using var session = await client.CreateSessionAsync(new SessionConfig
14+
await client.StartAsync();
15+
16+
try
1517
{
16-
Model = model,
17-
Provider = new ProviderConfig
18-
{
19-
Type = "openai",
20-
BaseUrl = baseUrl,
21-
},
22-
AvailableTools = [],
23-
SystemMessage = new SystemMessageConfig
18+
await using var session = await client.CreateSessionAsync(new SessionConfig
2419
{
25-
Mode = SystemMessageMode.Replace,
26-
Content = compactSystemPrompt,
27-
},
28-
});
20+
Model = model,
21+
Provider = new ProviderConfig
22+
{
23+
Type = "openai",
24+
BaseUrl = baseUrl,
25+
},
26+
AvailableTools = [],
27+
SystemMessage = new SystemMessageConfig
28+
{
29+
Mode = SystemMessageMode.Replace,
30+
Content = compactSystemPrompt,
31+
},
32+
});
2933

30-
var response = await session.SendAndWaitAsync(new MessageOptions
31-
{
32-
Prompt = "What is the capital of France?",
33-
});
34+
var response = await session.SendAndWaitAsync(new MessageOptions
35+
{
36+
Prompt = "What is the capital of France?",
37+
});
3438

35-
if (response != null)
39+
if (response != null)
40+
{
41+
Console.WriteLine(response.Data?.Content);
42+
}
43+
}
44+
finally
3645
{
37-
Console.WriteLine(response.Data?.Content);
46+
await client.StopAsync();
3847
}

test/scenarios/auth/byok-ollama/verify.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,12 @@ echo ""
6969
check "TypeScript (install)" bash -c "cd '$SCRIPT_DIR/typescript' && npm install --ignore-scripts 2>&1"
7070
check "TypeScript (build)" bash -c "cd '$SCRIPT_DIR/typescript' && npm run build 2>&1"
7171

72+
# C#: build
73+
check "C# (build)" bash -c "cd '$SCRIPT_DIR/csharp' && dotnet build --nologo -v q 2>&1"
74+
7275
if [ "${BYOK_SAMPLE_RUN_E2E:-}" = "1" ]; then
7376
run_with_timeout "TypeScript (run)" bash -c "cd '$SCRIPT_DIR/typescript' && node dist/index.js"
77+
run_with_timeout "C# (run)" bash -c "cd '$SCRIPT_DIR/csharp' && dotnet run --no-build 2>&1"
7478
else
7579
echo "⚠️ WARNING: E2E run was SKIPPED — only build was verified, not runtime behavior."
7680
echo " To run fully: set BYOK_SAMPLE_RUN_E2E=1 (and ensure Ollama is running)."

test/scenarios/auth/byok-openai/csharp/Program.cs

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,39 @@
1010
return 1;
1111
}
1212

13-
await using var client = new CopilotClient(new CopilotClientOptions
13+
using var client = new CopilotClient(new CopilotClientOptions
1414
{
1515
CliPath = Environment.GetEnvironmentVariable("COPILOT_CLI_PATH"),
1616
});
1717

18-
await using var session = await client.CreateSessionAsync(new SessionConfig
18+
await client.StartAsync();
19+
20+
try
1921
{
20-
Model = model,
21-
Provider = new ProviderConfig
22+
await using var session = await client.CreateSessionAsync(new SessionConfig
2223
{
23-
Type = "openai",
24-
BaseUrl = baseUrl,
25-
ApiKey = apiKey,
26-
},
27-
});
24+
Model = model,
25+
Provider = new ProviderConfig
26+
{
27+
Type = "openai",
28+
BaseUrl = baseUrl,
29+
ApiKey = apiKey,
30+
},
31+
});
2832

29-
var response = await session.SendAndWaitAsync(new MessageOptions
30-
{
31-
Prompt = "What is the capital of France?",
32-
});
33+
var response = await session.SendAndWaitAsync(new MessageOptions
34+
{
35+
Prompt = "What is the capital of France?",
36+
});
3337

34-
if (response != null)
38+
if (response != null)
39+
{
40+
Console.WriteLine(response.Data?.Content);
41+
}
42+
}
43+
finally
3544
{
36-
Console.WriteLine(response.Data?.Content);
45+
await client.StopAsync();
3746
}
38-
3947
return 0;
48+

test/scenarios/auth/byok-openai/verify.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,14 @@ check "Python (syntax)" bash -c "python3 -c \"import ast; ast.parse(open('$SCRI
7676
# Go: build
7777
check "Go (build)" bash -c "cd '$SCRIPT_DIR/go' && go build -o byok-openai-go . 2>&1"
7878

79+
# C#: build
80+
check "C# (build)" bash -c "cd '$SCRIPT_DIR/csharp' && dotnet build --nologo -v q 2>&1"
81+
7982
if [ "${BYOK_SAMPLE_RUN_E2E:-}" = "1" ] && [ -n "${OPENAI_API_KEY:-}" ]; then
8083
run_with_timeout "TypeScript (run)" bash -c "cd '$SCRIPT_DIR/typescript' && node dist/index.js"
8184
run_with_timeout "Python (run)" bash -c "cd '$SCRIPT_DIR/python' && python3 main.py"
8285
run_with_timeout "Go (run)" bash -c "cd '$SCRIPT_DIR/go' && ./byok-openai-go"
86+
run_with_timeout "C# (run)" bash -c "cd '$SCRIPT_DIR/csharp' && dotnet run --no-build 2>&1"
8387
else
8488
echo "⚠️ WARNING: E2E run was SKIPPED — only build was verified, not runtime behavior."
8589
echo " To run fully: set BYOK_SAMPLE_RUN_E2E=1 and OPENAI_API_KEY."

test/scenarios/auth/gh-app/csharp/Program.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
try
6969
{
70-
var session = await client.CreateSessionAsync(new SessionConfig
70+
await using var session = await client.CreateSessionAsync(new SessionConfig
7171
{
7272
Model = "gpt-4.1",
7373
});
@@ -81,8 +81,6 @@
8181
{
8282
Console.WriteLine(response.Data?.Content);
8383
}
84-
85-
await session.DisposeAsync();
8684
}
8785
finally
8886
{

0 commit comments

Comments
 (0)