private static void ResolveTypeNames()

in tools/codegen/exe/Effect.cs [312:399]


        private static void ResolveTypeNames(List<Effects.Effect> effects)
        {
            var typeRenames = new Dictionary<string, string[]>
            {
                // D2D name                       IDL name                   C++ name
                { "bool",         new string[] { "boolean",                 "boolean" } },
                { "int32",        new string[] { "INT32",                   "int32_t" } },
                { "uint32",       new string[] { "INT32",                   "int32_t" } },
                { "colorcontext", new string[] { "ColorManagementProfile*", "IColorManagementProfile*" } },
            };

            foreach (var property in GetAllEffectsProperties(effects))
            {
                if (property.TypeNameIdl != null)
                {
                    string xmlName = property.TypeNameIdl;

                    if (typeRenames.ContainsKey(xmlName))
                    {
                        // Specially remapped type, where D2D format XML files don't match WinRT type naming.
                        property.TypeNameIdl = typeRenames[xmlName][0];
                        property.TypeNameCpp = typeRenames[xmlName][1];
                        property.TypeNameBoxed = typeRenames[xmlName][1];
                    }
                    else if (xmlName.StartsWith("matrix") || xmlName.StartsWith("vector"))
                    {
                        if (property.Name.Contains("Rect"))
                        {
                            // D2D passes rectangle properties as float4, but we remap them to use strongly typed Rect.
                            property.TypeNameIdl = "Windows.Foundation.Rect";
                            property.TypeNameCpp = "Rect";
                        }
                        else if (property.Name.Contains("Color") && xmlName.StartsWith("vector"))
                        {
                            // D2D passes color properties as float3 or float4, but we remap them to use strongly typed Color.
                            property.TypeNameIdl = "Windows.UI.Color";
                            property.TypeNameCpp = "Color";
                        }
                        else
                        {
                            // Vector or matrix type.
                            property.TypeNameIdl = char.ToUpper(xmlName[0]) + xmlName.Substring(1);
                            property.TypeNameCpp = property.TypeNameIdl;

                            // Matrix5x4 is defined locally as part of Effects, but other math types live in the Numerics namespace.
                            if (!xmlName.Contains("5x4"))
                            {
                                property.TypeNameIdl = "NUMERICS." + property.TypeNameIdl;
                                property.TypeNameCpp = "Numerics::" + property.TypeNameCpp;
                            }
                        }

                        // Convert eg. "matrix3x2" to 6, or "vector3" to 3.
                        var sizeSuffix = xmlName.SkipWhile(char.IsLetter).ToArray();
                        var sizeElements = new string(sizeSuffix).Split('x').Select(int.Parse);
                        var size = sizeElements.Aggregate((a, b) => a * b);

                        property.TypeNameBoxed = "float[" + size + "]";
                    }
                    else if (xmlName == "blob")
                    {
                        // The D2D "blob" type projects as an array of floats.
                        property.TypeNameIdl = "float";
                        property.TypeNameCpp = "float";
                        property.TypeNameBoxed = "float";
                        property.IsArray = true;
                    }
                    else if (xmlName == "iunknown" && property.Name == "Table")
                    {
                        // Property of type ID2D1LookupTable3D is projected as EffectTransferTable3D.
                        property.TypeNameIdl = "EffectTransferTable3D*";
                        property.TypeNameCpp = property.TypeNameBoxed = "IEffectTransferTable3D*";
                    }
                    else
                    {
                        // Any other type.
                        property.TypeNameCpp = xmlName;
                        property.TypeNameBoxed = xmlName;

                        // Enums are internally stored as uints.
                        if (property.Type == "enum")
                        {
                            property.TypeNameBoxed = "uint32_t";
                        }
                    }
                }
            }
        }