private static IList <ITypeParameterSymbol> RenameTypeParameters(
            IList <ITypeParameterSymbol> typeParameters,
            IList <string> newNames,
            TypeGenerator typeGenerator)
        {
            // We generate the type parameter in two passes.  The first creates the new type
            // parameter.  The second updates the constraints to point at this new type parameter.
            var newTypeParameters = new List <CodeGenerationTypeParameterSymbol>();
            var mapping           = new Dictionary <ITypeSymbol, ITypeSymbol>();

            for (int i = 0; i < typeParameters.Count; i++)
            {
                var typeParameter = typeParameters[i];

                var newTypeParameter = new CodeGenerationTypeParameterSymbol(
                    typeParameter.ContainingType,
                    typeParameter.GetAttributes(),
                    typeParameter.Variance,
                    newNames[i],
                    typeParameter.ConstraintTypes,
                    typeParameter.HasConstructorConstraint,
                    typeParameter.HasReferenceTypeConstraint,
                    typeParameter.HasValueTypeConstraint,
                    typeParameter.Ordinal);

                newTypeParameters.Add(newTypeParameter);
                mapping.Add(typeParameter, (ITypeSymbol)newTypeParameter.Instance);
            }

            // Now we update the constraints.
            foreach (var newTypeParameter in newTypeParameters)
            {
                newTypeParameter.ConstraintTypes = ImmutableArray.CreateRange(newTypeParameter.ConstraintTypes, t => t.SubstituteTypes(mapping, typeGenerator));
            }

            return(newTypeParameters.Cast <ITypeParameterSymbol>().ToList());
        }
		private static IList<ITypeParameterSymbol> RenameTypeParameters(
			IList<ITypeParameterSymbol> typeParameters,
			IList<string> newNames,
			TypeGenerator typeGenerator)
		{
			// We generate the type parameter in two passes.  The first creates the new type
			// parameter.  The second updates the constraints to point at this new type parameter.
			var newTypeParameters = new List<CodeGenerationTypeParameterSymbol>();
			var mapping = new Dictionary<ITypeSymbol, ITypeSymbol>();
			for (int i = 0; i < typeParameters.Count; i++)
			{
				var typeParameter = typeParameters[i];

				var newTypeParameter = new CodeGenerationTypeParameterSymbol(
					typeParameter.ContainingType,
					typeParameter.GetAttributes(),
					typeParameter.Variance,
					newNames[i],
					typeParameter.ConstraintTypes,
					typeParameter.HasConstructorConstraint,
					typeParameter.HasReferenceTypeConstraint,
					typeParameter.HasValueTypeConstraint,
					typeParameter.Ordinal);

				newTypeParameters.Add(newTypeParameter);
				mapping.Add(typeParameter, (ITypeSymbol)newTypeParameter.Instance);
			}

			// Now we update the constraints.
			foreach (var newTypeParameter in newTypeParameters)
			{
				newTypeParameter.ConstraintTypes = ImmutableArray.CreateRange(newTypeParameter.ConstraintTypes, t => t.SubstituteTypes(mapping, typeGenerator));
			}

			return newTypeParameters.Cast<ITypeParameterSymbol>().ToList();
		}