Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Net 9 #404

Merged
merged 3 commits into from
Nov 18, 2024
Merged

Conversation

rizi
Copy link
Contributor

@rizi rizi commented Nov 14, 2024

This pull request updates lamar to .net 9 and all of its dependencies, this should fix #405.

As already mentioned via discord, there seems to be a timing problem in asp.net core 9 in combination with lamar.

These tests in MinimalApiTests.integration_tests are red, it can be fixed when adding this two lines of code, after the call of .UseLamar(....) and builder.Build() and before the call of app.Run();

var container = (IContainer)app.Services;
container.GetServices<Microsoft.AspNetCore.Diagnostics.IDeveloperPageExceptionFilter>();

Note
This workaround also works in real world asp.net core 9 applications.

The error when running the tests or starting a real world asp.net core 9 application
Unable to resolve service for type 'System.Collections.Generic.IEnumerable`1[Microsoft.AspNetCore.Diagnostics.IDeveloperPageExceptionFilter]' while attempting to activate 'Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl'.
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)

I also added a break point in Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl and the IEnumerable<Microsoft.AspNetCore.Diagnostics.IDeveloperPageExceptionFilter> is always empty, so it's seems there is some kind of timing issue when using Lamar (therefore it's not a problem with a missing registration).

Input from @jeremydmiller
Somehow the IEnumerable<Microsoft.AspNetCore.Diagnostics.IDeveloperPageExceptionFilter> is not even tried to be resolved by lamar (except when calling container.GetServices<Microsoft.AspNetCore.Diagnostics.IDeveloperPageExceptionFilter>(); before (maybe cached by aspnet.core)?)

Edit
Other dependencies are resolved by lamar
image
image
image

But of course that isn't a real solution, any help would highly be appreciated.

@rizi rizi force-pushed the AddSupportForNet9 branch from 1e2bc9b to 1b7bc56 Compare November 14, 2024 09:51
@rizi rizi mentioned this pull request Nov 14, 2024
@rizi rizi force-pushed the AddSupportForNet9 branch from 1b7bc56 to 11ba9d8 Compare November 14, 2024 21:40
@rizi rizi force-pushed the AddSupportForNet9 branch from 11ba9d8 to c5df30e Compare November 15, 2024 08:38
@jeremydmiller jeremydmiller merged commit a9fd707 into JasperFx:master Nov 18, 2024
1 check passed
@rizi rizi deleted the AddSupportForNet9 branch November 18, 2024 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Net 9
2 participants