From cf46a51866b9cee732fd878d60cbd4c88d0b74e4 Mon Sep 17 00:00:00 2001 From: Stephan Date: Wed, 25 Oct 2017 13:23:14 +0200 Subject: [PATCH] Getting NestedContent and ModelsBuilder happy --- build/NuSpecs/UmbracoCms.nuspec | 2 +- build/build-bootstrap.ps1 | 76 +++++++ build/build.ps1 | 205 +++++++++--------- src/SolutionInfo.cs | 2 +- .../Composing/LightInjectExtensions.cs | 4 +- .../Configuration/UmbracoVersion.cs | 2 +- .../Models/PublishedContent/ModelType.cs | 8 +- .../ValueConverters/IntegerValueConverter.cs | 5 + src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 6 +- src/Umbraco.Web.UI/packages.config | 2 +- .../NestedContentPropertyEditor.cs | 16 +- .../NestedContentManyValueConverter.cs | 4 +- .../NestedContentSingleValueConverter.cs | 2 +- .../PublishedCache/NuCache/ContentNode.cs | 13 +- src/umbraco.sln | 18 +- 15 files changed, 228 insertions(+), 137 deletions(-) create mode 100644 build/build-bootstrap.ps1 diff --git a/build/NuSpecs/UmbracoCms.nuspec b/build/NuSpecs/UmbracoCms.nuspec index c06ac853f8..66fa5dda7c 100644 --- a/build/NuSpecs/UmbracoCms.nuspec +++ b/build/NuSpecs/UmbracoCms.nuspec @@ -17,7 +17,7 @@ - + diff --git a/build/build-bootstrap.ps1 b/build/build-bootstrap.ps1 new file mode 100644 index 0000000000..c1b2cb0fbe --- /dev/null +++ b/build/build-bootstrap.ps1 @@ -0,0 +1,76 @@ + + # this script should be dot-sourced into the build.ps1 scripts + # right after the parameters declaration + # ie + # . "$PSScriptRoot\build-bootstrap.ps1" + + # THIS FILE IS DISTRIBUTED AS PART OF UMBRACO.BUILD + # DO NOT MODIFY IT - ALWAYS USED THE COMMON VERSION + + # ################################################################ + # BOOTSTRAP + # ################################################################ + + # reset errors + $error.Clear() + + # ensure we have temp folder for downloads + $scriptRoot = "$PSScriptRoot" + $scriptTemp = "$scriptRoot\temp" + if (-not (test-path $scriptTemp)) { mkdir $scriptTemp > $null } + + # get NuGet + $cache = 4 + $nuget = "$scriptTemp\nuget.exe" + if (-not $local) + { + $source = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" + if ((test-path $nuget) -and ((ls $nuget).CreationTime -lt [DateTime]::Now.AddDays(-$cache))) + { + Remove-Item $nuget -force -errorAction SilentlyContinue > $null + } + if (-not (test-path $nuget)) + { + Write-Host "Download NuGet..." + Invoke-WebRequest $source -OutFile $nuget + if (-not $?) { throw "Failed to download NuGet." } + } + } + elseif (-not (test-path $nuget)) + { + throw "Failed to locate NuGet.exe." + } + + # get the build system + if (-not $local) + { + $solutionRoot = "$scriptRoot\.." + $nugetConfig = @{$true="$solutionRoot\src\NuGet.config.user";$false="$solutionRoot\src\NuGet.config"}[(test-path "$solutionRoot\src\NuGet.config.user")] + &$nuget install Umbraco.Build -OutputDirectory $scriptTemp -Verbosity quiet -PreRelease -ConfigFile $nugetConfig + if (-not $?) { throw "Failed to download Umbraco.Build." } + } + + # ensure we have the build system + $ubuildPath = ls "$scriptTemp\Umbraco.Build.*" | sort -property CreationTime -descending | select -first 1 + if (-not $ubuildPath) + { + throw "Failed to locate the build system." + } + + # boot the build system + # this creates $global:ubuild + return &"$ubuildPath\ps\Boot.ps1" + + # at that point the build.ps1 script must boot the build system + # eg + # $ubuild.Boot($ubuildPath.FullName, [System.IO.Path]::GetFullPath("$scriptRoot\.."), + # @{ Local = $local; With7Zip = $false; WithNode = $false }, + # @{ continue = $continue }) + # if (-not $?) { throw "Failed to boot the build system." } + # + # and it's good practice to report + # eg + # Write-Host "Umbraco.Whatever Build" + # Write-Host "Umbraco.Build v$($ubuild.BuildVersion)" + + # eof \ No newline at end of file diff --git a/build/build.ps1 b/build/build.ps1 index 84e35ca7af..ba48a834c0 100644 --- a/build/build.ps1 +++ b/build/build.ps1 @@ -1,11 +1,11 @@ param ( - # load but don't execute + # get, don't execute [Parameter(Mandatory=$false)] - [Alias("n")] - [switch] $nop = $false, + [Alias("g")] + [switch] $get = $false, - # run local - don't download, assume everything is ready + # run local, don't download, assume everything is ready [Parameter(Mandatory=$false)] [Alias("l")] [Alias("loc")] @@ -13,74 +13,31 @@ # keep the build directories, don't clear them [Parameter(Mandatory=$false)] - [Alias("k")] - [Alias("keep")] - [switch] $keepBuildDirs = $false + [Alias("c")] + [Alias("cont")] + [switch] $continue = $false ) - Write-Host "Umbraco.Cms Build" - # ################################################################ # BOOTSTRAP # ################################################################ - # ensure we have temp folder for downloads - $scriptRoot = "$PSScriptRoot" - $scriptTemp = "$scriptRoot\temp" - if (-not (test-path $scriptTemp)) { mkdir $scriptTemp > $null } - - # get NuGet - $cache = 4 - $nuget = "$scriptTemp\nuget.exe" - if (-not $local) - { - $source = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" - if ((test-path $nuget) -and ((ls $nuget).CreationTime -lt [DateTime]::Now.AddDays(-$cache))) - { - Remove-Item $nuget -force -errorAction SilentlyContinue > $null - } - if (-not (test-path $nuget)) - { - Write-Host "Download NuGet..." - Invoke-WebRequest $source -OutFile $nuget - if (-not $?) { throw "Failed to download NuGet." } - } - } - elseif (-not (test-path $nuget)) - { - throw "Failed to locate NuGet.exe." - } - - # get the build system - if (-not $local) - { - $solutionRoot = "$scriptRoot\.." - $nugetConfig = @{$true="$solutionRoot\src\NuGet.config.user";$false="$solutionRoot\src\NuGet.config"}[(test-path "$solutionRoot\src\NuGet.config.user")] - &$nuget install Umbraco.Build -OutputDirectory $scriptTemp -Verbosity quiet -PreRelease -ConfigFile $nugetConfig - if (-not $?) { throw "Failed to download Umbraco.Build." } - } - - # ensure we have the build system - $ubuildPath = ls "$scriptTemp\Umbraco.Build.*" | sort -property CreationTime -descending | select -first 1 - if (-not $ubuildPath) - { - throw "Failed to locate the build system." - } - - # boot the build system - # this creates $global:ubuild - &"$ubuildPath\ps\Boot.ps1" - $ubuild.Boot($ubuildPath.FullName, [System.IO.Path]::GetFullPath("$scriptRoot\.."), + # create and boot the buildsystem + $ubuild = &"$PSScriptRoot\build-bootstrap.ps1" + if (-not $?) { return } + $ubuild.Boot($PSScriptRoot, @{ Local = $local; }, - @{ KeepBuildDirs = $keepBuildDirs }) - if (-not $?) { throw "Failed to boot the build system." } + @{ Continue = $continue }) + if ($ubuild.OnError()) { return } + + Write-Host "Zbu.ModelsBuilder Build" Write-Host "Umbraco.Build v$($ubuild.BuildVersion)" # ################################################################ # TASKS # ################################################################ - $ubuild | Add-Member -MemberType ScriptMethod SetMoreUmbracoVersion -value ` + $ubuild.DefineMethod("SetMoreUmbracoVersion", { param ( $semver ) @@ -98,9 +55,9 @@ $updater = New-Object "Umbraco.Build.ExpressPortUpdater" $csproj = "$($this.SolutionRoot)\src\Umbraco.Web.UI\Umbraco.Web.UI.csproj" $updater.Update($csproj, $release) - } + }) - $ubuild | Add-Member -MemberType ScriptMethod SandboxNode -value ` + $ubuild.DefineMethod("SandboxNode", { $global:node_path = $env:path $nodePath = $this.BuildEnv.NodePath @@ -111,18 +68,18 @@ $global:node_nodepath = $this.ClearEnvVar("NODEPATH") $global:node_npmcache = $this.ClearEnvVar("NPM_CONFIG_CACHE") $global:node_npmprefix = $this.ClearEnvVar("NPM_CONFIG_PREFIX") - } + }) - $ubuild | Add-Member -MemberType ScriptMethod RestoreNode -value ` + $ubuild.DefineMethod("RestoreNode", { $env:path = $node_path $this.SetEnvVar("NODEPATH", $node_nodepath) $this.SetEnvVar("NPM_CONFIG_CACHE", $node_npmcache) $this.SetEnvVar("NPM_CONFIG_PREFIX", $node_npmprefix) - } + }) - $ubuild | Add-Member -MemberType ScriptMethod CompileBelle -value ` + $ubuild.DefineMethod("CompileBelle", { $src = "$($this.SolutionRoot)\src" $log = "$($this.BuildTemp)\belle.log" @@ -133,24 +90,45 @@ # get a temp clean node env (will restore) $this.SandboxNode() - Push-Location "$($uenv.SolutionRoot)\src\Umbraco.Web.UI.Client" + # stupid PS is going to gather all "warnings" in $error + # so we have to take care of it else they'll bubble and kill the build + if ($error.Count -gt 0) { return } + + Push-Location "$($this.SolutionRoot)\src\Umbraco.Web.UI.Client" Write-Output "" > $log - Write-Output "node version is:" > $log + + Write-Output "### node version is:" > $log &node -v >> $log 2>&1 - Write-Output "npm version is:" >> $log 2>&1 + if (-not $?) { throw "Failed to report node version." } + + Write-Output "### npm version is:" >> $log 2>&1 &npm -v >> $log 2>&1 - Write-Output "clean npm cache" >> $log 2>&1 + if (-not $?) { throw "Failed to report npm version." } + + Write-Output "### clean npm cache" >> $log 2>&1 &npm cache clean >> $log 2>&1 - Write-Output "npm install" >> $log 2>&1 + $error.Clear() # that one can fail 'cos security bug - ignore + + Write-Output "### npm install" >> $log 2>&1 &npm install >> $log 2>&1 - Write-Output "install bower" >> $log 2>&1 + Write-Output ">> $? $($error.Count)" >> $log 2>&1 + + Write-Output "### install bower" >> $log 2>&1 &npm install -g bower >> $log 2>&1 - Write-Output "install gulp" >> $log 2>&1 + $error.Clear() # that one fails 'cos bower is deprecated - ignore + + Write-Output "### install gulp" >> $log 2>&1 &npm install -g gulp >> $log 2>&1 - Write-Output "install gulp-cli" >> $log 2>&1 + $error.Clear() # that one fails 'cos deprecated stuff - ignore + + Write-Output "### nstall gulp-cli" >> $log 2>&1 &npm install -g gulp-cli --quiet >> $log 2>&1 - Write-Output "gulp build for version $($this.Version.Release)" >> $log 2>&1 + if (-not $?) { throw "Failed to install gulp-cli" } # that one is expected to work + + Write-Output "### gulp build for version $($this.Version.Release)" >> $log 2>&1 &gulp build --buildversion=$this.Version.Release >> $log 2>&1 + if (-not $?) { throw "Failed to build" } # that one is expected to work + Pop-Location # fixme - should we filter the log to find errors? @@ -167,9 +145,9 @@ Write-Host "Set hidden attribute on node_modules" $dir = Get-Item -force "$src\Umbraco.Web.UI.Client\node_modules" $dir.Attributes = $dir.Attributes -bor ([System.IO.FileAttributes]::Hidden) - } + }) - $ubuild | Add-Member -MemberType ScriptMethod CompileUmbraco -value ` + $ubuild.DefineMethod("CompileUmbraco", { $buildConfiguration = "Release" @@ -222,9 +200,9 @@ if (-not $?) { throw "Failed to compile Umbraco.Compat7." } # /p:UmbracoBuild tells the csproj that we are building from PS, not VS - } + }) - $ubuild | Add-Member -MemberType ScriptMethod PrepareTests -value ` + $ubuild.DefineMethod("PrepareTests", { Write-Host "Prepare Tests" @@ -248,9 +226,9 @@ Write-Host "Create bin directory" mkdir "$($this.BuildTemp)\tests\bin" > $null } - } + }) - $ubuild | Add-Member -MemberType ScriptMethod CompileTests -value ` + $ubuild.DefineMethod("CompileTests", { $buildConfiguration = "Release" $log = "$($this.BuildTemp)\msbuild.tests.log" @@ -282,9 +260,9 @@ if (-not $?) { throw "Failed to compile tests." } # /p:UmbracoBuild tells the csproj that we are building from PS - } + }) - $ubuild | Add-Member -MemberType ScriptMethod PreparePackages -value ` + $ubuild.DefineMethod("PreparePackages", { Write-Host "Prepare Packages" @@ -359,9 +337,9 @@ mkdir "$tmp\WebPi\umbraco" > $null $this.CopyFiles("$tmp\WebApp", "*", "$tmp\WebPi\umbraco") $this.CopyFiles("$src\WebPi", "*", "$tmp\WebPi") - } + }) - $ubuild | Add-Member -MemberType ScriptMethod PackageZip -value ` + $ubuild.DefineMethod("PackageZip", { Write-Host "Create Zip packages" @@ -394,9 +372,9 @@ Write-Host "Hash WebPI" $hash = $this.GetFileHash("$out\UmbracoCms.WebPI.$($this.Version.Semver).zip") Write-Output $hash | out-file "$out\webpihash.txt" -encoding ascii - } + }) - $ubuild | Add-Member -MemberType ScriptMethod PrepareBuild -value ` + $ubuild.DefineMethod("PrepareBuild", { Write-Host "Clear folders and files" $this.RemoveDirectory("$($this.SolutionRoot)\src\Umbraco.Web.UI.Client\bower_components") @@ -404,9 +382,9 @@ $this.TempStoreFile("$($this.SolutionRoot)\src\Umbraco.Web.UI\web.config") Write-Host "Create clean web.config" $this.CopyFile("$($this.SolutionRoot)\src\Umbraco.Web.UI\web.Template.config", "$($this.SolutionRoot)\src\Umbraco.Web.UI\web.config") - } + }) - $ubuild | Add-Member -MemberType ScriptMethod PrepareNuGet -value ` + $ubuild.DefineMethod("PrepareNuGet", { Write-Host "Prepare NuGet" @@ -416,17 +394,17 @@ # fixme - that one does not exist in .bat build either? #mv "$($this.BuildTemp)\WebApp\Xslt\Web.config" "$($this.BuildTemp)\WebApp\Xslt\Web.config.transform" - } + }) - $ubuild | Add-Member -MemberType ScriptMethod RestoreNuGet -value ` + $ubuild.DefineMethod("RestoreNuGet", { Write-Host "Restore NuGet" Write-Host "Logging to $($this.BuildTemp)\nuget.restore.log" &$this.BuildEnv.NuGet restore "$($this.SolutionRoot)\src\Umbraco.sln" -ConfigFile $this.BuildEnv.NuGetConfig > "$($this.BuildTemp)\nuget.restore.log" if (-not $?) { throw "Failed to restore NuGet packages." } - } + }) - $ubuild | Add-Member -MemberType ScriptMethod PackageNuGet -value ` + $ubuild.DefineMethod("PackageNuGet", { $nuspecs = "$($this.SolutionRoot)\build\NuSpecs" @@ -440,19 +418,19 @@ &$this.BuildEnv.NuGet Pack "$nuspecs\UmbracoCms.Core.nuspec" ` -Properties BuildTmp="$($this.BuildTemp)" ` -Version "$($this.Version.Semver.ToString())" ` - -Symbols -Verbosity quiet -outputDirectory "$($this.BuildOutput)" + -Symbols -Verbosity detailed -outputDirectory "$($this.BuildOutput)" > "$($this.BuildTemp)\nupack.cmscore.log" if (-not $?) { throw "Failed to pack NuGet UmbracoCms.Core." } &$this.BuildEnv.NuGet Pack "$nuspecs\UmbracoCms.nuspec" ` -Properties BuildTmp="$($this.BuildTemp)" ` -Version $this.Version.Semver.ToString() ` - -Verbosity quiet -outputDirectory "$($this.BuildOutput)" + -Verbosity detailed -outputDirectory "$($this.BuildOutput)" > "$($this.BuildTemp)\nupack.cms.log" if (-not $?) { throw "Failed to pack NuGet UmbracoCms." } &$this.BuildEnv.NuGet Pack "$nuspecs\UmbracoCms.Compat7.nuspec" ` -Properties BuildTmp="$($this.BuildTemp)" ` -Version $this.Version.Semver.ToString() ` - -Verbosity quiet -outputDirectory "$($this.BuildOutput)" + -Verbosity detailed -outputDirectory "$($this.BuildOutput)" > "$($this.BuildTemp)\nupack.compat7.log" if (-not $?) { throw "Failed to pack NuGet UmbracoCms.Compat7." } # run hook @@ -462,25 +440,42 @@ $this.PostPackageNuGet(); if (-not $?) { throw "Failed to run hook." } } - } + }) - $ubuild | Add-Member -MemberType ScriptMethod Build -value ` + $ubuild.DefineMethod("VerifyNuGet", + { + $this.VerifyNuGetConsistency( + ("UmbracoCms", "UmbracoCms.Core", "UmbracoCms.Compat7"), + ("Umbraco.Core", "Umbraco.Web", "Umbraco.Web.UI", "Umbraco.Examine", "Umbraco.Compat7")) + if ($this.OnError()) { return } + }) + + $ubuild.DefineMethod("Build", { $this.PrepareBuild() + if ($this.OnError()) { return } $this.RestoreNuGet() + if ($this.OnError()) { return } $this.CompileBelle() + if ($this.OnError()) { return } $this.CompileUmbraco() + if ($this.OnError()) { return } $this.PrepareTests() + if ($this.OnError()) { return } $this.CompileTests() + if ($this.OnError()) { return } # not running tests $this.PreparePackages() + if ($this.OnError()) { return } $this.PackageZip() - $this.VerifyNuGet( - ("UmbracoCms", "UmbracoCms.Core", "UmbracoCms.Compat7"), - ("Umbraco.Core", "Umbraco.Web", "Umbraco.Web.UI", "Umbraco.Examine", "Umbraco.Compat7")) + if ($this.OnError()) { return } + $this.VerifyNuGet() + if ($this.OnError()) { return } $this.PrepareNuGet() + if ($this.OnError()) { return } $this.PackageNuGet() - } + if ($this.OnError()) { return } + }) # ################################################################ # RUN @@ -490,6 +485,10 @@ $ubuild.ReleaseBranches = @( "master" ) # run - if (-not $nop) { $ubuild.Build() } + if (-not $get) + { + $ubuild.Build() + if ($ubuild.OnError()) { return } + } Write-Host "Done" - if ($nop) { return $ubuild } + if ($get) { return $ubuild } diff --git a/src/SolutionInfo.cs b/src/SolutionInfo.cs index fd1ed4a277..982b1d7652 100644 --- a/src/SolutionInfo.cs +++ b/src/SolutionInfo.cs @@ -17,4 +17,4 @@ using System.Resources; // these are FYI and changed automatically [assembly: AssemblyFileVersion("8.0.0")] -[assembly: AssemblyInformationalVersion("8.0.0-alpha.27")] +[assembly: AssemblyInformationalVersion("8.0.0-alpha.28")] diff --git a/src/Umbraco.Core/Composing/LightInjectExtensions.cs b/src/Umbraco.Core/Composing/LightInjectExtensions.cs index db713a4be5..952dcd5f48 100644 --- a/src/Umbraco.Core/Composing/LightInjectExtensions.cs +++ b/src/Umbraco.Core/Composing/LightInjectExtensions.cs @@ -10,14 +10,14 @@ namespace Umbraco.Core.Composing /// /// Provides extensions to LightInject. /// - internal static class LightInjectExtensions + public static class LightInjectExtensions { /// /// Configure the container for Umbraco Core usage and assign to Current. /// /// The container. /// The container is now the unique application container and is now accessible via Current.Container. - public static void ConfigureUmbracoCore(this ServiceContainer container) + internal static void ConfigureUmbracoCore(this ServiceContainer container) { // supports annotated constructor injections // eg to specify the service name on some services diff --git a/src/Umbraco.Core/Configuration/UmbracoVersion.cs b/src/Umbraco.Core/Configuration/UmbracoVersion.cs index 1d0c37aa84..d40c4430fd 100644 --- a/src/Umbraco.Core/Configuration/UmbracoVersion.cs +++ b/src/Umbraco.Core/Configuration/UmbracoVersion.cs @@ -21,7 +21,7 @@ namespace Umbraco.Core.Configuration /// /// Gets the version comment of the executing code (eg "beta"). /// - public static string CurrentComment => "alpha.27"; + public static string CurrentComment => "alpha.28"; /// /// Gets the assembly version of Umbraco.Code.dll. diff --git a/src/Umbraco.Core/Models/PublishedContent/ModelType.cs b/src/Umbraco.Core/Models/PublishedContent/ModelType.cs index 3589643926..c784449523 100644 --- a/src/Umbraco.Core/Models/PublishedContent/ModelType.cs +++ b/src/Umbraco.Core/Models/PublishedContent/ModelType.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Reflection; +using Umbraco.Core.Exceptions; namespace Umbraco.Core.Models.PublishedContent { @@ -19,6 +20,7 @@ namespace Umbraco.Core.Models.PublishedContent { private ModelType(string contentTypeAlias) { + if (string.IsNullOrWhiteSpace(contentTypeAlias)) throw new ArgumentNullOrEmptyException(nameof(contentTypeAlias)); ContentTypeAlias = contentTypeAlias; Name = "{" + ContentTypeAlias + "}"; } @@ -227,10 +229,12 @@ namespace Umbraco.Core.Models.PublishedContent public override Guid GUID { get; } = Guid.NewGuid(); /// - public override Module Module => throw new NotSupportedException(); + //public override Module Module => throw new NotSupportedException(); + public override Module Module => GetType().Module; /// - public override Assembly Assembly => throw new NotSupportedException(); + //public override Assembly Assembly => throw new NotSupportedException(); + public override Assembly Assembly => GetType().Assembly; /// public override string FullName => Name; diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs index 51405f5132..c9ca2e4fcf 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs @@ -27,6 +27,11 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters return (int.TryParse(sourceString, out i)) ? i : 0; } + // in json an integer comes back as Int64 + // ignore overflows ;( + if (source is long) + return Convert.ToInt32(source); + // in the database an integer is an integer // default value is zero return (source is int) ? source : 0; diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index 1116d3a2cf..13a24d8c09 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -151,8 +151,8 @@ ..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll True - - ..\packages\Umbraco.ModelsBuilder.8.0.0-alpha0009\lib\Umbraco.ModelsBuilder.dll + + ..\packages\Umbraco.ModelsBuilder.8.0.0-alpha.11\lib\Umbraco.ModelsBuilder.dll @@ -1049,7 +1049,7 @@ xcopy "$(ProjectDir)"..\packages\SqlServerCE.4.0.0.1\x86\*.* "$(TargetDir)x86\" - + diff --git a/src/Umbraco.Web.UI/packages.config b/src/Umbraco.Web.UI/packages.config index 5f30038bc9..373055df2c 100644 --- a/src/Umbraco.Web.UI/packages.config +++ b/src/Umbraco.Web.UI/packages.config @@ -81,5 +81,5 @@ - + \ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/NestedContentPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/NestedContentPropertyEditor.cs index b35a63705c..1b76f98a26 100644 --- a/src/Umbraco.Web/PropertyEditors/NestedContentPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/NestedContentPropertyEditor.cs @@ -92,12 +92,22 @@ namespace Umbraco.Web.PropertyEditors public class DataTypeConfiguration { - public string[] ContentTypes { get; set; } + public NestedContentType[] ContentTypes { get; set; } public int? MinItems { get; set; } public int? MaxItems { get; set; } public bool ConfirmDeletes { get; set; } public bool ShowIcons { get; set; } public bool HideLabel { get; set; } + + public class NestedContentType + { + [JsonProperty("ncAlias")] + public string Alias { get; set; } + [JsonProperty("ncTabAlias")] + public string Tab { get; set; } + [JsonProperty("nameTemplate")] + public string Template { get; set; } + } } public override object MapDataTypeConfiguration(PreValueCollection preValues) @@ -105,7 +115,9 @@ namespace Umbraco.Web.PropertyEditors var d = preValues.PreValuesAsDictionary; return new DataTypeConfiguration { - ContentTypes = d.TryGetValue("contentTypes", out var preValue) ? preValue.Value.Split(',') : Array.Empty(), + ContentTypes = d.TryGetValue("contentTypes", out var preValue) + ? JsonConvert.DeserializeObject(preValue.Value) + : Array.Empty(), MinItems = d.TryGetValue("minItems", out preValue) && int.TryParse(preValue.Value, out var minItems) ? (int?) minItems : null, MaxItems = d.TryGetValue("maxItems", out preValue) && int.TryParse(preValue.Value, out var maxItems) ? (int?) maxItems : null, ConfirmDeletes = d.TryGetValue("confirmDeletes", out preValue) && preValue.Value == "1", diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentManyValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentManyValueConverter.cs index fabca03e98..fed8d81cdf 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentManyValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentManyValueConverter.cs @@ -37,7 +37,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters var contentTypes = propertyType.DataType.GetConfiguration().ContentTypes; return contentTypes.Length > 1 ? typeof (IEnumerable) - : typeof (IEnumerable<>).MakeGenericType(ModelType.For(contentTypes[0])); + : typeof (IEnumerable<>).MakeGenericType(ModelType.For(contentTypes[0].Alias)); } /// @@ -65,7 +65,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters var contentTypes = propertyType.DataType.GetConfiguration().ContentTypes; var elements = contentTypes.Length > 1 ? new List() - : PublishedModelFactory.CreateModelList(contentTypes[0]); + : PublishedModelFactory.CreateModelList(contentTypes[0].Alias); foreach (var sourceObject in objects) { diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentSingleValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentSingleValueConverter.cs index c0ad9fb519..4e522bd249 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentSingleValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentSingleValueConverter.cs @@ -36,7 +36,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters var contentTypes = propertyType.DataType.GetConfiguration().ContentTypes; return contentTypes.Length > 1 ? typeof(IPublishedElement) - : ModelType.For(contentTypes[0]); + : ModelType.For(contentTypes[0].Alias); } /// diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentNode.cs b/src/Umbraco.Web/PublishedCache/NuCache/ContentNode.cs index 24311c3876..7b08644882 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/ContentNode.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/ContentNode.cs @@ -132,6 +132,7 @@ namespace Umbraco.Web.PublishedCache.NuCache public readonly int CreatorId; // draft and published version (either can be null, but not both) + // are models not direct PublishedContent instances public IPublishedContent Draft; public IPublishedContent Published; @@ -142,13 +143,21 @@ namespace Umbraco.Web.PublishedCache.NuCache public ContentNodeKit ToKit() { + var draft = Draft is PublishedContentModel draftModel + ? (PublishedContent) draftModel.Unwrap() + : (PublishedContent) Draft; + + var published = Published is PublishedContentModel publishedModel + ? (PublishedContent) publishedModel.Unwrap() + : (PublishedContent) Published; + return new ContentNodeKit { Node = this, ContentTypeId = ContentType.Id, - DraftData = ((PublishedContent) Draft)?._contentData, - PublishedData = ((PublishedContent) Published)?._contentData + DraftData = draft?._contentData, + PublishedData = published?._contentData }; } } diff --git a/src/umbraco.sln b/src/umbraco.sln index a867f8a973..c2b0b85d68 100644 --- a/src/umbraco.sln +++ b/src/umbraco.sln @@ -1,12 +1,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.27004.2002 +VisualStudioVersion = 15.0.27004.2005 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Web.UI", "Umbraco.Web.UI\Umbraco.Web.UI.csproj", "{4C4C194C-B5E4-4991-8F87-4373E24CC19F}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{2849E9D4-3B4E-40A3-A309-F3CB4F0E125F}" ProjectSection(SolutionItems) = preProject - ..\build\build.md = ..\build\build.md ..\build\build.ps1 = ..\build\build.ps1 ..\build\BuildDocs.ps1 = ..\build\BuildDocs.ps1 ..\build\RevertToCleanInstall.bat = ..\build\RevertToCleanInstall.bat @@ -17,6 +16,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{2849E9D4 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{FD962632-184C-4005-A5F3-E705D92FC645}" ProjectSection(SolutionItems) = preProject + ..\BUILD.md = ..\BUILD.md ..\apidocs\docfx.filter.yml = ..\apidocs\docfx.filter.yml ..\apidocs\docfx.json = ..\apidocs\docfx.json ..\apidocs\index.md = ..\apidocs\index.md @@ -88,18 +88,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Tests.Benchmarks", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Compat7", "Umbraco.Compat7\Umbraco.Compat7.csproj", "{185E098F-5706-4B97-B404-EB974F05F633}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{460C4687-9209-4100-AAB0-82867B592FDC}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Umbraco.Build", "Umbraco.Build", "{F80CA2F0-168E-4364-AB75-A27DDD58643D}" - ProjectSection(SolutionItems) = preProject - ..\build\Modules\Umbraco.Build\Get-UmbracoBuildEnv.ps1 = ..\build\Modules\Umbraco.Build\Get-UmbracoBuildEnv.ps1 - ..\build\Modules\Umbraco.Build\Get-UmbracoVersion.ps1 = ..\build\Modules\Umbraco.Build\Get-UmbracoVersion.ps1 - ..\build\Modules\Umbraco.Build\Get-VisualStudio.ps1 = ..\build\Modules\Umbraco.Build\Get-VisualStudio.ps1 - ..\build\Modules\Umbraco.Build\Set-UmbracoVersion.ps1 = ..\build\Modules\Umbraco.Build\Set-UmbracoVersion.ps1 - ..\build\Modules\Umbraco.Build\Umbraco.Build.psm1 = ..\build\Modules\Umbraco.Build\Umbraco.Build.psm1 - ..\build\Modules\Umbraco.Build\Utilities.ps1 = ..\build\Modules\Umbraco.Build\Utilities.ps1 - EndProjectSection -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -146,8 +134,6 @@ Global {E3F9F378-AFE1-40A5-90BD-82833375DBFE} = {227C3B55-80E5-4E7E-A802-BE16C5128B9D} {5B03EF4E-E0AC-4905-861B-8C3EC1A0D458} = {227C3B55-80E5-4E7E-A802-BE16C5128B9D} {86DEB346-089F-4106-89C8-D852B9CF2A33} = {B5BD12C1-A454-435E-8A46-FF4A364C0382} - {460C4687-9209-4100-AAB0-82867B592FDC} = {2849E9D4-3B4E-40A3-A309-F3CB4F0E125F} - {F80CA2F0-168E-4364-AB75-A27DDD58643D} = {460C4687-9209-4100-AAB0-82867B592FDC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7A0F2E34-D2AF-4DAB-86A0-7D7764B3D0EC}