BryanWilhite / SonghayCore

core reusable, opinionated concerns for *all* 🧐 of my C# projects
http://songhayblog.azurewebsites.net/
MIT License
1 stars 0 forks source link

upgrade Solution to .NET 6 and remove obsolete/abandoned assets #131

Closed BryanWilhite closed 2 years ago

BryanWilhite commented 2 years ago

should there be a .NET 6 version of SonghayCore the following legacy load should be dropped

path remarks
Collections/ObservableSortingCollection.cs abandon previous investment in WPF
ComponentModel/BackgroundWorkerUtility.cs abandon previous investment in WPF
Cryptography/* (and Security/*) these assets need to be reviewed for contemporary usefulness
Extensions/FuncExtensions.cs (with ExpressionExtensions, ExpressionSeed.cs and FuncSeed.cs) this was just a novelty that can be moved to, say, a Jupyter notebook
Extensions/ICommunicationObjectExtensions.cs abandon previous investment in WCF
Extensions/IConfigurationBuilderExtensions.cs marked obsolete with suggested replacement for several versions
Extensions/IContractResolverExtensions.cs Newtonsoft.Json should no longer be considered a Core asset; consider moving to a Jupyter notebook
Extensions/IDictionaryExtensions.Obsolete.cs marked obsolete with suggested replacement for several versions
Extensions/IEnumerableOfTExtensions.cs at the very least, select members need to be marked Obsolete with replacements in, say, MoreLinq [GitHub]
Extensions/IIdentityExtensions.cs at the very least, the use of word Windows needs to be revisited
Extensions/JObjectExtensions.cs Newtonsoft.Json should no longer be considered a Core asset; attempt to replace all read operations with System.Text.Json equivalents; consider moving the rest to a Jupyter notebook
Extensions/JsonSerializerSettingsExtensions.cs Newtonsoft.Json should no longer be considered a Core asset; attempt to replace all operations with System.Text.Json equivalents; consider moving the rest to a Jupyter notebook
Extensions/JTokenExtensions.cs Newtonsoft.Json should no longer be considered a Core asset; attempt to replace all operations with System.Text.Json equivalents; consider moving the rest to a Jupyter notebook
Extensions/NullableExtensions.cs these assets need to be reviewed for contemporary usefulness [see #137 ]
Extensions/ObjectExtensions.cs these assets need to be reviewed for contemporary usefulness
Extensions/ObjectExtensions.GetProperties.cs these assets need to be reviewed for contemporary usefulness
Extensions/OpenAuthorizationDataExtensions.cs these members need to be moved down to the Songhay.Social level; Twitter has for years not been regarded as a Core asset
StringExtensions.WrapForRiaEndpoint abandon previous investment in WPF
JsonSerializationUtility.cs Newtonsoft.Json should no longer be considered a Core asset
OpcReferencedTypeStrategy.cs and OpcUtility.cs abandon previous investment in WPF
ProgramFileUtility.Obsolete.cs marked obsolete with suggested replacement for several versions
Songhay.Models.EditableObjectCache abandon previous investment in WPF
Models/IControlInteractionMessage.cs abandon previous investment in WPF
Models/HierarchicalNameValuePair and NameValuePair | replaced byKeyValuePair<TKey, TValue>`
ProgramUtility.InteropServices.cs abandon Windows-specific arcana

These changes imply that:

These changes are still avoiding revisiting the Songhay.Xml namespace. And is not answering questions around whether IObservable patterns play a role in the future UI work of this Studio.

BryanWilhite commented 2 years ago

compiler warnings:

/SonghayCore/SonghayCore/Security/SymmetricCrypt.cs(24,39): warning SYSLIB0021: 'AesCryptoServiceProvider' is obsolete: 'Derived cryptographic types are obsolete. Use the Create method on the base type instead.' [/SonghayCore/SonghayCore/SonghayCore.csproj]
/SonghayCore/SonghayCore/Security/SymmetricCrypt.cs(38,39): warning SYSLIB0021: 'AesCryptoServiceProvider' is obsolete: 'Derived cryptographic types are obsolete. Use the Create method on the base type instead.' [/SonghayCore/SonghayCore/SonghayCore.csproj]
/SonghayCore/SonghayCore/Security/SymmetricCrypt.cs(101,39): warning SYSLIB0021: 'AesCryptoServiceProvider' is obsolete: 'Derived cryptographic types are obsolete. Use the Create method on the base type instead.' [/SonghayCore/SonghayCore/SonghayCore.csproj]
/SonghayCore/SonghayCore/Security/SymmetricCrypt.cs(127,39): warning SYSLIB0021: 'AesCryptoServiceProvider' is obsolete: 'Derived cryptographic types are obsolete. Use the Create method on the base type instead.' [/SonghayCore/SonghayCore/SonghayCore.csproj]
/SonghayCore/SonghayCore/Security/SaltedHash.cs(33,24): warning SYSLIB0021: 'SHA256Managed' is obsolete: 'Derived cryptographic types are obsolete. Use the Create method on the base type instead.' [/SonghayCore/SonghayCore/SonghayCore.csproj]
/SonghayCore/SonghayCore/Security/SaltedHash.cs(56,30): warning SYSLIB0023: 'RNGCryptoServiceProvider' is obsolete: 'RNGCryptoServiceProvider is obsolete. To generate a random number, use one of the RandomNumberGenerator static methods instead.' [/SonghayCore/SonghayCore/SonghayCore.csproj]
/SonghayCore/SonghayCore/Cryptography/EncryptTransformer.cs(63,35): warning SYSLIB0021: 'DESCryptoServiceProvider' is obsolete: 'Derived cryptographic types are obsolete. Use the Create method on the base type instead.' [/SonghayCore/SonghayCore/SonghayCore.csproj]
/SonghayCore/SonghayCore/Cryptography/EncryptTransformer.cs(88,42): warning SYSLIB0021: 'TripleDESCryptoServiceProvider' is obsolete: 'Derived cryptographic types are obsolete. Use the Create method on the base type instead.' [/SonghayCore/SonghayCore/SonghayCore.csproj]
/SonghayCore/SonghayCore/Cryptography/EncryptTransformer.cs(113,35): warning SYSLIB0021: 'RC2CryptoServiceProvider' is obsolete: 'Derived cryptographic types are obsolete. Use the Create method on the base type instead.' [/SonghayCore/SonghayCore/SonghayCore.csproj]
/SonghayCore/SonghayCore/Cryptography/EncryptTransformer.cs(138,21): warning SYSLIB0022: 'Rijndael' is obsolete: 'The Rijndael and RijndaelManaged types are obsolete. Use Aes instead.' [/SonghayCore/SonghayCore/SonghayCore.csproj]
/SonghayCore/SonghayCore/Cryptography/EncryptTransformer.cs(138,45): warning SYSLIB0022: 'RijndaelManaged' is obsolete: 'The Rijndael and RijndaelManaged types are obsolete. Use Aes instead.' [/SonghayCore/SonghayCore/SonghayCore.csproj]
/SonghayCore/SonghayCore/Cryptography/DecryptTransformer.cs(36,35): warning SYSLIB0021: 'DESCryptoServiceProvider' is obsolete: 'Derived cryptographic types are obsolete. Use the Create method on the base type instead.' [/SonghayCore/SonghayCore/SonghayCore.csproj]
/SonghayCore/SonghayCore/Cryptography/DecryptTransformer.cs(44,42): warning SYSLIB0021: 'TripleDESCryptoServiceProvider' is obsolete: 'Derived cryptographic types are obsolete. Use the Create method on the base type instead.' [/SonghayCore/SonghayCore/SonghayCore.csproj]
/SonghayCore/SonghayCore/Cryptography/DecryptTransformer.cs(50,35): warning SYSLIB0021: 'RC2CryptoServiceProvider' is obsolete: 'Derived cryptographic types are obsolete. Use the Create method on the base type instead.' [/SonghayCore/SonghayCore/SonghayCore.csproj]
/SonghayCore/SonghayCore/Cryptography/DecryptTransformer.cs(56,21): warning SYSLIB0022: 'Rijndael' is obsolete: 'The Rijndael and RijndaelManaged types are obsolete. Use Aes instead.' [/SonghayCore/SonghayCore/SonghayCore.csproj]
/SonghayCore/SonghayCore/Cryptography/DecryptTransformer.cs(56,45): warning SYSLIB0022: 'RijndaelManaged' is obsolete: 'The Rijndael and RijndaelManaged types are obsolete. Use Aes instead.' [/SonghayCore/SonghayCore/SonghayCore.csproj]

in response to this news, I will be removing the entire Security and Cryptography namespaces 🚜 🔥 which has the side effects of the removal of:

all of these security features were not used by me since before .NET Core 2

BryanWilhite commented 2 years ago

first sweep 🧹 🚜 🔥 :

image

BryanWilhite commented 2 years ago

issue #135 will cover all of the Newtonsoft-related concerns here

BryanWilhite commented 2 years ago

this needs to be removed and thrown into a notebook later:

using System;
using System.Linq;
using System.Linq.Expressions;

namespace Songhay.Extensions
{
    /// <summary>
    /// Extensions of <see cref="System.Linq.Expressions.Expression"/>
    /// </summary>
    public static class ExpressionExtensions
    {
        /// <summary>
        /// Ors the specified this expression.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="thisExpression">The this expression.</param>
        /// <param name="expression">The expression.</param>
        /// <returns></returns>
        public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> thisExpression, Expression<Func<T, bool>> expression)
        {
            var invokedExpr = Expression.Invoke(expression, thisExpression.Parameters.Cast<Expression>());
            return Expression.Lambda<Func<T, bool>>(Expression.OrElse(thisExpression.Body, invokedExpr), thisExpression.Parameters);
        }

        /// <summary>
        /// Ands the specified this expression.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="thisExpression">The this expression.</param>
        /// <param name="expression">The expression.</param>
        /// <returns></returns>
        public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> thisExpression, Expression<Func<T, bool>> expression)
        {
            var invokedExpr = Expression.Invoke(expression, thisExpression.Parameters.Cast<Expression>());
            return Expression.Lambda<Func<T, bool>>(Expression.AndAlso(thisExpression.Body, invokedExpr), thisExpression.Parameters);
        }
    }
}
BryanWilhite commented 2 years ago

removing SonghayCore/Extensions/ObjectExtensions.GetProperties.cs:

using System.Linq;
using System.Reflection;

namespace Songhay.Extensions
{
    /// <summary>
    /// Extensions of <see cref="object"/>.
    /// </summary>
    public static partial class ObjectExtensions
    {
        /// <summary>
        /// Gets the properties.
        /// </summary>
        /// <param name="objectWithProperties">The object with properties.</param>
        public static PropertyInfo[] GetProperties(this object objectWithProperties)
        {
            if (objectWithProperties == null) return Enumerable.Empty<PropertyInfo>().ToArray();
            return objectWithProperties.GetType().GetProperties();
        }

        /// <summary>
        /// Gets the property.
        /// </summary>
        /// <param name="objectWithProperties">The object with properties.</param>
        /// <param name="propertyName">Name of the property.</param>
        public static PropertyInfo GetProperty(this object objectWithProperties, string propertyName)
        {
            var props = objectWithProperties.GetProperties();
            if (!props.Any()) return null;
            return props.FirstOrDefault(i => i.Name == propertyName);
        }

        /// <summary>
        /// Gets the property value.
        /// </summary>
        /// <param name="objectWithProperties">The object with properties.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <remarks>
        /// Very useful for an MVVM situation like this:
        /// <code>
        ///     var command = this.DataContext.GetPropertyValue("MyCommand") as ICommand;
        /// </code>
        ///
        /// Note that this member uses <c>property.GetValue(objectWithProperties, index: null)</c>.
        /// Passing null is “fine for normal simple properties, this will fail with indexer properties,
        /// which take a non-null argument list as specified by <c>PropertyInfo.GetIndexParameters</c>.”
        /// [https://stackoverflow.com/a/1355110/22944]
        /// </remarks>
        public static object GetPropertyValue(this object objectWithProperties, string propertyName)
        {
            var property = objectWithProperties.GetProperty(propertyName);
            if (property == null) return null;
            return property.GetValue(objectWithProperties, index: null);
        }
    }
}
BryanWilhite commented 2 years ago

i have decided to keep IEnumerableOfTExtensions but my remarks referring to MoreLinq [ :octocat: https://github.com/morelinq/MoreLINQ ] are added

BryanWilhite commented 2 years ago

i have decided to get rid of IIdentityExtensions 🔥 as I expect to run into this need rarely or in PowerShell

BryanWilhite commented 2 years ago

more expression stuff to go in a notebook:

using System;
using System.Linq.Expressions;

namespace Songhay;

/// <summary>
/// Seeds of <see cref="System.Linq.Expressions.Expression"/>
/// </summary>
public static class ExpressionSeed
{
    /// <summary>
    /// <see cref="System.Linq.Expressions.Expression"/> <c>true</c>.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <returns></returns>
    public static Expression<Func<T, bool>> True<T>() { return f => true; }

    /// <summary>
    /// <see cref="System.Linq.Expressions.Expression"/> <c>false</c>.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <returns></returns>
    public static Expression<Func<T, bool>> False<T>() { return f => false; }
}
using System;

namespace Songhay;

/// <summary>
/// Functor seeds
/// </summary>
public static class FuncSeed
{
    /// <summary>
    /// Predicate Functor for <c>true</c>.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public static Func<T, bool> True<T>() { return f => true; }

    /// <summary>
    /// Predicate Functor for <c>false</c>.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public static Func<T, bool> False<T>() { return f => false; }
}
BryanWilhite commented 2 years ago

Extensions.ObjectExtensions.IsType<TClass> can be removed in favor of the new pattern matching features of C#:

image