/// <summary> /// Assembles a document from the given template, answers and settings. /// </summary> /// <param name="template">The template to assemble.</param> /// <param name="answers">The answers to use during the assembly.</param> /// <param name="settings">The settings for the assembly.</param> /// <include file="../../Shared/Help.xml" path="Help/string/param[@name='logRef']"/> /// <returns>An <c>AssembleDocumentResult</c> that contains the results of the assembly.</returns> public AssembleDocumentResult AssembleDocument(Template template, System.IO.TextReader answers, AssembleDocumentSettings settings, string logRef) { // Validate input parameters, creating defaults as appropriate. string logStr = logRef == null ? string.Empty : logRef; if (template == null) { throw new ArgumentNullException("template", string.Format(@"Cloud.Services.AssembleDocument: the ""template"" parameter passed in was null, logRef: {0}", logStr)); } if (settings == null) { settings = new AssembleDocumentSettings(); } AssembleDocumentResult result = null; AssemblyResult asmResult = null; using (var client = new SoapClient(_subscriberID, _signingKey, HostAddress, ProxyAddress)) { asmResult = client.AssembleDocument( template, answers == null ? "" : answers.ReadToEnd(), settings, logRef ); } if (asmResult != null) { result = Util.ConvertAssemblyResult(template, asmResult, settings.Format); } return(result); }
public override async Task <bool> WriteOutputAsync(AssemblyResult assemblyResult) { string filename = System.IO.Path.GetFileNameWithoutExtension(assemblyResult.FilePath); string outputFile = System.IO.Path.Combine(_outputFolder, $"{filename}.fxt"); bool result = true; try { base.EnsureFolderCreated(); using (var f = System.IO.File.CreateText(outputFile)) { //for flat file the ordering is important, order by type, methods and sequence of invocation. foreach (var t in assemblyResult.Types.OrderBy(x => x.ClassType)) { foreach (var m in t.Methods.OrderBy(z => z.Name)) { foreach (var i in m.Invocations.OrderBy(r => r.Sequence)) { await f.WriteLineAsync($"{t.ClassType}::{m.Name}({m.Parameters})::{i.Invocation}"); } } } } } catch (Exception) { result = false; } return(result); }
public AssemblyResult GetTaskAssembly(IEnumerable <Compilation> compilations) { var assemblyResult = new AssemblyResult(); foreach (var compilation in compilations) { using (var ms = new MemoryStream()) { EmitResult result = compilation.Emit(ms); if (result.Success) { ms.Seek(0, SeekOrigin.Begin); var assembly = Assembly.Load(ms.ToArray()); assemblyResult.Assemblies.Add(assembly); } else { IEnumerable <Diagnostic> failures = result.Diagnostics.Where(diagnostic => diagnostic.IsWarningAsError || diagnostic.Severity == DiagnosticSeverity.Error); foreach (Diagnostic diagnostic in failures) { assemblyResult.CompileErrors.Add(string.Format("{0}: {1}", diagnostic.Id, diagnostic.GetMessage())); } } } } return(assemblyResult); }
public void Initialize() { AssemblyReader asmInfoProcessor = new AssemblyReader(); result = asmInfoProcessor.read(dllPath); testClassType = typeof(Class1); }
/// <summary> /// 根据反射读取协议dll,并生成协议解析源码 /// </summary> /// <param name="assemblyName"></param> public static string AssemblyParseDll(string assemblyName) { AssemblyHandler handler = new AssemblyHandler(); AssemblyResult result = handler.GetClassName(assemblyName); result.AssemblyNameList = new List <string>(); result.AssemblyNameList.Add(assemblyName); string strGenerateCode = GenerateCodeModel.GenerateCode(result.ClassList); //string codeFileName = "Client_Code.cs"; string codeFileName = ConstData.GenrateCodeFileName; try { string codeFileFullName = PathExt.codePath + ConstData.GenrateCodePathName + codeFileName; FileInfo fCodeFileName = new FileInfo(codeFileFullName); StreamWriter wResponseRecv = fCodeFileName.CreateText(); wResponseRecv.WriteLine(strGenerateCode); wResponseRecv.Close(); //codeFileFullName = PathExt.rootPath + ConstData.GenrateCodePathName + codeFileName; //fCodeFileName = new FileInfo(codeFileFullName); //wResponseRecv = fCodeFileName.CreateText(); //wResponseRecv.WriteLine(strGenerateCode); //wResponseRecv.Close(); } catch (System.Exception e) { Log.Error("e {0}", e.Message); } return(strGenerateCode); }
public Assembly Process() { IIOService ioService = new IOService(); string asmPath = ioService.OpenFileDialog(); if (asmPath != null) { AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += new ResolveEventHandler(CurrentDomain_ReflectionOnlyAssemblyResolve); System.Reflection.Assembly asm = System.Reflection.Assembly.ReflectionOnlyLoadFrom(asmPath); AssemblyInfoProcessor asmProcessor = new AssemblyInfoProcessor(asm); AssemblyResult asmRes = asmProcessor.GetStructeredInfo(); ObservableCollection <NameSpace> namespaces = new ObservableCollection <NameSpace>(); foreach (NamespaceResult namesp in asmRes.Namespaces) { ObservableCollection <DataType> types = new ObservableCollection <DataType>(); foreach (TypeResult typeRes in namesp.DataTypeResult) { DataType type = new DataType { Name = typeRes.Name, TypeInfo = new ObservableCollection <string>(typeRes.Fields.Concat(typeRes.Properties).Concat(typeRes.Methods)) }; types.Add(type); } NameSpace nmsp = new NameSpace { Name = namesp.Name, Types = types }; namespaces.Add(nmsp); } Assembly result = new Assembly { Name = asm.GetName().Name, Namespaces = namespaces }; return(result); } return(null); }
public void ToXml() { XmlDocument doc = new XmlDocument(); doc.LoadXml("<foo/>"); XmlNode parentNode = doc.ChildNodes[0]; AssemblyResult assemblyResult = new AssemblyResult(filename, @"C:\Foo\Bar"); XmlNode resultNode = assemblyResult.ToXml(parentNode); Assert.Equal("assembly", resultNode.Name); Assert.Equal(Path.GetFullPath(filename), resultNode.Attributes["name"].Value); Assert.Equal(@"C:\Foo\Bar", resultNode.Attributes["configFile"].Value); Assert.NotNull(resultNode.Attributes["run-date"]); Assert.NotNull(resultNode.Attributes["run-time"]); Assert.Equal("0.000", resultNode.Attributes["time"].Value); Assert.Equal("0", resultNode.Attributes["total"].Value); Assert.Equal("0", resultNode.Attributes["passed"].Value); Assert.Equal("0", resultNode.Attributes["failed"].Value); Assert.Equal("0", resultNode.Attributes["skipped"].Value); Assert.Contains("xUnit.net", resultNode.Attributes["test-framework"].Value); string expectedEnvironment = String.Format("{0}-bit .NET {1}", IntPtr.Size * 8, Environment.Version); Assert.Equal(expectedEnvironment, resultNode.Attributes["environment"].Value); }
public void ShouldReportPassFailSkipCounts() { using (var console = new RedirectedConsole()) { var listener = new ConsoleListener(); var assembly = typeof(ConsoleListener).Assembly; var version = assembly.GetName().Version; var assemblyResult = new AssemblyResult(assembly.Location); var conventionResult = new ConventionResult("Fake Convention"); var classResult = new ClassResult("Fake Class"); assemblyResult.Add(conventionResult); conventionResult.Add(classResult); classResult.Add(CaseResult.Passed("A", TimeSpan.Zero)); classResult.Add(CaseResult.Failed("B", TimeSpan.Zero, new ExceptionInfo(new Exception(), new AssertionLibraryFilter()))); classResult.Add(CaseResult.Failed("C", TimeSpan.Zero, new ExceptionInfo(new Exception(), new AssertionLibraryFilter()))); classResult.Add(CaseResult.Skipped("D", "Reason")); classResult.Add(CaseResult.Skipped("E", "Reason")); classResult.Add(CaseResult.Skipped("F", "Reason")); listener.AssemblyCompleted(assembly, assemblyResult); console.Lines().ShouldEqual("1 passed, 2 failed, 3 skipped, took 0.00 seconds (Fixie " + version + ")."); } }
public void ToXml_WithChildren() { XmlDocument doc = new XmlDocument(); doc.LoadXml("<foo/>"); XmlNode parentNode = doc.ChildNodes[0]; PassedResult passedResult = new PassedResult("foo", "bar", null, null); passedResult.ExecutionTime = 1.1; FailedResult failedResult = new FailedResult("foo", "bar", null, null, "extype", "message", "stack"); failedResult.ExecutionTime = 2.2; SkipResult skipResult = new SkipResult("foo", "bar", null, null, "reason"); ClassResult classResult = new ClassResult(typeof(object)); classResult.Add(passedResult); classResult.Add(failedResult); classResult.Add(skipResult); AssemblyResult assemblyResult = new AssemblyResult(filename); assemblyResult.Add(classResult); XmlNode resultNode = assemblyResult.ToXml(parentNode); Assert.Equal("3.300", resultNode.Attributes["time"].Value); Assert.Equal("3", resultNode.Attributes["total"].Value); Assert.Equal("1", resultNode.Attributes["passed"].Value); Assert.Equal("1", resultNode.Attributes["failed"].Value); Assert.Equal("1", resultNode.Attributes["skipped"].Value); Assert.Single(resultNode.SelectNodes("class")); }
public void Initialize() { Assembly asm = Assembly.ReflectionOnlyLoadFrom("./TestAssemblyProcessor.dll"); AssemblyInfoProcessor asmInfoProcessor = new AssemblyInfoProcessor(asm); asmResult = asmInfoProcessor.GetStructeredInfo(); testClassType = typeof(UnitTest1); }
public void Initialize() { string path = Directory.GetCurrentDirectory() + "\\LibraryForTesting.dll"; AssemblyBrowser.AssemblyBrowser browser = new AssemblyBrowser.AssemblyBrowser(); _result = browser.Browse(path); }
static XElement Assembly(AssemblyResult assemblyResult) { return(new XElement("test-suite", new XAttribute("success", assemblyResult.Failed == 0), new XAttribute("name", assemblyResult.Name), new XAttribute("time", Seconds(assemblyResult.Duration)), new XElement("results", assemblyResult.ConventionResults.Select(Convention)))); }
public static void Report(AssemblyResult result, NUnitListener errorListener) { Console.WriteLine(result.Summary); if (errorListener.HasError) { Assert.Fail(errorListener.FailResult.Exceptions.CompoundStackTrace); } }
public static void GetAsseblyResult(out AssemblyHandler handler, out AssemblyResult result) { //AssemblyHandler handler = new AssemblyHandler(); handler = new AssemblyHandler(); //AssemblyResult result = handler.GetClassName(ClientMsgDll); result = handler.GetClassName(ConstData.ServerMsgDll); result.AssemblyNameList = new List <string>(); result.AssemblyNameList.Add(ConstData.ServerMsgDll); }
public void Setup() { string path = @"C:\Users\dauks\source\repos\Spp_Lab3_Assembly_Browser\TestLib\bin\Debug\TestLib.dll"; // GetType().Assembly.Location AssemblyBrowser browser = new AssemblyBrowser(); _result = browser.GetNamespaces(path); }
static XElement Assembly(AssemblyResult assemblyResult) { return(new XElement("test-suite", new XAttribute("type", "Assembly"), new XAttribute("success", assemblyResult.Failed == 0), new XAttribute("name", assemblyResult.Name), new XAttribute("time", Seconds(assemblyResult.Duration)), new XAttribute("executed", true), new XAttribute("result", assemblyResult.Failed > 0 ? "Failure" : "Success"), new XElement("results", assemblyResult.ConventionResults.Select(Convention)))); }
public void ConstructorPassesArguments() { var resultPerFailureMechanism = new [] { new FailureMechanismSectionList(new [] { new FailureMechanismSection(0, 10) }) }; var combinedSectionResult = new [] { new FailureMechanismSectionWithCategory(0, 10, EInterpretationCategory.I) }; var result = new AssemblyResult(resultPerFailureMechanism, combinedSectionResult); Assert.AreEqual(resultPerFailureMechanism, result.ResultPerFailureMechanism); Assert.AreEqual(combinedSectionResult, result.CombinedSectionResult); }
public AssemblyResult Analyse() { try { using (var ass = Mono.Cecil.AssemblyDefinition.ReadAssembly(_assembly)) { var assembly = new AssemblyResult(ass.FullName, _assembly); foreach (var module in ass.Modules.OrderBy(m => m.FileName)) { foreach (var classType in module.GetTypes().OrderBy(z => z.FullName).Where(z => !z.IsInterface)) { var typeResult = new ClassTypeResult(classType.FullName, classType.Module.FileName); foreach (var method in classType.Methods.Where(e => !e.IsAbstract).OrderBy(e => e.FullName)) { int seq = 0; if (method.HasBody) { string parameters = String.Join(",", method.Parameters); var methodResult = new MethodResult(method.Name, parameters); foreach (var instruction in method.Body.Instructions .Where(u => ((u.OpCode == OpCodes.Call)) || (u.OpCode == OpCodes.Callvirt) || (u.OpCode == OpCodes.Calli) || (u.OpCode == OpCodes.Newobj) )) { var splits = instruction.Operand.ToString().Split(" "); var invoke = new InvocationResult(splits[1], splits[0], seq++); methodResult.Invocations.Add(invoke); } typeResult.Methods.Add(methodResult); } } assembly.Types.Add(typeResult); } } return(assembly); } } catch (Exception ex) { var err = new AssemblyResult("NotAvailable", _assembly); err.HandleException(ex); return(err); } }
/// <summary> /// <c>AssembleDocument</c> assembles (creates) a document from the given template, answers and settings. /// </summary> /// <param name="template">An instance of the Template class, from which the document will be assembled.</param> /// <param name="answers">The set of answers that will be applied to the template to assemble the document.</param> /// <param name="settings">Settings that will be used to assemble the document. /// These settings include the assembled document format (file extension), markup syntax, how to display fields with unanswered variables, etc</param> /// <param name="logRef">A string to display in logs related to this request.</param> /// <returns>returns information about the assembled document, the document type, the unanswered variables, the resulting answers, etc.</returns> public AssembleDocumentResult AssembleDocument(Template template, TextReader answers, AssembleDocumentSettings settings, string logRef) { // Validate input parameters, creating defaults as appropriate. string logStr = logRef == null ? string.Empty : logRef; if (template == null) { throw new ArgumentNullException("template", string.Format(@"WebService.Services.AssembleDocument: The ""template"" parameter passed in was null, logRef: {0}.", logStr)); } if (settings == null) { settings = new AssembleDocumentSettings(); } AssembleDocumentResult result = null; AssemblyResult asmResult = null; using (Proxy client = GetProxy()) { OutputFormat outputFormat; if (template.GeneratesDocument) { outputFormat = ConvertFormat(settings.Format); } else // avoid requesting any output other than answers from interview templates! (for the HDS web service) { outputFormat = OutputFormat.Answers; } AssemblyOptions assemblyOptions = ConvertOptions(settings); string fileName = GetRelativePath(template.GetFullPath()); asmResult = client.AssembleDocument( fileName, answers == null ? null : new BinaryObject[] { Util.GetBinaryObjectFromTextReader(answers) }, // answers outputFormat, assemblyOptions, null); SafeCloseClient(client, logRef); } if (asmResult != null) { result = Util.ConvertAssemblyResult(template, asmResult, settings.Format); } return(result); }
AssemblyResult Run(Assembly assembly, IEnumerable <Convention> conventions, params Type[] candidateTypes) { var assemblyResult = new AssemblyResult(assembly.Location); var assemblyInfo = new AssemblyInfo(assembly); listener.AssemblyStarted(assemblyInfo); foreach (var convention in conventions) { var conventionResult = Run(convention, candidateTypes); assemblyResult.Add(conventionResult); } listener.AssemblyCompleted(assemblyInfo, assemblyResult); return(assemblyResult); }
public void AssemblyCompleted(Assembly assembly, AssemblyResult result) { var assemblyName = typeof(ConsoleListener).Assembly.GetName(); var name = assemblyName.Name; var version = assemblyName.Version; var line = new StringBuilder(); line.AppendFormat("{0} passed", result.Passed); line.AppendFormat(", {0} failed", result.Failed); if (result.Skipped > 0) line.AppendFormat(", {0} skipped", result.Skipped); line.AppendFormat(" ({0} {1}).", name, version); Console.WriteLine(line); Console.WriteLine(); }
public static string AssemblyParseDll(string assemblyName, out AssemblyResult result) { AssemblyHandler handler = new AssemblyHandler(); result = handler.GetClassName(assemblyName); result.AssemblyNameList = new List <string>(); result.AssemblyNameList.Add(assemblyName); string strGenerateCode = GenerateCodeModel.GenerateCode(result.ClassTypeList); string codeFileName = "GateServer_Code.cs"; string codeFileFullName = @"..\..\Libs\ClientLib\" + codeFileName; FileInfo fCodeFileName = new FileInfo(codeFileFullName); StreamWriter wResponseRecv = fCodeFileName.CreateText(); wResponseRecv.WriteLine(strGenerateCode); wResponseRecv.Close(); return(strGenerateCode); }
public void AssemblyCompleted(Assembly assembly, AssemblyResult result) { var assemblyName = typeof(ConsoleListener).Assembly.GetName(); var name = assemblyName.Name; var version = assemblyName.Version; var line = new StringBuilder(); line.AppendFormat("{0} passed", result.Passed); line.AppendFormat(", {0} failed", result.Failed); if (result.Skipped > 0) { line.AppendFormat(", {0} skipped", result.Skipped); } line.AppendFormat(" ({0} {1}).", name, version); Console.WriteLine(line); Console.WriteLine(); }
private void MainForm_Load(object sender, EventArgs e) { var height = Height; var width = Width; MinimumSize = new Size(width, height); MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, height); AssemblyHandler handler = new AssemblyHandler(); mAssemblyResult = handler.GetClassName(protocolMsgDllName); foreach (var item in mAssemblyResult.ClassTypeList) { if (item.Key.Contains("Protocol") && item.Key.Contains("MSG_C2G")) { comboBox_ProtocolName.Items.Add(item.Value.Name); } } InitApi(); }
static XElement Assembly(AssemblyResult assemblyResult) { var now = DateTime.UtcNow; var classResults = assemblyResult.ConventionResults.SelectMany(x => x.ClassResults); return(new XElement("assembly", new XAttribute("name", assemblyResult.Name), new XAttribute("run-date", now.ToString("yyyy-MM-dd")), new XAttribute("run-time", now.ToString("HH:mm:ss")), new XAttribute("configFile", AppDomain.CurrentDomain.SetupInformation.ConfigurationFile), new XAttribute("time", Seconds(assemblyResult.Duration)), new XAttribute("total", assemblyResult.Total), new XAttribute("passed", assemblyResult.Passed), new XAttribute("failed", assemblyResult.Failed), new XAttribute("skipped", assemblyResult.Skipped), new XAttribute("environment", String.Format("{0}-bit .NET {1}", IntPtr.Size * 8, Environment.Version)), new XAttribute("test-framework", string.Format("Fixie {0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version)), classResults.Select(Class))); }
public override async Task <bool> WriteOutputAsync(AssemblyResult assemblyResult) { string filename = System.IO.Path.GetFileNameWithoutExtension(assemblyResult.FilePath); string outputFile = System.IO.Path.Combine(_outputFolder, $"{filename}.json"); bool result = true; try { base.EnsureFolderCreated(); using (var f = System.IO.File.Create(outputFile)) { await JsonSerializer.SerializeAsync <AssemblyResult>(f, assemblyResult); } } catch (Exception) { result = false; } return(result); }
public void BasicConsoleResultTest() { var x = TestResources.GetTestProjectAssembly("BasicConsole"); var result = new AssemblyAnalyzer(x); AssemblyResult assemblyResult = result.Analyse(); Assert.Equal(2, assemblyResult.Types.Count); Assert.Equal("<Module>", assemblyResult.Types[0].ClassType); Assert.Equal("BasicConsole.Program", assemblyResult.Types[1].ClassType); //Focus on 2nd classtype var ct = assemblyResult.Types[1]; Assert.Equal(2, ct.Methods.Count()); //Focus on 2d method var mt = ct.Methods[1]; Assert.Equal("Main", mt.Name); Assert.Equal("args", mt.Parameters); Assert.Equal(7, mt.Invocations.Count); }
public void AssemblyResultName() { AssemblyResult assemblyResult = new AssemblyResult(filename); Assert.Equal(Path.GetFullPath(filename), assemblyResult.Filename); }
AssemblyResult Run(RunContext runContext, IEnumerable<Convention> conventions, params Type[] candidateTypes) { var assemblyResult = new AssemblyResult(runContext.Assembly.Location); listener.AssemblyStarted(runContext.Assembly); foreach (var convention in conventions) { var conventionResult = convention.Execute(listener, candidateTypes); assemblyResult.Add(conventionResult); } listener.AssemblyCompleted(runContext.Assembly, assemblyResult); return assemblyResult; }
public void AssemblyCompleted(AssemblyInfo assembly, AssemblyResult result) { log.Info(result.Summary); }
public void TestInitialize() { GetAssemblyInfo getAssemblyInfo = new GetAssemblyInfo(); assemblyResult = getAssemblyInfo.Run(filename); }
public void AssemblyResultConfigFilename() { AssemblyResult assemblyResult = new AssemblyResult(filename, @"C:\Foo\Bar"); Assert.Equal(@"C:\Foo\Bar", assemblyResult.ConfigFilename); }
public void AssemblyCompleted(Assembly assembly, AssemblyResult result) { }
public void AssemblyResultCodeBase() { AssemblyResult assemblyResult = new AssemblyResult(filename); Assert.Equal(Path.GetDirectoryName(Path.GetFullPath(filename)), assemblyResult.Directory); }
public void AssemblyCompleted(Assembly assembly, AssemblyResult result) { Message("testSuiteFinished name='{0}'", assembly.FileName()); }