Skip to content

Commit fbc042e

Browse files
Fix 3 subagent-found bugs: trimmedPattern in search, Razor HTML escaping, whitespace-only type guard
- BookListingTool.cs: use trimmedPattern (not pattern) in Contains() search call - Index.cshtml: fix Razor HTML escaping of optional badge via @if block - BookGuidelinesTool.cs: use IsNullOrWhiteSpace guard for type param - BookGuidelinesTool.cs: fix description to say substring match not exact text Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 8e3629c commit fbc042e

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

EssentialCSharp.Web/Tools/BookGuidelinesTool.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ public BookGuidelinesTool(IGuidelinesService guidelinesService)
1818
}
1919

2020
[McpServerTool(Title = "Get C# Guidelines", ReadOnly = true, Destructive = false, Idempotent = true, OpenWorld = false),
21-
Description("Retrieve C# coding guidelines from the Essential C# book. Filter by keyword (exact text match), chapter number, or guideline type. Use the 'topic' parameter for relevance-ranked discovery by concept (e.g., 'exception handling', 'naming', 'async'). Each guideline includes its chapter and subsection context. Tip: use 'topic' for broad discovery; use 'keyword' for precise text matching.")]
21+
Description("Retrieve C# coding guidelines from the Essential C# book. Filter by keyword (case-insensitive substring match), chapter number, or guideline type. Use the 'topic' parameter for relevance-ranked discovery by concept (e.g., 'exception handling', 'naming', 'async'). Each guideline includes its chapter and subsection context. Tip: use 'topic' for broad discovery; use 'keyword' for precise substring matching.")]
2222
public string GetCSharpGuidelines(
23-
[Description("Optional keyword for exact-text search in guideline text and subsection name.")] string? keyword = null,
23+
[Description("Optional keyword for case-insensitive substring search in guideline text and subsection name.")] string? keyword = null,
2424
[Description("Optional chapter number to restrict results to a specific chapter.")] int? chapter = null,
2525
[Description("Optional guideline type: 'do', 'consider', 'avoid', or 'donot' (also accepts 'do not', 'dont').")] string? type = null,
26-
[Description("Optional topic or concept for relevance-ranked search (e.g., 'exception handling', 'naming', 'async'). Results are ordered by relevance. Use for broad discovery; use 'keyword' for exact text matching.")] string? topic = null,
26+
[Description("Optional topic or concept for relevance-ranked search (e.g., 'exception handling', 'naming', 'async'). Results are ordered by relevance. Use for broad discovery; use 'keyword' for substring text matching.")] string? topic = null,
2727
[Description("Maximum number of guidelines to return (1–50).")] int maxResults = 20)
2828
{
2929
maxResults = Math.Clamp(maxResults, 1, 50);
3030
GuidelineType? typeFilter = ParseGuidelineType(type);
3131

32-
if (type is not null && typeFilter is null)
32+
if (!string.IsNullOrWhiteSpace(type) && typeFilter is null)
3333
{
3434
return "Invalid guideline type. Valid values: 'do', 'consider', 'avoid', 'donot' (also accepts 'do not', 'dont').";
3535
}

EssentialCSharp.Web/Tools/BookListingTool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public async Task<string> SearchListingsByCode(
7373
foreach (var listing in listings)
7474
{
7575
if (found >= maxResults) break;
76-
if (listing.Content.Contains(pattern, StringComparison.OrdinalIgnoreCase))
76+
if (listing.Content.Contains(trimmedPattern, StringComparison.OrdinalIgnoreCase))
7777
{
7878
string langHint = listing.FileExtension == "cs" ? "csharp" : listing.FileExtension;
7979
sb.AppendLine(CultureInfo.InvariantCulture, $"### Listing {listing.ChapterNumber}.{listing.ListingNumber}");

EssentialCSharp.Web/Views/McpSetup/Index.cshtml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@
278278
<dl class="row mb-0 small">
279279
@foreach (var param in tool.Parameters)
280280
{
281-
<dt class="col-sm-3"><code>@param.Name</code>@(param.Required ? "" : " <span class=\"text-muted\">(optional)</span>")</dt>
281+
<dt class="col-sm-3">
282+
<code>@param.Name</code>
283+
@if (!param.Required) { <span class="text-muted">(optional)</span> }
284+
</dt>
282285
<dd class="col-sm-9">@param.Description</dd>
283286
}
284287
</dl>

0 commit comments

Comments
 (0)