Skip to content

Commit 3fca31f

Browse files
authored
.Net: [Feature Branch] Vector Store Logging (#10865)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Related: #10596 This PR enhances the vector store functionality by adding builder pattern implementations and logging decorators for key vector data interfaces, along with supporting utilities and DI integration. Interfaces handled: - `IKeywordHybridSearch<TRecord>` - `IVectorizableTextSearch<TRecord>` - `IVectorizedSearch<TRecord>` - `IVectorStore` - `IVectorStoreRecordCollection<TKey, TRecord>` Class types added: - Builders: implement a pipeline pattern with `Use` and `Build` methods. - Logging Extensions: provide reusable logging methods for tasks and enumerables, handling success, failure and cancellation. - Logging Decorators: wrap the interfaces to add logging by using `LoggingExtensions` reusable logging methods. - Builder Extensions: Add `AsBuilder` methods to convert service instances into builders. - Logging Builder Extensions: Add `UseLogging` methods to integrate logging into builder pipelines. - Service Collection Extensions: Add `Add{T}` and `AddKeyed{T}` methods for DI registration with configurable lifetimes. Other changes: - Split `Verify` class into `Verify` and `KernelVerify` in order to be able to use `Verify` methods in `Microsoft.Extensions.VectorData` package without a reference to Semantic Kernel specific logic, like `ValidPluginName`, `ValidFunctionName` etc. - Added unit tests for new classes and methods. - Added usage example in `Concepts/Memory` folder. ### Usage example Logging with manual registration: ```csharp var vectorStore = new InMemoryVectorStore() .AsBuilder() .UseLogging(this.LoggerFactory) .Build(); ``` Logging with DI: ```csharp serviceCollection.AddInMemoryVectorStore(); serviceCollection .AddVectorStore(s => s.GetRequiredService<InMemoryVectorStore>()) .UseLogging(this.LoggerFactory); ``` ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
1 parent 261fec4 commit 3fca31f

75 files changed

Lines changed: 4283 additions & 90 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.

‎dotnet/SK-dotnet.sln‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Diagnostics", "Diagnostics"
112112
src\InternalUtilities\src\Diagnostics\ExceptionExtensions.cs = src\InternalUtilities\src\Diagnostics\ExceptionExtensions.cs
113113
src\InternalUtilities\src\Diagnostics\ExperimentalAttribute.cs = src\InternalUtilities\src\Diagnostics\ExperimentalAttribute.cs
114114
src\InternalUtilities\src\Diagnostics\IsExternalInit.cs = src\InternalUtilities\src\Diagnostics\IsExternalInit.cs
115+
src\InternalUtilities\src\Diagnostics\KernelVerify.cs = src\InternalUtilities\src\Diagnostics\KernelVerify.cs
115116
src\InternalUtilities\src\Diagnostics\NullableAttributes.cs = src\InternalUtilities\src\Diagnostics\NullableAttributes.cs
116117
src\InternalUtilities\src\Diagnostics\RequiresDynamicCodeAttribute.cs = src\InternalUtilities\src\Diagnostics\RequiresDynamicCodeAttribute.cs
117118
src\InternalUtilities\src\Diagnostics\RequiresUnreferencedCodeAttribute.cs = src\InternalUtilities\src\Diagnostics\RequiresUnreferencedCodeAttribute.cs
118119
src\InternalUtilities\src\Diagnostics\UnconditionalSuppressMessageAttribute.cs = src\InternalUtilities\src\Diagnostics\UnconditionalSuppressMessageAttribute.cs
119-
src\InternalUtilities\src\Diagnostics\Verify.cs = src\InternalUtilities\src\Diagnostics\Verify.cs
120120
src\InternalUtilities\src\Diagnostics\UnreachableException.cs = src\InternalUtilities\src\Diagnostics\UnreachableException.cs
121+
src\InternalUtilities\src\Diagnostics\Verify.cs = src\InternalUtilities\src\Diagnostics\Verify.cs
122+
src\InternalUtilities\src\Diagnostics\ActivityExtensions.cs = src\InternalUtilities\src\Diagnostics\ActivityExtensions.cs
123+
src\InternalUtilities\src\Diagnostics\LoggingExtensions.cs = src\InternalUtilities\src\Diagnostics\LoggingExtensions.cs
121124
EndProjectSection
122125
EndProject
123126
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Linq", "Linq", "{B00AD427-0047-4850-BEF9-BA8237EA9D8B}"
@@ -138,10 +141,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "System", "System", "{3CDE10
138141
ProjectSection(SolutionItems) = preProject
139142
src\InternalUtilities\src\System\EnvExtensions.cs = src\InternalUtilities\src\System\EnvExtensions.cs
140143
src\InternalUtilities\src\System\IListExtensions.cs = src\InternalUtilities\src\System\IListExtensions.cs
144+
src\InternalUtilities\src\System\IndexRange.cs = src\InternalUtilities\src\System\IndexRange.cs
141145
src\InternalUtilities\src\System\InternalTypeConverter.cs = src\InternalUtilities\src\System\InternalTypeConverter.cs
142146
src\InternalUtilities\src\System\NonNullCollection.cs = src\InternalUtilities\src\System\NonNullCollection.cs
143147
src\InternalUtilities\src\System\TypeConverterFactory.cs = src\InternalUtilities\src\System\TypeConverterFactory.cs
144-
src\InternalUtilities\src\System\IndexRange.cs = src\InternalUtilities\src\System\IndexRange.cs
145148
EndProjectSection
146149
EndProject
147150
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Type", "Type", "{E85EA4D0-BB7E-4DFD-882F-A76EB8C0B8FF}"
@@ -492,8 +495,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Agents.Bedrock", "src\Agent
492495
EndProject
493496
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModelContextProtocol", "samples\Demos\ModelContextProtocol\ModelContextProtocol.csproj", "{B16AC373-3DA8-4505-9510-110347CD635D}"
494497
EndProject
498+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VectorData.UnitTests", "src\Connectors\VectorData.UnitTests\VectorData.UnitTests.csproj", "{89FC596F-CB81-4733-829B-4527D0FFC291}"
499+
EndProject
495500
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlServerIntegrationTests", "src\VectorDataIntegrationTests\SqlServerIntegrationTests\SqlServerIntegrationTests.csproj", "{A5E6193C-8431-4C6E-B674-682CB41EAA0C}"
496501
EndProject
502+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VectorData", "src\Connectors\VectorData\VectorData.csproj", "{8A40AE00-4A7D-4ED0-A9DA-BB7A98EFABD3}"
503+
EndProject
497504
Global
498505
GlobalSection(SolutionConfigurationPlatforms) = preSolution
499506
Debug|Any CPU = Debug|Any CPU
@@ -1359,12 +1366,24 @@ Global
13591366
{B16AC373-3DA8-4505-9510-110347CD635D}.Publish|Any CPU.Build.0 = Debug|Any CPU
13601367
{B16AC373-3DA8-4505-9510-110347CD635D}.Release|Any CPU.ActiveCfg = Release|Any CPU
13611368
{B16AC373-3DA8-4505-9510-110347CD635D}.Release|Any CPU.Build.0 = Release|Any CPU
1369+
{89FC596F-CB81-4733-829B-4527D0FFC291}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1370+
{89FC596F-CB81-4733-829B-4527D0FFC291}.Debug|Any CPU.Build.0 = Debug|Any CPU
1371+
{89FC596F-CB81-4733-829B-4527D0FFC291}.Publish|Any CPU.ActiveCfg = Publish|Any CPU
1372+
{89FC596F-CB81-4733-829B-4527D0FFC291}.Publish|Any CPU.Build.0 = Publish|Any CPU
1373+
{89FC596F-CB81-4733-829B-4527D0FFC291}.Release|Any CPU.ActiveCfg = Release|Any CPU
1374+
{89FC596F-CB81-4733-829B-4527D0FFC291}.Release|Any CPU.Build.0 = Release|Any CPU
13621375
{A5E6193C-8431-4C6E-B674-682CB41EAA0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13631376
{A5E6193C-8431-4C6E-B674-682CB41EAA0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
13641377
{A5E6193C-8431-4C6E-B674-682CB41EAA0C}.Publish|Any CPU.ActiveCfg = Debug|Any CPU
13651378
{A5E6193C-8431-4C6E-B674-682CB41EAA0C}.Publish|Any CPU.Build.0 = Debug|Any CPU
13661379
{A5E6193C-8431-4C6E-B674-682CB41EAA0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
13671380
{A5E6193C-8431-4C6E-B674-682CB41EAA0C}.Release|Any CPU.Build.0 = Release|Any CPU
1381+
{8A40AE00-4A7D-4ED0-A9DA-BB7A98EFABD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1382+
{8A40AE00-4A7D-4ED0-A9DA-BB7A98EFABD3}.Debug|Any CPU.Build.0 = Debug|Any CPU
1383+
{8A40AE00-4A7D-4ED0-A9DA-BB7A98EFABD3}.Publish|Any CPU.ActiveCfg = Publish|Any CPU
1384+
{8A40AE00-4A7D-4ED0-A9DA-BB7A98EFABD3}.Publish|Any CPU.Build.0 = Publish|Any CPU
1385+
{8A40AE00-4A7D-4ED0-A9DA-BB7A98EFABD3}.Release|Any CPU.ActiveCfg = Release|Any CPU
1386+
{8A40AE00-4A7D-4ED0-A9DA-BB7A98EFABD3}.Release|Any CPU.Build.0 = Release|Any CPU
13681387
EndGlobalSection
13691388
GlobalSection(SolutionProperties) = preSolution
13701389
HideSolutionNode = FALSE
@@ -1550,7 +1569,9 @@ Global
15501569
{DAD5FC6A-8CA0-43AC-87E1-032DFBD6B02A} = {3F260A77-B6C9-97FD-1304-4B34DA936CF4}
15511570
{8C658E1E-83C8-4127-B8BF-27A638A45DDD} = {6823CD5E-2ABE-41EB-B865-F86EC13F0CF9}
15521571
{B16AC373-3DA8-4505-9510-110347CD635D} = {5D4C0700-BBB5-418F-A7B2-F392B9A18263}
1572+
{89FC596F-CB81-4733-829B-4527D0FFC291} = {5A7028A7-4DDF-4E4F-84A9-37CE8F8D7E89}
15531573
{A5E6193C-8431-4C6E-B674-682CB41EAA0C} = {4F381919-F1BE-47D8-8558-3187ED04A84F}
1574+
{8A40AE00-4A7D-4ED0-A9DA-BB7A98EFABD3} = {24503383-A8C4-4255-9998-28D70FE8E99A}
15541575
EndGlobalSection
15551576
GlobalSection(ExtensibilityGlobals) = postSolution
15561577
SolutionGuid = {FBDC56A3-86AD-4323-AA0F-201E59123B83}

‎dotnet/samples/Concepts/Concepts.csproj‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
<ProjectReference Include="..\..\src\Connectors\Connectors.Onnx\Connectors.Onnx.csproj" />
7878
<ProjectReference Include="..\..\src\Connectors\Connectors.Ollama\Connectors.Ollama.csproj" />
7979
<ProjectReference Include="..\..\src\Connectors\Connectors.OpenAI\Connectors.OpenAI.csproj" />
80+
<ProjectReference Include="..\..\src\Connectors\VectorData\VectorData.csproj" />
8081
<ProjectReference Include="..\..\src\Experimental\Orchestration.Flow\Experimental.Orchestration.Flow.csproj" />
8182
<ProjectReference Include="..\..\src\Extensions\PromptTemplates.Handlebars\PromptTemplates.Handlebars.csproj" />
8283
<ProjectReference Include="..\..\src\Extensions\PromptTemplates.Liquid\PromptTemplates.Liquid.csproj" />
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
3+
using Azure.Identity;
4+
using Microsoft.Extensions.DependencyInjection;
5+
using Microsoft.Extensions.VectorData;
6+
using Microsoft.SemanticKernel;
7+
using Microsoft.SemanticKernel.Connectors.AzureOpenAI;
8+
using Microsoft.SemanticKernel.Connectors.InMemory;
9+
using Microsoft.SemanticKernel.Embeddings;
10+
11+
namespace Memory;
12+
13+
/// <summary>
14+
/// A simple example showing how to ingest data into a vector store and then use vector search to find related records to a given string
15+
/// with enabled telemetry.
16+
/// </summary>
17+
public class VectorStore_Telemetry(ITestOutputHelper output) : BaseTest(output)
18+
{
19+
[Fact]
20+
public async Task LoggingManualRegistrationAsync()
21+
{
22+
// Create an embedding generation service.
23+
var textEmbeddingGenerationService = new AzureOpenAITextEmbeddingGenerationService(
24+
TestConfiguration.AzureOpenAIEmbeddings.DeploymentName,
25+
TestConfiguration.AzureOpenAIEmbeddings.Endpoint,
26+
new AzureCliCredential());
27+
28+
// Manually construct an InMemory vector store with enabled logging.
29+
var vectorStore = new InMemoryVectorStore()
30+
.AsBuilder()
31+
.UseLogging(this.LoggerFactory)
32+
.Build();
33+
34+
await RunExampleAsync(textEmbeddingGenerationService, vectorStore);
35+
36+
// Output:
37+
// CreateCollectionIfNotExistsAsync invoked.
38+
// CreateCollectionIfNotExistsAsync completed.
39+
// UpsertAsync invoked.
40+
// UpsertAsync completed.
41+
// UpsertAsync invoked.
42+
// UpsertAsync completed.
43+
// UpsertAsync invoked.
44+
// UpsertAsync completed.
45+
// VectorizedSearchAsync invoked.
46+
// VectorizedSearchAsync completed.
47+
48+
// Search string: What is an Application Programming Interface
49+
// Result: Application Programming Interface. A set of rules and specifications that allow software components to communicate and exchange data.
50+
}
51+
52+
[Fact]
53+
public async Task LoggingDependencyInjectionAsync()
54+
{
55+
var serviceCollection = new ServiceCollection();
56+
57+
// Add an embedding generation service.
58+
serviceCollection.AddAzureOpenAITextEmbeddingGeneration(
59+
TestConfiguration.AzureOpenAIEmbeddings.DeploymentName,
60+
TestConfiguration.AzureOpenAIEmbeddings.Endpoint,
61+
new AzureCliCredential());
62+
63+
// Add InMemory vector store
64+
serviceCollection.AddInMemoryVectorStore();
65+
66+
// Register InMemoryVectorStore with enabled logging.
67+
serviceCollection
68+
.AddVectorStore(s => s.GetRequiredService<InMemoryVectorStore>())
69+
.UseLogging(this.LoggerFactory);
70+
71+
var services = serviceCollection.BuildServiceProvider();
72+
73+
var vectorStore = services.GetRequiredService<IVectorStore>();
74+
var textEmbeddingGenerationService = services.GetRequiredService<ITextEmbeddingGenerationService>();
75+
76+
await RunExampleAsync(textEmbeddingGenerationService, vectorStore);
77+
78+
// Output:
79+
// CreateCollectionIfNotExistsAsync invoked.
80+
// CreateCollectionIfNotExistsAsync completed.
81+
// UpsertAsync invoked.
82+
// UpsertAsync completed.
83+
// UpsertAsync invoked.
84+
// UpsertAsync completed.
85+
// UpsertAsync invoked.
86+
// UpsertAsync completed.
87+
// VectorizedSearchAsync invoked.
88+
// VectorizedSearchAsync completed.
89+
90+
// Search string: What is an Application Programming Interface
91+
// Result: Application Programming Interface. A set of rules and specifications that allow software components to communicate and exchange data.
92+
}
93+
94+
private async Task RunExampleAsync(
95+
ITextEmbeddingGenerationService textEmbeddingGenerationService,
96+
IVectorStore vectorStore)
97+
{
98+
// Get and create collection if it doesn't exist.
99+
var collection = vectorStore.GetCollection<ulong, Glossary>("skglossary");
100+
await collection.CreateCollectionIfNotExistsAsync();
101+
102+
// Create glossary entries and generate embeddings for them.
103+
var glossaryEntries = CreateGlossaryEntries().ToList();
104+
var tasks = glossaryEntries.Select(entry => Task.Run(async () =>
105+
{
106+
entry.DefinitionEmbedding = await textEmbeddingGenerationService.GenerateEmbeddingAsync(entry.Definition);
107+
}));
108+
await Task.WhenAll(tasks);
109+
110+
// Upsert the glossary entries into the collection and return their keys.
111+
var upsertedKeysTasks = glossaryEntries.Select(x => collection.UpsertAsync(x));
112+
var upsertedKeys = await Task.WhenAll(upsertedKeysTasks);
113+
114+
// Search the collection using a vector search.
115+
var searchString = "What is an Application Programming Interface";
116+
var searchVector = await textEmbeddingGenerationService.GenerateEmbeddingAsync(searchString);
117+
var searchResult = await collection.VectorizedSearchAsync(searchVector, new() { Top = 1 });
118+
var resultRecords = await searchResult.Results.ToListAsync();
119+
120+
Console.WriteLine("Search string: " + searchString);
121+
Console.WriteLine("Result: " + resultRecords.First().Record.Definition);
122+
Console.WriteLine();
123+
}
124+
125+
/// <summary>
126+
/// Sample model class that represents a glossary entry.
127+
/// </summary>
128+
/// <remarks>
129+
/// Note that each property is decorated with an attribute that specifies how the property should be treated by the vector store.
130+
/// This allows us to create a collection in the vector store and upsert and retrieve instances of this class without any further configuration.
131+
/// </remarks>
132+
private sealed class Glossary
133+
{
134+
[VectorStoreRecordKey]
135+
public ulong Key { get; set; }
136+
137+
[VectorStoreRecordData(IsFilterable = true)]
138+
public string Category { get; set; }
139+
140+
[VectorStoreRecordData]
141+
public string Term { get; set; }
142+
143+
[VectorStoreRecordData]
144+
public string Definition { get; set; }
145+
146+
[VectorStoreRecordVector(1536)]
147+
public ReadOnlyMemory<float> DefinitionEmbedding { get; set; }
148+
}
149+
150+
/// <summary>
151+
/// Create some sample glossary entries.
152+
/// </summary>
153+
/// <returns>A list of sample glossary entries.</returns>
154+
private static IEnumerable<Glossary> CreateGlossaryEntries()
155+
{
156+
yield return new Glossary
157+
{
158+
Key = 1,
159+
Category = "External Definitions",
160+
Term = "API",
161+
Definition = "Application Programming Interface. A set of rules and specifications that allow software components to communicate and exchange data."
162+
};
163+
164+
yield return new Glossary
165+
{
166+
Key = 2,
167+
Category = "Core Definitions",
168+
Term = "Connectors",
169+
Definition = "Connectors allow you to integrate with various services provide AI capabilities, including LLM, AudioToText, TextToAudio, Embedding generation, etc."
170+
};
171+
172+
yield return new Glossary
173+
{
174+
Key = 3,
175+
Category = "External Definitions",
176+
Term = "RAG",
177+
Definition = "Retrieval Augmented Generation - a term that refers to the process of retrieving additional data to provide as context to an LLM to use when generating a response (completion) to a user’s question (prompt)."
178+
};
179+
}
180+
}

‎dotnet/src/Connectors/VectorData.Abstractions/PACKAGE.md‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Contains abstractions for accessing Vector Databases and Vector Indexes.
44

55
## Key Features
66

7-
- Interfaces for Vector Database implementations which are provided in other packages including `Microsoft.SemanticKernel.Connectors.AzureAISearch`.
7+
- Interfaces for Vector Database implementation. Vector Database implementations are provided separately in other packages, for example `Microsoft.SemanticKernel.Connectors.AzureAISearch`.
88

99
## How to Use
1010

@@ -22,14 +22,25 @@ The main types provided by this library are:
2222

2323
## Related Packages
2424

25+
Vector Database utilities:
26+
27+
- `Microsoft.Extensions.VectorData`
28+
29+
Vector Database implementations:
30+
2531
- `Microsoft.SemanticKernel.Connectors.AzureAISearch`
2632
- `Microsoft.SemanticKernel.Connectors.AzureCosmosDBMongoDB`
2733
- `Microsoft.SemanticKernel.Connectors.AzureCosmosNoSQL`
34+
- `Microsoft.SemanticKernel.Connectors.InMemory`
35+
- `Microsoft.SemanticKernel.Connectors.MongoDB`
2836
- `Microsoft.SemanticKernel.Connectors.Pinecone`
37+
- `Microsoft.SemanticKernel.Connectors.Postgres`
2938
- `Microsoft.SemanticKernel.Connectors.Qdrant`
3039
- `Microsoft.SemanticKernel.Connectors.Redis`
40+
- `Microsoft.SemanticKernel.Connectors.Sqlite`
41+
- `Microsoft.SemanticKernel.Connectors.SqlServer`
3142
- `Microsoft.SemanticKernel.Connectors.Weaviate`
3243

3344
## Feedback & Contributing
3445

35-
Microsoft.Extensions.DependencyInjection.Abstractions is released as open source under the [MIT license](https://licenses.nuget.org/MIT). Bug reports and contributions are welcome at [the GitHub repository](https://github.com/microsoft/semantic-kernel).
46+
Microsoft.Extensions.VectorData.Abstractions is released as open source under the [MIT license](https://licenses.nuget.org/MIT). Bug reports and contributions are welcome at [the GitHub repository](https://github.com/microsoft/semantic-kernel).
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Suppressing errors for Test projects under dotnet folder
2+
[*.cs]
3+
dotnet_diagnostic.CA2007.severity = none # Do not directly await a Task
4+
dotnet_diagnostic.VSTHRD111.severity = none # Use .ConfigureAwait(bool) is hidden by default, set to none to prevent IDE from changing on autosave
5+
dotnet_diagnostic.CS1591.severity = none # Missing XML comment for publicly visible type or member
6+
dotnet_diagnostic.IDE1006.severity = warning # Naming rule violations
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<AssemblyName>VectorData.UnitTests</AssemblyName>
5+
<RootNamespace>VectorData.UnitTests</RootNamespace>
6+
<TargetFramework>net8.0</TargetFramework>
7+
<IsTestProject>true</IsTestProject>
8+
<Nullable>enable</Nullable>
9+
<ImplicitUsings>disable</ImplicitUsings>
10+
<IsPackable>false</IsPackable>
11+
<NoWarn>$(NoWarn);SKEXP0001,SKEXP0020,VSTHRD111,CA2007,CS1591</NoWarn>
12+
</PropertyGroup>
13+
14+
<ItemGroup>
15+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
16+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
17+
<PackageReference Include="Moq" />
18+
<PackageReference Include="xunit" />
19+
<PackageReference Include="xunit.runner.visualstudio">
20+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21+
<PrivateAssets>all</PrivateAssets>
22+
</PackageReference>
23+
<PackageReference Include="coverlet.collector">
24+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
25+
<PrivateAssets>all</PrivateAssets>
26+
</PackageReference>
27+
</ItemGroup>
28+
29+
<ItemGroup>
30+
<Compile Include="$(RepoRoot)/dotnet/src/InternalUtilities/test/AssertExtensions.cs" Link="%(RecursiveDir)%(Filename)%(Extension)" />
31+
<Compile Include="$(RepoRoot)/dotnet/src/InternalUtilities/src/Linq/AsyncEnumerable.cs" Link="%(RecursiveDir)%(Filename)%(Extension)" />
32+
<Compile Include="$(RepoRoot)/dotnet/src/InternalUtilities/src/Diagnostics/Verify.cs" Link="Diagnostics/Verify.cs" />
33+
<Compile Include="$(RepoRoot)/dotnet/src/InternalUtilities/src/Diagnostics/NullableAttributes.cs" Link="Diagnostics/NullableAttributes.cs" />
34+
<Compile Include="$(RepoRoot)/dotnet/src/InternalUtilities/src/Diagnostics/CompilerServicesAttributes.cs" Link="Diagnostics/CompilerServicesAttributes.cs" />
35+
</ItemGroup>
36+
37+
<ItemGroup>
38+
<ProjectReference Include="..\VectorData\VectorData.csproj" />
39+
</ItemGroup>
40+
41+
</Project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
3+
using Microsoft.Extensions.VectorData;
4+
using Moq;
5+
using Xunit;
6+
7+
namespace VectorData.UnitTests;
8+
9+
public class KeywordHybridSearchBuilderExtensionsTests
10+
{
11+
[Fact]
12+
public void AsBuilderReturnsKeywordHybridSearchBuilder()
13+
{
14+
// Arrange
15+
var search = new Mock<IKeywordHybridSearch<string>>().Object;
16+
17+
// Act
18+
var builder = search.AsBuilder();
19+
20+
// Assert
21+
Assert.IsType<KeywordHybridSearchBuilder<string>>(builder);
22+
Assert.Same(search, builder.Build());
23+
}
24+
}

0 commit comments

Comments
 (0)