MicroElements source only package: Reflection. Classes: TypeExtensions, TypeCheck, ObjectExtensions, Expressions, CodeCompiler, FriendlyName.
$ dotnet add package MicroElements.Reflection.SourcesMicroElements source only package: Reflection. Classes: TypeExtensions, TypeCheck, ObjectExtensions, Expressions, CodeCompiler, FriendlyName.
Gets friendly (human readable) name for the type.
Usage
// Without GetFriendlyName
typeof(List<ValueTuple<int?, string>?>).Name.Should().Be("List`1");
typeof(List<ValueTuple<int?, string>?>).FullName.Should().StartWith("System.Collections.Generic.List`1[[System.Nullable`1[[System.ValueTuple`2[[System.Nullable`1[[System.Int32, System.Private.CoreLib");
// With GetFriendlyName
typeof(List<(int Key, string Value)>).GetFriendlyName().Should().Be("List<ValueTuple<int, string>>");
Notes:
string, object, bool, byte, char, decimal, double, short, int, long, sbyte, float, ushort, uint, ulong, void. Example: Int32 -> int.typeAliases paramList'1 -> List<int>Int32[] -> int[]Nullable value types adds ? at the endList<Tuple<int, string>>BuildFriendlyName.