v16: Start removing scope references (#18074)
* Start removing scope references * Update src/Umbraco.Infrastructure/Examine/UmbracoIndexConfig.cs Co-authored-by: Andy Butland <abutland73@gmail.com> * Make test-only ctor internal * Fix tests * Dont treat warnings as errors * Disable package validation, as this is a major --------- Co-authored-by: Andy Butland <abutland73@gmail.com>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
<Nullable>enable</Nullable>
|
||||
<WarningsAsErrors>nullable</WarningsAsErrors>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
|
||||
@@ -40,7 +40,7 @@
|
||||
<!-- Package Validation -->
|
||||
<PropertyGroup>
|
||||
<GenerateCompatibilitySuppressionFile>false</GenerateCompatibilitySuppressionFile>
|
||||
<EnablePackageValidation>true</EnablePackageValidation>
|
||||
<EnablePackageValidation>false</EnablePackageValidation>
|
||||
<PackageValidationBaselineVersion>15.0.0</PackageValidationBaselineVersion>
|
||||
<EnableStrictModeForCompatibleFrameworksInPackage>true</EnableStrictModeForCompatibleFrameworksInPackage>
|
||||
<EnableStrictModeForCompatibleTfms>true</EnableStrictModeForCompatibleTfms>
|
||||
|
||||
@@ -15,20 +15,19 @@ public class ContentValueSetValidator : ValueSetValidator, IContentValueSetValid
|
||||
private const string PathKey = "path";
|
||||
private static readonly IEnumerable<string> ValidCategories = new[] { IndexTypes.Content, IndexTypes.Media };
|
||||
private readonly IPublicAccessService? _publicAccessService;
|
||||
private readonly IScopeProvider? _scopeProvider;
|
||||
private readonly Scoping.IScopeProvider? _scopeProvider;
|
||||
|
||||
// used for tests
|
||||
public ContentValueSetValidator(bool publishedValuesOnly, int? parentId = null, IEnumerable<string>? includeItemTypes = null, IEnumerable<string>? excludeItemTypes = null)
|
||||
: this(publishedValuesOnly, true, null, null, parentId, includeItemTypes, excludeItemTypes, null, null)
|
||||
internal ContentValueSetValidator(bool publishedValuesOnly, int? parentId = null, IEnumerable<string>? includeItemTypes = null, IEnumerable<string>? excludeItemTypes = null)
|
||||
: this(publishedValuesOnly, true, null, null, parentId, includeItemTypes, excludeItemTypes)
|
||||
{
|
||||
}
|
||||
|
||||
[Obsolete("Use the overload accepting includeFields and excludeFields instead. This overload will be removed in Umbraco 14.")]
|
||||
public ContentValueSetValidator(
|
||||
bool publishedValuesOnly,
|
||||
bool supportProtectedContent,
|
||||
IPublicAccessService? publicAccessService,
|
||||
IScopeProvider? scopeProvider,
|
||||
Scoping.IScopeProvider? scopeProvider,
|
||||
int? parentId,
|
||||
IEnumerable<string>? includeItemTypes,
|
||||
IEnumerable<string>? excludeItemTypes)
|
||||
@@ -41,26 +40,6 @@ public class ContentValueSetValidator : ValueSetValidator, IContentValueSetValid
|
||||
_scopeProvider = scopeProvider;
|
||||
}
|
||||
|
||||
[Obsolete("This constructor is obsolete, the IScopeProvider will change to Infrastructure.Scoping.ScopeProvider instead, this will be removed in Umbraco 14.")]
|
||||
public ContentValueSetValidator(
|
||||
bool publishedValuesOnly,
|
||||
bool supportProtectedContent,
|
||||
IPublicAccessService? publicAccessService,
|
||||
IScopeProvider? scopeProvider,
|
||||
int? parentId = null,
|
||||
IEnumerable<string>? includeItemTypes = null,
|
||||
IEnumerable<string>? excludeItemTypes = null,
|
||||
IEnumerable<string>? includeFields = null,
|
||||
IEnumerable<string>? excludeFields = null)
|
||||
: base(includeItemTypes, excludeItemTypes, includeFields, excludeFields)
|
||||
{
|
||||
PublishedValuesOnly = publishedValuesOnly;
|
||||
SupportProtectedContent = supportProtectedContent;
|
||||
ParentId = parentId;
|
||||
_publicAccessService = publicAccessService;
|
||||
_scopeProvider = scopeProvider;
|
||||
}
|
||||
|
||||
protected override IEnumerable<string> ValidIndexCategories => ValidCategories;
|
||||
|
||||
public bool PublishedValuesOnly { get; }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Examine;
|
||||
using Umbraco.Cms.Core.Scoping;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using IScopeProvider = Umbraco.Cms.Infrastructure.Scoping.IScopeProvider;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
|
||||
@@ -17,10 +17,10 @@ public class UmbracoIndexConfig : IUmbracoIndexConfig
|
||||
protected IScopeProvider ScopeProvider { get; }
|
||||
|
||||
public IContentValueSetValidator GetContentValueSetValidator() =>
|
||||
new ContentValueSetValidator(false, true, PublicAccessService, ScopeProvider);
|
||||
new ContentValueSetValidator(false, true, PublicAccessService, ScopeProvider, null, null, null);
|
||||
|
||||
public IContentValueSetValidator GetPublishedContentValueSetValidator() =>
|
||||
new ContentValueSetValidator(true, false, PublicAccessService, ScopeProvider);
|
||||
new ContentValueSetValidator(true, false, PublicAccessService, ScopeProvider, null, null, null);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="IValueSetValidator" /> for the member indexer
|
||||
|
||||
@@ -18,6 +18,7 @@ using Umbraco.Cms.Infrastructure.Examine;
|
||||
using Umbraco.Cms.Infrastructure.Persistence;
|
||||
using Umbraco.Cms.Tests.Integration.Testing;
|
||||
using Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services;
|
||||
using IScopeProvider = Umbraco.Cms.Infrastructure.Scoping.IScopeProvider;
|
||||
|
||||
namespace Umbraco.Cms.Tests.Integration.Umbraco.Examine.Lucene.UmbracoExamine;
|
||||
|
||||
@@ -113,7 +114,9 @@ public abstract class ExamineBaseTest : UmbracoIntegrationTest
|
||||
false,
|
||||
publicAccessServiceMock.Object,
|
||||
scopeProviderMock.Object,
|
||||
parentId);
|
||||
parentId,
|
||||
null,
|
||||
null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
// Copyright (c) Umbraco.
|
||||
// See LICENSE for more details.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Examine;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Scoping;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Infrastructure.Examine;
|
||||
using Umbraco.Cms.Infrastructure.Scoping;
|
||||
|
||||
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Infrastructure.Examine;
|
||||
|
||||
@@ -24,7 +22,10 @@ public class UmbracoContentValueSetValidatorTests
|
||||
false,
|
||||
true,
|
||||
Mock.Of<IPublicAccessService>(),
|
||||
Mock.Of<IScopeProvider>());
|
||||
Mock.Of<IScopeProvider>(),
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
|
||||
var result =
|
||||
validator.Validate(ValueSet.FromObject("555", IndexTypes.Content, new { hello = "world", path = "-1,555" }));
|
||||
@@ -48,7 +49,10 @@ public class UmbracoContentValueSetValidatorTests
|
||||
false,
|
||||
true,
|
||||
Mock.Of<IPublicAccessService>(),
|
||||
Mock.Of<IScopeProvider>());
|
||||
Mock.Of<IScopeProvider>(),
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
|
||||
var result = validator.Validate(ValueSet.FromObject("555", IndexTypes.Content, new { hello = "world" }));
|
||||
Assert.AreEqual(ValueSetValidationStatus.Failed, result.Status);
|
||||
@@ -68,7 +72,9 @@ public class UmbracoContentValueSetValidatorTests
|
||||
true,
|
||||
Mock.Of<IPublicAccessService>(),
|
||||
Mock.Of<IScopeProvider>(),
|
||||
555);
|
||||
555,
|
||||
null,
|
||||
null);
|
||||
|
||||
var result =
|
||||
validator.Validate(ValueSet.FromObject("555", IndexTypes.Content, new { hello = "world", path = "-1,555" }));
|
||||
@@ -170,7 +176,9 @@ public class UmbracoContentValueSetValidatorTests
|
||||
true,
|
||||
Mock.Of<IPublicAccessService>(),
|
||||
Mock.Of<IScopeProvider>(),
|
||||
includeItemTypes: new List<string> { "include-content" });
|
||||
null,
|
||||
new List<string> { "include-content" },
|
||||
null);
|
||||
|
||||
var result = validator.Validate(ValueSet.FromObject(
|
||||
"555",
|
||||
@@ -201,7 +209,9 @@ public class UmbracoContentValueSetValidatorTests
|
||||
true,
|
||||
Mock.Of<IPublicAccessService>(),
|
||||
Mock.Of<IScopeProvider>(),
|
||||
excludeItemTypes: new List<string> { "exclude-content" });
|
||||
null,
|
||||
null,
|
||||
new List<string> { "exclude-content" });
|
||||
|
||||
var result = validator.Validate(ValueSet.FromObject(
|
||||
"555",
|
||||
@@ -232,8 +242,9 @@ public class UmbracoContentValueSetValidatorTests
|
||||
true,
|
||||
Mock.Of<IPublicAccessService>(),
|
||||
Mock.Of<IScopeProvider>(),
|
||||
includeItemTypes: new List<string> { "include-content", "exclude-content" },
|
||||
excludeItemTypes: new List<string> { "exclude-content" });
|
||||
null,
|
||||
new List<string> { "include-content", "exclude-content" },
|
||||
new List<string> { "exclude-content" });
|
||||
|
||||
var result = validator.Validate(ValueSet.FromObject(
|
||||
"555",
|
||||
@@ -270,7 +281,10 @@ public class UmbracoContentValueSetValidatorTests
|
||||
true,
|
||||
false,
|
||||
Mock.Of<IPublicAccessService>(),
|
||||
Mock.Of<IScopeProvider>());
|
||||
Mock.Of<IScopeProvider>(),
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
|
||||
var result =
|
||||
validator.Validate(ValueSet.FromObject(
|
||||
@@ -310,7 +324,10 @@ public class UmbracoContentValueSetValidatorTests
|
||||
true,
|
||||
false,
|
||||
Mock.Of<IPublicAccessService>(),
|
||||
Mock.Of<IScopeProvider>());
|
||||
Mock.Of<IScopeProvider>(),
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
|
||||
var result =
|
||||
validator.Validate(ValueSet.FromObject(
|
||||
@@ -337,7 +354,10 @@ public class UmbracoContentValueSetValidatorTests
|
||||
true,
|
||||
true,
|
||||
Mock.Of<IPublicAccessService>(),
|
||||
Mock.Of<IScopeProvider>());
|
||||
Mock.Of<IScopeProvider>(),
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
|
||||
var result =
|
||||
validator.Validate(ValueSet.FromObject("555", IndexTypes.Content, new { hello = "world", path = "-1,555" }));
|
||||
@@ -373,7 +393,10 @@ public class UmbracoContentValueSetValidatorTests
|
||||
true,
|
||||
true,
|
||||
Mock.Of<IPublicAccessService>(),
|
||||
Mock.Of<IScopeProvider>());
|
||||
Mock.Of<IScopeProvider>(),
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
|
||||
var result = validator.Validate(new ValueSet(
|
||||
"555",
|
||||
@@ -443,7 +466,10 @@ public class UmbracoContentValueSetValidatorTests
|
||||
false,
|
||||
false,
|
||||
publicAccessService.Object,
|
||||
Mock.Of<IScopeProvider>());
|
||||
Mock.Of<IScopeProvider>(),
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
|
||||
var result =
|
||||
validator.Validate(ValueSet.FromObject("555", IndexTypes.Content, new { hello = "world", path = "-1,555" }));
|
||||
|
||||
Reference in New Issue
Block a user