367 instantiations of TextContent
DotNetInvocationHostedAgent (1)
EchoAIAgent.cs (1)
36Contents = [new TextContent($"Echo: {GetInputText(messages)}")]
Microsoft.Extensions.AI (2)
ChatCompletion\ImageGeneratingChatClient.cs (1)
179newContents.Add(new TextContent($"[{ImageKey}:{imageId}] available for edit.")
ChatCompletion\OpenTelemetryImageGenerator.cs (1)
180content.Add(new TextContent(request.Prompt));
Microsoft.Extensions.AI.Abstractions (7)
ChatCompletion\ChatMessage.cs (2)
31: this(role, content is null ? [] : [new TextContent(content)]) 116!string.IsNullOrWhiteSpace(text) ? new TextContent(text) :
ChatCompletion\ChatResponseExtensions.cs (1)
288static (contents, start, end) => new(MergeText(contents, start, end)) { AdditionalProperties = contents[start].AdditionalProperties?.Clone() });
ChatCompletion\ChatResponseUpdate.cs (2)
48: this(role, content is null ? null : [new TextContent(content)]) 184!string.IsNullOrWhiteSpace(text) ? new TextContent(text) :
SpeechToText\SpeechToTextResponse.cs (1)
36: this(content is null ? [] : [new TextContent(content)])
SpeechToText\SpeechToTextResponseUpdate.cs (1)
53: this(content is null ? [] : [new TextContent(content)])
Microsoft.Extensions.AI.Abstractions.Tests (69)
ChatCompletion\ChatMessageTests.cs (5)
90content.Add(new TextContent($"text-{i}")); 149new TextContent("text-1"), 150new TextContent("text-2"), 255new TextContent("content-1") 267new TextContent("content-4")
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (10)
767new() { Contents = [new TextContent("D") { Annotations = [new()] }] }, 768new() { Contents = [new TextContent("E") { Annotations = [new()] }] }, 769new() { Contents = [new TextContent("F") { Annotations = [new()] }] }, 770new() { Contents = [new TextContent("G") { Annotations = [] }] }, 771new() { Contents = [new TextContent("H") { Annotations = [] }] }, 772new() { Contents = [new TextContent("I") { Annotations = [new()] }] }, 773new() { Contents = [new TextContent("J") { Annotations = [new()] }] }, 775new() { Contents = [new TextContent("L") { Annotations = [new()] }] }, 778new() { Contents = [new TextContent("O") { Annotations = [new()] }] }, 779new() { Contents = [new TextContent("P") { Annotations = [new()] }] },
ChatCompletion\ChatResponseUpdateTests.cs (12)
44update.Contents.Add(new TextContent("text")); 48IList<AIContent> newList = [new TextContent("text")]; 95new TextContent("text-1"), 96new TextContent("text-2"), 121new TextContent("text-1"), 125new TextContent("text-2"), 184new TextContent("text-1"), 188new TextContent("text-2"), 246var originalContents = new List<AIContent> { new TextContent("text1"), new TextContent("text2") }; 379var sharedContents = new List<AIContent> { new TextContent("initial") }; 392sharedContents.Add(new TextContent("added"));
Contents\AIContentTests.cs (1)
67new TextContent("a"),
Contents\CodeInterpreterToolCallContentTests.cs (3)
30IList<AIContent> inputs = [new TextContent("print('hello')")]; 52new TextContent("import numpy as np"), 72new TextContent("print('hello')"),
Contents\CodeInterpreterToolResultContentTests.cs (3)
30IList<AIContent> output = [new TextContent("Hello, World!")]; 52new TextContent("Execution completed"), 74new TextContent("Hello, World!"),
Contents\McpServerToolResultContentTests.cs (2)
41IList<AIContent> outputs = [new TextContent("test result")]; 58Outputs = [new TextContent("result")]
Contents\TextContentTests.cs (3)
17TextContent c = new(text); 26TextContent c = new(null); 55var content = new TextContent("Hello, world!");
Image\ImageGenerationResponseTests.cs (1)
139new TextContent("Generated image description") // Edge case: text content in image response
Realtime\RealtimeClientMessageTests.cs (5)
40var contents = new List<AIContent> { new TextContent("Hello") }; 51var item = new RealtimeConversationItem([new TextContent("Hello")]); 54var newItem = new RealtimeConversationItem([new TextContent("World")]); 63var item = new RealtimeConversationItem([new TextContent("Hello")]); 140new RealtimeConversationItem([new TextContent("Hello")], "item_1", ChatRole.User),
Realtime\RealtimeConversationItemTests.cs (5)
16IList<AIContent> contents = [new TextContent("Hello")]; 28IList<AIContent> contents = [new TextContent("Hello"), new TextContent("World")]; 39IList<AIContent> contents = [new TextContent("Initial")]; 42IList<AIContent> newContents = [new TextContent("Updated")];
Realtime\RealtimeServerMessageTests.cs (2)
194new RealtimeConversationItem([new TextContent("response")], "item_1"), 248var item = new RealtimeConversationItem([new TextContent("output")], "item_out_1", ChatRole.Assistant);
SpeechToText\SpeechToTextClientExtensionsTests.cs (1)
65update.Contents.Add(new TextContent("world"));
SpeechToText\SpeechToTextResponseTests.cs (9)
76content.Add(new TextContent($"text-{i}")); 133List<AIContent> newContents = [new TextContent("text1"), new TextContent("text2")]; 150new TextContent("Text1"), 151new TextContent("Text2"), 152new TextContent("Text3"), 153new TextContent("Text4"), 210new TextContent("Hello, "), 212new TextContent("world!")
SpeechToText\SpeechToTextResponseUpdateExtensionsTests.cs (3)
52new([new TextContent("You?")]) { ModelId = "model123", StartTime = TimeSpan.FromSeconds(24), EndTime = TimeSpan.FromSeconds(25), AdditionalProperties = new() { ["c"] = "d" } }, 139new() { Contents = [new TextContent("Hello, ")] }, 141new() { Contents = [new TextContent("world!")] },
SpeechToText\SpeechToTextResponseUpdateTests.cs (4)
41List<AIContent> newList = [new TextContent("content1")]; 65new TextContent("text-1"), 66new TextContent("text-2"), 93new TextContent("text-1"),
Microsoft.Extensions.AI.Evaluation (1)
EvaluationContext.cs (1)
127: this(name, contents: new TextContent(content))
Microsoft.Extensions.AI.Evaluation.Integration.Tests (6)
SafetyEvaluatorTests.cs (6)
339new TextContent("What does this image depict?"), 377new TextContent("Here's an image pertaining to DotNet:"), 411new TextContent("What does this image depict?"), 424new TextContent("Here's an image pertaining to Microsoft Copilot:"), 460new TextContent("What does this image depict?"), 473new TextContent("Here's an image pertaining to Microsoft Copilot:"),
Microsoft.Extensions.AI.Evaluation.NLP (2)
BLEUEvaluatorContext.cs (1)
54contents: [.. references.Select(c => new TextContent(c))])
GLEUEvaluatorContext.cs (1)
54contents: [.. references.Select(c => new TextContent(c))])
Microsoft.Extensions.AI.Evaluation.Quality (4)
IntentResolutionEvaluatorContext.cs (1)
43: base(name: ToolDefinitionsContextName, contents: [new TextContent(toolDefinitions.RenderAsJson())])
RetrievalEvaluatorContext.cs (1)
47contents: [.. retrievedContextChunks.Select(c => new TextContent(c))])
TaskAdherenceEvaluatorContext.cs (1)
44: base(name: ToolDefinitionsContextName, contents: [new TextContent(toolDefinitions.RenderAsJson())])
ToolCallAccuracyEvaluatorContext.cs (1)
45: base(name: ToolDefinitionsContextName, contents: [new TextContent(toolDefinitions.RenderAsJson())])
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (9)
DiskBased\DiskBasedResultStoreTests.cs (2)
70AIContent[] contents = [new TextContent("first"), new TextContent("second")];
ScenarioRunResultTests.cs (6)
24var content1 = new TextContent("content1"); 25var content2 = new TextContent("content2"); 26var content3 = new TextContent("content3"); 116var content1 = new TextContent("content1"); 117var content2 = new TextContent("content2"); 118var content3 = new TextContent("content3");
SerializationChainingTests.cs (1)
31Contents = [new TextContent("A user message")]
Microsoft.Extensions.AI.Integration.Tests (4)
ChatClientIntegrationTests.cs (2)
185new TextContent("What does this logo say?"), 203new TextContent("What text does this document contain?"),
ImageGeneratingChatClientIntegrationTests.cs (2)
166[new ChatMessage(ChatRole.User, [new TextContent("Please edit this image to add a red border"), originalImageData])], 381new TextContent("Here's an image to process"),
Microsoft.Extensions.AI.OpenAI (13)
OpenAIChatClient.cs (2)
564annotationContent = new(null); 792aiContent = new TextContent(contentPart.Text);
OpenAIRealtimeClientSession.cs (4)
1134contents.Add(new TextContent(textPart.Text)); 1138contents.Add(new TextContent(outputTextPart.Text)); 1151contents.Add(new TextContent(outputAudioPart.Transcript)); 1201: new TextContent(mcpItem.ToolOutput);
OpenAIResponsesChatClient.cs (4)
476yield return CreateUpdate(new TextContent(outputTextDeltaUpdate.Delta)); 1702TextContent text = new(part.Text); 1868new TextContent(mtci.ToolOutput)], 1898outputContents.Add(new TextContent(ciclo.Logs) { RawRepresentation = ciclo });
OpenAISpeechToTextClient.cs (3)
69response.Contents = [new TextContent(translation.Text)]; 83response.Contents = [new TextContent(transcription.Text)]; 144result.Contents = [new TextContent(deltaUpdate.Delta)];
Microsoft.Extensions.AI.OpenAI.Tests (30)
OpenAIChatClientTests.cs (5)
960new(ChatRole.System, [new TextContent("You are a really nice friend."), new TextContent("Really nice.")]), 1503new TextContent("hi, how are you?"), 1509new FunctionResultContent("12345", new TextContent("Said hello")), 1626new TextContent("What does this logo say?"),
OpenAIConversionTests.cs (13)
730new TextContent("Hi there!"), 799new TextContent("Hi there!"), 850new TextContent("Hello, "), 853new TextContent("World"), 854new TextContent("!"), 858new TextContent("Hi!"), 1219new TextContent("I'll call a function."), 1490var mcpToolResult = new McpServerToolResultContent("call_123") { Outputs = isError ? [new ErrorContent("error")] : [new TextContent("sunny")] }; 1521new TextContent("Here's an image and some text."), 1590new TextContent("I'll process this complex data."), 1845new TextContent("Processing your request..."), 2086new TextContent("Third message with function call"), 2121new TextContent("I'll call a function"),
OpenAIResponseClientIntegrationTests.cs (5)
567Tools = [AIFunctionFactory.Create((int a, int b) => new TextContent($"The sum is {a + b}"), "AddNumbers", "Adds two numbers together")] 589new TextContent($"Weather in {city}: "), 590new TextContent("Sunny, 72°F") 665new TextContent("Analysis result: "), 667new TextContent(" - Image provided above")
OpenAIResponseClientTests.cs (7)
1866? new TextContent("hello") 4929new ChatMessage(ChatRole.Tool, [new FunctionResultContent("call_123", new TextContent("Result text"))]) 4988new TextContent("First part. "), 4989new TextContent("Second part.") 5223new TextContent("Text result: "), 5225new TextContent(" - Image uploaded") 5676new TextContent("Check this image: "),
Microsoft.Extensions.AI.Stabilization.Tests (7)
AIContentSerializationRegressionTests.cs (1)
23new TextContent("hello"),
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\Contents\CodeInterpreterToolCallContentTests.cs (3)
30IList<AIContent> inputs = [new TextContent("print('hello')")]; 52new TextContent("import numpy as np"), 72new TextContent("print('hello')"),
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\Contents\CodeInterpreterToolResultContentTests.cs (3)
30IList<AIContent> output = [new TextContent("Hello, World!")]; 52new TextContent("Execution completed"), 74new TextContent("Hello, World!"),
Microsoft.Extensions.AI.Tests (55)
ChatCompletion\ChatClientStructuredOutputExtensionsTests.cs (1)
200new TextContent("I'm going to invoke a function to get the data."),
ChatCompletion\DistributedCachingChatClientTest.cs (5)
369new() { Role = ChatRole.Assistant, Contents = [new TextContent("Hello")] }, 370new() { Role = ChatRole.Assistant, Contents = [new TextContent(" world, ")] }, 376new TextContent("how ") 387new TextContent("are you?") 745new ChatMessage(ChatRole.Assistant, [new TextContent("Hey")])));
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (12)
1257new TextContent("please proceed"), 1362new TextContent("please proceed"), 1615yield return new ChatResponseUpdate(ChatRole.Assistant, [new TextContent("Text 1")]) { MessageId = messageId }; 1617yield return new ChatResponseUpdate(ChatRole.Assistant, [new TextContent("Text 2")]) { MessageId = messageId }; 1873new McpServerToolResultContent("callId2") { Outputs = [new TextContent("Result 2")] }, 1874new TextContent("world") 1889new McpServerToolResultContent("callId2") { Outputs = [new TextContent("Result 2")] }, 1890new TextContent("world") 1958new TextContent("world"), 1960[new McpServerToolResultContent("callId2") { Outputs = [new TextContent("Result 2")] }] : 1977new TextContent("world"), 1979[new McpServerToolResultContent("callId2") { Outputs = [new TextContent("Result 2")] }] :
ChatCompletion\FunctionInvokingChatClientTests.cs (5)
984new ChatMessage(ChatRole.Assistant, [new TextContent("extra"), new FunctionCallContent("callId1", "Func1"), new TextContent("stuff")]), 988new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } }), new TextContent("more")]), 1198updates = [new() { Contents = [new TextContent("OK bye")] }]; 1362? [new TextContent($"The search results were '{string.Join(", ", frcs.Select(frc => frc.Result))}'")]
ChatCompletion\OpenTelemetryChatClientTests.cs (11)
406new TextContent("Assistant response text"), 444new TextContent("User request text"), 605new TextContent("Hello!"), 607new TextContent("How are you?"), 660new TextContent("Processing with tools..."), 661new CodeInterpreterToolCallContent("ci-call-1") { Inputs = [new TextContent("print('hello')")] }, 662new CodeInterpreterToolResultContent("ci-call-1") { Outputs = [new TextContent("hello")] }, 666new McpServerToolResultContent("mcp-call-1") { Outputs = [new TextContent("Tool result")] }, 677yield return new() { Contents = [new CodeInterpreterToolCallContent("ci-call-1") { Inputs = [new TextContent("print('hello')")] }] }; 678yield return new() { Contents = [new CodeInterpreterToolResultContent("ci-call-1") { Outputs = [new TextContent("hello")] }] }; 691yield return new() { Contents = [new McpServerToolResultContent("mcp-call-1") { Outputs = [new TextContent("Tool result")] }] };
Functions\AIFunctionFactoryTest.cs (18)
1162AIFunctionFactory.Create(() => (AIContent)new TextContent("text")), 1163AIFunctionFactory.Create(async () => (AIContent)new TextContent("text")), 1164AIFunctionFactory.Create(async ValueTask<AIContent> () => (AIContent)new TextContent("text")), 1165AIFunctionFactory.Create(() => new TextContent("text")), 1166AIFunctionFactory.Create(async () => new TextContent("text")), 1167AIFunctionFactory.Create(async ValueTask<AIContent> () => new TextContent("text")), 1179AIFunctionFactory.Create(() => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1180AIFunctionFactory.Create(async () => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1181AIFunctionFactory.Create(async ValueTask<IEnumerable<AIContent>> () => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1186AIFunctionFactory.Create(() => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1187AIFunctionFactory.Create(async () => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1188AIFunctionFactory.Create(async ValueTask<AIContent[]> () => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1193AIFunctionFactory.Create(() => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1194AIFunctionFactory.Create(async () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1195AIFunctionFactory.Create(async ValueTask<List<AIContent>> () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1200AIFunctionFactory.Create(() => (IList<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1201AIFunctionFactory.Create(async () => (IList<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1202AIFunctionFactory.Create(async ValueTask<IList<AIContent>> () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
Realtime\OpenTelemetryRealtimeClientTests.cs (2)
1001var item = new RealtimeConversationItem([new TextContent("Hello from client")], role: ChatRole.User); 1010var item = new RealtimeConversationItem([new TextContent("User text message")], role: ChatRole.User);
SpeechToText\OpenTelemetrySpeechToTextClientTests.cs (1)
75new TextContent(" text."),
Microsoft.Extensions.DataIngestion (1)
Utils\Batching.cs (1)
33contents.Add(new TextContent(chunk.Content));
Microsoft.Extensions.DocumentExtraction.Abstractions.Tests (10)
DelegatingDocumentExtractionClientTests.cs (1)
68section.Elements.Add(new ExtractionDocumentTextElement(new TextContent("**body**"), role: "heading") { HeadingLevel = 3 });
DocumentExtractionDocumentBuilderTests.cs (9)
112ExtractionDocument expected = new("canonical", new TextContent("provider root")); 115ExtractionDocumentSection root = new(new TextContent("supplied section")); 116ExtractionDocumentSection nested = new(new TextContent("supplied nested")); 117ExtractionDocumentTableElement table = new(new TextContent("supplied table"), 1, 1); 118ExtractionDocumentTextElement content = new(new TextContent("**cell**"), role: "Vendor.Custom") { HeadingLevel = 10 }; 150content.Content = new TextContent("changed"); 153table.Cells[0, 0] = new ExtractionDocumentTableCell(new ExtractionDocumentTextElement(new TextContent("replacement"))); 176ExtractionDocumentImageElement image = new(new TextContent("visible"), "plain visible"); 292ExtractionDocument expected = new("minimal", new TextContent("visible")) { RawRepresentation = borrowed };
Microsoft.Extensions.DocumentExtraction.Tests (4)
DocumentExtractionMiddlewareTests.cs (4)
251section.Elements.Add(new ExtractionDocumentImageElement(new TextContent("visible **text**"), "visible text")); 372ExtractionDocumentImageElement image = new(new TextContent("visible **text**"), "visible text"); 523ExtractionDocument expected = new("secret/path", new TextContent("visible **text**")) { RawRepresentation = native }; 525ExtractionDocumentImageElement image = new(new TextContent("visible text"), "visible text");
Microsoft.Extensions.Documents.Abstractions.Tests (142)
DocumentElementTests.cs (16)
19section.Elements.Add(new ExtractionDocumentTextElement(new TextContent("semantic paragraph"))); 28ExtractionDocumentTextElement element = new(new TextContent("stored markdown")); 32element.Content = new TextContent("updated markdown"); 40ExtractionDocumentTextElement element = new(new TextContent("content")); 60ExtractionDocumentTextElement element = new(new TextContent("content")); 82ExtractionDocumentTextElement element = new(new TextContent("content")); 109ExtractionDocumentTextElement element = new(new TextContent("content")); 150ExtractionDocumentTextElement element = new(new TextContent("stored"), role: "heading") 170ExtractionDocumentTextElement element = new(new TextContent("")); 193ExtractionDocumentTextElement text = new(new TextContent("visible")); 222ExtractionDocumentTextElement text = new(new TextContent("")); 227text.Content = new TextContent("temporary"); 228text.Content = new TextContent(""); 241ExtractionDocumentTextElement text = new(new TextContent("visible **text**")); 242ExtractionDocumentImageElement image = new(new TextContent("")) { Source = new Uri("urn:image:page7"), AlternativeText = "diagram only" }; 243ExtractionDocumentTextElement extension = new(new TextContent("extension"), role: "vendor-extra");
DocumentExtensionElementTests.cs (1)
67ExtractionDocumentTextElement extension = new(new TextContent("visible **text**"), role: "vendor-extra");
DocumentImageElementTests.cs (3)
16ExtractionDocumentImageElement image = new(new TextContent("stored image")); 35ExtractionDocumentImageElement image = new(new TextContent("stored image")) 49ExtractionDocumentImageElement image = new(new TextContent("stored image markdown"))
DocumentReferencesTests.cs (2)
212ExtractionDocumentTextElement text = new(new TextContent("visible")); 365ExtractionDocumentTextElement text = new(new TextContent("visible"));
DocumentReviewFollowUpTests.cs (7)
49ExtractionDocumentTextElement text = new(new TextContent("original")); 56text.Content = new TextContent("changed"); 101ExtractionDocumentSection root = new(new TextContent("local")); 103ExtractionDocumentTextElement text = new(new TextContent("body")); 123ExtractionDocumentTextElement shared = new(new TextContent("value")); 147ExtractionDocumentTextElement text = new(new TextContent("visible")); 190ExtractionDocumentTextElement text = new(new TextContent("named page"));
DocumentSectionTests.cs (6)
16ExtractionDocumentSection section = new(new TextContent("stored section markdown")); 25ExtractionDocumentSection section = new(new TextContent("stored section markdown")); 37ExtractionDocumentTextElement first = new(new TextContent("first")); 39ExtractionDocumentTextElement nestedFirst = new(new TextContent("nested-first")); 40ExtractionDocumentTextElement nestedLast = new(new TextContent("nested-last")); 41ExtractionDocumentTextElement last = new(new TextContent("last"));
DocumentTableCellCollectionTests.cs (18)
18ExtractionDocumentTextElement firstContent = new(new TextContent("first")); 19ExtractionDocumentTextElement lastContent = new(new TextContent("last")); 44ExtractionDocumentTextElement content = new(new TextContent("cell")); 61ExtractionDocumentImageElement image = new(new TextContent("stored image")) 84ExtractionDocumentTextElement oldContent = new(new TextContent("old")); 85ExtractionDocumentTextElement replacementContent = new(new TextContent("replacement")); 112ExtractionDocumentTextElement content = new(new TextContent("cell")); 141TextContent paragraphA = new("Paragraph A **before** the image."); 142TextContent paragraphB = new("Paragraph B *after* the image."); 257ExtractionDocumentTextElement paragraph = new(new TextContent("cell-only paragraph")); 333ExtractionDocumentTextElement content = new(new TextContent("content")); 358ExtractionDocumentTableCell anchor = new(new ExtractionDocumentTextElement(new TextContent("MERGED_A")), 2, 2, "header"); 359ExtractionDocumentTableCell ordinary = new(new ExtractionDocumentTextElement(new TextContent("B"))); 388ExtractionDocumentTextElement text = new(new TextContent("MERGED_A")); 439ExtractionDocumentTextElement anchorText = new(new TextContent("MERGED_A")); 445ExtractionDocumentTextElement candidateText = new(new TextContent("candidate **value**")); 507ExtractionDocumentTextElement oldText = new(new TextContent("lO0? &")); 518ExtractionDocumentTextElement replacementText = new(new TextContent("replacement?"));
DocumentTableCellTests.cs (8)
19ExtractionDocumentTextElement content = new(new TextContent("cell")); 38ExtractionDocumentTextElement content = new(new TextContent("cell")); 78ExtractionDocumentTextElement text = new(new TextContent("cell")); 105ExtractionDocumentTextElement text = new(new TextContent("cell")); 147ExtractionDocumentTextElement text = new(new TextContent("content")); 168ExtractionDocumentTextElement text = new(new TextContent("lO0 ??")); 176first.Elements.Add(new ExtractionDocumentTextElement(new TextContent("first"))); 177second.Elements.Add(new ExtractionDocumentTextElement(new TextContent("second")));
DocumentTableElementTests.cs (18)
17ExtractionDocumentTextElement leaf = new(new TextContent("L|R")); 34ExtractionDocumentTextElement text = new(new TextContent("A|<&")); 62ExtractionDocumentTableCell wide = new(new ExtractionDocumentTextElement(new TextContent("wide")), 2, 3); 63ExtractionDocumentTableCell corner = new(new ExtractionDocumentTextElement(new TextContent("corner")), role: "rowHeader"); 73ExtractionDocumentTableCell small = new(new ExtractionDocumentTextElement(new TextContent("small"))); 103ExtractionDocumentTableElement table = new(new TextContent("stored table"), 2, 3); 128ExtractionDocumentTableElement table = new(new TextContent("stored table"), rowCount, columnCount); 144ExtractionDocumentTextElement text = new(new TextContent("candidate")); 167table.Cells[0, 1] = new ExtractionDocumentTableCell(new ExtractionDocumentTextElement(new TextContent("one"))); 168table.Cells[1, 0] = new ExtractionDocumentTableCell(new ExtractionDocumentTextElement(new TextContent("two"))); 183table.Cells[0, 0] = new ExtractionDocumentTableCell(new ExtractionDocumentTextElement(new TextContent("left|right"))); 192table.Cells[0, 0] = new ExtractionDocumentTableCell(new ExtractionDocumentTextElement(new TextContent("semantic cell"))); 202ExtractionDocumentTableCell anchor = new(new ExtractionDocumentTextElement(new TextContent("MERGED_A<&")), 2, 2, "columnHeader"); 204table.Cells[2, 0] = new ExtractionDocumentTableCell(new ExtractionDocumentTextElement(new TextContent("B")), role: "rowHeader"); 235ExtractionDocumentTextElement text = new(new TextContent(" INV0ICE 1O0? <&| "), role: "heading"); 259ExtractionDocumentTextElement text = new(new TextContent("A|<")); 307ExtractionDocumentTextElement text = new(new TextContent("INV0ICE 1O0?")); 389ExtractionDocumentTextElement text = new(new TextContent("mapped A"));
DocumentTests.Composition.cs (7)
32ExtractionDocumentTextElement cellText = new(new TextContent("cell")); 37"text" => new ExtractionDocumentTextElement(new TextContent("visible")), 38"image" => new ExtractionDocumentImageElement(new TextContent("visible")), 86ExtractionDocumentTextElement text = new(new TextContent("**local**")); 87ExtractionDocumentImageElement image = new(new TextContent("")) { Source = new Uri("urn:local:image"), AlternativeText = "local diagram" }; 88ExtractionDocumentTextElement extension = new(new TextContent("extension"), role: "application-extra"); 90ExtractionDocumentTextElement cellText = new(new TextContent("cell|value"));
DocumentTests.cs (19)
18ExtractionDocument document = new("document-id", new TextContent("stored document")); 36ExtractionDocument document = new("document", new TextContent("stored markdown")); 46ExtractionDocument document = new("document", markdown is null ? null : new TextContent(markdown)); 56section.Elements.Add(new ExtractionDocumentImageElement(new TextContent("stored image markdown")) 77first.Elements.Add(new ExtractionDocumentTextElement(new TextContent("first semantic"))); 78second.Elements.Add(new ExtractionDocumentTextElement(new TextContent("second semantic"))); 90ExtractionDocument document = new("document", new TextContent("stored markdown")); 101ExtractionDocument document = new("document", new TextContent("stored markdown")); 103document.Content = new TextContent("updated markdown"); 113ExtractionDocumentTextElement firstText = new(new TextContent("first text")); 115ExtractionDocumentTextElement nestedText = new(new TextContent("nested text")); 116ExtractionDocumentImageElement image = new(new TextContent("image")); 117ExtractionDocumentTextElement extension = new(new TextContent("extension"), role: "application-extra"); 120ExtractionDocumentTextElement secondText = new(new TextContent("second text")); 146nested.Elements.Add(new ExtractionDocumentTextElement(new TextContent("content"))); 161ExtractionDocumentTextElement text7 = new(new TextContent("same text")); 162ExtractionDocumentTextElement text2 = new(new TextContent("same text")); 208ExtractionDocument document = new("shared-body", new TextContent("visible")); 232ExtractionDocumentTextElement text = new(new TextContent("visible **text**"));
DocumentTests.StandardContent.cs (25)
20TextContent payload = new(markdown); 36ExtractionDocumentSection section = new(new TextContent(markdown)); 48TextContent payload = new(markdown); 72TextContent first = new("**first**"); 75section.Elements.Add(new ExtractionDocumentTextElement(new TextContent(string.Empty))); 76section.Elements.Add(new ExtractionDocumentTextElement(new TextContent("last|value"))); 90ExtractionDocument document = new("empty-local", new TextContent(string.Empty)); 91ExtractionDocumentSection section = new(new TextContent(string.Empty)); 92section.Elements.Add(new ExtractionDocumentTextElement(new TextContent("child"))); 109section.Elements.Add(new ExtractionDocumentTextElement(new TextContent("first"))); 122CustomElement custom = new(new TextContent("custom|value")); 130section.Elements.Insert(0, new ExtractionDocumentTextElement(new TextContent("prefix"))); 133CustomElement cellContent = new(new TextContent("cell|value")); 146TextContent payload = new(markdown); 165ExtractionDocument document = new("local", new TextContent("root introduction")); 166ExtractionDocumentSection section = new(new TextContent("section introduction")); 168ExtractionDocumentTableElement table = new(new TextContent("table caption"), 1, 1); 169ExtractionDocumentTextElement cellText = new(new TextContent("leaf|value")); 182cellText.Content = new TextContent("edited"); 219ExtractionDocumentTextElement text = new(new TextContent("cell")); 236TextContent payload = new("first"); 247text.Content = new TextContent("second"); 390TextContent shared = new("same|payload"); 425ExtractionDocumentTextElement text = new(new TextContent("**literal markdown**")); 449ChatMessage semantic = new(ChatRole.User, [text.Content!, new TextContent(image.Text!)]);
DocumentTextElementTests.cs (9)
16ExtractionDocumentTextElement element = new(new TextContent("stored markdown"), role: "pageFooter"); 34ExtractionDocumentTextElement element = new(new TextContent("**citation** [1]"), role: role); 57Assert.Throws<ArgumentException>(nameof(role), () => new ExtractionDocumentTextElement(new TextContent("markdown"), role: role)); 63ExtractionDocumentTextElement heading = new(new TextContent("Title"), role: "heading") { HeadingLevel = 1 }; 64ExtractionDocumentTextElement pageHeader = new(new TextContent("Title"), role: "pageHeader"); 65ExtractionDocumentTextElement custom = new(new TextContent("ordinary **text**"), role: "VendorHeading") { HeadingLevel = 10 }; 91ExtractionDocumentTextElement element = new(new TextContent("header"), role: "heading") 105ExtractionDocumentTextElement element = new(new TextContent("header"), role: "heading") 119ExtractionDocumentTextElement element = new(new TextContent("header"), role: "heading")
PreviewContractTests.cs (3)
18TextContent original = new("**literal** <&| OCR 1O0?"); 30TextContent replacement = new("plain unchanged"); 89ExtractionDocumentTextElement text = new(new TextContent("unmodified"));
326 references to TextContent
Microsoft.AspNetCore.Components.AI (3)
Pipeline\RichTextContentHandler.cs (1)
38if (content is RichTextContent or TextContent)
Pipeline\TextBlockHandler.cs (2)
15TextContent? textContent = null; 18if (content is TextContent tc)
Microsoft.Extensions.AI (3)
Common\OtelMessageSerializer.cs (2)
69case TextContent tc when !string.IsNullOrWhiteSpace(tc.Text): 297if (input is TextContent tc && !string.IsNullOrEmpty(tc.Text))
Realtime\OpenTelemetryRealtimeClientSession.cs (1)
530case TextContent tc when !string.IsNullOrEmpty(tc.Text):
Microsoft.Extensions.AI.Abstractions (24)
ChatCompletion\ChatMessage.cs (1)
77/// This property concatenates the text of all <see cref="TextContent"/> objects in <see cref="Contents"/>.
ChatCompletion\ChatResponseExtensions.cs (9)
57/// <see cref="TextContent"/> instances in a row may be combined into a single <see cref="TextContent"/>. 111/// <see cref="TextContent"/> instances in a row may be combined into a single <see cref="TextContent"/>. 134/// <see cref="TextContent"/> instances in a row may be combined into a single <see cref="TextContent"/>. 162/// <see cref="TextContent"/> instances in a row may be combined into a single <see cref="TextContent"/>. 284Coalesce<TextContent>(
ChatCompletion\ChatResponseUpdate.cs (1)
97/// This property concatenates the text of all <see cref="TextContent"/> objects in <see cref="Contents"/>.
Contents\AIAnnotation.cs (1)
26/// for <see cref="TextContent"/>.
Contents\AIContent.cs (1)
17[JsonDerivedType(typeof(TextContent), typeDiscriminator: "text")]
Contents\AIContentExtensions.cs (4)
18/// <summary>Concatenates the text of all <see cref="TextContent"/> instances in the list.</summary> 30return (list[0] as TextContent)?.Text ?? string.Empty; 37if (list[i] is TextContent text) 59return string.Concat(contents.OfType<TextContent>());
Contents\CodeInterpreterToolResultContent.cs (1)
27/// <see cref="DataContent"/> for binary data, <see cref="TextContent"/> for standard output text,
Contents\TextContent.cs (1)
16/// Initializes a new instance of the <see cref="TextContent"/> class.
Contents\TextReasoningContent.cs (2)
13/// <see cref="TextReasoningContent"/> is distinct from <see cref="TextContent"/>. <see cref="TextReasoningContent"/> 15/// the model, which is represented by <see cref="TextContent"/>. Neither types derives from the other.
Contents\TextSpanAnnotatedRegion.cs (1)
10/// <remarks>This <see cref="AnnotatedRegion"/> typically applies to <see cref="TextContent"/>.</remarks>
SpeechToText\SpeechToTextResponse.cs (1)
66/// This property concatenates the text of all <see cref="TextContent"/> objects in <see cref="Contents"/>.
SpeechToText\SpeechToTextResponseUpdate.cs (1)
86/// This property concatenates the text of all <see cref="TextContent"/> objects in <see cref="Contents"/>.
Microsoft.Extensions.AI.Abstractions.Tests (84)
ChatCompletion\ChatMessageTests.cs (13)
48TextContent tc = Assert.IsType<TextContent>(message.Contents[0]); 108TextContent tc = Assert.IsType<TextContent>(message.Contents[i]); 154TextContent textContent = Assert.IsType<TextContent>(message.Contents[3]); 159((TextContent)message.Contents[3]).Text = "text-3"; 281((TextContent)chatMessage.Contents[0]).Text = "content-1-override"; // Override the content of the first text content item that has the "content-1" content 296var textContent = deserializedMessage.Contents[0] as TextContent; 319textContent = deserializedMessage.Contents[3] as TextContent; 384var textContent = Assert.IsType<TextContent>(result.Contents[0]);
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (20)
674TextContent[] contents = message.Contents.OfType<TextContent>().ToArray(); 710Assert.Equal("ABC", Assert.IsType<TextContent>(message.Contents[0]).Text); 712Assert.Equal("GH", Assert.IsType<TextContent>(message.Contents[2]).Text); 714Assert.Equal("K", Assert.IsType<TextContent>(message.Contents[4]).Text); 716Assert.Equal("MN", Assert.IsType<TextContent>(message.Contents[6]).Text); 785Assert.Equal("ABC", Assert.IsType<TextContent>(message.Contents[0]).Text); 786Assert.Equal("D", Assert.IsType<TextContent>(message.Contents[1]).Text); 787Assert.Equal("E", Assert.IsType<TextContent>(message.Contents[2]).Text); 788Assert.Equal("F", Assert.IsType<TextContent>(message.Contents[3]).Text); 789Assert.Equal("GH", Assert.IsType<TextContent>(message.Contents[4]).Text); 790Assert.Equal("I", Assert.IsType<TextContent>(message.Contents[5]).Text); 791Assert.Equal("J", Assert.IsType<TextContent>(message.Contents[6]).Text); 792Assert.Equal("K", Assert.IsType<TextContent>(message.Contents[7]).Text); 793Assert.Equal("L", Assert.IsType<TextContent>(message.Contents[8]).Text); 794Assert.Equal("MN", Assert.IsType<TextContent>(message.Contents[9]).Text); 795Assert.Equal("O", Assert.IsType<TextContent>(message.Contents[10]).Text); 796Assert.Equal("P", Assert.IsType<TextContent>(message.Contents[11]).Text); 816Assert.Equal("Hello, world!", Assert.IsType<TextContent>(Assert.Single(Assert.Single(response.Messages).Contents)).Text); 957Assert.IsType<TextContent>(message.Contents[0]).Text);
ChatCompletion\ChatResponseUpdateTests.cs (13)
101TextContent textContent = Assert.IsType<TextContent>(update.Contents[3]); 106((TextContent)update.Contents[3]).Text = "text-3"; 144Assert.IsType<TextContent>(result.Contents[0]); 145Assert.Equal("text-1", ((TextContent)result.Contents[0]).Text); 156Assert.IsType<TextContent>(result.Contents[4]); 157Assert.Equal("text-2", ((TextContent)result.Contents[4]).Text); 208Assert.IsType<TextContent>(result.Contents[0]); 209Assert.Equal("text-1", ((TextContent)result.Contents[0]).Text); 220Assert.IsType<TextContent>(result.Contents[4]); 221Assert.Equal("text-2", ((TextContent)result.Contents[4]).Text); 442var textContent = Assert.IsType<TextContent>(result.Contents[0]);
Contents\CodeInterpreterToolCallContentTests.cs (5)
60Assert.IsType<TextContent>(c.Inputs[0]); 84Assert.IsType<TextContent>(deserializedSut.Inputs[0]); 85Assert.Equal("print('hello')", ((TextContent)deserializedSut.Inputs[0]).Text); 116var textInput = Assert.IsType<TextContent>(ciCall.Inputs[0]);
Contents\CodeInterpreterToolResultContentTests.cs (5)
61Assert.IsType<TextContent>(c.Outputs[0]); 86Assert.IsType<TextContent>(deserializedSut.Outputs[0]); 87Assert.Equal("Hello, World!", ((TextContent)deserializedSut.Outputs[0]).Text); 118var textOutput = Assert.IsType<TextContent>(ciResult.Outputs[0]);
Contents\McpServerToolResultContentTests.cs (3)
75Assert.Equal("result", Assert.IsType<TextContent>(Assert.Single(deserializedContent.Outputs)).Text); 105var textOutput = Assert.IsType<TextContent>(mcpResult.Outputs[0]);
Contents\TextContentTests.cs (7)
17TextContent c = new(text); 26TextContent c = new(null); 55var content = new TextContent("Hello, world!"); 58var deserializedContent = JsonSerializer.Deserialize<TextContent>(json, AIJsonUtilities.DefaultOptions); 80var textContent = Assert.IsType<TextContent>(result);
Image\ImageGenerationResponseTests.cs (1)
152Assert.IsType<TextContent>(deserialized.Contents[2]);
SpeechToText\SpeechToTextResponseTests.cs (9)
52TextContent tc = Assert.IsType<TextContent>(response.Contents[0]); 92TextContent tc = Assert.IsType<TextContent>(response.Contents[i]); 173Assert.Equal($"Text{i + 1}", ((TextContent)result.Contents[i]).Text); 236Assert.Equal("Hello, ", Assert.IsType<TextContent>(update.Contents[0]).Text); 238Assert.Equal("world!", Assert.IsType<TextContent>(update.Contents[2]).Text); 286var textContent = Assert.IsType<TextContent>(result.Contents[0]);
SpeechToText\SpeechToTextResponseUpdateExtensionsTests.cs (3)
126TextContent[] contents = response.Contents.OfType<TextContent>().ToArray(); 153Assert.Equal("Hello, world!", Assert.IsType<TextContent>(Assert.Single(response.Contents)).Text);
SpeechToText\SpeechToTextResponseUpdateTests.cs (4)
71TextContent textContent = Assert.IsType<TextContent>(update.Contents[3]); 145var textContent = Assert.IsType<TextContent>(result.Contents[0]);
Utilities\AIJsonUtilitiesTests.cs (1)
1268Assert.Throws<ArgumentException>("contentType", () => options.AddAIContentType<TextContent>("discriminator"));
Microsoft.Extensions.AI.Evaluation (11)
ChatMessageExtensions.cs (6)
101/// <see cref="TextContent"/>s. If the <paramref name="message"/> does not contain any <see cref="TextContent"/>s 116if (!message.Contents.OfType<TextContent>().Any()) 140/// <see cref="TextContent"/>s. Any <paramref name="messages"/> that contain no <see cref="TextContent"/>s will be 142/// <see cref="TextContent"/>s then this function will return an empty string.
ChatResponseExtensions.cs (3)
22/// <see cref="TextContent"/>s. Any <see cref="ChatResponse.Messages"/> that contain no <see cref="TextContent"/>s 24/// <see cref="TextContent"/>s then this function will return an empty string.
EvaluationContext.cs (2)
59/// <see cref="TextContent"/> objects for text, <see cref="DataContent"/> or <see cref="UriContent"/> objects for 65/// <see cref="TextContent"/> object that includes the contained text.
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (10)
DiskBased\DiskBasedResultStoreTests.cs (2)
97context.Contents.Select(c => Assert.IsType<TextContent>(c).Text), 98restoredContext.Contents.Select(c => Assert.IsType<TextContent>(c).Text));
ScenarioRunResultTests.cs (8)
24var content1 = new TextContent("content1"); 25var content2 = new TextContent("content2"); 26var content3 = new TextContent("content3"); 116var content1 = new TextContent("content1"); 117var content2 = new TextContent("content2"); 118var content3 = new TextContent("content3"); 483if (x is TextContent xText && y is TextContent yText)
Microsoft.Extensions.AI.Evaluation.Safety (6)
AIContentExtensions.cs (1)
11=> content is TextContent || content is UsageContent;
ContentSafetyEvaluator.cs (2)
113contents.OfType<TextContent>() is IEnumerable<TextContent> textContents && textContents.Any() &&
ContentSafetyServicePayloadUtilities.cs (3)
320if (content is TextContent textContent) 515$"The current evaluation being performed by {evaluatorName} only supports content of type '{nameof(TextContent)}', '{nameof(UriContent)}' and '{nameof(DataContent)}'. " + 524$"The current evaluation being performed by {evaluatorName} only supports content of type '{nameof(TextContent)}'. " +
Microsoft.Extensions.AI.Integration.Tests (8)
ChatClientIntegrationTests.cs (4)
169var singleTextContent = (TextContent)history[1].Contents.Single(); 667((TextContent)message.Contents[0]).Text += "!"; 701((TextContent)message.Contents[0]).Text += "!";
ImageGeneratingChatClientIntegrationTests.cs (3)
99foreach (var textContent in contents.OfType<TextContent>()) 394var textContents = userMessage.Contents.OfType<TextContent>().ToList();
ReducingChatClientTests.cs (1)
100if (content is TextContent text)
Microsoft.Extensions.AI.OpenAI (9)
OpenAIChatClient.cs (3)
295case TextContent textContent: 561TextContent? annotationContent = returnMessage.Contents.OfType<TextContent>().FirstOrDefault();
OpenAIRealtimeClientSession.cs (1)
668if (content is TextContent textContent)
OpenAIResponsesChatClient.cs (5)
1359case TextContent textContent: 1435case TextContent tc: 1556case TextContent textContent: 1625mtci.ToolOutput = string.Concat(mstrc.Outputs?.OfType<TextContent>() ?? []); 1702TextContent text = new(part.Text);
Microsoft.Extensions.AI.OpenAI.Tests (31)
OpenAIChatClientTests.cs (4)
1285TextContent fcc = Assert.IsType<TextContent>(response.Messages.Single().Contents[0]); 1954var text = message.Contents.OfType<TextContent>().Single();
OpenAIConversionTests.cs (6)
908Assert.Equal("Hello, world!", Assert.IsType<TextContent>(message.Contents[0], exactMatch: false).Text); 939Assert.Equal("Hello, world!", Assert.IsType<TextContent>(message.Contents[0], exactMatch: false).Text); 1232var textContent = message.Contents.OfType<TextContent>().FirstOrDefault(); 1304TextContent? textContent = message.Contents.OfType<TextContent>().FirstOrDefault();
OpenAIResponseClientIntegrationTests.cs (5)
70if (toolResultContent.Outputs.OfType<TextContent>().FirstOrDefault() is { } resultOutput) 117TextContent tc = m.Contents.OfType<TextContent>().First(); 555var content = Assert.IsType<TextContent>(Assert.Single(toolResult.Outputs!));
OpenAIResponseClientTests.cs (16)
1750Assert.StartsWith("The `README.md` file for `Microsoft.Extensions.AI.Abstractions` is located at", Assert.IsType<TextContent>(Assert.Single(result.Outputs!)).Text); 2126Assert.StartsWith("Available pages for dotnet/extensions", Assert.IsType<TextContent>(Assert.Single(firstResult.Outputs!)).Text); 2138Assert.StartsWith("The `README.md` file for `Microsoft.Extensions.AI.Abstractions` is located at", Assert.IsType<TextContent>(Assert.Single(secondResult.Outputs!)).Text); 2537Assert.StartsWith("Available pages for dotnet/extensions", Assert.IsType<TextContent>(Assert.Single(firstResult.Outputs!)).Text); 2549Assert.StartsWith("The path to the `README.md` file", Assert.IsType<TextContent>(Assert.Single(secondResult.Outputs!)).Text); 3511var textContent = Assert.IsType<TextContent>(message.Contents[2]); 3731var textContent = Assert.IsType<TextContent>(message.Contents[2]); 6244var textContent = Assert.Single(message.Contents.OfType<TextContent>()); 7645var textContent = Assert.IsType<TextContent>(message.Contents[2]); 7780var textUpdates = updates.Where(u => u.Contents.OfType<TextContent>().Any()).ToList(); 7797var textContent = message.Contents.OfType<TextContent>().Single();
Microsoft.Extensions.AI.Stabilization.Tests (11)
AIContentSerializationRegressionTests.cs (1)
32Assert.IsType<TextContent>(roundtripped[0]);
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\Contents\CodeInterpreterToolCallContentTests.cs (5)
60Assert.IsType<TextContent>(c.Inputs[0]); 84Assert.IsType<TextContent>(deserializedSut.Inputs[0]); 85Assert.Equal("print('hello')", ((TextContent)deserializedSut.Inputs[0]).Text); 116var textInput = Assert.IsType<TextContent>(ciCall.Inputs[0]);
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\Contents\CodeInterpreterToolResultContentTests.cs (5)
61Assert.IsType<TextContent>(c.Outputs[0]); 86Assert.IsType<TextContent>(deserializedSut.Outputs[0]); 87Assert.Equal("Hello, World!", ((TextContent)deserializedSut.Outputs[0]).Text); 118var textOutput = Assert.IsType<TextContent>(ciResult.Outputs[0]);
Microsoft.Extensions.AI.Tests (11)
ChatCompletion\DistributedCachingChatClientTest.cs (4)
347c => Assert.Equal("This becomes one chunk", Assert.IsType<TextContent>(c).Text), 349c => Assert.Equal("... and this becomes another one.", Assert.IsType<TextContent>(c).Text)); 425var content = Assert.IsType<TextContent>(Assert.Single(item.Contents));
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (2)
1642Assert.Equal("Text 1", update.Contents.OfType<TextContent>().First().Text); 1648Assert.Equal("Text 2", update.Contents.OfType<TextContent>().First().Text);
ChatCompletion\FunctionInvokingChatClientTests.cs (2)
1222m => Assert.Equal("OK bye", Assert.IsType<TextContent>(Assert.Single(m.Contents)).Text)); 1262Assert.IsType<TextContent>(Assert.Single(response.Messages[4].Contents));
ChatCompletion\UseDelegateChatClientTests.cs (2)
103cc.Messages.SelectMany(c => c.Contents).OfType<TextContent>().Last().Text += " world"; 206cc.Messages.SelectMany(c => c.Contents).OfType<TextContent>().Last().Text += " world (non-streaming)";
Functions\AIFunctionFactoryTest.cs (1)
1160await ValidateAsync<TextContent>(
Microsoft.Extensions.DocumentExtraction.Abstractions.Tests (15)
DelegatingDocumentExtractionClientTests.cs (2)
77Assert.Equal("**body**", Assert.IsType<TextContent>(Assert.Single(actual.EnumerateContent()).Content).Text); 87Assert.Equal("**body**", Assert.IsType<TextContent>(Assert.Single(actual.EnumerateContent()).Content).Text);
DocumentExtractionDocumentBuilderTests.cs (13)
142Assert.Equal("**cell**", Assert.IsType<TextContent>(content.Content).Text); 143Assert.Equal("provider root", Assert.IsType<TextContent>(actual.Content).Text); 144Assert.Equal("supplied section", Assert.IsType<TextContent>(root.Content).Text); 145Assert.Equal("supplied nested", Assert.IsType<TextContent>(nested.Content).Text); 146Assert.Equal("supplied table", Assert.IsType<TextContent>(table.Content).Text); 151Assert.Equal("changed", Assert.IsType<TextContent>(table.Cells[0, 0]!.Content!.Content).Text); 152Assert.Equal("changed", Assert.IsType<TextContent>(content.Content).Text); 154Assert.Equal("replacement", Assert.IsType<TextContent>(table.Cells[0, 0]!.Content!.Content).Text); 155Assert.Equal("supplied table", Assert.IsType<TextContent>(table.Content).Text); 156Assert.Equal("supplied nested", Assert.IsType<TextContent>(nested.Content).Text); 157Assert.Equal("provider root", Assert.IsType<TextContent>(actual.Content).Text); 158Assert.Equal("changed", Assert.IsType<TextContent>(content.Content).Text); 309Assert.Equal("visible", Assert.IsType<TextContent>(actual.Content).Text);
Microsoft.Extensions.DocumentExtraction.Tests (4)
DocumentExtractionMiddlewareTests.cs (4)
274Assert.Equal("visible **text**", Assert.IsType<TextContent>(Assert.Single(actual.EnumerateContent()).Content).Text); 390Assert.Equal("visible **text**", Assert.IsType<TextContent>(image.Content).Text); 648Assert.Equal("visible **text**", Assert.IsType<TextContent>(actual.Content).Text); 649Assert.Equal("visible text", Assert.IsType<TextContent>(image.Content).Text);
Microsoft.Extensions.Documents.Abstractions (3)
ExtractionDocumentElement.cs (3)
23/// Text elements require nonnull <see cref="TextContent"/>, including assignments through a base reference. 33if (value is not TextContent) 68public ExtractionDocumentTextElement(TextContent content, string? role = null)
Microsoft.Extensions.Documents.Abstractions.Tests (93)
DocumentElementTests.cs (12)
22Assert.Equal("semantic paragraph", Assert.IsType<TextContent>(Assert.Single(section.Elements).Content).Text); 30Assert.Equal("stored markdown", Assert.IsType<TextContent>(element.Content).Text); 34Assert.Equal("updated markdown", Assert.IsType<TextContent>(element.Content).Text); 171Assert.Equal("", Assert.IsType<TextContent>(element.Content).Text); 214Assert.Equal("visible", Assert.IsType<TextContent>(text.Content).Text); 225Assert.Equal("", Assert.IsType<TextContent>(text.Content).Text); 229Assert.Equal("", Assert.IsType<TextContent>(text.Content).Text); 258Assert.DoesNotContain(native.Marker, Assert.IsType<TextContent>(text.Content).Text, StringComparison.Ordinal); 259Assert.DoesNotContain("RAW_BODY_ONLY_91", Assert.IsType<TextContent>(text.Content).Text, StringComparison.Ordinal); 262Assert.Equal("", Assert.IsType<TextContent>(image.Content).Text); 263Assert.Equal("visible **text**", Assert.IsType<TextContent>(text.Content).Text); 265Assert.Equal("extension", Assert.IsType<TextContent>(extension.Content).Text);
DocumentExtensionElementTests.cs (2)
50Assert.Equal(typeof(TextContent), parameters[0].ParameterType); 91Assert.Equal("visible **text**", Assert.IsType<TextContent>(extension.Content).Text);
DocumentImageElementTests.cs (2)
41Assert.Equal("stored image", Assert.IsType<TextContent>(image.Content).Text); 55Assert.Equal("stored image markdown", Assert.IsType<TextContent>(image.Content).Text);
DocumentReviewFollowUpTests.cs (1)
59Assert.Equal("changed", Assert.IsType<TextContent>(text.Content).Text);
DocumentSectionTests.cs (3)
18Assert.Equal("stored section markdown", Assert.IsType<TextContent>(section.Content).Text); 27Assert.IsType<TextContent>(section.Content).Text = "plain section text"; 28Assert.Equal("plain section text", Assert.IsType<TextContent>(section.Content).Text);
DocumentTableCellCollectionTests.cs (8)
141TextContent paragraphA = new("Paragraph A **before** the image."); 142TextContent paragraphB = new("Paragraph B *after* the image."); 192Assert.Equal("Paragraph A **before** the image.", Assert.IsType<TextContent>(first.Content).Text); 193Assert.Equal("Paragraph B *after* the image.", Assert.IsType<TextContent>(last.Content).Text); 282Assert.Equal("cell-only paragraph", Assert.IsType<TextContent>(paragraph.Content).Text); 488Assert.Equal("candidate **value**", Assert.IsType<TextContent>(candidateText.Content).Text); 548Assert.Equal("lO0? &", Assert.IsType<TextContent>(oldText.Content).Text); 549Assert.Equal("replacement?", Assert.IsType<TextContent>(replacementText.Content).Text);
DocumentTableCellTests.cs (4)
93Assert.Equal("cell", Assert.IsType<TextContent>(text.Content).Text); 94Assert.Equal("cell", Assert.IsType<TextContent>(text.Content).Text); 109Assert.Equal("cell", Assert.IsType<TextContent>(text.Content).Text); 209Assert.Equal("lO0 ??", Assert.IsType<TextContent>(text.Content).Text);
DocumentTableElementTests.cs (15)
28Assert.Equal("L|R", Assert.IsType<TextContent>(leaf.Content).Text); 48Assert.Equal("A|<&", Assert.IsType<TextContent>(text.Content).Text); 105Assert.Equal("stored table", Assert.IsType<TextContent>(table.Content).Text); 133Assert.Equal("stored table", Assert.IsType<TextContent>(table.Content).Text); 175Assert.Equal("one", Assert.IsType<TextContent>(table.Cells[0, 1]!.Content!.Content).Text); 176Assert.Equal("two", Assert.IsType<TextContent>(table.Cells[1, 0]!.Content!.Content).Text); 185Assert.Equal("left|right", Assert.IsType<TextContent>(table.Cells[0, 0]!.Content!.Content).Text); 195Assert.Equal("semantic cell", Assert.IsType<TextContent>(table.Cells[0, 0]!.Content!.Content).Text); 211Assert.Equal("MERGED_A<&", Assert.IsType<TextContent>(anchor.Content!.Content).Text); 243Assert.Equal(" INV0ICE 1O0? <&| ", Assert.IsType<TextContent>(text.Content).Text); 244Assert.Equal(" INV0ICE 1O0? <&| ", Assert.IsType<TextContent>(text.Content).Text); 272Assert.Equal("A|<", Assert.IsType<TextContent>(text.Content).Text); 323Assert.Equal("INV0ICE 1O0?", Assert.IsType<TextContent>(text.Content).Text); 410Assert.Equal("mapped A", Assert.IsType<TextContent>(text.Content).Text); 411Assert.Equal("mapped A", Assert.IsType<TextContent>(text.Content).Text);
DocumentTests.Composition.cs (2)
102Assert.Equal("**local**", Assert.IsType<TextContent>(text.Content).Text); 103Assert.Equal("cell|value", Assert.IsType<TextContent>(cellText.Content).Text);
DocumentTests.cs (9)
21Assert.Equal("stored document", Assert.IsType<TextContent>(document.Content).Text); 38Assert.Equal("stored markdown", Assert.IsType<TextContent>(document.Content).Text); 48Assert.Equal(markdown, (document.Content as TextContent)?.Text); 66Assert.Equal("stored image markdown", Assert.IsType<TextContent>(image.Content).Text); 84document.EnumerateContent().Select(element => Assert.IsType<TextContent>(element.Content).Text)); 102Assert.Equal("stored markdown", Assert.IsType<TextContent>(document.Content).Text); 105Assert.Equal("updated markdown", Assert.IsType<TextContent>(document.Content).Text); 221Assert.Equal("visible", Assert.IsType<TextContent>(document.Content).Text); 247Assert.Equal("visible **text**", Assert.IsType<TextContent>(text.Content).Text);
DocumentTests.StandardContent.cs (30)
20TextContent payload = new(markdown); 24Assert.Same(markdown, Assert.IsType<TextContent>(document.Content).Text); 26Assert.Equal("**changed**", Assert.IsType<TextContent>(document.Content).Text); 38Assert.Same(markdown, Assert.IsType<TextContent>(section.Content).Text); 48TextContent payload = new(markdown); 66Assert.Equal("updated", Assert.IsType<TextContent>(text.Content).Text); 72TextContent first = new("**first**"); 81document.EnumerateContent().Select(element => Assert.IsType<TextContent>(element.Content).Text)); 84document.EnumerateContent().Select(element => Assert.IsType<TextContent>(element.Content).Text)); 95Assert.Equal("", Assert.IsType<TextContent>(document.Content).Text); 96Assert.Equal("", Assert.IsType<TextContent>(section.Content).Text); 99Assert.Equal("", Assert.IsType<TextContent>(section.Content).Text); 102Assert.Equal("child", Assert.IsType<TextContent>(Assert.Single(document.EnumerateContent()).Content).Text); 116Assert.Equal("first", Assert.IsType<TextContent>(section.Elements[0].Content).Text); 129Assert.Equal("custom|value", Assert.IsType<TextContent>(custom.Content).Text); 139Assert.Equal("cell|value", Assert.IsType<TextContent>(cellContent.Content).Text); 146TextContent payload = new(markdown); 157Assert.Equal("**OCR**", Assert.IsType<TextContent>(text.Content).Text); 175Assert.Equal("root introduction", Assert.IsType<TextContent>(document.Content).Text); 176Assert.Equal("section introduction", Assert.IsType<TextContent>(section.Content).Text); 180Assert.Equal("leaf|value", Assert.IsType<TextContent>(cellText.Content).Text); 183Assert.Equal("edited", Assert.IsType<TextContent>(table.Cells[0, 0]!.Content!.Content).Text); 184Assert.Equal("edited", Assert.IsType<TextContent>(cellText.Content).Text); 185Assert.Equal("table caption", Assert.IsType<TextContent>(table.Content).Text); 236TextContent payload = new("first"); 245Assert.Equal("second", Assert.IsType<TextContent>(text.Content).Text); 249Assert.Equal("second", Assert.IsType<TextContent>(text.Content).Text); 390TextContent shared = new("same|payload"); 418Assert.Equal("changed", Assert.IsType<TextContent>(first.Content).Text); 419Assert.Equal("changed", Assert.IsType<TextContent>(second.Content).Text);
DocumentTextElementTests.cs (2)
19Assert.Equal("stored markdown", Assert.IsType<TextContent>(element.Content).Text); 44Assert.Equal("**citation** [1]", Assert.IsType<TextContent>(element.Content).Text);
PreviewContractTests.cs (3)
18TextContent original = new("**literal** <&| OCR 1O0?"); 30TextContent replacement = new("plain unchanged"); 34Assert.Equal("mutated **literal**", Assert.IsType<TextContent>(element.Content).Text);