Skip to content

Commit 06b0c3c

Browse files
authored
Merge branch 'release/10.2.2' into data-provided-property
2 parents 4bb08b5 + e8b2739 commit 06b0c3c

35 files changed

Lines changed: 429 additions & 90 deletions

File tree

DNN Platform/DotNetNuke.Web.Client.ResourceManager/ClientResourceController.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ namespace DotNetNuke.Web.Client.ResourceManager
1111

1212
using DotNetNuke.Abstractions.Application;
1313
using DotNetNuke.Abstractions.ClientResources;
14+
using DotNetNuke.Instrumentation;
1415

1516
/// <inheritdoc />
1617
public class ClientResourceController : IClientResourceController
1718
{
19+
private static readonly ILog Logger = LoggerSource.Instance.GetLogger(typeof(ClientResourceController));
1820
private readonly IHostSettings hostSettings;
1921
private readonly IApplicationStatusInfo appStatus;
22+
private readonly Guid controllerId;
23+
private bool hasBegunRendering;
2024

2125
/// <summary>Initializes a new instance of the <see cref="ClientResourceController"/> class.</summary>
2226
/// <param name="hostSettings">The host settings.</param>
@@ -34,6 +38,8 @@ public ClientResourceController(IHostSettings hostSettings, IApplicationStatusIn
3438
this.hostSettings = hostSettings;
3539
this.appStatus = appStatus;
3640
this.RegisterPathNameAlias("SharedScripts", "~/Resources/Shared/Scripts/");
41+
this.controllerId = Guid.NewGuid();
42+
Logger.Debug($"ClientResourceController initialized with ID {this.controllerId}");
3743
}
3844

3945
private List<IFontResource> Fonts { get; set; } = [];
@@ -198,6 +204,8 @@ public void RemoveStylesheetByPath(string stylesheetPath, string pathNameAlias)
198204
/// <inheritdoc />
199205
public string RenderDependencies(ResourceType resourceType, string provider, string applicationPath)
200206
{
207+
this.hasBegunRendering = true;
208+
Logger.Debug($"Rendering dependencies for CRC id {this.controllerId} with ResourceType={resourceType}, Provider={provider}, ApplicationPath={applicationPath}. We have {this.Scripts.Count} scripts, {this.Stylesheets.Count} stylesheets and {this.Fonts.Count} fonts.");
201209
var sortedList = new List<IResource>();
202210
if (resourceType is ResourceType.Font or ResourceType.All)
203211
{
@@ -264,6 +272,15 @@ private List<T> AddResource<T>(List<T> resources, T resource)
264272
where T : IResource
265273
{
266274
resource.ResolvedPath = this.ResolvePath(resource.FilePath, resource.PathNameAlias);
275+
Logger.Debug($"Adding resource {resource.ResolvedPath} to CRC id {this.controllerId} which currently has {resources.Count} resources");
276+
277+
if (this.hasBegunRendering)
278+
{
279+
Logger.Error($"Cannot add resource {resource.ResolvedPath} to CRC id {this.controllerId} because rendering has already begun");
280+
281+
////throw new InvalidOperationException("Cannot add resources after rendering has begun.");
282+
}
283+
267284
resources.RemoveAll(l => string.Equals(l.ResolvedPath, resource.ResolvedPath, StringComparison.OrdinalIgnoreCase)); // remove any existing link with the same key (i.e. exactly the same resolved path)
268285
if (!string.IsNullOrEmpty(resource.Name))
269286
{

DNN Platform/DotNetNuke.Web.Mvc/Framework/DnnWebViewPage.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,33 @@
44

55
namespace DotNetNuke.Web.Mvc.Framework
66
{
7+
using System;
78
using System.Web.Mvc;
89

910
using DotNetNuke.Common;
11+
using DotNetNuke.Framework;
1012
using DotNetNuke.Web.Mvc.Helpers;
1113

1214
using Microsoft.Extensions.DependencyInjection;
1315

1416
public abstract class DnnWebViewPage : WebViewPage
1517
{
18+
private readonly IServicesFramework servicesFramework;
19+
20+
/// <summary>Initializes a new instance of the <see cref="DnnWebViewPage"/> class.</summary>
21+
[Obsolete("Deprecated in DotNetNuke 10.2.2. Please use overload with IServicesFramework. Scheduled removal in v12.0.0.")]
22+
protected DnnWebViewPage()
23+
: this(null)
24+
{
25+
}
26+
27+
/// <summary>Initializes a new instance of the <see cref="DnnWebViewPage"/> class.</summary>
28+
/// <param name="servicesFramework">The web API service framework.</param>
29+
protected DnnWebViewPage(IServicesFramework servicesFramework)
30+
{
31+
this.servicesFramework = servicesFramework ?? Globals.GetCurrentServiceProvider().GetRequiredService<IServicesFramework>();
32+
}
33+
1634
public DnnHelper<object> Dnn { get; set; }
1735

1836
public new DnnHtmlHelper<object> Html { get; set; }
@@ -23,7 +41,7 @@ public abstract class DnnWebViewPage : WebViewPage
2341
public override void InitHelpers()
2442
{
2543
this.Ajax = new AjaxHelper<object>(this.ViewContext, this);
26-
this.Html = new DnnHtmlHelper<object>(this.ViewContext, this);
44+
this.Html = new DnnHtmlHelper<object>(this.ViewContext, this, this.servicesFramework);
2745
this.Url = new DnnUrlHelper(this.ViewContext);
2846
this.Dnn = ActivatorUtilities.CreateInstance<DnnHelper<object>>(Globals.GetCurrentServiceProvider(), this.ViewContext, this);
2947
}

DNN Platform/DotNetNuke.Web.Mvc/Framework/DnnWebViewPage{TModel}.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,33 @@
33
// See the LICENSE file in the project root for more information
44
namespace DotNetNuke.Web.Mvc.Framework
55
{
6+
using System;
67
using System.Web.Mvc;
78

89
using DotNetNuke.Common;
10+
using DotNetNuke.Framework;
911
using DotNetNuke.Web.Mvc.Helpers;
1012

1113
using Microsoft.Extensions.DependencyInjection;
1214

1315
public abstract class DnnWebViewPage<TModel> : WebViewPage<TModel>
1416
{
17+
private readonly IServicesFramework servicesFramework;
18+
19+
/// <summary>Initializes a new instance of the <see cref="DnnWebViewPage{TModel}"/> class.</summary>
20+
[Obsolete("Deprecated in DotNetNuke 10.2.2. Please use overload with IServicesFramework. Scheduled removal in v12.0.0.")]
21+
protected DnnWebViewPage()
22+
: this(null)
23+
{
24+
}
25+
26+
/// <summary>Initializes a new instance of the <see cref="DnnWebViewPage{TModel}"/> class.</summary>
27+
/// <param name="servicesFramework">The web API service framework.</param>
28+
protected DnnWebViewPage(IServicesFramework servicesFramework)
29+
{
30+
this.servicesFramework = servicesFramework ?? Globals.GetCurrentServiceProvider().GetRequiredService<IServicesFramework>();
31+
}
32+
1533
public DnnHelper<TModel> Dnn { get; set; }
1634

1735
public new DnnHtmlHelper<TModel> Html { get; set; }
@@ -22,7 +40,7 @@ public abstract class DnnWebViewPage<TModel> : WebViewPage<TModel>
2240
public override void InitHelpers()
2341
{
2442
this.Ajax = new AjaxHelper<TModel>(this.ViewContext, this);
25-
this.Html = new DnnHtmlHelper<TModel>(this.ViewContext, this);
43+
this.Html = new DnnHtmlHelper<TModel>(this.ViewContext, this, this.servicesFramework);
2644
this.Url = new DnnUrlHelper(this.ViewContext);
2745
this.Dnn = ActivatorUtilities.CreateInstance<DnnHelper<TModel>>(Globals.GetCurrentServiceProvider(), this.ViewContext, this);
2846
}

DNN Platform/DotNetNuke.Web.Mvc/Helpers/DnnHtmlHelper.cs

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,69 @@ namespace DotNetNuke.Web.Mvc.Helpers
1111
using System.Web.Mvc;
1212
using System.Web.Routing;
1313

14+
using DotNetNuke.Common;
1415
using DotNetNuke.Framework;
1516
using DotNetNuke.UI.Modules;
1617
using DotNetNuke.Web.Mvc.Framework.Controllers;
1718

19+
using Microsoft.Extensions.DependencyInjection;
20+
1821
public class DnnHtmlHelper
1922
{
23+
private readonly IServicesFramework servicesFramework;
24+
2025
/// <summary>Initializes a new instance of the <see cref="DnnHtmlHelper"/> class.</summary>
2126
/// <param name="viewContext">The view context.</param>
2227
/// <param name="viewDataContainer">The ViewData container.</param>
28+
[Obsolete("Deprecated in DotNetNuke 10.2.2. Please use overload with IServicesFramework. Scheduled removal in v12.0.0.")]
2329
public DnnHtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer)
24-
: this(viewContext, viewDataContainer, RouteTable.Routes)
30+
: this(viewContext, viewDataContainer, (IServicesFramework)null)
31+
{
32+
}
33+
34+
/// <summary>Initializes a new instance of the <see cref="DnnHtmlHelper"/> class.</summary>
35+
/// <param name="viewContext">The view context.</param>
36+
/// <param name="viewDataContainer">The ViewData container.</param>
37+
/// <param name="servicesFramework">The web API service framework.</param>
38+
public DnnHtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer, IServicesFramework servicesFramework)
39+
: this(viewContext, viewDataContainer, RouteTable.Routes, servicesFramework)
2540
{
2641
}
2742

2843
/// <summary>Initializes a new instance of the <see cref="DnnHtmlHelper"/> class.</summary>
2944
/// <param name="viewContext">The view context.</param>
3045
/// <param name="viewDataContainer">The ViewData container.</param>
3146
/// <param name="routeCollection">The route collection.</param>
47+
[Obsolete("Deprecated in DotNetNuke 10.2.2. Please use overload with IServicesFramework. Scheduled removal in v12.0.0.")]
3248
public DnnHtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection)
33-
: this(new HtmlHelper(viewContext, viewDataContainer, routeCollection))
49+
: this(viewContext, viewDataContainer, routeCollection, null)
50+
{
51+
}
52+
53+
/// <summary>Initializes a new instance of the <see cref="DnnHtmlHelper"/> class.</summary>
54+
/// <param name="viewContext">The view context.</param>
55+
/// <param name="viewDataContainer">The ViewData container.</param>
56+
/// <param name="routeCollection">The route collection.</param>
57+
/// <param name="servicesFramework">The web API service framework.</param>
58+
public DnnHtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection, IServicesFramework servicesFramework)
59+
: this(new HtmlHelper(viewContext, viewDataContainer, routeCollection), servicesFramework)
3460
{
3561
}
3662

3763
/// <summary>Initializes a new instance of the <see cref="DnnHtmlHelper"/> class.</summary>
3864
/// <param name="htmlHelper">The HtmlHelper to wrap.</param>
65+
[Obsolete("Deprecated in DotNetNuke 10.2.2. Please use overload with IServicesFramework. Scheduled removal in v12.0.0.")]
3966
protected DnnHtmlHelper(HtmlHelper htmlHelper)
67+
: this(htmlHelper, null)
68+
{
69+
}
70+
71+
/// <summary>Initializes a new instance of the <see cref="DnnHtmlHelper"/> class.</summary>
72+
/// <param name="htmlHelper">The HtmlHelper to wrap.</param>
73+
/// <param name="servicesFramework">The web API service framework.</param>
74+
protected DnnHtmlHelper(HtmlHelper htmlHelper, IServicesFramework servicesFramework)
4075
{
76+
this.servicesFramework = servicesFramework ?? Globals.GetCurrentServiceProvider().GetRequiredService<IServicesFramework>();
4177
this.HtmlHelper = htmlHelper;
4278

4379
var controller = htmlHelper.ViewContext.Controller as IDnnController;
@@ -64,10 +100,9 @@ protected DnnHtmlHelper(HtmlHelper htmlHelper)
64100

65101
internal HtmlHelper HtmlHelper { get; set; }
66102

67-
[SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Breaking change")]
68103
public MvcHtmlString AntiForgeryToken()
69104
{
70-
ServicesFramework.Instance.RequestAjaxAntiForgerySupport();
105+
this.servicesFramework.RequestAjaxAntiForgerySupport();
71106
return new MvcHtmlString(string.Empty);
72107
}
73108

DNN Platform/DotNetNuke.Web.Mvc/Helpers/DnnHtmlHelper{TModel}.cs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,49 @@
44

55
namespace DotNetNuke.Web.Mvc.Helpers
66
{
7+
using System;
78
using System.Web.Mvc;
89
using System.Web.Routing;
910

11+
using DotNetNuke.Framework;
12+
1013
public class DnnHtmlHelper<TModel> : DnnHtmlHelper
1114
{
1215
/// <summary>Initializes a new instance of the <see cref="DnnHtmlHelper{TModel}"/> class.</summary>
1316
/// <param name="viewContext">The view context.</param>
1417
/// <param name="viewDataContainer">The ViewData container.</param>
18+
[Obsolete("Deprecated in DotNetNuke 10.2.2. Please use overload with IServicesFramework. Scheduled removal in v12.0.0.")]
1519
public DnnHtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer)
16-
: this(viewContext, viewDataContainer, RouteTable.Routes)
20+
: this(viewContext, viewDataContainer, (IServicesFramework)null)
21+
{
22+
}
23+
24+
/// <summary>Initializes a new instance of the <see cref="DnnHtmlHelper{TModel}"/> class.</summary>
25+
/// <param name="viewContext">The view context.</param>
26+
/// <param name="viewDataContainer">The ViewData container.</param>
27+
/// <param name="servicesFramework">The web API service framework.</param>
28+
public DnnHtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer, IServicesFramework servicesFramework)
29+
: this(viewContext, viewDataContainer, RouteTable.Routes, servicesFramework)
1730
{
1831
}
1932

2033
/// <summary>Initializes a new instance of the <see cref="DnnHtmlHelper{TModel}"/> class.</summary>
2134
/// <param name="viewContext">The view context.</param>
2235
/// <param name="viewDataContainer">The ViewData container.</param>
2336
/// <param name="routeCollection">The route collection.</param>
37+
[Obsolete("Deprecated in DotNetNuke 10.2.2. Please use overload with IServicesFramework. Scheduled removal in v12.0.0.")]
2438
public DnnHtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection)
25-
: base(new HtmlHelper<TModel>(viewContext, viewDataContainer, routeCollection))
39+
: this(viewContext, viewDataContainer, routeCollection, null)
40+
{
41+
}
42+
43+
/// <summary>Initializes a new instance of the <see cref="DnnHtmlHelper{TModel}"/> class.</summary>
44+
/// <param name="viewContext">The view context.</param>
45+
/// <param name="viewDataContainer">The ViewData container.</param>
46+
/// <param name="routeCollection">The route collection.</param>
47+
/// <param name="servicesFramework">The web API service framework.</param>
48+
public DnnHtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection, IServicesFramework servicesFramework)
49+
: base(new HtmlHelper<TModel>(viewContext, viewDataContainer, routeCollection), servicesFramework)
2650
{
2751
}
2852

DNN Platform/DotNetNuke.Web/UI/WebControls/DnnDropDownList.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,25 @@ public class DnnDropDownList : Panel, INamingContainer
3131

3232
private readonly Lazy<DnnDropDownListOptions> options = new Lazy<DnnDropDownListOptions>(() => new DnnDropDownListOptions());
3333
private readonly IClientResourceController clientResourceController;
34+
private readonly IServicesFramework servicesFramework;
3435

3536
private DnnGenericHiddenField<DnnDropDownListState> stateControl;
3637
private HtmlAnchor selectedValue;
3738

3839
/// <summary>Initializes a new instance of the <see cref="DnnDropDownList"/> class.</summary>
3940
[Obsolete("Deprecated in DotNetNuke 10.2.2. Please use overload with IClientResourceController. Scheduled removal in v12.0.0.")]
4041
public DnnDropDownList()
41-
: this(null)
42+
: this(null, null)
4243
{
4344
}
4445

4546
/// <summary>Initializes a new instance of the <see cref="DnnDropDownList"/> class.</summary>
4647
/// <param name="clientResourceController">The client resource controller.</param>
47-
public DnnDropDownList(IClientResourceController clientResourceController)
48+
/// <param name="servicesFramework">The web API service framework.</param>
49+
public DnnDropDownList(IClientResourceController clientResourceController, IServicesFramework servicesFramework)
4850
{
4951
this.clientResourceController = clientResourceController ?? Globals.GetCurrentServiceProvider().GetRequiredService<IClientResourceController>();
52+
this.servicesFramework = servicesFramework ?? Globals.GetCurrentServiceProvider().GetRequiredService<IServicesFramework>();
5053
}
5154

5255
/// <summary>Occurs when the selection from the list control changes between posts to the server.</summary>
@@ -261,7 +264,7 @@ protected override void OnInit(EventArgs e)
261264
{
262265
base.OnInit(e);
263266
this.StateControl.Value = string.Empty; // for state persistence (stateControl)
264-
ServicesFramework.Instance.RequestAjaxAntiForgerySupport();
267+
this.servicesFramework.RequestAjaxAntiForgerySupport();
265268
}
266269

267270
/// <inheritdoc />

DNN Platform/DotNetNuke.Web/UI/WebControls/DnnFileDropDownList.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace DotNetNuke.Web.UI.WebControls
1313
using DotNetNuke.Abstractions.ClientResources;
1414
using DotNetNuke.Common;
1515
using DotNetNuke.Common.Utilities;
16+
using DotNetNuke.Framework;
1617
using DotNetNuke.Services.FileSystem;
1718
using DotNetNuke.Services.Localization;
1819
using DotNetNuke.Web.Common;
@@ -27,14 +28,15 @@ public class DnnFileDropDownList : DnnDropDownList
2728
/// <summary>Initializes a new instance of the <see cref="DnnFileDropDownList"/> class.</summary>
2829
[Obsolete("Deprecated in DotNetNuke 10.2.2. Please use overload with IClientResourceController. Scheduled removal in v12.0.0.")]
2930
public DnnFileDropDownList()
30-
: this(Globals.GetCurrentServiceProvider().GetRequiredService<IClientResourceController>())
31+
: this(Globals.GetCurrentServiceProvider().GetRequiredService<IClientResourceController>(), Globals.GetCurrentServiceProvider().GetRequiredService<IServicesFramework>())
3132
{
3233
}
3334

3435
/// <summary>Initializes a new instance of the <see cref="DnnFileDropDownList"/> class.</summary>
3536
/// <param name="clientResourceController">The client resource controller.</param>
36-
public DnnFileDropDownList(IClientResourceController clientResourceController)
37-
: base(clientResourceController)
37+
/// <param name="servicesFramework">The web API service framework.</param>
38+
public DnnFileDropDownList(IClientResourceController clientResourceController, IServicesFramework servicesFramework)
39+
: base(clientResourceController, servicesFramework)
3840
{
3941
}
4042

0 commit comments

Comments
 (0)