Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is an 'inflated type'?

Tags:

c#

In the Unity documentation they talk about inflated type such as in here:

Field value cannot be a specific specialization of a generic type(inflated type).

What does that mean exactly ?

like image 414
aybe Avatar asked Mar 26 '20 15:03

aybe


Video Answer


1 Answers

Mono's documentation, which Unity's terminology may well be based upon (with Unity internally using Mono), defines it as a synonym of a type instance, i.e. a generic type with concrete types assigned to its generic type parameters:

Terminology

Type/Method instantiation == Type/Method instance == Inflated Type/Method.

Therefore, in the sentece you cite from Unity's documentation, it sounds like "inflated type" is meant to be a shorter way to express the entirety of "specific specialization of a generic type".

In other words, the field value must not be of a generic type with supplied type parameters.

If I may hazard a guess, that might have something to do with the typical difficulty that you always stumble over when trying to write a serialization/deserialization for arbitrary .NET objects - as long as you work with non-generic types, all is fine and GetType().FullName will give you the full class name, which can be resolved again upon deserialization. However, once you come across a generic type, GetType().FullName will only return the number of type arguments, so both List<string> and List<int> will become "System.Collections.Generic.List`1", from where you will get back to the original types only with some extra work.

like image 65
O. R. Mapper Avatar answered Oct 22 '22 22:10

O. R. Mapper