< Summary

Information
Class: NexusLabs.Needlr.Copilot.WebSearchResult
Assembly: NexusLabs.Needlr.Copilot
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.Copilot/WebSearchResult.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 73
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Text()100%11100%
get_Citations()100%11100%
get_SearchQueries()100%11100%
ToString()100%11100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.Copilot/WebSearchResult.cs

#LineLine coverage
 1using System.Collections.Generic;
 2
 3namespace NexusLabs.Needlr.Copilot;
 4
 5/// <summary>
 6/// The structured result of a Copilot web search, including the answer text,
 7/// source citations, and the search queries that were performed.
 8/// </summary>
 9/// <remarks>
 10/// <para>
 11/// <see cref="ToString"/> returns <see cref="Text"/> so that existing agent
 12/// tool flows (which stringify tool results) continue to work unchanged.
 13/// </para>
 14/// <para>
 15/// Host code that needs citation or search query metadata can inspect
 16/// <see cref="Citations"/> and <see cref="SearchQueries"/> directly.
 17/// </para>
 18/// </remarks>
 19/// <example>
 20/// <code>
 21/// var tools = CopilotToolSet.Create(opts => opts.EnableWebSearch = true);
 22/// var webSearch = tools[0];
 23/// var result = await webSearch.InvokeAsync(new AIFunctionArguments(
 24///     new Dictionary&lt;string, object?&gt; { ["query"] = "latest .NET version" }));
 25///
 26/// if (result is WebSearchResult searchResult)
 27/// {
 28///     Console.WriteLine(searchResult.Text);
 29///     foreach (var citation in searchResult.Citations)
 30///     {
 31///         Console.WriteLine($"  [{citation.Title}]({citation.Url})");
 32///     }
 33/// }
 34/// </code>
 35/// </example>
 36public sealed class WebSearchResult
 37{
 1638    internal WebSearchResult(
 1639        string text,
 1640        IReadOnlyList<WebSearchCitation> citations,
 1641        IReadOnlyList<WebSearchQuery> searchQueries)
 42    {
 1643        Text = text;
 1644        Citations = citations;
 1645        SearchQueries = searchQueries;
 1646    }
 47
 48    /// <summary>
 49    /// The answer text generated by the web search. May contain
 50    /// <c>【3:N†source】</c> citation markers whose positions are
 51    /// described by <see cref="Citations"/>.
 52    /// </summary>
 2453    public string Text { get; }
 54
 55    /// <summary>
 56    /// Source citations extracted from the search result. Each citation maps a
 57    /// character span in <see cref="Text"/> to a source URL. Empty when the
 58    /// API did not return any annotations.
 59    /// </summary>
 2460    public IReadOnlyList<WebSearchCitation> Citations { get; }
 61
 62    /// <summary>
 63    /// The Bing search queries that the Copilot web search tool performed
 64    /// while generating the answer. Empty when no web searches were triggered.
 65    /// </summary>
 1366    public IReadOnlyList<WebSearchQuery> SearchQueries { get; }
 67
 68    /// <summary>
 69    /// Returns <see cref="Text"/> so that agent tool flows that stringify
 70    /// results continue to receive the answer content.
 71    /// </summary>
 272    public override string ToString() => Text;
 73}