Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.10" />
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="10.8.0" />
<PackageVersion Include="Microsoft.SemanticKernel" Version="1.79.0" />
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.PgVector" Version="1.74.0-preview" />
<PackageVersion Include="CommunityToolkit.VectorData.PgVector" Version="1.0.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.301" />
<!-- Pin to patched versions; NuGet.Protocol 6.12.5+ fixes GHSA-g4vj-cjjj-v7hg (pulled in by Microsoft.VisualStudio.Web.CodeGeneration.Design) -->
<PackageVersion Include="NuGet.Packaging" Version="7.6.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PackageReference Include="Azure.Identity" />
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" />
<PackageReference Include="Microsoft.SemanticKernel" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.PgVector" />
<PackageReference Include="CommunityToolkit.VectorData.PgVector" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" />
<PackageReference Include="ModelContextProtocol" />
<PackageReference Include="ModelContextProtocol.AspNetCore" />
Expand Down
26 changes: 20 additions & 6 deletions EssentialCSharp.Chat.Tests/PgVectorConnectorTests.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
using EssentialCSharp.Chat.Common.Models;
using Microsoft.SemanticKernel.Connectors.PgVector;
using CommunityToolkit.VectorData.PgVector;

namespace EssentialCSharp.Chat.Tests;

public class PgVectorConnectorTests
{
/// <summary>
/// Verifies that PostgresVectorStore.GetCollection does not throw a TypeLoadException,
/// which would indicate a version mismatch between Microsoft.SemanticKernel core and
/// Microsoft.SemanticKernel.Connectors.PgVector (e.g., missing vtable slots on
/// internal types like PostgresModelBuilder).
/// Verifies the runtime vector-data API shape is compatible with the currently resolved
/// CommunityToolkit connector assemblies. If this fails with MissingMethodException
/// (for example on VectorSearchOptions<T>.get_OldFilter()), package versions are out of sync.
/// </summary>
[Test]
public async Task GetCollection_WithBookContentChunk_DoesNotThrowTypeLoadException()
public async Task GetCollection_WithBookContentChunk_RuntimeVectorDataApiShapeIsCompatible()
{
// Arrange — no real DB connection is needed; connections are only opened for actual queries
#pragma warning disable SKEXP0010 // PostgresVectorStore is experimental
Expand All @@ -24,5 +23,20 @@ public async Task GetCollection_WithBookContentChunk_DoesNotThrowTypeLoadExcepti

// Assert
await Assert.That(collection).IsNotNull();

// Drive the same vector-search path used in production so binary-incompatible package
// combinations fail in tests before deployment.
await using var enumerator = collection
.SearchAsync(
new ReadOnlyMemory<float>(new float[1536]),
1,
options: new Microsoft.Extensions.VectorData.VectorSearchOptions<BookContentChunk>
{
VectorProperty = x => x.TextEmbedding
},
cancellationToken: CancellationToken.None)
.GetAsyncEnumerator();

await Assert.ThrowsAsync<Exception>(async () => await enumerator.MoveNextAsync().AsTask());
}
}
2 changes: 1 addition & 1 deletion EssentialCSharp.Chat/EssentialCSharp.Chat.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<ItemGroup>
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" />
<PackageReference Include="Microsoft.SemanticKernel" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.PgVector" />
<PackageReference Include="CommunityToolkit.VectorData.PgVector" />
<PackageReference Include="ModelContextProtocol" />
<PackageReference Include="IntelliTect.Multitool" />
<PackageReference Include="System.CommandLine" />
Expand Down