-
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
Refactor Globals.cs to use Dependency Injection #3153
Comments
When we implement this throughout the platform should we be recommending GetService()If the container fails to find the dependency, the method will return null, which will most likely cause a GetRequiredService()If the container fails to find the dependency, the container will throw an exception and stop the app right there Most of the Globals and usage throughout the internals of DNN are required, so I tend towards |
To properly migrate from My goal is to get as many of these marked for deprecation for v11 as I don't want to have to migrate a Globals file to .NET Core and we have no idea when we are ready for the switch, but I want us to be prepared @mitchelsellers @bdukes |
I think that makes sense @ahoefling. Do we need to require that these new interfaces are .NET Standard compliant (i.e. don't reference types from |
@bdukes this is a great question! I am all for creating a new library called I think this is an important change, can you leave this feedback on PR #3160 so we can set the stage right for follow-up PRs and how we want it implemented |
Just for triage, this issue is not complete right, it is a big item that will be done as multiple PRs correct? Also how much of this can we do in 9 or does it all need to go to 10. One issue was that existing modules would need to be recompiled if used APIs or dependencies get moved into a new library... |
Hi folks, I see the latest DNN release marks Globals.NavigateURL as becoming obsolete in a future release:
There doesn't appear to be any recommendations in the code moving forward. Is there guidance on how we are to replace our usage of Globals.NavigateURL in 3rd party modules? I'd prefer to not suppress these messages for now unless I have to. Thanks! |
@tpperlman The recommendation will be to use the new INavigationProvider interface with Dependency Injection for your custom solutions - #3160 |
Thanks @mitchelsellers! So if I understand correctly the new way going forward would be to add a reference DotNetNuke.Abstractions in the project and replace entries like:
with
|
Yes! |
I guess this would be for Dnn10? Just asking for triage, will put it there but if I am wrong feel free to change or comment |
If any of the labels I put don't make sense, please edit or let me know... |
@Constantine-Ketskalo that doesn't appear (to me) to be related to this issue. You'll want to review the build documentation, which describes using Cake to build packages and setup a dev site. Just running the site from Visual Studio doesn't provide a complete site install, unfortunately. /cc @donker |
Thank you so much, @bdukes. |
Actually,You can get a instance of INavigationManager when your control inherit from PortalModuleBase.
Or
I verified them in DNN 9.10.2 |
In MVC you can get the services injected for you using constructor injection like described here: Note that since you need INavagationManager, this is already registered by DNN itself so for that one, you don't need to also implement IDnnStartup |
Description of problem
In DNN 9.4.0 we introduced Dependency Injection and it is time to start refactoring the
Globals.cs
file to use Dependency Injection. This is a massive undertaking and should not be attempted in 1 Pull Request. This work item should serve as an epic that we can link others back to as we solve small problems.Description of solution
Refactor sections of
Globals.cs
into manageable interfaces grouped in logical chunks. For example all of theNavigateURL
methods should move to an interface calledINavigationManager
.Description of alternatives considered
N/A
Screenshots
N/A
Affected browser
Work Items
A table of work items of chunks that we will break out the
Globals.cs
intoINavigationManager
The text was updated successfully, but these errors were encountered: