mirror of
https://github.com/chylex/.NET-Community-Toolkit.git
synced 2025-04-13 20:15:45 +02:00
Removed Deprecated for 7.0 (#3435)
Removed: * Major components: * TabView/TabViewItem * HeaderedTextBlock * FacebookService and Microsoft.Toolkit.Uwp.Services project * RSS Parsers * Smaller methods: * StringExtensions.ToSafeString * LinkedIn, Twitter and Weibo sync Logout methods. * ConnectedAnimations.SetListDataItemForNextConnectedAnnimation * TileControl.IsCompositionSupported * NotifyTaskCompletion * Singleton This is still missing the update on the docs repo. ## Contributes towards #3062 ## Fixes #3396 ## PR Type What kind of change does this PR introduce? <!-- Please uncomment one or more that apply to this PR. --> <!-- - Bugfix --> <!-- - Feature --> <!-- - Code style update (formatting) --> <!-- - Refactoring (no functional changes, no api changes) --> <!-- - Build or CI related changes --> <!-- - Documentation content changes --> <!-- - Sample app changes --> - Other... Please describe: Removing dead code. ## What is the current behavior? Obsolete classes marked as obsolete, but still exist in code. ## What is the new behavior? Some classes/methods marked as obsolete are now removed from code. ## PR Checklist Please check if your PR fulfills the following requirements: - [X] Tested code with current [supported SDKs](../readme.md#supported) - [ ] Pull Request has been submitted to the documentation repository [instructions](..\contributing.md#docs). Link: <!-- docs PR link --> - [X] Sample in sample app has been added / updated (for bug fixes / features) - [ ] Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/windows-toolkit/WindowsCommunityToolkit-design-assets) - [ ] Tests for the changes have been added (for bug fixes / features) (if applicable) - [X] Header has been added to all new source files (run *build/UpdateHeaders.bat*) - [ ] Contains **NO** breaking changes This PR IS a breaking change, as instead of just providing a warning, any developers that uses the dead code will now get missing method/class exceptions.
This commit is contained in:
commit
49eb987ac9
Microsoft.Toolkit
@ -86,14 +86,6 @@ public static bool IsDecimal(this string str)
|
||||
/// <returns><c>true</c> if the string contains only letters; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsCharacterString(this string str) => Regex.IsMatch(str, CharactersRegex);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string representation of an object.
|
||||
/// </summary>
|
||||
/// <param name="value">The object to convert.</param>
|
||||
/// <returns>String representation of the object.</returns>
|
||||
[Obsolete("Use value?.ToString() instead. This will be removed in the next release of the toolkit.")]
|
||||
public static string ToSafeString(this object value) => value?.ToString();
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string with HTML comments, scripts, styles, and tags removed.
|
||||
/// </summary>
|
||||
|
@ -1,141 +0,0 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.Toolkit.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper class to wrap around a Task to provide more information usable for UI data binding scenarios. As discussed in MSDN Magazine: https://msdn.microsoft.com/magazine/dn605875.
|
||||
/// </summary>
|
||||
/// <typeparam name="TResult">Type of result returned by task.</typeparam>
|
||||
[Obsolete("This helper will be removed in a future release, use the ObservableObject base class from Microsoft.Toolkit.Mvvm and the SetAndNotifyOnCompletion method")]
|
||||
public sealed class NotifyTaskCompletion<TResult> : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NotifyTaskCompletion{TResult}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="task">Task to wait on.</param>
|
||||
public NotifyTaskCompletion(Task<TResult> task)
|
||||
{
|
||||
Task = task;
|
||||
if (!task.IsCompleted)
|
||||
{
|
||||
TaskCompletion = WatchTaskAsync(task);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task WatchTaskAsync(Task task)
|
||||
{
|
||||
try
|
||||
{
|
||||
await task;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
if (PropertyChanged == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Status)));
|
||||
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsCompleted)));
|
||||
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsNotCompleted)));
|
||||
|
||||
if (task.IsCanceled)
|
||||
{
|
||||
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsCanceled)));
|
||||
}
|
||||
else if (task.IsFaulted)
|
||||
{
|
||||
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsFaulted)));
|
||||
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Exception)));
|
||||
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(InnerException)));
|
||||
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(ErrorMessage)));
|
||||
}
|
||||
else
|
||||
{
|
||||
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsSuccessfullyCompleted)));
|
||||
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Result)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the task that is being waited on.
|
||||
/// </summary>
|
||||
public Task<TResult> Task { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the task wrapper task.
|
||||
/// </summary>
|
||||
public Task TaskCompletion { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the result of the given task.
|
||||
/// </summary>
|
||||
public TResult Result
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Task.Status == TaskStatus.RanToCompletion) ?
|
||||
Task.Result :
|
||||
default(TResult);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the status of the task.
|
||||
/// </summary>
|
||||
public TaskStatus Status => Task.Status;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the task is completed.
|
||||
/// </summary>
|
||||
public bool IsCompleted => Task.IsCompleted;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the task is not completed.
|
||||
/// </summary>
|
||||
public bool IsNotCompleted => !Task.IsCompleted;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the task was successfully completed.
|
||||
/// </summary>
|
||||
public bool IsSuccessfullyCompleted => Task.Status == TaskStatus.RanToCompletion;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the task was canceled.
|
||||
/// </summary>
|
||||
public bool IsCanceled => Task.IsCanceled;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether there was an error with the task.
|
||||
/// </summary>
|
||||
public bool IsFaulted => Task.IsFaulted;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the exception which occurred on the task (if one occurred).
|
||||
/// </summary>
|
||||
public AggregateException Exception => Task.Exception;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the inner exception of the task.
|
||||
/// </summary>
|
||||
public Exception InnerException => Exception?.InnerException;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the error message of the task.
|
||||
/// </summary>
|
||||
public string ErrorMessage => InnerException?.Message ?? Exception.Message;
|
||||
|
||||
/// <summary>
|
||||
/// PropertyChanged event.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace Microsoft.Toolkit.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Obsolete see https://github.com/windows-toolkit/WindowsCommunityToolkit/issues/3134.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type to be used for creating the Singleton instance.</typeparam>
|
||||
/// <example>
|
||||
/// Instead of this helper, migrate your code to this pattern instead:
|
||||
/// <code>
|
||||
/// // Setup Singleton
|
||||
/// public class MyClass
|
||||
/// {
|
||||
/// public static MyClass Instance { get; } = new MyClass();
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
[Obsolete("This helper will be removed in a future release, see example tag for code replacement. https://github.com/windows-toolkit/WindowsCommunityToolkit/issues/3134")]
|
||||
public static class Singleton<T>
|
||||
where T : new()
|
||||
{
|
||||
// Use ConcurrentDictionary for thread safety.
|
||||
private static readonly ConcurrentDictionary<Type, T> _instances = new ConcurrentDictionary<Type, T>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the Singleton class.
|
||||
/// </summary>
|
||||
public static T Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
// Safely creates the first instance or retrieves the existing instance across threads.
|
||||
return _instances.GetOrAdd(typeof(T), (t) => new T());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user