private void WriteConstructorInvocation(ObjectCreationExpression node)
		{
			if (node.Constructor.DeclaringType is TypeSpecification)
			{
				GenericInstanceType generic = node.Constructor.DeclaringType as GenericInstanceType;
				if (generic != null)
				{
					if (SupportsSpecialNullable && (generic.GetFriendlyFullName(Language).IndexOf("System.Nullable<") == 0) &&
						generic.GenericArguments[0].IsValueType)
					{
						TypeReference toWrite = generic.GenericArguments[0];
						if (generic.PostionToArgument.ContainsKey(0))
						{
							toWrite = generic.PostionToArgument[0];
						}
						WriteReferenceAndNamespaceIfInCollision(toWrite);
						WriteToken("?");
						return;
					}
				}
			}

			if (node.Constructor.DeclaringType.Namespace == "System")
			{
				WriteReferenceAndNamespaceIfInCollision(node.Constructor.DeclaringType);
				return;
			}

			if (node.Constructor.DeclaringType.DeclaringType != null)
			{
				TypeReference declaringType = node.Constructor.DeclaringType.DeclaringType;
				if (node.Constructor.DeclaringType.IsGenericInstance)
				{
					GenericInstanceType referenceGeneric = node.Constructor.DeclaringType as GenericInstanceType;
					if (declaringType.HasGenericParameters)
					{
						/// Transfer the parameters from reference up to the declaring type.
						/// Bare in mind, that the declaring type might have less generic parameters.
						/// Transfer just the first X that match.
						/// This is needed, because VB and C# don't allow other language syntax

						GenericInstanceType declaringTypeInstance = new GenericInstanceType(declaringType);

						Collection<TypeReference> nestedTypeBackup = new Collection<TypeReference>(referenceGeneric.GenericArguments);
						Collection<TypeReference> declaringBackup = new Collection<TypeReference>(declaringTypeInstance.GenericArguments);
						int parametersToMoveUp = declaringType.GenericParameters.Count;
						for (int i = 0; i < parametersToMoveUp; i++)
						{
							/// check if it moves the parameters forward or not
							declaringTypeInstance.AddGenericArgument(referenceGeneric.GenericArguments[i]);
							declaringTypeInstance.GenericArguments.Add(referenceGeneric.GenericArguments[i]);
						}
						WriteReferenceAndNamespaceIfInCollision(declaringTypeInstance);
						Write(".");
						if (referenceGeneric.GenericArguments.Count - parametersToMoveUp > 0)
						{
							WriteConstructorNameAndGenericArguments(node, true, parametersToMoveUp);
						}
						else
						{
							WriteConstructorNameAndGenericArguments(node, false);
						}
						referenceGeneric.GenericArguments.Clear();
						referenceGeneric.GenericArguments.AddRange(nestedTypeBackup);

						declaringTypeInstance.GenericArguments.Clear();
						declaringTypeInstance.GenericArguments.AddRange(declaringBackup);
						return;
					}
				}

				WriteReferenceAndNamespaceIfInCollision(declaringType);
				Write(".");
				WriteConstructorNameAndGenericArguments(node);
			}
			else
			{
				bool isTypeNameInCollision = IsTypeNameInCollision(node.Constructor.DeclaringType.Name);
				WriteNamespace(node.Constructor.DeclaringType.GetElementType(), isTypeNameInCollision);
				WriteConstructorNameAndGenericArguments(node);
			}
		}
		private void WriteReference(TypeReference reference)
		{
			if (reference.DeclaringType != null)
			{
				TypeReference declaringType = reference.DeclaringType;
				if (reference.IsGenericInstance)
				{
					GenericInstanceType referenceGeneric = reference as GenericInstanceType;
					if (declaringType.HasGenericParameters)
					{
						/// Transfer the parameters from reference up to the declaring type.
						/// Bare in mind, that the declaring type might have less generic parameters.
						/// Transfer just the first X that match.
						/// This is needed, because VB and C# don't allow other language syntax

						GenericInstanceType declaringTypeInstance = new GenericInstanceType(declaringType);

						Collection<TypeReference> nestedTypeBackup = new Collection<TypeReference>(referenceGeneric.GenericArguments);
						Collection<TypeReference> declaringBackup = new Collection<TypeReference>(declaringTypeInstance.GenericArguments);
						int parametersToMoveUp = declaringType.GenericParameters.Count;
						for (int i = 0; i < parametersToMoveUp; i++)
						{
							/// check if it moves the parameters forward or not
							declaringTypeInstance.AddGenericArgument(referenceGeneric.GenericArguments[i]);
							declaringTypeInstance.GenericArguments.Add(referenceGeneric.GenericArguments[i]);
						}
						WriteReference(declaringTypeInstance);
						Write(".");
						if (referenceGeneric.GenericArguments.Count - parametersToMoveUp > 0)
						{
							WriteTypeSpecification(referenceGeneric, parametersToMoveUp);
						}
						else
						{
							string typeName = GetTypeName(reference);
							WriteReference(typeName, reference);
						}
						referenceGeneric.GenericArguments.Clear();
						referenceGeneric.GenericArguments.AddRange(nestedTypeBackup);

						declaringTypeInstance.GenericArguments.Clear();
						declaringTypeInstance.GenericArguments.AddRange(declaringBackup);
						return;
					}
					else
					{
						WriteReference(declaringType);
						Write(".");
					}
				}
				else
				{
					WriteReference(declaringType);
					Write(".");
				}
			}

			if (reference is TypeSpecification)
			{
				WriteTypeSpecification(reference as TypeSpecification);
				return;
			}

			string typeString;
			if (reference.Namespace != "System")
			{
				typeString = GetTypeName(reference);
			}
			else
			{
				typeString = ToTypeString(reference);

				if (reference.Scope.Name != "mscorlib" && reference.Scope.Name != "CommonLanguageRuntimeLibrary")
				{
					typeString = Utilities.EscapeTypeName(typeString, this.Language);
				}
			}

			if (reference.HasGenericParameters || (!Language.IsEscapedWord(typeString) && !Language.IsValidIdentifier(typeString)))
			{
				if (reference is TypeDefinition && reference.HasGenericParameters)
				{
					typeString = GetTypeName(reference);

					int genericParametersStartIndex = 0;
					if (reference.DeclaringType != null && reference.DeclaringType.HasGenericParameters)
					{
						genericParametersStartIndex = reference.DeclaringType.GenericParameters.Count;
					}

					if (genericParametersStartIndex < reference.GenericParameters.Count)
					{
						typeString += GenericLeftBracket;
						for (int i = genericParametersStartIndex; i < reference.GenericParameters.Count; i++)
						{
							if (i > genericParametersStartIndex)
							{
								typeString += ", ";
							}
							if (!Language.IsValidIdentifier(reference.GenericParameters[i].Name))
							{
								typeString += Language.ReplaceInvalidCharactersInIdentifier(reference.GenericParameters[i].Name);
							}
							else
							{
								typeString += reference.GenericParameters[i].Name;
							}
						}

						typeString += GenericRightBracket;
						// check if the type name is actually correct
					}
				}
				else
				{
					typeString = GetTypeName(reference);
					//typeString = Language.ReplaceInvalidCharactersInIdentifier(typeString);
				}
			}

			if (reference.IsGenericParameter)
			{
				WriteReference(typeString, null);
			}
			else
			{
				WriteReference(typeString, reference);
			}
		}
		private string HandleNestedGenericTypes(TypeReference parameterType)
		{
			/// Transfer the parameters from reference up to the declaring type.
			/// Bare in mind, that the declaring type might have less generic parameters.
			/// Transfer just the first X that match.
			/// This is needed, because VB and C# don't allow other language syntax
			StringBuilder result = new StringBuilder();
			TypeReference declaringType = parameterType.DeclaringType;
			GenericInstanceType referenceGeneric = parameterType as GenericInstanceType;

			GenericInstanceType declaringTypeInstance = new GenericInstanceType(declaringType);

			Collection<TypeReference> nestedTypeBackup = new Collection<TypeReference>(referenceGeneric.GenericArguments);
			Collection<TypeReference> declaringBackup = new Collection<TypeReference>(declaringTypeInstance.GenericArguments);
			int parametersToMoveUp = declaringType.GenericParameters.Count;
			for (int i = 0; i < parametersToMoveUp; i++)
			{
				declaringTypeInstance.AddGenericArgument(referenceGeneric.GenericArguments[i]);
				declaringTypeInstance.GenericArguments.Add(referenceGeneric.GenericArguments[i]);
			}
			result.Append(GetParameterTypeRepresentation(declaringTypeInstance));
			result.Append('.');
			if (referenceGeneric.GenericArguments.Count - parametersToMoveUp > 0)
			{
				result.Append(AppendGenericArguments(referenceGeneric, parametersToMoveUp));
			}
			else
			{
				string ptName = GenericHelper.GetNonGenericName(parameterType.Name);
				result.Append(ptName);
			}
			referenceGeneric.GenericArguments.Clear();
			referenceGeneric.GenericArguments.AddRange(nestedTypeBackup);

			declaringTypeInstance.GenericArguments.Clear();
			declaringTypeInstance.GenericArguments.AddRange(declaringBackup);
			return result.ToString();
		}