static ArrayDescriptor() { EmptyRanks = new ArrayDescriptor(typeof(void), new int[0]); }
private int TouchAndWriteTypeIdWithFullStamp(Type type) { var typeDescriptor = (TypeFullDescriptor)type; // stamping `Type` is different than `Module`, `Assembly`, etc. so we need a special method for that ArrayDescriptor arrayDescriptor = null; if(Helpers.ContainsGenericArguments(typeDescriptor.UnderlyingType)) { if(typeDescriptor.UnderlyingType.IsArray) { arrayDescriptor = new ArrayDescriptor(typeDescriptor.UnderlyingType); typeDescriptor = (TypeFullDescriptor)arrayDescriptor.ElementType; } else { arrayDescriptor = ArrayDescriptor.EmptyRanks; } } if(typeDescriptor.UnderlyingType.IsGenericType) { var genericTypeDefinition = typeDescriptor.UnderlyingType.GetGenericTypeDefinition(); var genericTypeDefinitionDescriptor = (TypeFullDescriptor)genericTypeDefinition; TouchAndWriteTypeIdWithFullStampInner(genericTypeDefinitionDescriptor); var isOpen = Helpers.IsOpenGenericType(typeDescriptor.UnderlyingType); writer.Write(isOpen); if(!isOpen) { foreach(var genericArgumentType in typeDescriptor.UnderlyingType.GetGenericArguments()) { TouchAndWriteTypeIdWithFullStamp(genericArgumentType); } } } else { TouchAndWriteTypeIdWithFullStampInner(typeDescriptor); } if(arrayDescriptor != null) { writer.WriteArray(arrayDescriptor.Ranks); } return 0; }