public void GenerateXml_WithErrors() { var errorAggregator = new ErrorAggregator <Exception>(); var validationException1 = SetUpExceptionWithDummyStackTrace("test validation exception", new DefaultValidationLog()); errorAggregator.AddException(validationException1); var reportGenerator = new ValidationErrorReportGenerator(errorAggregator, Helpers.RemotionReflectorFactory.GetRemotionReflection()); var output = reportGenerator.GenerateXml(); var validationExceptionElement = new RecursiveExceptionReportGenerator(validationException1).GenerateXml(); validationExceptionElement.Add( new XElement("ValidationLog", new XAttribute("number-of-rules-executed", validationException1.ValidationLog.GetNumberOfRulesExecuted()), new XAttribute("number-of-failures", validationException1.ValidationLog.GetNumberOfFailures()), new XAttribute("number-of-unexpected-exceptions", validationException1.ValidationLog.GetNumberOfUnexpectedExceptions()), new XAttribute("number-of-warnings", validationException1.ValidationLog.GetNumberOfWarnings()), new XAttribute("number-of-successes", validationException1.ValidationLog.GetNumberOfSuccesses()) )); var expectedOutput = new XElement("ValidationErrors", validationExceptionElement); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }
public void GenerateXml_WithValidationLogNullObject() { var errorAggregator = new ErrorAggregator <Exception>(); var validationException1 = SetUpExceptionWithDummyStackTrace("test validation exception", new DefaultValidationLog()); errorAggregator.AddException(validationException1); var remotionReflectorStub = MockRepository.GenerateStub <IRemotionReflector>(); var reportGenerator = new ValidationErrorReportGenerator(errorAggregator, remotionReflectorStub); remotionReflectorStub.Stub(_ => _.GetValidationLogFromValidationException(null)).IgnoreArguments() .Return(new ReflectedObject(new ValidationLogNullObject())); var output = reportGenerator.GenerateXml(); var validationExceptionElement = new RecursiveExceptionReportGenerator(validationException1).GenerateXml(); validationExceptionElement.Add( new XElement( "ValidationLog", new XAttribute("number-of-rules-executed", 0), new XAttribute("number-of-failures", 0), new XAttribute("number-of-unexpected-exceptions", 0), new XAttribute("number-of-warnings", 0), new XAttribute("number-of-successes", 0))); var expectedOutput = new XElement("ValidationErrors", validationExceptionElement); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }
public ValidationErrorReportGenerator(ErrorAggregator <Exception> errorAggregator, IRemotionReflector remotionReflector) { ArgumentUtility.CheckNotNull("errorAggregator", errorAggregator); ArgumentUtility.CheckNotNull("remotionReflector", remotionReflector); _errorAggregator = errorAggregator; _remotionReflector = remotionReflector; }
public ValidationErrorReportGenerator(ErrorAggregator<Exception> errorAggregator, IRemotionReflector remotionReflector) { ArgumentUtility.CheckNotNull ("errorAggregator", errorAggregator); ArgumentUtility.CheckNotNull ("remotionReflector", remotionReflector); _errorAggregator = errorAggregator; _remotionReflector = remotionReflector; }
public void GenerateXml_NoErrors() { var errorAggregator = new ErrorAggregator <Exception>(); var reportGenerator = new ValidationErrorReportGenerator(errorAggregator, Helpers.RemotionReflectorFactory.GetRemotionReflection()); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement("ValidationErrors"); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }
public void GenerateXml_NoErrors() { var errorAggregator = new ErrorAggregator<Exception>(); var reportGenerator = new ConfigurationErrorReportGenerator (errorAggregator); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement ("ConfigurationErrors"); Assert.That (output.ToString(), Is.EqualTo (expectedOutput.ToString())); }
public void GenerateXml_NoErrors() { var errorAggregator = new ErrorAggregator <Exception>(); var reportGenerator = new ConfigurationErrorReportGenerator(errorAggregator); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement("ConfigurationErrors"); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }
public void AddException_RetrieveWithExceptionsProperty() { var errorAggregator = new ErrorAggregator <Exception>(); var exception1 = new Exception("test exception"); var exception2 = new Exception("another text exception"); errorAggregator.AddException(exception1); errorAggregator.AddException(exception2); Assert.That(new[] { exception1, exception2 }, Is.EqualTo(errorAggregator.Exceptions.ToList())); }
public void AddException_RetrieveWithExceptionsProperty() { var errorAggregator = new ErrorAggregator<Exception>(); var exception1 = new Exception("test exception"); var exception2 = new Exception ("another text exception"); errorAggregator.AddException(exception1); errorAggregator.AddException(exception2); Assert.That(new[] { exception1, exception2 }, Is.EqualTo(errorAggregator.Exceptions.ToList())); }
public FullReportGenerator( InvolvedType[] involvedTypes, ErrorAggregator<Exception> configurationErrors, ErrorAggregator<Exception> validationErrors, IRemotionReflector remotionReflector, IOutputFormatter outputFormatter) { ArgumentUtility.CheckNotNull ("_involvedTypes", involvedTypes); ArgumentUtility.CheckNotNull ("configurationErrors", configurationErrors); ArgumentUtility.CheckNotNull ("validationErrors", validationErrors); ArgumentUtility.CheckNotNull ("remotionReflector", remotionReflector); ArgumentUtility.CheckNotNull ("outputFormatter", outputFormatter); _involvedTypes = involvedTypes; _configurationErrors = configurationErrors; _validationErrors = validationErrors; _remotionReflector = remotionReflector; _outputFormatter = outputFormatter; }
public FullReportGenerator( InvolvedType[] involvedTypes, ErrorAggregator <Exception> configurationErrors, ErrorAggregator <Exception> validationErrors, IRemotionReflector remotionReflector, IOutputFormatter outputFormatter) { ArgumentUtility.CheckNotNull("_involvedTypes", involvedTypes); ArgumentUtility.CheckNotNull("configurationErrors", configurationErrors); ArgumentUtility.CheckNotNull("validationErrors", validationErrors); ArgumentUtility.CheckNotNull("remotionReflector", remotionReflector); ArgumentUtility.CheckNotNull("outputFormatter", outputFormatter); _involvedTypes = involvedTypes; _configurationErrors = configurationErrors; _validationErrors = validationErrors; _remotionReflector = remotionReflector; _outputFormatter = outputFormatter; }
public InvolvedTypeFinder( ReflectedObject mixinConfiguration, Assembly[] assemblies, ErrorAggregator<Exception> configurationErrors, ErrorAggregator<Exception> validationErrors, IRemotionReflector remotionReflector ) { ArgumentUtility.CheckNotNull ("mixinConfiguration", mixinConfiguration); ArgumentUtility.CheckNotNull ("assemblies", assemblies); ArgumentUtility.CheckNotNull ("configurationErrors", configurationErrors); ArgumentUtility.CheckNotNull ("validationErrors", validationErrors); ArgumentUtility.CheckNotNull ("remotionReflector", remotionReflector); _mixinConfiguration = mixinConfiguration; _assemblies = assemblies; _configurationErrors = configurationErrors; _validationErrors = validationErrors; _remotionReflector = remotionReflector; }
public InvolvedTypeFinder( ReflectedObject mixinConfiguration, Assembly[] assemblies, ErrorAggregator <Exception> configurationErrors, ErrorAggregator <Exception> validationErrors, IRemotionReflector remotionReflector ) { ArgumentUtility.CheckNotNull("mixinConfiguration", mixinConfiguration); ArgumentUtility.CheckNotNull("assemblies", assemblies); ArgumentUtility.CheckNotNull("configurationErrors", configurationErrors); ArgumentUtility.CheckNotNull("validationErrors", validationErrors); ArgumentUtility.CheckNotNull("remotionReflector", remotionReflector); _mixinConfiguration = mixinConfiguration; _assemblies = assemblies; _configurationErrors = configurationErrors; _validationErrors = validationErrors; _remotionReflector = remotionReflector; }
public void GenerateXml_WithErrors() { var errorAggregator = new ErrorAggregator <Exception>(); var innerException1 = SetUpExceptionWithDummyStackTrace("inner exception", null); var Exception1 = SetUpExceptionWithDummyStackTrace("test configuration exception 1", innerException1); var Exception2 = SetUpExceptionWithDummyStackTrace("test configuration excpetion 2", null); errorAggregator.AddException(Exception1); errorAggregator.AddException(Exception2); var reportGenerator = new ConfigurationErrorReportGenerator(errorAggregator); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement( "ConfigurationErrors", new RecursiveExceptionReportGenerator(Exception1).GenerateXml(), new RecursiveExceptionReportGenerator(Exception2).GenerateXml() ); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }
public void GenerateXml_WithErrors() { var errorAggregator = new ErrorAggregator<Exception>(); var innerException1 = SetUpExceptionWithDummyStackTrace ("inner exception", null); var Exception1 = SetUpExceptionWithDummyStackTrace ("test configuration exception 1", innerException1); var Exception2 = SetUpExceptionWithDummyStackTrace ("test configuration excpetion 2", null); errorAggregator.AddException (Exception1); errorAggregator.AddException (Exception2); var reportGenerator = new ConfigurationErrorReportGenerator (errorAggregator); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement ( "ConfigurationErrors", new RecursiveExceptionReportGenerator (Exception1).GenerateXml(), new RecursiveExceptionReportGenerator (Exception2).GenerateXml() ); Assert.That (output.ToString(), Is.EqualTo (expectedOutput.ToString())); }
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; }
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); }
public void SetUp() { _configurationErrors = new ErrorAggregator <Exception>(); _validationErrors = new ErrorAggregator <Exception>(); }
public ConfigurationErrorReportGenerator(ErrorAggregator <Exception> errorAggregator) { ArgumentUtility.CheckNotNull("errorAggregator", errorAggregator); _errorAggregator = errorAggregator; }
public ConfigurationErrorReportGenerator(ErrorAggregator<Exception> errorAggregator) { ArgumentUtility.CheckNotNull ("errorAggregator", errorAggregator); _errorAggregator = errorAggregator; }