Exemple #1
0
        private static bool InternalRun(XRefArguments arguments)
        {
            var argsOk = CheckArguments (arguments);
              if (!argsOk)
            return false;

              IRemotionReflector reflector;
              if (!CreateReflector(arguments, out reflector))
            return false;

              var assemblyResolver = AssemblyResolver.Create();
              AppDomain.CurrentDomain.AssemblyResolve += assemblyResolver.HandleAssemblyResolve;

              reflector.InitializeLogging ();

              var typeDiscoveryService = reflector.GetTypeDiscoveryService();

              ICollection allTypes;
              try
              {
            allTypes = typeDiscoveryService.GetTypes (null, true);
              }
              catch (Exception ex)
              {
            Log.SendError (ex.ToString());
            return false;
              }

              var allAssemblies = allTypes.Cast<Type>().Select (t => t.Assembly)
              .Distinct()
              .Where (a => !reflector.IsRelevantAssemblyForConfiguration (a) || !reflector.IsNonApplicationAssembly (a))
              .ToArray();

              if (!allAssemblies.Any())
              {
            Log.SendError ("\"{0}\" contains no assemblies or only assemblies on the ignore list", arguments.AssemblyDirectory);
            return false;
              }

              var mixinConfiguration = reflector.BuildConfigurationFromAssemblies (allAssemblies);
              var outputFormatter = new OutputFormatter ();
              var configurationErrors = new ErrorAggregator<Exception> ();
              var validationErrors = new ErrorAggregator<Exception> ();

              var involvedTypes = new InvolvedTypeFinder (mixinConfiguration, allAssemblies, configurationErrors, validationErrors, reflector).FindInvolvedTypes ();
              var reportGenerator = new FullReportGenerator (involvedTypes, configurationErrors, validationErrors, reflector, outputFormatter);
              var outputDocument = reportGenerator.GenerateXmlDocument ();

              var xmlFile = Path.Combine (arguments.OutputDirectory,
                                 !string.IsNullOrEmpty (arguments.XMLOutputFileName)
                                   ? arguments.XMLOutputFileName
                                   : "MixinXRef.xml");

              outputDocument.Save (xmlFile);

              reportGenerator = null;
              GC.Collect ();

              allAssemblies = null;
              GC.Collect ();
              GC.WaitForPendingFinalizers ();

              if (!arguments.SkipHTMLGeneration)
              {
            var transformerExitCode = new XRefTransformer (xmlFile, arguments.OutputDirectory).GenerateHtmlFromXml ();
            if (transformerExitCode != 0)
            {
              Log.SendError ("Error applying XSLT (code {0})", transformerExitCode);
              return false;
            }

            // copy resources folder
            var xRefPath = Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location);
            new DirectoryInfo (Path.Combine (xRefPath, @"xml_utilities\resources")).CopyTo (Path.Combine (arguments.OutputDirectory, "resources"));

            Log.SendInfo ("Mixin Documentation successfully generated to '{0}'.", arguments.OutputDirectory);
              }
              else
              {
            Log.SendInfo ("  Skipping HTML generation");
              }

              return true;
        }
Exemple #2
0
        private static bool InternalRun(XRefArguments arguments)
        {
            var argsOk = CheckArguments(arguments);

            if (!argsOk)
            {
                return(false);
            }

            IRemotionReflector reflector;

            if (!CreateReflector(arguments, out reflector))
            {
                return(false);
            }

            var assemblyResolver = AssemblyResolver.Create();

            AppDomain.CurrentDomain.AssemblyResolve += assemblyResolver.HandleAssemblyResolve;

            reflector.InitializeLogging();

            var typeDiscoveryService = reflector.GetTypeDiscoveryService();

            ICollection allTypes;

            try
            {
                allTypes = typeDiscoveryService.GetTypes(null, true);
            }
            catch (Exception ex)
            {
                Log.SendError(ex.ToString());
                return(false);
            }

            var allAssemblies = allTypes.Cast <Type>().Select(t => t.Assembly)
                                .Distinct()
                                .Where(a => !reflector.IsRelevantAssemblyForConfiguration(a) || !reflector.IsNonApplicationAssembly(a))
                                .ToArray();

            if (!allAssemblies.Any())
            {
                Log.SendError("\"{0}\" contains no assemblies or only assemblies on the ignore list", arguments.AssemblyDirectory);
                return(false);
            }

            var mixinConfiguration  = reflector.BuildConfigurationFromAssemblies(allAssemblies);
            var outputFormatter     = new OutputFormatter();
            var configurationErrors = new ErrorAggregator <Exception> ();
            var validationErrors    = new ErrorAggregator <Exception> ();

            var involvedTypes   = new InvolvedTypeFinder(mixinConfiguration, allAssemblies, configurationErrors, validationErrors, reflector).FindInvolvedTypes();
            var reportGenerator = new FullReportGenerator(involvedTypes, configurationErrors, validationErrors, reflector, outputFormatter);
            var outputDocument  = reportGenerator.GenerateXmlDocument();

            var xmlFile = Path.Combine(arguments.OutputDirectory,
                                       !string.IsNullOrEmpty(arguments.XMLOutputFileName)
                                   ? arguments.XMLOutputFileName
                                   : "MixinXRef.xml");

            outputDocument.Save(xmlFile);

            reportGenerator = null;
            GC.Collect();

            allAssemblies = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();

            if (!arguments.SkipHTMLGeneration)
            {
                var transformerExitCode = new XRefTransformer(xmlFile, arguments.OutputDirectory).GenerateHtmlFromXml();
                if (transformerExitCode != 0)
                {
                    Log.SendError("Error applying XSLT (code {0})", transformerExitCode);
                    return(false);
                }

                // copy resources folder
                var xRefPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                new DirectoryInfo(Path.Combine(xRefPath, @"xml_utilities\resources")).CopyTo(Path.Combine(arguments.OutputDirectory, "resources"));

                Log.SendInfo("Mixin Documentation successfully generated to '{0}'.", arguments.OutputDirectory);
            }
            else
            {
                Log.SendInfo("  Skipping HTML generation");
            }

            return(true);
        }