Models builder: Move InMemoryAuto models builder and razor runtime compilation into its own package to enable hot reload (#20187)
* Move in memory models builder out of core * Move runtime validations into backoffice development project * Obsolete ModelsMode enum * Move the InMemoryModelsbuilder/RRC novel into the Backoffice development umbraco builder extension * Add runtime validator to warn if InMemoryAuto is selected but the package isn't installed * Add backoffice development to template * Remove propertyGroup * Remove oopsie * Check for modelsbuilder in notification handler instead of runtime validator * Update src/Umbraco.Cms.Api.Management/Controllers/ModelsBuilder/BuildModelsBuilderController.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/Umbraco.Infrastructure/Runtime/RuntimeModeValidators/ModelsBuilderModeValidator.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove ModelsMode enum and ModelsModeExtensions * Apply suggestions from code review Co-authored-by: Kenn Jacobsen <kja@umbraco.dk> * Move project to source folder --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Kenn Jacobsen <kja@umbraco.dk>
This commit is contained in:
@@ -4,11 +4,13 @@ using Microsoft.Extensions.Options;
|
||||
using Moq;
|
||||
using NPoco;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Configuration;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.Semver;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
using Umbraco.Cms.DevelopmentMode.Backoffice.InMemoryAuto;
|
||||
using Umbraco.Cms.Infrastructure.Persistence;
|
||||
using Umbraco.Cms.Infrastructure.Telemetry.Providers;
|
||||
|
||||
@@ -90,18 +92,18 @@ public class SystemInformationServiceTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(ModelsMode.Nothing)]
|
||||
[TestCase(ModelsMode.InMemoryAuto)]
|
||||
[TestCase(ModelsMode.SourceCodeAuto)]
|
||||
[TestCase(ModelsMode.SourceCodeManual)]
|
||||
public void ReportsModelsModeCorrectly(ModelsMode modelsMode)
|
||||
[TestCase(Constants.ModelsBuilder.ModelsModes.Nothing)]
|
||||
[TestCase(ModelsModeConstants.InMemoryAuto)]
|
||||
[TestCase(Constants.ModelsBuilder.ModelsModes.SourceCodeAuto)]
|
||||
[TestCase(Constants.ModelsBuilder.ModelsModes.SourceCodeManual)]
|
||||
public void ReportsModelsModeCorrectly(string modelsMode)
|
||||
{
|
||||
var userDataService = CreateSystemInformationService(modelsMode: modelsMode);
|
||||
var userData = userDataService.GetTroubleshootingInformation().ToArray();
|
||||
|
||||
var actual = userData.FirstOrDefault(x => x.Key == "Models Builder Mode");
|
||||
Assert.IsNotNull(actual.Value);
|
||||
Assert.AreEqual(modelsMode.ToString(), actual.Value);
|
||||
Assert.AreEqual(modelsMode, actual.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -133,7 +135,7 @@ public class SystemInformationServiceTests
|
||||
|
||||
private ISystemTroubleshootingInformationService CreateSystemInformationService(
|
||||
string culture = "",
|
||||
ModelsMode modelsMode = ModelsMode.InMemoryAuto,
|
||||
string modelsMode = ModelsModeConstants.InMemoryAuto,
|
||||
bool isDebug = true,
|
||||
RuntimeMode runtimeMode = RuntimeMode.BackofficeDevelopment)
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@ using Umbraco.Cms.Core.Configuration;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
using Umbraco.Cms.DevelopmentMode.Backoffice.InMemoryAuto;
|
||||
using Umbraco.Cms.Infrastructure.Persistence;
|
||||
using Umbraco.Cms.Infrastructure.Telemetry.Providers;
|
||||
|
||||
@@ -18,18 +19,18 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Telemetry;
|
||||
public class SystemTroubleshootingInformationTelemetryProviderTests
|
||||
{
|
||||
[Test]
|
||||
[TestCase(ModelsMode.Nothing)]
|
||||
[TestCase(ModelsMode.InMemoryAuto)]
|
||||
[TestCase(ModelsMode.SourceCodeAuto)]
|
||||
[TestCase(ModelsMode.SourceCodeManual)]
|
||||
public void ReportsModelsModeCorrectly(ModelsMode modelsMode)
|
||||
[TestCase(Constants.ModelsBuilder.ModelsModes.Nothing)]
|
||||
[TestCase(ModelsModeConstants.InMemoryAuto)]
|
||||
[TestCase(Constants.ModelsBuilder.ModelsModes.SourceCodeAuto)]
|
||||
[TestCase(Constants.ModelsBuilder.ModelsModes.SourceCodeManual)]
|
||||
public void ReportsModelsModeCorrectly(string modelsMode)
|
||||
{
|
||||
var telemetryProvider = CreateProvider(modelsMode);
|
||||
var usageInformation = telemetryProvider.GetInformation().ToArray();
|
||||
|
||||
var actual = usageInformation.FirstOrDefault(x => x.Name == Constants.Telemetry.ModelsBuilderMode);
|
||||
Assert.IsNotNull(actual?.Data);
|
||||
Assert.AreEqual(modelsMode.ToString(), actual.Data);
|
||||
Assert.AreEqual(modelsMode, actual.Data);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -93,7 +94,7 @@ public class SystemTroubleshootingInformationTelemetryProviderTests
|
||||
}
|
||||
|
||||
private SystemTroubleshootingInformationTelemetryProvider CreateProvider(
|
||||
ModelsMode modelsMode = ModelsMode.InMemoryAuto,
|
||||
string modelsMode = ModelsModeConstants.InMemoryAuto,
|
||||
bool isDebug = true,
|
||||
string environment = "",
|
||||
RuntimeMode runtimeMode = RuntimeMode.BackofficeDevelopment)
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Umbraco.Cms.DevelopmentMode.Backoffice\Umbraco.Cms.DevelopmentMode.Backoffice.csproj" />
|
||||
<ProjectReference Include="..\Umbraco.Tests.Common\Umbraco.Tests.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user