Esempio n. 1
0
        // <summary>
        //   Closes all open types
        // </summary>
        //
        // <remarks>
        //   We usually use TypeBuilder types.  When we are done
        //   creating the type (which will happen after we have added
        //   methods, fields, etc) we need to "Define" them before we
        //   can save the Assembly
        // </remarks>
        static public void CloseTypes()
        {
            //
            // We do this in two passes, first we close the structs,
            // then the classes, because it seems the code needs it this
            // way.  If this is really what is going on, we should probably
            // make sure that we define the structs in order as well.
            //
            foreach (TypeContainer tc in type_container_resolve_order)
            {
                if (tc.Kind == Kind.Struct && tc.Parent == root)
                {
                    tc.CloseType();
                }
            }

            foreach (TypeContainer tc in type_container_resolve_order)
            {
                if (!(tc.Kind == Kind.Struct && tc.Parent == root))
                {
                    tc.CloseType();
                }
            }

            if (root.Delegates != null)
            {
                foreach (Delegate d in root.Delegates)
                {
                    d.CloseType();
                }
            }


            //
            // If we have a <PrivateImplementationDetails> class, close it
            //
            if (helper_classes != null)
            {
                foreach (TypeBuilder type_builder in helper_classes)
                {
#if GMCS_SOURCE
                    type_builder.SetCustomAttribute(TypeManager.GetCompilerGeneratedAttribute(Location.Null));
#endif
                    type_builder.CreateType();
                }
            }

            type_container_resolve_order = null;
            helper_classes = null;
            //root = null;
            TypeManager.CleanUp();
        }