private void DefineTypeParameterBuildersIfPresent(ILConversion conversion, ConvertedTypeDefinition_I convertedType)
        {
            if (!convertedType.IsGeneric())
            {
                return;
            }

            var gtd = (ConvertedGenericTypeDefinition_I)convertedType;

            if (!gtd.HasTypeParameters())
            {
                return;
            }

            var ctwtb = (ConvertedTypeDefinitionWithTypeBuilder_I)convertedType;

            var tpList = gtd.TypeParameters.All;

            var names = Types.TypeParameters.GetNames(conversion, gtd);

            var genericParameters = convertedType.TypeBuilder.DefineGenericParameters(names);

            gtd.TypeParameters.Builders = genericParameters;

            for (var i = 0; i < tpList.Count; i++)
            {
                var tp = (ConvertedGenericParameterTypeDefinition)tpList[i];

                tp.Builder = genericParameters[i];

                tp.UnderlyingType = genericParameters[i];
            }
        }
Exemple #2
0
        //public void BakeTypes(ILConversion conversion, List<ConvertedTypeDefinition_I> list)
        //{
        //    // NEED TO GO THROUGH ALL;
        //    // * Base Types
        //    // * Interface Types
        //    // * Nested Types
        //    // * Generic Type Parameter Constraints

        //    // AND MAKE SURE THEY ARE BAKED FIRST

        //    //for (int i = 0; i < list.Count; i++)
        //    //{
        //    //    var input = list[i];

        //    //    Bake(conversion, input);
        //    //}
        //}



        private void EnsureGenericIsReadyForBaking(ILConversion conversion, ConvertedTypeDefinition_I input)
        {
            if (!input.IsGeneric())
            {
                return;
            }

            if (!(input is ConvertedGenericTypeDefinition_I convertedGeneric))
            {
                throw new System.Exception("Expected at least a converted generic.");
            }

            if (convertedGeneric.HasTypeArguments())
            {
                for (int i = 0; i < convertedGeneric.TypeArguments.All.Count; i++)
                {
                    var typeArgument = convertedGeneric.TypeArguments.All[i];



                    //Bake(conversion, convertedTypeArgument);
                }
            }

            if (!convertedGeneric.HasTypeParameters())
            {
                return;
            }

            for (int i = 0; i < convertedGeneric.TypeParameters.All.Count; i++)
            {
                var typeParameter = (ConvertedGenericParameterTypeDefinition)convertedGeneric.TypeParameters.All[i];

                if (typeParameter.BaseTypeConstraint != null)
                {
                    var classConstraint = typeParameter.BaseTypeConstraint.Class;
                }

                if (typeParameter.InterfaceTypeConstraints == null)
                {
                    continue;
                }

                for (int j = 0; j < typeParameter.InterfaceTypeConstraints.Count; j++)
                {
                    var interfaceTypeConstraint = typeParameter.InterfaceTypeConstraints[j];

                    if (interfaceTypeConstraint.Interface == null)
                    {
                        continue;
                    }

                    var interfaceConstraint = interfaceTypeConstraint.Interface;
                }
            }
        }