Conversation
tests/ExpressiveSharp.MongoDB.IntegrationTests/Tests/ExpressiveMongoQueryProviderTests.cs
Fixed
Show fixed
Hide fixed
tests/ExpressiveSharp.MongoDB.IntegrationTests/Infrastructure/MongoContainerFixture.cs
Fixed
Show fixed
Hide fixed
tests/ExpressiveSharp.MongoDB.IntegrationTests/Infrastructure/MongoContainerFixture.cs
Fixed
Show fixed
Hide fixed
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Adds first-class MongoDB support to ExpressiveSharp by introducing a MongoDB-specific query provider/wrapper that expands [Expressive] members before MongoDB LINQ translation, plus a new integration test suite running against a containerized MongoDB instance.
Changes:
- Introduces
ExpressiveSharp.MongoDBwith anIMongoQueryProviderdecorator andIExpressiveMongoQueryable<T>wrapper. - Adds MongoDB-specific polyfill async stubs (generator-intercepted) and default transformer options tailored for MongoDB LINQ translation.
- Adds MongoDB integration tests + CI job using Testcontainers.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/ExpressiveSharp.MongoDB.IntegrationTests/Tests/TransformerPipelineTests.cs | Validates transformer pipeline output is translatable by Mongo LINQ; includes custom options test. |
| tests/ExpressiveSharp.MongoDB.IntegrationTests/Tests/PolyfillInterceptorTests.cs | Verifies generator interception for delegate-based LINQ in Mongo queries. |
| tests/ExpressiveSharp.MongoDB.IntegrationTests/Tests/ExpressiveMongoQueryProviderTests.cs | Exercises provider-level [Expressive] expansion in select/where/orderby scenarios. |
| tests/ExpressiveSharp.MongoDB.IntegrationTests/Tests/ExpressiveMongoQueryableTests.cs | Ensures wrapper/provider types are preserved and Mongo-specific APIs still work. |
| tests/ExpressiveSharp.MongoDB.IntegrationTests/Tests/ExpressiveMongoCollectionTests.cs | Validates higher-level collection wrapper delegates CRUD and supports LINQ. |
| tests/ExpressiveSharp.MongoDB.IntegrationTests/Tests/EmbeddedDocumentTests.cs | Validates [Expressive] expansion works with embedded documents/null-conditional chains. |
| tests/ExpressiveSharp.MongoDB.IntegrationTests/Tests/AsyncMethodTests.cs | Validates Mongo async operations work through the delegate-lambda chain. |
| tests/ExpressiveSharp.MongoDB.IntegrationTests/Infrastructure/MongoTestBase.cs | Creates per-test DB, seeds embedded documents, and cleans up databases. |
| tests/ExpressiveSharp.MongoDB.IntegrationTests/Infrastructure/MongoContainerFixture.cs | Manages a MongoDB Testcontainers lifecycle at assembly scope. |
| tests/ExpressiveSharp.MongoDB.IntegrationTests/ExpressiveSharp.MongoDB.IntegrationTests.csproj | New MSTest project referencing MongoDB + Testcontainers + generator analyzer. |
| src/ExpressiveSharp.MongoDB/MongoExpressiveOptions.cs | Provides MongoDB-oriented default transformer pipeline. |
| src/ExpressiveSharp.MongoDB/Infrastructure/ExpressiveMongoQueryProvider.cs | Decorates IMongoQueryProvider to expand expressions before execution. |
| src/ExpressiveSharp.MongoDB/Infrastructure/ExpressiveMongoQueryable.cs | Wraps IQueryable<T> so chained operations keep the expressive provider. |
| src/ExpressiveSharp.MongoDB/IExpressiveMongoQueryable.cs | Marker interface for MongoDB queryables that support rewrite/interception. |
| src/ExpressiveSharp.MongoDB/Extensions/MongoExpressiveExtensions.cs | Entry points to wrap Mongo queryables/collections with expressive expansion. |
| src/ExpressiveSharp.MongoDB/Extensions/ExpressiveQueryableMongoExtensions.cs | Generator-intercepted async stubs targeting MongoQueryable. |
| src/ExpressiveSharp.MongoDB/ExpressiveMongoCollection.cs | Convenience wrapper around IMongoCollection<TDocument> exposing expressive LINQ. |
| src/ExpressiveSharp.MongoDB/ExpressiveSharp.MongoDB.csproj | New MongoDB integration project (adds MongoDB.Driver). |
| ExpressiveSharp.slnx | Adds new MongoDB projects to the solution. |
| Directory.Packages.props | Adds package versions for MongoDB.Driver and Testcontainers.MongoDb. |
| .github/workflows/ci.yml | Adds a dedicated MongoDB container test job. |
| .devcontainer/devcontainer.json | Adjusts Docker-in-Docker feature configuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public IEnumerator<T> GetEnumerator() => _source.GetEnumerator(); | ||
| IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)_source).GetEnumerator(); |
There was a problem hiding this comment.
GetEnumerator() delegates directly to _source, which executes the query using the underlying Mongo provider and bypasses ExpressiveMongoQueryProvider.Execute/ExecuteAsync (so [Expressive] expansion may not happen for synchronous enumeration like foreach / ToList()). Implement enumeration via the wrapper Provider (e.g., execute Expression through _provider) so execution always flows through the expanding provider.
| public IEnumerator<T> GetEnumerator() => _source.GetEnumerator(); | |
| IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)_source).GetEnumerator(); | |
| public IEnumerator<T> GetEnumerator() | |
| { | |
| var result = _provider.Execute<IEnumerable<T>>(Expression); | |
| return result.GetEnumerator(); | |
| } | |
| IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); |
| { | ||
| // Use custom options with no transformers — raw expansion only | ||
| var customOptions = new ExpressiveOptions(); | ||
| var customQuery = MongoDB.Extensions.MongoExpressiveExtensions.AsExpressive( |
There was a problem hiding this comment.
MongoDB.Extensions.MongoExpressiveExtensions doesn’t exist in this repo (the extension is ExpressiveSharp.MongoDB.Extensions.MongoExpressiveExtensions). This will not compile; call the correct extension method/namespace (or just use Orders.AsExpressive(customOptions)).
| var customQuery = MongoDB.Extensions.MongoExpressiveExtensions.AsExpressive( | |
| var customQuery = ExpressiveSharp.MongoDB.Extensions.MongoExpressiveExtensions.AsExpressive( |
tests/ExpressiveSharp.MongoDB.IntegrationTests/Tests/ExpressiveMongoQueryProviderTests.cs
Outdated
Show resolved
Hide resolved
tests/ExpressiveSharp.MongoDB.IntegrationTests/Tests/ExpressiveMongoQueryProviderTests.cs
Outdated
Show resolved
Hide resolved
| var results = await Orders.AsQueryable() | ||
| .AsExpressive() | ||
| .Select(o => o.Total) |
There was a problem hiding this comment.
These .AsExpressive() calls will currently bind to ExpressiveSharp.Extensions.ExpressiveQueryableExtensions.AsExpressive (because ExpressiveSharp.MongoDB.Extensions isn’t imported), which won’t install ExpressiveMongoQueryProvider and will leave [Expressive] members unexpanded for Mongo translation. Import/use the MongoDB integration AsExpressive extension explicitly to ensure the provider decoration happens.
tests/ExpressiveSharp.MongoDB.IntegrationTests/Tests/PolyfillInterceptorTests.cs
Outdated
Show resolved
Hide resolved
tests/ExpressiveSharp.MongoDB.IntegrationTests/Tests/PolyfillInterceptorTests.cs
Outdated
Show resolved
Hide resolved
…nterceptorTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ved readability and functionality
Integrate MongoDB support into ExpressiveSharp, including the addition of MongoDB.Driver and Testcontainers.MongoDb packages. Implement a new queryable interface and related functionality to enable LINQ queries with expressive syntax for MongoDB collections. Include integration tests to verify the new features.