Fix rewriter when the sync method is in the same extensions class#110
Fix rewriter when the sync method is in the same extensions class#110virzak merged 1 commit intozompinc:masterfrom
Conversation
3a210c4 to
48e1da9
Compare
|
@virzak Would love to have your eyes on this when you get some spare time. No rush, I just wanted to make sure it didn’t slip through the cracks. |
|
Will look at it this weekend probably |
After a long time trying to understand what could be missing I decided to compile the original and the generated code in the test project. It immediately provided all the missing types. In your case we needed to add typeof(IListSource).Assembly.Location Also compilation revealed lots of issues in the test cases which had to be fixed. Once you rebase, you should be good to continue. |
Pull request zompinc#108 fixed EF Core async to sync generation. EF Core async methods are found in the `EntityFrameworkQueryableExtensions` class, so a mapping from EntityFrameworkQueryableExtensions to System.Linq.Queryable was added. Unfortunately, this was not enough. The `EntityFrameworkQueryableExtensions` class also contains extension methods that have both an async and a sync method. For example: `ExecuteDeleteAsync` and `ExecuteDelete`. This commit fixes the translation for those methods where both the async and sync methods are in the same extension class.
48e1da9 to
4e83b85
Compare
|
Awesome, thanks for figuring this out! I have rebased my branch and everything is working as expected now. 🥳 This pull request is now ready for review. |
|
Version 2.0.13 is on nuget. Thanks so much, Cédric! |
Pull request #108 made sure that EF Core async extensions (such as
AnyAsyncare properly translated to theSystem.Linq.Queryable.Anyextension method).Unfortunately, this introduced a regression. When async and sync methods are in the same extension class (such as ExecuteDeleteAsync and ExecuteDelete) the generated sync method would be wrong. I.e., generated in
System.Linq.Queryableinstead ofMicrosoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.This pull request tries to address this issue. Unfortunately, I'm again facing discrepancies between the
GenerationSandbox.TestsandGenerator.Testsprojects. This is why this pull request is opened a draft.When used in the
GenerationSandbox.Testsproject, the generated code is correct.When generated in the
Generator.Testsproject, the generated code is incorrect. Note how theAnyandExecuteDeletemethods are not generated with their fully qualified names.I don't understand why the generated code is different. I have identified that var symbol = GetSymbol(node) returns null for
InvocationExpressionSyntax InvocationExpression dbSet.AnyAsync(cancellationToken)inGenerator.Testsand not null inGenerationSandbox.Testsbut I don't understand why.