public bool Execute()
#endif
        {
            try
            {
                List <Type> types = WinMDInput.SelectMany(x => GetTypes(x, References)).ToList();

                var collectedMetadata = new List <TypeDefinition>();

                foreach (var type in types)
                {
                    var typeDefinition = new TypeDefinition();
                    typeDefinition.Type = type;

                    typeDefinition.HasCustomActivationFactory = HasAttribute("MUXHasCustomActivationFactoryAttribute", type);

                    typeDefinition.NeedsActivationFactory = NeedsActivationFactory(type);

                    var props = typeDefinition.Properties = CollectProperties(type);

                    var events = typeDefinition.Events = CollectEvents(type);

                    // If this type has DependencyProperty properties then write out the helpers
                    if (props.Count > 0 || events.Count > 0)
                    {
                        collectedMetadata.Add(typeDefinition);
                    }
                }

                foreach (var typeDefinition in collectedMetadata)
                {
                    var    type   = typeDefinition.Type;
                    string header = WriteHeader(typeDefinition);
                    string impl   = WriteImplementation(typeDefinition, collectedMetadata);

                    string headerPath = Path.Combine(OutputDirectory, type.Name + ".properties.h");
                    string implPath   = Path.Combine(OutputDirectory, type.Name + ".properties.cpp");

                    try
                    {
                        Directory.CreateDirectory(OutputDirectory);
                    }
                    catch
                    {
                    }

                    RewriteFileIfNecessary(headerPath, header);
                    RewriteFileIfNecessary(implPath, impl);
                }

                FilesWritten = _pendingFilesWritten.ToArray();

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine("ERROR: {0}", e.ToString());
                return(false);
            }
        }
        public bool Execute()
#endif
        {
            try
            {
                List <Type> types = WinMDInput.SelectMany(x => GetTypes(x, References)).ToList();

                var collectedMetadata = new List <TypeDefinition>();

                foreach (var type in types)
                {
                    if (IncludedTypesMetadata != null && !IncludedTypesMetadata.ContainsKey(type.Name))
                    {
                        // Skip types not explicitly included by the override metadata
                        continue;
                    }

                    var typeDefinition = new TypeDefinition();
                    typeDefinition.Type = type;

                    typeDefinition.HasCustomActivationFactory =
                        HasAttribute(HasCustomActivationFactoryMetadata, type.Name, "MUXHasCustomActivationFactoryAttribute", type);

                    typeDefinition.NeedsActivationFactory = NeedsActivationFactory(type);

                    var props = typeDefinition.Properties = CollectProperties(type);

                    var events = typeDefinition.Events = CollectEvents(type);

                    // If this type has DependencyProperty properties then write out the helpers
                    if (props.Count > 0 || events.Count > 0)
                    {
                        collectedMetadata.Add(typeDefinition);
                    }
                }

                foreach (var typeDefinition in collectedMetadata)
                {
                    var    type   = typeDefinition.Type;
                    string header = WriteHeader(typeDefinition);
                    string impl   = WriteImplementation(typeDefinition, collectedMetadata);

                    string headerPath = Path.Combine(OutputDirectory, type.Name + ".properties.h");
                    string implPath   = Path.Combine(OutputDirectory, type.Name + ".properties.cpp");

                    try
                    {
                        Directory.CreateDirectory(OutputDirectory);
                    }
                    catch
                    {
                    }

                    RewriteFileIfNecessary(headerPath, header);
                    RewriteFileIfNecessary(implPath, impl);
                }

                if (IncludedTypesMetadata == null) // Only do this if we aren't running in OS repo
                {
                    collectedMetadata = collectedMetadata.OrderBy(x => x.Type.Name).ToList();

                    // Workaround for Deliverable 18767852: WinMD Feature Request: Custom attributes (for codegen hints) which are stripped out of SDK metadata
                    // In the OS repo we can't use IDL attributes as they would be part of public metadata. So instead
                    // we write this summary file which in the dep.controls/MUX build is an output file. But in the OS
                    // build it can be a "sidecar" file that carries the metadata that we can't store in the IDL.
                    // So the truth is in the IDL but in the OS repo if you need to RunWUXCCodeGen without round-tripping
                    // through the dep.controls build then you can manually edit MetadataSummary.cs in a pinch.
                    string metadataSummary     = WriteMetadataSummary(collectedMetadata);
                    string metadataSummaryPath = Path.Combine(OutputDirectory, "MetadataSummary.cs");
                    RewriteFileIfNecessary(metadataSummaryPath, metadataSummary);

                    FilesWritten = _pendingFilesWritten.ToArray();
                }

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine("ERROR: {0}", e.ToString());
                return(false);
            }
        }