TypeSupport 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package TypeSupport --version 1.0.0                
NuGet\Install-Package TypeSupport -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TypeSupport" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TypeSupport --version 1.0.0                
#r "nuget: TypeSupport, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install TypeSupport as a Cake Addin
#addin nuget:?package=TypeSupport&version=1.0.0

// Install TypeSupport as a Cake Tool
#tool nuget:?package=TypeSupport&version=1.0.0                

TypeSupport

A CSharp library that makes it easier to work with Types dynamically by providing extensions and tools that makes your life easier. Additionally, it includes a flexible Object factory for creating and initializing all kinds of types.

Description

The best way to understand what TypeSupport can do is to see it in action! It is used as the foundation for many other packages.

Installation

Install TypeSupport from the Package Manager Console:

PM> Install-Package TypeSupport

Usage

Type Support

Getting started - create a TypeSupport from a type

using TypeSupport;

var type = typeof(MyObject);
var typeSupport = new TypeSupport(type);

or do it using the extensions (we will use this syntax going forward):

using TypeSupport;

var type = typeof(MyObject);
var typeSupport = type.TypeSupport();

get information about an array:

var type = typeof(int[]);
var typeSupport = type.TypeSupport();

var isArray = typeSupport.IsArray; // true
var elementType = typeSupport.ElementType; // int

get information about a Dictionary:

var type = typeof(Dictionary<int, string>);
var typeSupport = type.TypeSupport();

var isArray = typeSupport.IsDictionary; // true
var elementTypes = typeSupport.GenericArgumentTypes; // System.Int32, System.String

get info about an interface:

var type = typeof(IVehicle);
var typeSupport = type.TypeSupport();

var isArray = typeSupport.IsInterface; // true
var classesThatImplementICustomInterface = typeSupport.KnownConcreteTypes;
// [] = Car, Truck, Van, Motorcycle

get info about a class:

[Description("A car object")]
public class Car : IVehicle
{
  public string Name { get; set; }
  public Car() { }
}
var type = typeof(Car);
var typeSupport = type.TypeSupport();

var isArray = typeSupport.HasEmptyConstructor; // true
var attributes = typeSupport.Attributes;
// [] = DescriptionAttribute

working with enums:

public enum Colors : byte
{
  Red = 1,
  Green = 2,
  Blue = 3
}
var type = typeof(Colors);
var typeSupport = type.TypeSupport();

var isEnum = typeSupport.IsEnum; // true
var enumValues = typeSupport.EnumValues;
// [] = <1, Red>, <2, Green>, <3, blue>
var enumType = typeSupport.EnumType; // System.Byte

working with Tuples:

var tupleType = typeof(Tuple<int, string, double>);
var valueTupleType = typeof((IVehicle, string));
var tupleTypeSupport = type.TypeSupport();
var valueTupleTypeSupport = valueTupleType.TypeSupport();

var isTuple = tupleTypeSupport.IsTuple; // true
var isValueTuple = valueTupleTypeSupport.IsValueTuple; // true
var tupleGenericArguments = tupleTypeSupport.GenericArgumentTypes; // System.Int32, System.String, System.Double
var valueTupleGenericArguments = valueTupleTypeSupport.GenericArgumentTypes; // IVehicle, System.String
// there's lots more you can do, such as getting the value from a Tuple instance:

var car = new Car();
var description = "My cool car";
var myTuple = (car, description);
var items = myTuple.GetValueTupleItemObjects();
// [] = Car, "My cool car"

Object factory

Create new objects of any type:

var factory = new ObjectFactory();
var listInstance = factory.CreateEmptyObject<IList<int>>(); // List<int>() 0 elements
var dictionaryInstance = factory.CreateEmptyObject<IDictionary<int, string>>(); // Dictionary<int, string>() 0 elements
var emptyByteArray = factory.CreateEmptyObject<byte[]>(); // byte[0] empty byte array
var byteArray = factory.CreateEmptyObject<byte[]>(length: 64); // byte[64]
var tupleInstance = factory.CreateEmptyObject<(int, string)>(); // tupleInstance.Item1 = 0, tupleInstance.item2 = null
var myComplexObject = factory.CreateEmptyObject<MyComplexObject>();

Create objects without parameterless constructors:

public class CustomObject
{
  public int Id { get; }
  public CustomObject(int id)
  {
    Id = id;
  }
}
var factory = new ObjectFactory();
var myObj = factory.CreateEmptyObject<CustomObject>(); // CustomObject
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (16)

Showing the top 5 NuGet packages that depend on TypeSupport:

Package Downloads
Blazor-State

A Blazor state management library by TimeWarp

AnySerializer

Serialize and deserialize any object without decoration/attributes.

Core-State

A fork of the Core state management library by TimeWarp for use in .Net Maui

Binner.Model.Common

Binner common model library

Binner.StorageProvider.MySql

MySql storage provider for Binner

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on TypeSupport:

Repository Stars
TimeWarpEngineering/timewarp-state
A Blazor State management library by TimeWarp.
replaysMike/Binner
Open source parts inventory system for makers, electronics hobby, and professional engineers
replaysMike/AnyDiff
A CSharp (C#) diff library that allows you to diff two objects and get a list of the differences back.
Version Downloads Last updated
1.2.0 97,081 3/14/2023
1.1.12 166,972 9/15/2021
1.1.11 481 8/10/2021
1.1.10 830 7/29/2021
1.1.8 474 7/28/2021
1.1.7 481 7/28/2021
1.1.4 113,293 7/9/2020
1.1.3 4,994 6/9/2020
1.1.0 527 6/9/2020
1.0.108 34,758 4/18/2020
1.0.107 515 4/18/2020
1.0.106 731 4/16/2020
1.0.104 506 4/16/2020
1.0.103 518 4/16/2020
1.0.102 8,089 4/13/2020
1.0.100 7,208 1/8/2020
1.0.99 574 1/7/2020
1.0.98 554 1/7/2020
1.0.97 3,323 12/2/2019
1.0.92 13,478 6/30/2019
1.0.90 85,459 5/22/2019
1.0.89 1,030 5/22/2019
1.0.88 859 5/22/2019
1.0.86 649 5/22/2019
1.0.85 635 5/22/2019
1.0.79 94,481 5/16/2019
1.0.78 617 5/16/2019
1.0.77 666 5/15/2019
1.0.76 639 5/15/2019
1.0.73 703 5/9/2019
1.0.68 639 5/1/2019
1.0.66 3,066 4/20/2019
1.0.62 672 4/20/2019
1.0.61 659 4/20/2019
1.0.58 655 4/17/2019
1.0.54 679 4/15/2019
1.0.51 1,039 4/14/2019
1.0.46 45,522 12/20/2018
1.0.45 2,623 12/20/2018
1.0.44 720 12/19/2018
1.0.43 728 12/19/2018
1.0.42 747 12/19/2018
1.0.34 728 12/19/2018
1.0.26 1,082 12/12/2018
1.0.15 827 12/5/2018
1.0.14 779 12/5/2018
1.0.12 13,173 12/4/2018
1.0.10 42,820 12/2/2018
1.0.8 1,376 12/2/2018
1.0.7 1,316 11/30/2018
1.0.6 1,505 11/29/2018
1.0.5 1,532 11/29/2018
1.0.4 1,629 11/28/2018
1.0.3 1,070 11/22/2018
1.0.2 756 11/22/2018
1.0.1 745 11/22/2018
1.0.0 817 11/21/2018

TypeSupport provides tools to give you more information about .Net types and factories for working with objects, collections, enums and more.