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

Fix selection of custom ContextManager through CslaOptions #4049

Merged
merged 2 commits into from
Jun 20, 2024

Conversation

rockfordlhotka
Copy link
Member

@rockfordlhotka rockfordlhotka commented Jun 19, 2024

Fixes #4047

This pull request addresses the issue of ApplicationContextAccessor not selecting the ContextManager specified in CslaOptions.ContextManagerType over the default one. The changes ensure that custom ContextManager types are prioritized and registered before the default types, allowing for the correct ContextManager to be used according to the configuration.

  • Modifies the RegisterContextManager method in ConfigurationExtensions.cs to use TryAddScoped instead of AddScoped for registering default ContextManager types. This change prevents overwriting custom registrations if a custom ContextManagerType is provided in CslaOptions.
  • Ensures that if a custom ContextManagerType is specified, it is registered before attempting to register any default ContextManager types, allowing the custom type to take precedence.
  • Applies TryAddScoped in the LoadContextManager method for loading specific ContextManager types based on the environment, further ensuring that custom types are not overwritten by default or environment-specific types.

For more details, open the Copilot Workspace session.

@rockfordlhotka rockfordlhotka marked this pull request as draft June 19, 2024 03:04
@rockfordlhotka
Copy link
Member Author

This isn't complete. It is my first attempt at using the new GH Copilot workspace preview feature. Not entirely sure the AI did the right thing, and in any case, it didn't generate (or allow me to add) any unit tests.

@rockfordlhotka rockfordlhotka marked this pull request as ready for review June 20, 2024 01:00
@rockfordlhotka rockfordlhotka merged commit 018f366 into main Jun 20, 2024
1 check passed
@rockfordlhotka rockfordlhotka deleted the rockfordlhotka/fix-contextmanager-selection branch June 20, 2024 01:00
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.

Cannot change ContextManager through CslaOptions.ContextManagerType
1 participant