Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Obsolete APIs #15939

Merged
merged 5 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 1 addition & 5 deletions src/OrchardCore.Modules/OrchardCore.Layers/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ public async Task<int> UpdateFrom2Async()
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
_ruleMigrator.Migrate(layer.LayerRule.Name, layer.LayerRule);
}

await _layerService.UpdateAsync(layers);
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
91 changes: 0 additions & 91 deletions src/OrchardCore.Modules/OrchardCore.Liquid/Services/SlugService.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ public override async Task<IDisplayResult> UpdateAsync(ContentMenuItemPart part,
await updater.TryUpdateModelAsync(model, Prefix);

part.ContentItem.DisplayText = model.Name;
// This code can be removed in a later release.
#pragma warning disable 0618
part.Name = model.Name;
#pragma warning restore 0618

return Edit(part);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ public override async Task<IDisplayResult> UpdateAsync(LinkMenuItemPart part, IU
part.Url = model.Url;
part.ContentItem.DisplayText = model.Name;

// This code can be removed in a later release.
#pragma warning disable 0618
part.Name = model.Name;
#pragma warning restore 0618

var urlToValidate = part.Url;

if (!string.IsNullOrEmpty(urlToValidate))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ public LinkMenuItemQueryObjectType()
{
Name = "LinkMenuItemPart";

// This code can be removed in a later release.
#pragma warning disable 0618
Field(x => x.Name, nullable: true).Description("Deprecated. Use displayText.");
#pragma warning restore 0618
Field(x => x.Url, nullable: true);
}
}
Expand Down
17 changes: 0 additions & 17 deletions src/OrchardCore.Modules/OrchardCore.Menu/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,6 @@ private static void MigrateMenuItems(List<ContentItem> menuItems)
{
foreach (var menuItem in menuItems)
{
var linkMenuItemPart = menuItem.As<LinkMenuItemPart>();
Piedone marked this conversation as resolved.
Show resolved Hide resolved
if (linkMenuItemPart != null)
{
// This code can be removed in a later release.
Piedone marked this conversation as resolved.
Show resolved Hide resolved
#pragma warning disable 0618
menuItem.DisplayText = linkMenuItemPart.Name;
#pragma warning restore 0618
}

var contentMenuItemPart = menuItem.As<ContentMenuItemPart>();
if (contentMenuItemPart != null)
{
#pragma warning disable 0618
menuItem.DisplayText = contentMenuItemPart.Name;
#pragma warning restore 0618
}

var menuItemsListPart = menuItem.As<MenuItemsListPart>();
if (menuItemsListPart != null)
{
Expand Down
Loading