Skip to content

Commit

Permalink
Remove Obsolete APIs (#15939)
Browse files Browse the repository at this point in the history
Co-authored-by: Zoltán Lehóczky <[email protected]>
  • Loading branch information
MikeAlhayek and Piedone authored May 3, 2024
1 parent dc70203 commit 4bd2294
Show file tree
Hide file tree
Showing 53 changed files with 22 additions and 975 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,104 +57,4 @@ public interface IContentDefinitionService
Task AlterTypePartsOrderAsync(ContentTypeDefinition typeDefinition, string[] partNames);

Task AlterPartFieldsOrderAsync(ContentPartDefinition partDefinition, string[] fieldNames);

[Obsolete($"Instead, utilize the {nameof(LoadTypesAsync)} method. This current method is slated for removal in upcoming releases.")]
IEnumerable<EditTypeViewModel> LoadTypes()
=> LoadTypesAsync().GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(GetTypesAsync)} method. This current method is slated for removal in upcoming releases.")]
IEnumerable<EditTypeViewModel> GetTypes()
=> GetTypesAsync().GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(LoadTypeAsync)} method. This current method is slated for removal in upcoming releases.")]
EditTypeViewModel LoadType(string name)
=> LoadTypeAsync(name).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(GetTypeAsync)} method. This current method is slated for removal in upcoming releases.")]
EditTypeViewModel GetType(string name)
=> GetTypeAsync(name).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(AddTypeAsync)} method. This current method is slated for removal in upcoming releases.")]
ContentTypeDefinition AddType(string name, string displayName)
=> AddTypeAsync(name, displayName).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(RemoveTypeAsync)} method. This current method is slated for removal in upcoming releases.")]
void RemoveType(string name, bool deleteContent)
=> RemoveTypeAsync(name, deleteContent).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(AddPartToTypeAsync)} method. This current method is slated for removal in upcoming releases.")]
void AddPartToType(string partName, string typeName)
=> AddPartToTypeAsync(partName, typeName).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(AddReusablePartToTypeAsync)} method. This current method is slated for removal in upcoming releases.")]
void AddReusablePartToType(string name, string displayName, string description, string partName, string typeName)
=> AddReusablePartToTypeAsync(name, displayName, description, partName, typeName).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(RemovePartFromTypeAsync)} method. This current method is slated for removal in upcoming releases.")]
void RemovePartFromType(string partName, string typeName)
=> RemovePartFromTypeAsync(partName, typeName);

[Obsolete($"Instead, utilize the {nameof(GenerateContentTypeNameFromDisplayNameAsync)} method. This current method is slated for removal in upcoming releases.")]
string GenerateContentTypeNameFromDisplayName(string displayName)
=> GenerateContentTypeNameFromDisplayNameAsync(displayName).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(GenerateFieldNameFromDisplayNameAsync)} method. This current method is slated for removal in upcoming releases.")]
string GenerateFieldNameFromDisplayName(string partName, string displayName)
=> GenerateFieldNameFromDisplayNameAsync(partName, displayName).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(LoadPartsAsync)} method. This current method is slated for removal in upcoming releases.")]
IEnumerable<EditPartViewModel> LoadParts(bool metadataPartsOnly)
=> LoadPartsAsync(metadataPartsOnly).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(GetPartsAsync)} method. This current method is slated for removal in upcoming releases.")]
IEnumerable<EditPartViewModel> GetParts(bool metadataPartsOnly)
=> GetPartsAsync(metadataPartsOnly).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(LoadPartAsync)} method. This current method is slated for removal in upcoming releases.")]
EditPartViewModel LoadPart(string name)
=> LoadPartAsync(name).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(GetPartAsync)} method. This current method is slated for removal in upcoming releases.")]
EditPartViewModel GetPart(string name)
=> GetPartAsync(name).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(AddPartAsync)} method. This current method is slated for removal in upcoming releases.")]
EditPartViewModel AddPart(CreatePartViewModel partViewModel)
=> AddPartAsync(partViewModel).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(RemovePartAsync)} method. This current method is slated for removal in upcoming releases.")]
void RemovePart(string name)
=> RemovePartAsync(name).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(GetFieldsAsync)} method. This current method is slated for removal in upcoming releases.")]
IEnumerable<Type> GetFields()
=> GetFieldsAsync().GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(AddFieldToPartAsync)} method. This current method is slated for removal in upcoming releases.")]
void AddFieldToPart(string fieldName, string fieldTypeName, string partName)
=> AddFieldToPartAsync(fieldName, fieldTypeName, partName).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(AddFieldToPartAsync)} method. This current method is slated for removal in upcoming releases.")]
void AddFieldToPart(string fieldName, string displayName, string fieldTypeName, string partName)
=> AddFieldToPartAsync(fieldName, displayName, fieldTypeName, partName).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(RemoveFieldFromPartAsync)} method. This current method is slated for removal in upcoming releases.")]
void RemoveFieldFromPart(string fieldName, string partName)
=> RemoveFieldFromPartAsync(fieldName, partName).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(AlterFieldAsync)} method. This current method is slated for removal in upcoming releases.")]
void AlterField(EditPartViewModel partViewModel, EditFieldViewModel fieldViewModel)
=> AlterFieldAsync(partViewModel, fieldViewModel).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(AlterTypePartAsync)} method. This current method is slated for removal in upcoming releases.")]
void AlterTypePart(EditTypePartViewModel partViewModel)
=> AlterTypePartAsync(partViewModel).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(AlterTypePartsOrderAsync)} method. This current method is slated for removal in upcoming releases.")]
void AlterTypePartsOrder(ContentTypeDefinition typeDefinition, string[] partNames)
=> AlterTypePartsOrderAsync(typeDefinition, partNames).GetAwaiter().GetResult();

[Obsolete($"Instead, utilize the {nameof(AlterPartFieldsOrderAsync)} method. This current method is slated for removal in upcoming releases.")]
void AlterPartFieldsOrder(ContentPartDefinition partDefinition, string[] fieldNames)
=> AlterPartFieldsOrderAsync(partDefinition, fieldNames).GetAwaiter().GetResult();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

Expand All @@ -7,8 +6,4 @@ namespace OrchardCore.ContentTypes.Services;
public interface IStereotypeService
{
Task<IEnumerable<StereotypeDescription>> GetStereotypesAsync();

[Obsolete($"Instead, utilize the {nameof(GetStereotypesAsync)} method. This current method is slated for removal in upcoming releases.")]
IEnumerable<StereotypeDescription> GetStereotypes()
=> GetStereotypesAsync().GetAwaiter().GetResult();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

Expand All @@ -7,8 +6,4 @@ namespace OrchardCore.ContentTypes.Services;
public interface IStereotypesProvider
{
Task<IEnumerable<StereotypeDescription>> GetStereotypesAsync();

[Obsolete($"Instead, utilize the {nameof(GetStereotypesAsync)} method. This current method is slated for removal in upcoming releases.")]
IEnumerable<StereotypeDescription> GetStereotypes()
=> GetStereotypesAsync().GetAwaiter().GetResult();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ public class ContentTypeSelection
public bool IsSelected { get; set; }
public ContentTypeDefinition ContentTypeDefinition { get; set; }

[Obsolete($"Instead, utilize the {nameof(BuildAsync)} method. This current method is slated for removal in upcoming releases.")]
public static ContentTypeSelection[] Build(IContentDefinitionManager contentDefinitionManager, IEnumerable<string> selectedContentTypes)
=> BuildAsync(contentDefinitionManager, selectedContentTypes).GetAwaiter().GetResult();

public static async Task<ContentTypeSelection[]> BuildAsync(IContentDefinitionManager contentDefinitionManager, IEnumerable<string> selectedContentTypes)
{
var contentTypes = (await contentDefinitionManager.ListTypeDefinitionsAsync())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -31,7 +30,7 @@ public async override Task<IDisplayResult> UpdateAsync(TActivity model, IUpdateM
await updater.TryUpdateModelAsync(viewModel, Prefix, x => x.SelectedContentTypeNames);

model.ContentTypeFilter = (await FilterContentTypesQueryAsync(viewModel.SelectedContentTypeNames)).ToList();

return Edit(model);
}

Expand All @@ -55,13 +54,6 @@ public override IDisplayResult Display(TActivity activity)
);
}

/// <summary>
/// Filters out any content type that doesn't exist.
/// </summary>
[Obsolete($"Instead, utilize the {nameof(FilterContentTypesQueryAsync)} method. This current method is slated for removal in upcoming releases.")]
protected IEnumerable<string> FilterContentTypesQuery(IEnumerable<string> contentTypeNames)
=> FilterContentTypesQueryAsync(contentTypeNames).GetAwaiter().GetResult();

protected async Task<IEnumerable<string>> FilterContentTypesQueryAsync(IEnumerable<string> contentTypeNames)
{
var contentTypeDefinitions = (await ContentDefinitionManager.ListTypeDefinitionsAsync()).ToDictionary(x => x.Name);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using OrchardCore.ContentManagement;
using OrchardCore.DisplayManagement;
using OrchardCore.DisplayManagement.Descriptors;
Expand All @@ -8,17 +9,19 @@ namespace OrchardCore.Forms;

public class FormShapeTableProvider : IShapeTableProvider
{
public void Discover(ShapeTableBuilder builder)
public ValueTask DiscoverAsync(ShapeTableBuilder builder)
{
builder.Describe("Widget__Form")
.OnDisplaying(context =>
{
if (context.Shape.TryGetProperty<ContentItem>("ContentItem", out var contentItem)
&& contentItem.TryGet<FormElementPart>(out var elementPart)
if (context.Shape.TryGetProperty<ContentItem>("ContentItem", out var contentItem)
&& contentItem.TryGet<FormElementPart>(out var elementPart)
&& !string.IsNullOrEmpty(elementPart.Id))
{
context.Shape.Metadata.Alternates.Add($"Widget__{contentItem.ContentType}_{elementPart.Id.EncodeAlternateElement()}");
}
});

return ValueTask.CompletedTask;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ public LayerQueryObjectType()
Name = "Layer";

Field(layer => layer.Name).Description("The name of the layer.");
#pragma warning disable 0618
Field(layer => layer.Rule).Description("Deprecated. The rule that activates the layer.");
#pragma warning restore 0618
Field<ListGraphType<StringGraphType>, IEnumerable<Condition>>("layerrule")
.Description("The rule that activates the layer.")
.Resolve(ctx => ctx.Source.LayerRule.Conditions);
Expand Down
28 changes: 3 additions & 25 deletions src/OrchardCore.Modules/OrchardCore.Layers/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using OrchardCore.Data.Migration;
using OrchardCore.Layers.Indexes;
using OrchardCore.Layers.Services;
using OrchardCore.Rules;
using OrchardCore.Rules.Services;
using YesSql.Sql;

Expand All @@ -12,16 +11,13 @@ public class Migrations : DataMigration
{
private readonly ILayerService _layerService;
private readonly IConditionIdGenerator _conditionIdGenerator;
private readonly IRuleMigrator _ruleMigrator;

public Migrations(
ILayerService layerService,
IConditionIdGenerator conditionIdGenerator,
IRuleMigrator ruleMigrator)
IConditionIdGenerator conditionIdGenerator)
{
_layerService = layerService;
_conditionIdGenerator = conditionIdGenerator;
_ruleMigrator = ruleMigrator;
}

public async Task<int> CreateAsync()
Expand Down Expand Up @@ -49,26 +45,8 @@ await SchemaBuilder.AlterIndexTableAsync<LayerMetadataIndex>(table => table
"Zone")
);

return 2;
}

public async Task<int> UpdateFrom2Async()
{
var layers = await _layerService.LoadLayersAsync();
foreach (var layer in layers.Layers)
{
layer.LayerRule = new Rule();
_conditionIdGenerator.GenerateUniqueId(layer.LayerRule);

#pragma warning disable 0618
_ruleMigrator.Migrate(layer.Rule, layer.LayerRule);

layer.Rule = string.Empty;
#pragma warning restore 0618
}

await _layerService.UpdateAsync(layers);

// Migration was cleaned up in version 2.0.
// Jump to step 3 during create.
return 3;
}
}
Expand Down
7 changes: 0 additions & 7 deletions src/OrchardCore.Modules/OrchardCore.Layers/Models/Layer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using OrchardCore.Rules;

namespace OrchardCore.Layers.Models
Expand All @@ -7,12 +6,6 @@ public class Layer
{
public string Name { get; set; }

/// <summary>
/// This property is obsolete and layer rules should be used instead.
/// It can be removed in a future version.
/// </summary>
[Obsolete("The rule property is obsolete and LayerRule should be used instead.")]
public string Rule { get; set; }
public string Description { get; set; }

public Rule LayerRule { get; set; }
Expand Down
10 changes: 0 additions & 10 deletions src/OrchardCore.Modules/OrchardCore.Layers/Recipes/LayerStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,17 @@ namespace OrchardCore.Layers.Recipes
public class LayerStep : IRecipeStepHandler
{
private readonly ILayerService _layerService;
private readonly IRuleMigrator _ruleMigrator;
private readonly IConditionIdGenerator _conditionIdGenerator;
private readonly IEnumerable<IConditionFactory> _factories;
private readonly JsonSerializerOptions _serializationOptions;

public LayerStep(
ILayerService layerService,
IRuleMigrator ruleMigrator,
IConditionIdGenerator conditionIdGenerator,
IEnumerable<IConditionFactory> factories,
IOptions<DocumentJsonSerializerOptions> serializationOptions)
{
_layerService = layerService;
_ruleMigrator = ruleMigrator;
_conditionIdGenerator = conditionIdGenerator;
_factories = factories;
_serializationOptions = serializationOptions.Value.SerializerOptions;
Expand Down Expand Up @@ -107,13 +104,6 @@ public async Task ExecuteAsync(RecipeExecutionContext context)
}
}

// Migrate any old rule in a recipe to the new rule format.
// Do not import the old rule.
if (!string.IsNullOrEmpty(layerStep.Rule))
{
_ruleMigrator.Migrate(layerStep.Rule, layer.LayerRule);
}

if (!string.IsNullOrEmpty(layerStep.Description))
{
layer.Description = layerStep.Description;
Expand Down
Loading

0 comments on commit 4bd2294

Please sign in to comment.