Fix errors caused by changed namespaces
This commit is contained in:
@@ -10,8 +10,7 @@
|
||||
/// </summary>
|
||||
public static class ModelsBuilder
|
||||
{
|
||||
|
||||
public const string DefaultModelsNamespace = "Umbraco.Web.PublishedModels";
|
||||
public const string DefaultModelsNamespace = "Umbraco.Cms.Web.Common.PublishedModels";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,8 +70,8 @@ namespace Umbraco.Cms.Core.IO
|
||||
// either
|
||||
// @inherits Umbraco.Web.Mvc.UmbracoViewPage
|
||||
// @inherits Umbraco.Web.Mvc.UmbracoViewPage<ModelClass>
|
||||
content.AppendLine("@using Umbraco.Web.PublishedModels;");
|
||||
content.Append("@inherits Umbraco.Web.Common.AspNetCore.UmbracoViewPage");
|
||||
content.AppendLine("@using Umbraco.Cms.Web.Common.PublishedModels;");
|
||||
content.Append("@inherits Umbraco.Cms.Web.Common.AspNetCore.UmbracoViewPage");
|
||||
if (modelClassName.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
content.Append("<");
|
||||
|
||||
@@ -2,8 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
|
||||
@@ -28,10 +28,13 @@ namespace Umbraco.Cms.ModelsBuilder.Embedded.Building
|
||||
{
|
||||
"System",
|
||||
"System.Linq.Expressions",
|
||||
"Umbraco.Core.Models.PublishedContent",
|
||||
"Umbraco.Web.PublishedCache",
|
||||
"Umbraco.ModelsBuilder.Embedded",
|
||||
"Umbraco.Cms.Core"
|
||||
"Umbraco.Cms.Core.Models.PublishedContent",
|
||||
"Umbraco.Web.PublishedCache", // Todo: Remove/Edit this once namespaces has been aligned.
|
||||
"Umbraco.Cms.Core.PublishedCache",
|
||||
"Umbraco.Cms.ModelsBuilder.Embedded",
|
||||
"Umbraco.Cms.Core",
|
||||
"Umbraco.Core", // TODO: Remove once namespace is gone, after which BuilderTests needs to be adjusted.
|
||||
"Umbraco.Extensions"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -14,8 +14,8 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Templates
|
||||
{
|
||||
var view = ViewHelper.GetDefaultFileContent();
|
||||
Assert.AreEqual(
|
||||
FixView(@"@using Umbraco.Web.PublishedModels;
|
||||
@inherits Umbraco.Web.Common.AspNetCore.UmbracoViewPage
|
||||
FixView(@"@using Umbraco.Cms.Web.Common.PublishedModels;
|
||||
@inherits Umbraco.Cms.Web.Common.AspNetCore.UmbracoViewPage
|
||||
@{
|
||||
Layout = null;
|
||||
}"), FixView(view));
|
||||
@@ -26,8 +26,8 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Templates
|
||||
{
|
||||
var view = ViewHelper.GetDefaultFileContent(layoutPageAlias: "Dharznoik");
|
||||
Assert.AreEqual(
|
||||
FixView(@"@using Umbraco.Web.PublishedModels;
|
||||
@inherits Umbraco.Web.Common.AspNetCore.UmbracoViewPage
|
||||
FixView(@"@using Umbraco.Cms.Web.Common.PublishedModels;
|
||||
@inherits Umbraco.Cms.Web.Common.AspNetCore.UmbracoViewPage
|
||||
@{
|
||||
Layout = ""Dharznoik.cshtml"";
|
||||
}"), FixView(view));
|
||||
@@ -38,8 +38,8 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Templates
|
||||
{
|
||||
var view = ViewHelper.GetDefaultFileContent(modelClassName: "ClassName");
|
||||
Assert.AreEqual(
|
||||
FixView(@"@using Umbraco.Web.PublishedModels;
|
||||
@inherits Umbraco.Web.Common.AspNetCore.UmbracoViewPage<ClassName>
|
||||
FixView(@"@using Umbraco.Cms.Web.Common.PublishedModels;
|
||||
@inherits Umbraco.Cms.Web.Common.AspNetCore.UmbracoViewPage<ClassName>
|
||||
@{
|
||||
Layout = null;
|
||||
}"), FixView(view));
|
||||
@@ -50,8 +50,8 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Templates
|
||||
{
|
||||
var view = ViewHelper.GetDefaultFileContent(modelNamespace: "Models");
|
||||
Assert.AreEqual(
|
||||
FixView(@"@using Umbraco.Web.PublishedModels;
|
||||
@inherits Umbraco.Web.Common.AspNetCore.UmbracoViewPage
|
||||
FixView(@"@using Umbraco.Cms.Web.Common.PublishedModels;
|
||||
@inherits Umbraco.Cms.Web.Common.AspNetCore.UmbracoViewPage
|
||||
@{
|
||||
Layout = null;
|
||||
}"), FixView(view));
|
||||
@@ -62,8 +62,8 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Templates
|
||||
{
|
||||
var view = ViewHelper.GetDefaultFileContent(modelClassName: "ClassName", modelNamespace: "My.Models");
|
||||
Assert.AreEqual(
|
||||
FixView(@"@using Umbraco.Web.PublishedModels;
|
||||
@inherits Umbraco.Web.Common.AspNetCore.UmbracoViewPage<ContentModels.ClassName>
|
||||
FixView(@"@using Umbraco.Cms.Web.Common.PublishedModels;
|
||||
@inherits Umbraco.Cms.Web.Common.AspNetCore.UmbracoViewPage<ContentModels.ClassName>
|
||||
@using ContentModels = My.Models;
|
||||
@{
|
||||
Layout = null;
|
||||
@@ -75,8 +75,8 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Templates
|
||||
{
|
||||
var view = ViewHelper.GetDefaultFileContent(modelClassName: "ClassName", modelNamespace: "My.Models", modelNamespaceAlias: "MyModels");
|
||||
Assert.AreEqual(
|
||||
FixView(@"@using Umbraco.Web.PublishedModels;
|
||||
@inherits Umbraco.Web.Common.AspNetCore.UmbracoViewPage<MyModels.ClassName>
|
||||
FixView(@"@using Umbraco.Cms.Web.Common.PublishedModels;
|
||||
@inherits Umbraco.Cms.Web.Common.AspNetCore.UmbracoViewPage<MyModels.ClassName>
|
||||
@using MyModels = My.Models;
|
||||
@{
|
||||
Layout = null;
|
||||
@@ -88,8 +88,8 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Templates
|
||||
{
|
||||
var view = ViewHelper.GetDefaultFileContent(layoutPageAlias: "Dharznoik", modelClassName: "ClassName", modelNamespace: "My.Models", modelNamespaceAlias: "MyModels");
|
||||
Assert.AreEqual(
|
||||
FixView(@"@using Umbraco.Web.PublishedModels;
|
||||
@inherits Umbraco.Web.Common.AspNetCore.UmbracoViewPage<MyModels.ClassName>
|
||||
FixView(@"@using Umbraco.Cms.Web.Common.PublishedModels;
|
||||
@inherits Umbraco.Cms.Web.Common.AspNetCore.UmbracoViewPage<MyModels.ClassName>
|
||||
@using MyModels = My.Models;
|
||||
@{
|
||||
Layout = ""Dharznoik.cshtml"";
|
||||
|
||||
@@ -59,12 +59,15 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded
|
||||
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
using Umbraco.ModelsBuilder.Embedded;
|
||||
using Umbraco.Cms.Core.PublishedCache;
|
||||
using Umbraco.Cms.ModelsBuilder.Embedded;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Web.PublishedModels
|
||||
namespace Umbraco.Cms.Web.Common.PublishedModels
|
||||
{
|
||||
[PublishedModel(""type1"")]
|
||||
public partial class Type1 : PublishedContentModel
|
||||
@@ -139,7 +142,7 @@ namespace Umbraco.Web.PublishedModels
|
||||
var modelsBuilderConfig = new ModelsBuilderSettings();
|
||||
var builder = new TextBuilder(modelsBuilderConfig, types)
|
||||
{
|
||||
ModelsNamespace = "Umbraco.Web.PublishedModels"
|
||||
ModelsNamespace = "Umbraco.Cms.Web.Common.PublishedModels"
|
||||
};
|
||||
|
||||
var sb1 = new StringBuilder();
|
||||
@@ -164,12 +167,15 @@ namespace Umbraco.Web.PublishedModels
|
||||
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
using Umbraco.ModelsBuilder.Embedded;
|
||||
using Umbraco.Cms.Core.PublishedCache;
|
||||
using Umbraco.Cms.ModelsBuilder.Embedded;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Web.PublishedModels
|
||||
namespace Umbraco.Cms.Web.Common.PublishedModels
|
||||
{
|
||||
[PublishedModel(""type1"")]
|
||||
public partial class Type1 : PublishedContentModel
|
||||
@@ -265,8 +271,8 @@ namespace Umbraco.Web.PublishedModels
|
||||
|
||||
[TestCase("int", typeof(int))]
|
||||
[TestCase("global::System.Collections.Generic.IEnumerable<int>", typeof(IEnumerable<int>))]
|
||||
[TestCase("global::Umbraco.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.BuilderTestsClass1", typeof(BuilderTestsClass1))]
|
||||
[TestCase("global::Umbraco.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.BuilderTests.Class1", typeof(Class1))]
|
||||
[TestCase("global::Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.BuilderTestsClass1", typeof(BuilderTestsClass1))]
|
||||
[TestCase("global::Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.BuilderTests.Class1", typeof(Class1))]
|
||||
public void WriteClrType(string expected, Type input)
|
||||
{
|
||||
// note - these assertions differ from the original tests in MB because in the embedded version, the result of Builder.IsAmbiguousSymbol is always true
|
||||
@@ -282,14 +288,14 @@ namespace Umbraco.Web.PublishedModels
|
||||
|
||||
[TestCase("int", typeof(int))]
|
||||
[TestCase("global::System.Collections.Generic.IEnumerable<int>", typeof(IEnumerable<int>))]
|
||||
[TestCase("global::Umbraco.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.BuilderTestsClass1", typeof(BuilderTestsClass1))]
|
||||
[TestCase("global::Umbraco.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.BuilderTests.Class1", typeof(Class1))]
|
||||
[TestCase("global::Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.BuilderTestsClass1", typeof(BuilderTestsClass1))]
|
||||
[TestCase("global::Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.BuilderTests.Class1", typeof(Class1))]
|
||||
public void WriteClrTypeUsing(string expected, Type input)
|
||||
{
|
||||
// note - these assertions differ from the original tests in MB because in the embedded version, the result of Builder.IsAmbiguousSymbol is always true
|
||||
// which means global:: syntax will be applied to most things
|
||||
var builder = new TextBuilder();
|
||||
builder.Using.Add("Umbraco.Tests.UnitTests.Umbraco.ModelsBuilder");
|
||||
builder.Using.Add("Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder");
|
||||
builder.ModelsNamespaceForTests = "ModelsNamespace";
|
||||
var sb = new StringBuilder();
|
||||
builder.WriteClrType(sb, input);
|
||||
@@ -357,14 +363,14 @@ namespace Umbraco.Web.PublishedModels
|
||||
{
|
||||
var builder = new TextBuilder();
|
||||
builder.Using.Add("System.Text");
|
||||
builder.Using.Add("Umbraco.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded");
|
||||
builder.Using.Add("Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded");
|
||||
builder.ModelsNamespaceForTests = "SomeRandomNamespace";
|
||||
var sb = new StringBuilder();
|
||||
builder.WriteClrType(sb, typeof(ASCIIEncoding));
|
||||
|
||||
// note - these assertions differ from the original tests in MB because in the embedded version, the result of Builder.IsAmbiguousSymbol is always true
|
||||
// which means global:: syntax will be applied to most things
|
||||
Assert.AreEqual("global::Umbraco.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.ASCIIEncoding", sb.ToString());
|
||||
Assert.AreEqual("global::Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.ASCIIEncoding", sb.ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -372,14 +378,14 @@ namespace Umbraco.Web.PublishedModels
|
||||
{
|
||||
var builder = new TextBuilder();
|
||||
builder.Using.Add("System.Text");
|
||||
builder.Using.Add("Umbraco.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded");
|
||||
builder.ModelsNamespaceForTests = "Umbraco.Tests.UnitTests.Umbraco.ModelsBuilder.Models";
|
||||
builder.Using.Add("Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded");
|
||||
builder.ModelsNamespaceForTests = "Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Models";
|
||||
var sb = new StringBuilder();
|
||||
builder.WriteClrType(sb, typeof(ASCIIEncoding));
|
||||
|
||||
// note - these assertions differ from the original tests in MB because in the embedded version, the result of Builder.IsAmbiguousSymbol is always true
|
||||
// which means global:: syntax will be applied to most things
|
||||
Assert.AreEqual("global::Umbraco.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.ASCIIEncoding", sb.ToString());
|
||||
Assert.AreEqual("global::Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.ASCIIEncoding", sb.ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -387,14 +393,14 @@ namespace Umbraco.Web.PublishedModels
|
||||
{
|
||||
var builder = new TextBuilder();
|
||||
builder.Using.Add("System.Text");
|
||||
builder.Using.Add("Umbraco.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded");
|
||||
builder.Using.Add("Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded");
|
||||
builder.ModelsNamespaceForTests = "SomeRandomNamespace";
|
||||
var sb = new StringBuilder();
|
||||
builder.WriteClrType(sb, typeof(ASCIIEncoding.Nested));
|
||||
|
||||
// note - these assertions differ from the original tests in MB because in the embedded version, the result of Builder.IsAmbiguousSymbol is always true
|
||||
// which means global:: syntax will be applied to most things
|
||||
Assert.AreEqual("global::Umbraco.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.ASCIIEncoding.Nested", sb.ToString());
|
||||
Assert.AreEqual("global::Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.ASCIIEncoding.Nested", sb.ToString());
|
||||
}
|
||||
|
||||
public class Class1
|
||||
|
||||
Reference in New Issue
Block a user