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

feat: Added support for named options (#478) #534

Merged
merged 7 commits into from
Mar 6, 2022

Conversation

LamarLugli
Copy link
Contributor

No description provided.

@LamarLugli
Copy link
Contributor Author

I added support for named options using the WithPerTenantNamedOptions<TOptions> extension method on the builder. This will preserve backwards compatibility with users using WithPerTenantOptions<TOptions>.

@LamarLugli LamarLugli changed the title Added support for named options (#478) feat: Added support for named options (#478) Feb 25, 2022
@AndrewTriesToCode
Copy link
Contributor

Thank you very much!

Do you think you can add in some unit tests to confirm that the right named options are impacted and no other named or unnamed options are?

Can you update the docs to mention that named options are supported with this method?

I'll try to review this quickly.

@LamarLugli
Copy link
Contributor Author

LamarLugli commented Feb 25, 2022

I would be happy to update the documentation. I'll update the pull request with some new documentation.

Do you think you can add in some unit tests to confirm that the right named options are impacted and no other named or unnamed options are? Are you asking about different classes of options to make sure there is no crossover, or configuring two different names of the same class? My existing tests already cover the latter.

@AndrewTriesToCode
Copy link
Contributor

Ah perfect -- I didn't see your tests and first and I see now you did update the docs. Thanks again! I will get this out in a release ASAP.

@AndrewTriesToCode
Copy link
Contributor

Note to self -- prioritize for this week.

@AndrewTriesToCode
Copy link
Contributor

AndrewTriesToCode commented Mar 6, 2022

@LamarLugli I made some edits and I want to see if you agree. I also updated the docs -- if you agree with my changes I'll go ahead and put out a new release.

  1. I reworked your named options class so that it works like this:
services.AddMultiTenant<TenantInfo>()...
    .WithPerTenantNamedOptions<MyOptions>(name, (options, tenantInfo) =>
    {
        // only update options named "someOptionsName"
        options.MyOption1 = (int)tenantInfo.Items["someValue"];
        options.MyOption2 = (int)tenantInfo.Items["anotherValue"];
    });

The difference is the name isn't part of the delegate and the delegate only gets called if the name is correct via the options factory (so no need to check if the name matches). This is how .NET does it and I wanted to match it as closely as possible.

  1. I obsoleted the unnamed options types and now WithPerTenantOptions simply calls WithPerTenantNamedOptions with a null name -- this means it works just like before but piggy backs on your implementation.

Copy link
Contributor

@AndrewTriesToCode AndrewTriesToCode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some changes -- see my comment.

@LamarLugli
Copy link
Contributor Author

This looks great. Thanks for making this even better.

@AndrewTriesToCode AndrewTriesToCode merged commit 6f9528d into Finbuckle:main Mar 6, 2022
github-actions bot pushed a commit that referenced this pull request Mar 6, 2022
## [6.7.0](v6.6.1...v6.7.0) (2022-03-06)

### Features

* Added support for named options ([#478](#478)) ([#534](#534)) ([6f9528d](6f9528d))
@AndrewTriesToCode
Copy link
Contributor

🎉 This PR is included in version 6.7.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants