-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Description
Given the following async code
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Zomp.SyncMethodGenerator.IntegrationTests
{
using Microsoft.EntityFrameworkCore;
public partial class EntityFrameworkQueryableExtensions
{
[Zomp.SyncMethodGenerator.CreateSyncVersion]
public async Task<bool> QueryableExtensionAsync(IQueryable<object> source, CancellationToken cancellationToken)
{
return await source.AnyAsync(cancellationToken);
}
}
}Zomp.SyncMethodGenerator generates the following sync code which does not compile (Error CS0117 : 'EntityFrameworkQueryableExtensions' does not contain a definition for 'Any')
// <auto-generated/>
#nullable enable
namespace Zomp.SyncMethodGenerator.IntegrationTests
{
public partial class EntityFrameworkQueryableExtensions
{
public bool QueryableExtension(global::System.Linq.IQueryable<object> source)
{
return global::Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.Any(source);
}
}
}Now the really weird part is that if I add this exact same code in a unit test, the generated code works since Any() is called on IQueryable instead of EntityFrameworkQueryableExtensions.
//HintName: Zomp.SyncMethodGenerator.IntegrationTests.EntityFrameworkQueryableExtensions.QueryableExtensionAsync.g.cs
// <auto-generated/>
#nullable enable
namespace Zomp.SyncMethodGenerator.IntegrationTests
{
public partial class EntityFrameworkQueryableExtensions
{
public bool QueryableExtension(IQueryable<object> source)
{
return source.Any();
}
}
}I have a EntityFrameworkQueryableExtensions branch in my fork that reproduces this issue.
✅ The new EntityFrameworkQueryableExtensions test passes.
❌ The same code, when added to the GenerationSandbox.Tests project fails to compile as explained above.
Do you have any idea what's going on here?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels