-
Notifications
You must be signed in to change notification settings - Fork 754
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
Created IHostSettingsService for Dependency Injection #3990
Conversation
I am working on the unit tests for this one, but wanted to submit the PR so the business rules could get reviewed. There are a bunch of mocking issues with unit tests. We should wait until #3988 is merged prior to merging this. I would like to rebase on that to ensure we have a good merge in the unit test files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial pass review overall looks good on this, I think we need to be sure to coordinate AND focus on being sure that we have true performance & memory management done on DI channels before we recommend this route.
/// <returns>host setting.</returns> | ||
public Dictionary<string, ConfigurationSetting> GetSettings() | ||
/// <inheritdoc/> | ||
Dictionary<string, IConfigurationSetting> INewHostController.GetSettings() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be public
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I extracted the new IConfigurationSetting
interface into the abstractions project. It is not possible to have 2 identical methods in a class with different return types. The compiler reports errors as it doesn't know how to handle it. Explicit interface implementations like this is a way to solve it. Considering the new interface will only be used for Dependency Injection I believe this change is safe.
Once we move the deprecated method Dictionary<string, ConfigurationSetting> GetSettings()
we can remove the explicit declaration and make this public
Thanks for the review @mitchelsellers . I would like us to hold off on merging this until we complete #3988 as the unit testing work done in that PR will help this one. When you get a chance could you review that one, I am interested in your thoughts on the new interfaces I added. |
DNN Platform/DotNetNuke.Abstractions/Entities/IConfigurationSetting.cs
Outdated
Show resolved
Hide resolved
Now that #3988 is merged, this PR needs to be rebased on |
8ea078c
to
b65b016
Compare
@ahoefling I've updated your branch with the rebase. Hope it helps! |
@bdukes thanks for the assist, managing the rebase gave me a great head start on fixing all the broken unit tests. I have updated the PR with the requested changes and fixed all the unit tests. It was quite satisfying updating unit test mocks to use the new Changes
What's NextI have checked all the builds locally and all the unit tests are passing. I have not ran the generated installer build yet, but plan to do it on tomorrow (8/20/2020) when I get a chance. If someone wants to grab the install file and report back, that would save me some time and be a big help! |
I just tested the installer and it appears to work without issue |
DNN Platform/DotNetNuke.Abstractions/Entities/IConfigurationSetting.cs
Outdated
Show resolved
Hide resolved
DNN Platform/DotNetNuke.Abstractions/Entities/Controllers/IHostController.cs
Outdated
Show resolved
Hide resolved
DNN Platform/Tests/DotNetNuke.Tests.Content/DotNetNuke.Tests.Content.csproj
Outdated
Show resolved
Hide resolved
Since we are having conversations about migrating items such as Perhaps something like this public class HostSettingEntity
{
public int Id { get; set; }
public string Key { get; set; }
public string Value { get; set; }
public bool IsSecured { get; set; }
} public class HostSetting
{
public string Key { get; set; }
public string Value { get; set; }
} In this example I created a |
I thought about this a little bit more and wanted to share some additional thoughts. Right now we are dealing with the public class HostSetting : IConfigurationSetting
{
public int Id { get; set; }
// interface members
public string Key { get; set; }
public string Value { get; set; }
public bool IsSecured { get; set; }
}
public class PortalSetting : IConfigurationSetting
{
public int PortalSettingId { get; set; }
public int PortalId { get; set; }
// interface members
public string Key { get; set; }
public string Value { get; set; }
public bool IsSecured { get; set; }
}
public class ModuleSetting : IConfigurationSetting
{
public int ModuleId { get; set; }
// interface members
public string Key { get; set; }
public string Value { get; set; }
public bool IsSecured { get; set; }
}
public class RoleSetting : IConfigurationSetting
{
public int RoleSettingId { get; set; }
public int RoleId { get; set; }
// interface members
public string Key { get; set; }
public string Value { get; set; }
public bool IsSecured { get; set; }
}
// there are some omitted tables This will generate a high level of interoperability with lower level data-access as we modernize this part of the platform. It would be very powerful if all of these tables used a very similar polymorphic Business Layer that only overrides the default rules if it needs to add additional properties besides the Primary Key. In the example of |
I really like these thoughts and being able to have a discussion around them. Regarding the entity vs. business model idea, in my mind the entity class would be an implementation detail which isn't exposed via any of the abstractions, so the details of it don't need to necessarily conform to some standard. Whatever intermediate classes are used by data access shouldn't impact the design of the interface. That said, if we find a model/approach we like, we might as well be consistent with it (while leaving room to deviate where it makes sense). I think there's probably value in creating a single interface for the various types settings, for example I could imagine an API similar to |
@bdukes This will also give us some more time to digest these ideas prior to making any strong opinions on a Currently the DNN Entities that exist in |
So, would you recommend moving |
I would tend to agree with @bdukes on this one, I would really like to try and keep like elements together, so I think that putting any sort of models into a separate namespace would be confusing, and additionally would clutter that namespace greatly in the future. |
@bdukes @mitchelsellers I'm thinking of moving
to
I think this would follow our guidelines as it is a model used at the application level. Our current pattern appears to be keeping service related interfaces at the root level and models in the folders. Do you all have any thoughts on this? |
I really like the use of "Application" to hold those larger level items, honestly, in some ways the IHostController might be good as well to go there. Might we get a quick call setup @ahoefling and @bdukes might be faster to just chat through this a bit? |
I have a little time this morning (but @ahoefling just messaged me that he was switching projects, so he may not have time). I agree that My question with |
I have no problem moving
to
I originally moved it to the root namespace as a place to put all the services. Considering the service is focused on "Application" level business rules it does make sense to put it back. (I think it was originally in there when I first submitted the PR and I moved it out to try it this way). I don't have time for a call today unfortunately, but I can continue the dialogue on github |
@bdukes
I would argue that it should keep the prefix of |
I agree with the above and like the .Settings namespace as well |
Perfect! I'll make the following changes to the PR later today Move: I'll do an audit of our changes and make sure I have no other questions. Once I push the update I'll request a re-review from both of you (@bdukes and @mitchelsellers). This should give us an opportunity to make sure there are no confusions or last minute questions on the change |
… generate better error reports
…stance let the DI container handle resolving the state
…same instance for the life of the request
01f8264
to
c24c66f
Compare
|
Is this ready to merge @mitchelsellers @bdukes ? And if so, in 9.7.1 or we hold it for 9.8.0 ? |
@bdukes @ahoefling thoughts? I think it is ok, as it isn't breaking |
@mitchelsellers sounds, good, merging... |
I think we have good test coverage on this and it doesn't introduce breaking changes. 🎉 |
Related to #3985
Summary
This does not close the linked work item, but is required before I can submit a pull request.
Added an
IHostController
an abstraction of theHostController
that will be used with Dependency Injection. The DotNetNuke.Library code for this is a small sample of what I have been thinking would be a good approach for migrating controllers and entities from DotNetNuke.Library to DotNetNuke.Abstractions.