From 5f9447fc2aaf86ac31e782b64820af2244873c7a Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 15 Jan 2021 18:17:13 +1100 Subject: [PATCH] Got a POC working with dynamic recompilation --- .../Models/ModelsBuilderSettings.cs | 11 +- .../BackOffice/DashboardReport.cs | 6 +- .../UmbracoBuilderExtensions.cs | 338 ++++++++++++++---- .../ModelsBuilderNotificationHandler.cs | 7 +- .../PureLiveModelFactory.cs | 107 ++++-- .../RoslynCompiler.cs | 9 +- .../UmbracoAssemblyLoadContext.cs | 13 +- .../PublishedSnapshotService.cs | 11 +- .../AspNetCore/UmbracoViewPage.cs | 11 +- .../UmbracoBuilderExtensions.cs | 2 + .../ModelBinders/ContentModelBinder.cs | 10 +- src/Umbraco.Web.UI.NetCore/Startup.cs | 8 + 12 files changed, 410 insertions(+), 123 deletions(-) diff --git a/src/Umbraco.Core/Configuration/Models/ModelsBuilderSettings.cs b/src/Umbraco.Core/Configuration/Models/ModelsBuilderSettings.cs index bace0f96c4..18f79e5602 100644 --- a/src/Umbraco.Core/Configuration/Models/ModelsBuilderSettings.cs +++ b/src/Umbraco.Core/Configuration/Models/ModelsBuilderSettings.cs @@ -21,12 +21,19 @@ namespace Umbraco.Core.Configuration.Models /// If this is false then absolutely nothing happens. /// Default value is false which means that unless we have this setting, nothing happens. /// - public bool Enable { get; set; } = false; + // TODO: This setting makes no sense at all, this basically just disables haveing models be able to reset dynamically + // and configure some dashboards but the models are all still built and active! + // Can this be truly disabled or not? + // Then there's other ways to disable things - EnableFactory also causes odd flags but again, how can this be disabled? + // The other ways that flags change are ModelsMode. + // TODO: Make these make sense and test what is possible + // Confirmed A) Enabled = false, ModelsMode = Nothing, EnabledFagtory = false == EXPLODES, null refs because these things are needed unless you replace nucache. + public bool Enable { get; set; } = true; /// /// Gets or sets a value for the models mode. /// - public ModelsMode ModelsMode { get; set; } = ModelsMode.Nothing; + public ModelsMode ModelsMode { get; set; } = ModelsMode.PureLive; /// /// Gets or sets a value for models namespace. diff --git a/src/Umbraco.ModelsBuilder.Embedded/BackOffice/DashboardReport.cs b/src/Umbraco.ModelsBuilder.Embedded/BackOffice/DashboardReport.cs index c615559920..6b413ad4a1 100644 --- a/src/Umbraco.ModelsBuilder.Embedded/BackOffice/DashboardReport.cs +++ b/src/Umbraco.ModelsBuilder.Embedded/BackOffice/DashboardReport.cs @@ -1,4 +1,4 @@ -using System.Text; +using System.Text; using Microsoft.Extensions.Options; using Umbraco.Configuration; using Umbraco.Core.Configuration; @@ -41,9 +41,13 @@ namespace Umbraco.ModelsBuilder.Embedded.BackOffice sb.Append("