From d088fae2e54e0bd134944bb02858649d328b65d6 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 30 Dec 2020 14:14:25 +0100 Subject: [PATCH] Removed unnecessary code --- .../Extensions/TypeExtensions.cs | 50 ------------------- 1 file changed, 50 deletions(-) delete mode 100644 src/ComputeSharp.Graphics/Extensions/TypeExtensions.cs diff --git a/src/ComputeSharp.Graphics/Extensions/TypeExtensions.cs b/src/ComputeSharp.Graphics/Extensions/TypeExtensions.cs deleted file mode 100644 index 427c418c..00000000 --- a/src/ComputeSharp.Graphics/Extensions/TypeExtensions.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.Contracts; -using System.Linq; - -namespace ComputeSharp.Graphics.Extensions -{ - /// - /// A that provides extension methods for the type. - /// - internal static class TypeExtensions - { - /// - /// The mapping of supported known types to display string. - /// - private static readonly IReadOnlyDictionary KnownTypes = new Dictionary - { - [typeof(bool)] = "bool", - [typeof(int)] = "int", - [typeof(uint)] = "uint", - [typeof(float)] = "float", - [typeof(double)] = "double" - }; - - /// - /// Gets a friendly display for the input type. - /// - /// The input type to analyze. - [Pure] - public static string ToFriendlyString(this Type type) - { - // Array types of arbitrary rank - if (type.IsArray) - { - int rank = type.GetArrayRank(); - return $"{type.GetElementType()!.ToFriendlyString()}[{new string(Enumerable.Repeat(',', rank - 1).ToArray())}]"; - } - - // Non generic types - string? name; - if (type.GetGenericArguments().Length == 0) return KnownTypes.TryGetValue(type, out name) ? name : type.Name; - - // Generic types - Type[] genericArguments = type.GetGenericArguments(); - string typeDefeninition = KnownTypes.TryGetValue(type, out name) ? name : type.Name; - string polishedName = typeDefeninition.Substring(0, typeDefeninition.IndexOf("`")); - return $"{polishedName}<{string.Join(",", genericArguments.Select(ToFriendlyString))}>"; - } - } -}