private void Render(XmlWriter reportBuilder, AssemblyInfo assemblyInfo, IEnumerable<ContextInfo> contexts)
        {
            reportBuilder.WriteStartElement("testsuite");
            reportBuilder.WriteAttributeString("name", assemblyInfo.Name);

            // gather statistics
            var specsInThisAssembly = contexts.SelectMany(x => SpecificationsByContext[x]);

            var specsByResult = specsInThisAssembly.GroupBy(x => ResultsBySpecification[x].Status)
                .ToDictionary(x => x.Key, x => x.Count());

            reportBuilder.WriteAttributeString("test", specsInThisAssembly.Count().ToString());
            reportBuilder.WriteAttributeString("failures", specsByResult.ContainsKey(Status.Failing) ? specsByResult[Status.Failing].ToString() : "0");
            reportBuilder.WriteAttributeString("skipped",
                ((specsByResult.ContainsKey(Status.Ignored) ? specsByResult[Status.Ignored] : 0) +
                 (specsByResult.ContainsKey(Status.NotImplemented) ? specsByResult[Status.NotImplemented] : 0)).ToString());
            

            foreach (var entry in contexts.GroupBy(x => x.Concern))
            {
                RenderTestsForConcern(reportBuilder, entry.Key, entry);
            }

            reportBuilder.WriteEndElement();
        }
Esempio n. 2
0
        public async Task<TestResult> RunTestAsync(AssemblyInfo assemblyInfo, CancellationToken cancellationToken)
        {
            var contentFile = _contentUtil.GetTestResultContentFile(assemblyInfo);
            var assemblyPath = assemblyInfo.AssemblyPath;
            var builder = new StringBuilder();
            builder.AppendLine($"{Path.GetFileName(assemblyPath)} - {contentFile.Checksum}");
            builder.AppendLine("===");
            builder.AppendLine(contentFile.Content);
            builder.AppendLine("===");
            Logger.Log(builder.ToString());

            try
            {
                var cachedTestResult = await _dataStorage.TryGetCachedTestResult(contentFile.Checksum);
                if (cachedTestResult.HasValue)
                {
                    Logger.Log($"{Path.GetFileName(assemblyPath)} - cache hit");
                    return Migrate(assemblyInfo, cachedTestResult.Value);
                }
            }
            catch (Exception ex)
            {
                Logger.Log($"Error reading cache {ex}");
            }

            Logger.Log($"{Path.GetFileName(assemblyPath)} - running");
            var testResult = await _testExecutor.RunTestAsync(assemblyInfo, cancellationToken);
            await CacheTestResult(contentFile, testResult).ConfigureAwait(true);
            return testResult;
        }
Esempio n. 3
0
        private string BuildTestResultContent(AssemblyInfo assemblyInfo)
        {
            var builder = new StringBuilder();
            var assemblyPath = assemblyInfo.AssemblyPath;
            builder.AppendLine($"Assembly: {Path.GetFileName(assemblyPath)} {GetFileChecksum(assemblyPath)}");
            builder.AppendLine($"Display Name: {assemblyInfo.DisplayName}");
            builder.AppendLine($"Results File Name; {assemblyInfo.ResultsFileName}");

            var configFilePath = $"{assemblyPath}.config";
            var configFileChecksum = File.Exists(configFilePath)
                ? GetFileChecksum(configFilePath)
                : "<no config file>";
            builder.AppendLine($"Config: {Path.GetFileName(configFilePath)} {configFileChecksum}");

            builder.AppendLine($"Xunit: {Path.GetFileName(_options.XunitPath)} {GetFileChecksum(_options.XunitPath)}");
            AppendReferences(builder, assemblyPath);
            builder.AppendLine("Options:");
            builder.AppendLine($"\t{nameof(_options.Test64)} - {_options.Test64}");
            builder.AppendLine($"\t{nameof(_options.UseHtml)} - {_options.UseHtml}");
            builder.AppendLine($"\t{nameof(_options.Trait)} - {_options.Trait}");
            builder.AppendLine($"\t{nameof(_options.NoTrait)} - {_options.NoTrait}");
            builder.AppendLine($"Extra Options: {assemblyInfo.ExtraArguments}");

            return builder.ToString();
        }
Esempio n. 4
0
        public static bool IsAssemblyInGAC(string assemblyName)
        {
            var assembyInfo = new AssemblyInfo { cchBuf = 512 };
            assembyInfo.currentAssemblyPath = new string('\0', assembyInfo.cchBuf);

            IAssemblyCache assemblyCache;

            var hr = CreateAssemblyCache(out assemblyCache, 0);

            if (hr == IntPtr.Zero)
            {
                hr = assemblyCache.QueryAssemblyInfo(
                    1,
                    assemblyName,
                    ref assembyInfo);

                if (hr != IntPtr.Zero)
                {
                    return false;
                }

                return true;
            }

            Marshal.ThrowExceptionForHR(hr.ToInt32());
            return false;
        }
Esempio n. 5
0
 private void AddAssemblyToList(AssemblyInfo info)
 {
     if (info != null && info.IsManagedAssembly)
       {
     listViewAssemblies.Items.Add(CreateListViewItem(info));
       }
 }
Esempio n. 6
0
        private static ListViewItem CreateListViewItem(AssemblyInfo info)
        {
            var item = new ListViewItem(new string[]
              {
            Path.GetFileName(info.FilePath),
            info.DotNetVersion,
            (info.IsAnyCpu ? "Any CPU" : info.Is32BitOnly ? "x86" : info.Is64BitOnly ? "x64" : "UNKNOWN") + (info.Is32BitPreferred ? " (x86 preferred)" : string.Empty),
            info.IsSigned ? "Yes" : "No",
            info.FilePath
              });

              item.Tag = info.FilePath;
              item.UseItemStyleForSubItems = false;

              // Update the color of the signed column.
              if (info.IsSigned)
              {
            item.SubItems[3].ForeColor = Color.Green;
              }
              else
              {
            item.SubItems[3].ForeColor = Color.Red;
              }

              return item;
        }
        /// <summary>
        /// Registers the specified assembly and resolves the types in it when the AppDomain requests for it.
        /// </summary>
        /// <param name="assemblyFilePath">The path to the assemly to load in the LoadFrom context.</param>
        /// <remarks>This method does not load the assembly immediately, but lazily until someone requests a <see cref="Type"/>
        /// declared in the assembly.</remarks>
        public async void LoadAssemblyFrom(string assemblyFilePath)
        {
            //if (!this.handlesAssemblyResolve)
            //{
            //    AppDomain.CurrentDomain.AssemblyResolve += this.CurrentDomain_AssemblyResolve;
            //    this.handlesAssemblyResolve = true;
            //}

            Uri assemblyUri = GetFileUri(assemblyFilePath);

            if (assemblyUri == null)
            {
                throw new ArgumentException(ResourceHelper.InvalidArgumentAssemblyUri, "assemblyFilePath");
            }

            StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(assemblyUri.AbsoluteUri));

            AssemblyName assemblyName = new AssemblyName { Name = file.DisplayName };
            if (this.loadedAssemblies.Any(a => assemblyName == a.AssemblyName))
            {
                return;
            }

            var assembly = Assembly.Load(assemblyName);
            var assemblyInfo = new AssemblyInfo() { AssemblyName = assemblyName, AssemblyUri = assemblyUri, Assembly = assembly };
            this.loadedAssemblies.Add(assemblyInfo);
        }
Esempio n. 8
0
        public static string GetVersion(AssemblyInfo info)
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
            try
            {
                switch (info)
                {
                    case AssemblyInfo.Title:
                        return fvi.ProductName;
                    case AssemblyInfo.Version:

                        int major = fvi.FileMajorPart;
                        int minor = fvi.FileMinorPart;
                        int rev = fvi.FileBuildPart;

                        string version =
                            major.ToString(CultureInfo.InvariantCulture) + "." +
                            minor.ToString(CultureInfo.InvariantCulture) + "." +
                            rev.ToString(CultureInfo.InvariantCulture);
                        return version;

                    case AssemblyInfo.Company:
                        return fvi.CompanyName;
                }
            }
            catch (Exception)
            {
                return null;
            }
            return null;
        }
Esempio n. 9
0
        public void AssemblyInfoExecute()
        {
            AssemblyInfo task = new AssemblyInfo();
            task.BuildEngine = new MockBuild();
            task.CodeLanguage = "cs";
            string outputFile = Path.Combine(testDirectory, "AssemblyInfo.cs");
            task.OutputFile = outputFile;
            task.AssemblyTitle = "AssemblyInfoTask";
            task.AssemblyDescription = "AssemblyInfo Description";
            task.AssemblyConfiguration = "";
            task.AssemblyCompany = "Company Name, LLC";
            task.AssemblyProduct = "AssemblyInfoTask";
            task.AssemblyCopyright = "Copyright (c) Company Name, LLC 2005";
            task.AssemblyTrademark = "";
            task.ComVisible = false;
            task.CLSCompliant = true;
            task.Guid = "d038566a-1937-478a-b5c5-b79c4afb253d";
            task.AssemblyVersion = "1.2.3.4";
            task.AssemblyFileVersion = "1.2.3.4";
            task.AssemblyInformationalVersion = "1.2.3.4";
            task.AssemblyKeyFile = @"..\MSBuild.Community.Tasks\MSBuild.Community.Tasks.snk";
            Assert.IsTrue(task.Execute(), "Execute Failed");

            Assert.IsTrue(File.Exists(outputFile), "File missing: " + outputFile);
        }
Esempio n. 10
0
        /// <summary>
        /// Registers the specified assembly and resolves the types in it when the AppDomain requests for it.
        /// </summary>
        /// <param name="assemblyFilePath">The path to the assemly to load in the LoadFrom context.</param>
        /// <remarks>This method does not load the assembly immediately, but lazily until someone requests a <see cref="Type"/>
        /// declared in the assembly.</remarks>
        public void LoadAssemblyFrom(string assemblyFilePath)
        {
            if (!this.handlesAssemblyResolve)
            {
                AppDomain.CurrentDomain.AssemblyResolve += this.CurrentDomain_AssemblyResolve;
                this.handlesAssemblyResolve = true;
            }

            Uri assemblyUri = GetFileUri(assemblyFilePath);

            if (assemblyUri == null)
            {
                throw new ArgumentException(Resources.InvalidArgumentAssemblyUri, "assemblyFilePath");
            }

            if (!File.Exists(assemblyUri.LocalPath))
            {
                throw new FileNotFoundException();
            }

            AssemblyName assemblyName = AssemblyName.GetAssemblyName(assemblyUri.LocalPath);
            AssemblyInfo assemblyInfo = this.registeredAssemblies.FirstOrDefault(a => assemblyName == a.AssemblyName);

            if (assemblyInfo != null)
            {
                return;
            }

            assemblyInfo = new AssemblyInfo() { AssemblyName = assemblyName, AssemblyUri = assemblyUri };
            this.registeredAssemblies.Add(assemblyInfo);
        }
 public override void OnAssemblyStart(AssemblyInfo assembly)
 {
     _originalDirectory = Directory.GetCurrentDirectory();
     if (assembly.Location != null)
     {
         Directory.SetCurrentDirectory(Path.GetDirectoryName(assembly.Location));
     }
 }
Esempio n. 12
0
 private static TestCacheData CreateTestCacheData(AssemblyInfo assemblyInfo, string resultsFileName, CachedTestResult testResult)
 {
     return new TestCacheData()
     {
         TestResultData = CreateTestResultData(resultsFileName, testResult),
         TestSourceData = CreateTestSourceData(assemblyInfo)
     };
 }
Esempio n. 13
0
 public FrmAbout()
 {
     InitializeComponent();
     var ai = new AssemblyInfo();
     this.Text = String.Format( "О {0}", ai.AssemblyTitle );
     this.txt_vesion_null.Text = String.Format( "{0}", ai.AssemblyVersion );
     this.txt_cr.Text = ai.AssemblyCopyright;
 }
Esempio n. 14
0
 public IAssemblyInfo LoadFrom(string assemblyName)
 {
     Assembly assembly = Assembly.LoadFrom(assemblyName);
     IAssemblyInfo assemblyInfo = new AssemblyInfo();
     assemblyInfo.Name = assembly.FullName;
     assemblyInfo.Types = LoadTypes(assembly);
     return assemblyInfo;
 }
Esempio n. 15
0
 static Shell()
 {
     Input = Console.In;
     Output = Console.Out;
     Error = new ErrorConsoleWriter(Console.Error);
     CommandsResolver = Infrastucture.CommandsResolver.Default;
     HelpBuilder = HelpBuilder.Default;
     AssemblyInfo = new AssemblyInfo(Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly());
 }
    public long GetAssemblyTime(AssemblyInfo assemblyInfo)
    {
      if (_assemblyTimes.ContainsKey(assemblyInfo))
      {
        return _assemblyTimes[assemblyInfo];
      }

      return -1;
    }
Esempio n. 17
0
 public About()
 {
     
     InitializeComponent();
     AssemblyInfo entryAssemblyInfo = new AssemblyInfo(System.Reflection.Assembly.GetEntryAssembly());
     Titletb.Text = entryAssemblyInfo.ProductTitleAndVersion;
     Descriptiontb.Text = entryAssemblyInfo.Description;
     Copyrightb.Text = entryAssemblyInfo.Copyright;
 }
        public override void OnAssemblyStart(AssemblyInfo assembly)
        {
            var asm = Assembly.LoadFrom(assembly.Location);

            var assemblyContexts = _explorer.FindAssemblyContextsIn(asm);
            assemblyContexts.Each(assemblyContext =>
            {
                assemblyContext.OnAssemblyStart();
                _executedAssemblyContexts.Add(assemblyContext);
            });
        }
Esempio n. 19
0
 public void Initialize()
 {
     var info = new AssemblyInfo();
     AboutDescriptionLabel.Text = info.Description;
     AboutProductLabel.Text = info.Title;
     var changeLog = ClassLibrary.Helper.FindResource<string>("ChangeLog.txt");
     ChangeLogTextBox.Text = changeLog;
     var license = ClassLibrary.Helper.FindResource<string>("License.txt");
     LicenseTextBox.Text = license;
     LicenseTabPage.Text = string.Format("{0} {1} License", Application.ProductName, new Version(Application.ProductVersion).ToString(2));
 }
Esempio n. 20
0
        public void AssemblyInfo_GetCurrentAssemblyInfo_InformationsIsCorrect()
        {
            var assemblyInfo = new AssemblyInfo(Assembly.GetAssembly((typeof(AssemblyInfoTests))));

            Assert.AreEqual("Alexander Krylkov", assemblyInfo.CompanyName);
            Assert.AreEqual("Licensed under LGPL", assemblyInfo.Copyright);
            Assert.AreEqual("Simplify.Core unit tests", assemblyInfo.Description);
            Assert.AreEqual("Simplify", assemblyInfo.ProductName);
            Assert.AreEqual("Simplify.Core.Tests", assemblyInfo.Title);
            Assert.AreEqual("1.0.0.0", assemblyInfo.Version.ToString());
        }
Esempio n. 21
0
 public frmMain()
 {
     //This call is required by the Windows Form Designer.
     InitializeComponent();
     //Add any initialization after the InitializeComponent() call
     // So that we only need to set the title of the application once,
     // we use the AssemblyInfo class (defined in the AssemblyInfo.cs file)
     // to read the AssemblyTitle attribute.
     AssemblyInfo ainfo = new AssemblyInfo();
     this.Text = ainfo.Title;
     this.mnuAbout.Text = string.Format("&About {0} ...", ainfo.Title);
 }
Esempio n. 22
0
        public void It_doesnt_find_internal_types()
        {
            var assemblyInfo = new AssemblyInfo();

            assemblyInfo.ReadAssembly(Compiler.GetAssembly(
            @"namespace MyNamespace
            {
            internal class MyInternalClass { }
            }"));

            Assert.AreEqual(0, assemblyInfo.Types.Count);
        }
Esempio n. 23
0
        public void It_finds_public_types()
        {
            var assemblyInfo = new AssemblyInfo();

            assemblyInfo.ReadAssembly(Compiler.GetAssembly(
            @"namespace MyNamespace
            {
            public class MyClass { }
            }"));

            Assert.AreEqual(1, assemblyInfo.Types.Count);
        }
Esempio n. 24
0
        public void It_reads_the_assembly_name()
        {
            var assemblyInfo = new AssemblyInfo();

            assemblyInfo.ReadAssembly(Compiler.GetAssembly("MyAssembly.dll",
            @"namespace MyNamespace
            {
            public class MyClass { }
            }"));

            Assert.AreEqual("MyAssembly", assemblyInfo.Name);
        }
Esempio n. 25
0
        public void AssemblyInfoVB() {
            AssemblyInfo task = new AssemblyInfo();
            task.BuildEngine = new MockBuild();
            task.CodeLanguage = "vb";
            string outputFile = Path.Combine(testDirectory, "VersionInfo.vb");
            task.OutputFile = outputFile;
            task.AssemblyVersion = "1.2.3.4";
            task.AssemblyFileVersion = "1.2.3.4";
            task.AssemblyInformationalVersion = "1.2.3.4";
            Assert.IsTrue(task.Execute(), "Execute Failed");

            Assert.IsTrue(File.Exists(outputFile), "File missing: " + outputFile);

        }
Esempio n. 26
0
        public static IAssemblyInfo ReadConfig(string configFileName, bool folderMode, string location)
        {
            var config = helper.ReadConfig(configFileName, folderMode, location);

            if (config == null)
            {
                config = new AssemblyInfo();
            }

            // Convert '/' and '\\' to platform-specific path separator.
            ConvertConfigPaths(config);

            return config;
        }
Esempio n. 27
0
        public void It_can_exclude_specified_types()
        {
            var assemblyInfo = new AssemblyInfo();

            assemblyInfo.ReadAssembly(Compiler.GetAssembly(
            @"namespace MyNamespace
            {
            public class MyClass1 { }

            public class MyClass2 { }
            }"), "Class2");

            Assert.AreEqual("MyClass1", assemblyInfo.Types.Single().Name);
        }
Esempio n. 28
0
        public void It_reads_the_assembly_version()
        {
            var assemblyInfo = new AssemblyInfo();

            assemblyInfo.ReadAssembly(Compiler.GetAssembly(
            @"[assembly: System.Reflection.AssemblyVersion(""1.2.3.4"")]

            namespace MyNamespace
            {
            public class MyClass { }
            }"));

            Assert.AreEqual("1.2.3.4", assemblyInfo.Version);
        }
Esempio n. 29
0
 internal ContentFile GetTestResultContentFile(AssemblyInfo assemblyInfo)
 {
     try
     {
         var content = BuildTestResultContent(assemblyInfo);
         var checksum = GetChecksum(content);
         return new ContentFile(checksum: checksum, content: content);
     }
     catch (Exception ex)
     {
         Logger.Log($"Error creating log file {ex.Message} {ex.StackTrace}");
         return ContentFile.Empty;
     }
 }
Esempio n. 30
0
        public static string GetAssemblyPath(string name)
        {
            if (name == null)
                throw new ArgumentNullException(nameof(name));

            var assemblyInfo = new AssemblyInfo {cchBuffer = AssemblyPathMax };

            assemblyInfo.currentAssemblyPath = new string((char) 0, assemblyInfo.cchBuffer);

            IAssemblyCache assemblyCache;
            if (CreateAssemblyCache(out assemblyCache, 0) >= 0 && assemblyCache.QueryAssemblyInfo(0, name, ref assemblyInfo) < 0)
                return (string) null;

            return assemblyInfo.currentAssemblyPath;
        }
Esempio n. 31
0
        void AnalyzeMethodBody(AssemblyInfo assemblyInfo, MethodDefinition caller, Action <CallInfo> onCallFound, Action <ProjectIssue> onIssueFound)
        {
            if (!caller.DebugInformation.HasSequencePoints)
            {
                return;
            }

            Profiler.BeginSample("ScriptAuditor.AnalyzeMethodBody");

            var callerNode          = new CallTreeNode(caller);
            var perfCriticalContext = IsPerformanceCriticalContext(caller);

            foreach (var inst in caller.Body.Instructions.Where(i => m_OpCodes.Contains(i.OpCode)))
            {
                SequencePoint s = null;
                for (var i = inst; i != null; i = i.Previous)
                {
                    s = caller.DebugInformation.GetSequencePoint(i);
                    if (s != null)
                    {
                        break;
                    }
                }

                Location location = null;
                if (s != null)
                {
                    location            = new Location(AssemblyHelper.ResolveAssetPath(assemblyInfo, s.Document.Url), s.StartLine);
                    callerNode.location = location;
                }
                else
                {
                    // sequence point not found. Assuming caller.IsHideBySig == true
                }

                if (inst.OpCode == OpCodes.Call || inst.OpCode == OpCodes.Callvirt)
                {
                    onCallFound(new CallInfo
                    {
                        callee              = (MethodReference)inst.Operand,
                        caller              = caller,
                        location            = location,
                        perfCriticalContext = perfCriticalContext
                    });
                }

                foreach (var analyzer in m_InstructionAnalyzers)
                {
                    if (analyzer.GetOpCodes().Contains(inst.OpCode))
                    {
                        var projectIssue = analyzer.Analyze(caller, inst);
                        if (projectIssue != null)
                        {
                            projectIssue.dependencies.perfCriticalContext = perfCriticalContext;
                            projectIssue.dependencies.AddChild(callerNode);
                            projectIssue.location = location;
                            projectIssue.SetCustomProperties(new[] { assemblyInfo.name });

                            onIssueFound(projectIssue);
                        }
                    }
                }
            }
            Profiler.EndSample();
        }
Esempio n. 32
0
 public void AssemblyCompleted(AssemblyInfo assembly, AssemblyResult result)
 {
     Message("testSuiteFinished name='{0}'", SuiteName(assembly));
 }
Esempio n. 33
0
 public void Update(AssemblyInfo o)
 {
     ExecuteNonQuery(string.Format("UPDATE AssemblyInfo SET Name = '{0}', Description = '{1}', Project = '{2}', Configuration = '{3}', Company = '{4}', Product = '{5}', Copyright = '{6}', Trademark = '{7}', Culture = '{8}', Version = '{9}', FileVersion = '{10}', ComVisibility = '{11}' WHERE ID = '{12}'",
                                   o.Name, o.Description, o.Project, o.Configuration, o.Company, o.Product, o.Copyright, o.Trademark, o.Culture, o.Version, o.FileVersion, o.ComVisibility, o.ID.ToString()));
 }
Esempio n. 34
0
 public void AssemblyStart(AssemblyInfo assembly)
 {
 }
Esempio n. 35
0
 public void OnAssemblyStart(AssemblyInfo assembly)
 {
     _currentAssembly = assembly;
     _contextsByAssembly.Add(_currentAssembly, new List <ContextInfo>());
 }
Esempio n. 36
0
        public AssemblyInfoTests()
        {
            var assembly = typeof(TestLibClass).Assembly;

            _info = new AssemblyInfo(assembly);
        }
Esempio n. 37
0
        static void Main(string[] args)
        {
            try
            {
                // Set the path of the config file.
                string configPath = "";

                // Get the Web application configuration object.
                Configuration config =
                    WebConfigurationManager.OpenWebConfiguration(configPath);

                // Get the section related object.
                CompilationSection configSection =
                    (CompilationSection)config.GetSection("system.web/compilation");

                // Display title and info.
                Console.WriteLine("ASP.NET Configuration Info");
                Console.WriteLine();

                // Display Config details.
                Console.WriteLine("File Path: {0}",
                                  config.FilePath);
                Console.WriteLine("Section Path: {0}",
                                  configSection.SectionInformation.Name);

                // Create a new assembly reference.
                AssemblyInfo myAssembly =
                    new AssemblyInfo("MyAssembly, Version=1.0.0000.0, " +
                                     "Culture=neutral, Public KeyToken=b03f5f7f11d50a3a");
                // Add an assembly to the configuration.
                configSection.Assemblies.Add(myAssembly);

                // Add a second assembly reference.
                AssemblyInfo myAssembly2 = new AssemblyInfo("MyAssembly2");
                configSection.Assemblies.Add(myAssembly2);

                // Assembly Collection
                int i = 1;
                int j = 1;
                foreach (AssemblyInfo assemblyItem in configSection.Assemblies)
                {
                    Console.WriteLine();
                    Console.WriteLine("Assemblies {0} Details:", i);
                    Console.WriteLine("Type: {0}", assemblyItem.ElementInformation.Type);
                    Console.WriteLine("Source: {0}", assemblyItem.ElementInformation.Source);
                    Console.WriteLine("LineNumber: {0}", assemblyItem.ElementInformation.LineNumber);
                    Console.WriteLine("Properties Count: {0}",
                                      assemblyItem.ElementInformation.Properties.Count);
                    j = 1;
                    foreach (PropertyInformation propertyItem in assemblyItem.ElementInformation.Properties)
                    {
                        Console.WriteLine("Property {0} Name: {1}", j, propertyItem.Name);
                        Console.WriteLine("Property {0} Value: {1}", j, propertyItem.Value);
                        j++;
                    }
                    i++;
                }

                // Remove an assembly.
                configSection.Assemblies.Remove("MyAssembly, Version=1.0.0000.0, " +
                                                "Culture=neutral, Public KeyToken=b03f5f7f11d50a3a");

                // Remove an assembly.
                configSection.Assemblies.RemoveAt(configSection.Assemblies.Count - 1);

                // Update if not locked.
                if (!configSection.SectionInformation.IsLocked)
                {
                    config.Save();
                    Console.WriteLine("** Configuration updated.");
                }
                else
                {
                    Console.WriteLine("** Could not update, section is locked.");
                }
            }

            catch (Exception e)
            {
                // Unknown error.
                Console.WriteLine(e.ToString());
            }

            // Display and wait.
            Console.ReadLine();
        }
Esempio n. 38
0
 public void AssemblyStarted(AssemblyInfo assembly)
 {
     Console.WriteLine("------ Testing Assembly {0} ------", Path.GetFileName(assembly.Location));
     Console.WriteLine();
 }
Esempio n. 39
0
 public string GetNameForAssemblyInfo(AssemblyInfo assembly)
 {
     return(_assemblyNameMap == null ? string.Empty : _assemblyNameMap[assembly]);
 }
 public void OnAssemblyStart(AssemblyInfo assembly)
 {
     _listener.OnAssemblyStart(assembly);
 }
Esempio n. 41
0
 public void AssemblyCompleted(AssemblyInfo assembly, AssemblyResult result)
 {
     log.Info(result.Summary);
 }
 public void OnAssemblyEnd(AssemblyInfo assembly)
 {
     _listener.OnAssemblyEnd(assembly);
 }
Esempio n. 43
0
 public void AddOrUpdate(AssemblyInfo ainfo)
 {
     this.assemblyInfoTable.AddOrUpdate(ai => ai.AssemblyId == ainfo.AssemblyId, ainfo);
 }
 public void IncrementUsage(AssemblyInfo sourceAssembly)
 {
     _usedInAssemblies.Add(sourceAssembly);
 }
Esempio n. 45
0
        public virtual void Run(GeneratorProjectInfo projectInfo)
        {
            //"lang:scharp",
            //@"/target C:\Work\Behemoth\Trunk\Source\Binaries\Telerik.Windows.Controls.dll",
            //string[] testArgs = new string[] {"/target" @"C:\Work\Behemoth\Trunk\Source\Binaries\Telerik.Windows.Controls.dll", @"/out", "c:\\dir" };

#if ENGINEONLYBUILD
            if (projectInfo == null)
            {
                projectInfo = new GeneratorProjectInfo(new CommandLineHelpError());
            }
#endif

            if (projectInfo == null)
            {
                CommandLineManager.WriteLineColor(ConsoleColor.Red, "args = null");
                CommandLineManager.ResetColor();

                return;
            }

            try
            {
                // If there is an error, there is no need to create output directory, because there will not be any project generation at all.
                if (projectInfo.Error == null)
                {
                    try
                    {
                        this.CreateOutputDirectory(projectInfo);
                    }
                    catch (Exception ex)
                    {
                        if (ex is IOException || ex is UnauthorizedAccessException || ex is ArgumentException ||
                            ex is PathTooLongException || ex is DirectoryNotFoundException || ex is NotSupportedException)
                        {
                            projectInfo.Error = new CommandLineError(CommandLineManager.InvalidDirectoryPathError + ex.Message);
                        }
                        else
                        {
                            throw;
                        }
                    }
                }

                if (projectInfo.Error == null)
                {
                    CommandLineManager.WriteLine();

                    CommandLineManager.WriteLineColor(ConsoleColor.White, description);
                    CommandLineManager.WriteLineColor(ConsoleColor.White, new string(Enumerable.Range(0, description.Length).Select(i => '=').ToArray()));
                    Console.WriteLine();
                    Console.WriteLine("Generates MS Visual Studio(r) Project from .NET assembly.");
                    CommandLineManager.WriteLine();

                    if (!CLRHelper.IsValidClrFile(projectInfo.Target))
                    {
                        CommandLineManager.WriteLineColor(ConsoleColor.Red, "The target assembly is not a valid CLR assembly.");
                        return;
                    }

                    AssemblyDefinition        assembly = Telerik.JustDecompiler.Decompiler.Utilities.GetAssembly(projectInfo.Target);
                    ProjectGenerationSettings settings = this.GetSettings(projectInfo);
                    if (!settings.VisualStudioSupportedProjectType)
                    {
                        CommandLineManager.WriteLineColor(ConsoleColor.Red, this.ReplaceRegisteredTrademarkSymbol(settings.ErrorMessage));
                        return;
                    }
                    else if (!settings.JustDecompileSupportedProjectType)
                    {
                        CommandLineManager.WriteLineColor(ConsoleColor.Yellow, this.ReplaceRegisteredTrademarkSymbol(settings.ErrorMessage));
                        CommandLineManager.WriteLine();
                    }
                    else if (!projectInfo.IsDefaultFrameworkVersion)
                    {
                        AssemblyInfo assemblyInfo = NoCacheAssemblyInfoService.Instance.GetAssemblyInfo(assembly, new ConsoleFrameworkResolver(projectInfo.FrameworkVersion));
                        if (assemblyInfo.ModulesFrameworkVersions[assembly.MainModule] != projectInfo.FrameworkVersion)
                        {
                            CommandLineManager.WriteLineColor(ConsoleColor.Yellow, "JustDecompile managed to determine the target assembly framework. The fallback target framework version command line option is ignored.");
                            CommandLineManager.WriteLine();
                        }
                    }

                    CommandLineManager.WriteLineColor(ConsoleColor.White, "Project Creation:");
                    CommandLineManager.WriteLineColor(ConsoleColor.White, "============================");

                    TimeSpan projectGenerationTime = RunInternal(assembly, projectInfo, settings);

                    CommandLineManager.WriteLine();
                    CommandLineManager.WriteLineColor(ConsoleColor.White, "============================");
                    CommandLineManager.WriteLineColor(ConsoleColor.White, string.Format("Finished in {0:0.0} seconds.", projectGenerationTime.TotalSeconds));

                    count = 0;
                }
                else
                {
                    projectInfo.Error.PrintError();
                }
            }
            catch (Exception ex)
            {
                CommandLineManager.WriteLine();
                CommandLineManager.WriteLineColor(ConsoleColor.Red, ex.Message);

                OnExceptionThrown(ex);
            }
            finally
            {
                CommandLineManager.WriteLine();
                CommandLineManager.ResetColor();
            }
        }
        internal static Assembly ResolveAssembly(object sender, ResolveEventArgs e)
        {
            AssemblyInfo info             = new AssemblyInfo(e.Name);
            string       assemblyFullName = info.GetAssemblyFullName(false);
            string       str2             = Convert.ToBase64String(Encoding.UTF8.GetBytes(assemblyFullName));

            string[] strArray = "ezJiMjQwNDRmLTY0NDgtNDczMi1hMGQ4LTlhNGIzNzg0MWY0N30sIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49M2U1NjM1MDY5M2Y3MzU1ZQ==,[z]{5afba4e7-4cbd-48f4-ae87-5cb4a100aac0},ezJiMjQwNDRmLTY0NDgtNDczMi1hMGQ4LTlhNGIzNzg0MWY0N30=,[z]{5afba4e7-4cbd-48f4-ae87-5cb4a100aac0},SHRtbEFnaWxpdHlQYWNrLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWJkMzE5YjE5ZWFmM2I0M2E=,[z]{22a11d39-8946-4a47-958b-a3b1fb426f2d},SHRtbEFnaWxpdHlQYWNr,[z]{22a11d39-8946-4a47-958b-a3b1fb426f2d}".Split(new char[] { ',' });
            string   key      = string.Empty;
            bool     flag     = false;
            bool     flag2    = false;

            for (int i = 0; i < (strArray.Length - 1); i += 2)
            {
                if (strArray[i] == str2)
                {
                    key = strArray[i + 1];
                    break;
                }
            }
            if ((key.Length == 0) && (info.PublicKeyToken.Length == 0))
            {
                str2 = Convert.ToBase64String(Encoding.UTF8.GetBytes(info.Name));
                for (int j = 0; j < (strArray.Length - 1); j += 2)
                {
                    if (strArray[j] == str2)
                    {
                        key = strArray[j + 1];
                        break;
                    }
                }
            }
            if (key.Length > 0)
            {
                if (key[0] == '[')
                {
                    int    index = key.IndexOf(']');
                    string str4  = key.Substring(1, index - 1);
                    flag  = str4.IndexOf('z') >= 0;
                    flag2 = str4.IndexOf('t') >= 0;
                    key   = key.Substring(index + 1);
                }
                lock (hashtable)
                {
                    if (hashtable.ContainsKey(key))
                    {
                        return(hashtable[key]);
                    }
                    Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(key);
                    if (manifestResourceStream != null)
                    {
                        int    length = (int)manifestResourceStream.Length;
                        byte[] buffer = new byte[length];
                        manifestResourceStream.Read(buffer, 0, length);
                        if (flag)
                        {
                            buffer = SimpleZip.Unzip(buffer);
                        }
                        Assembly assembly = null;
                        if (!flag2)
                        {
                            try
                            {
                                assembly = Assembly.Load(buffer);
                            }
                            catch (FileLoadException)
                            {
                                flag2 = true;
                            }
                            catch (BadImageFormatException)
                            {
                                flag2 = true;
                            }
                        }
                        if (flag2)
                        {
                            try
                            {
                                string path = string.Format(@"{0}{1}\", Path.GetTempPath(), key);
                                Directory.CreateDirectory(path);
                                string str6 = path + info.Name + ".dll";
                                if (!File.Exists(str6))
                                {
                                    FileStream stream2 = File.OpenWrite(str6);
                                    stream2.Write(buffer, 0, buffer.Length);
                                    stream2.Close();
                                    MoveFileEx(str6, null, 4);
                                    MoveFileEx(path, null, 4);
                                }
                                assembly = Assembly.LoadFile(str6);
                            }
                            catch
                            {
                            }
                        }
                        hashtable[key] = assembly;
                        return(assembly);
                    }
                }
            }
            return(null);
        }
Esempio n. 47
0
 public void OnAssemblyEnd(AssemblyInfo assembly)
 {
     _currentAssembly.CapturedOutput = assembly.CapturedOutput;
 }
Esempio n. 48
0
        public async IAsyncEnumerable <SourceFile> Load(SessionId sessionId, string[] loaded_files, [EnumeratorCancellation] CancellationToken token)
        {
            var asm_files = new List <string>();
            var pdb_files = new List <string>();

            foreach (string file_name in loaded_files)
            {
                if (file_name.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase))
                {
                    pdb_files.Add(file_name);
                }
                else
                {
                    asm_files.Add(file_name);
                }
            }

            List <DebugItem> steps = new List <DebugItem>();

            foreach (string url in asm_files)
            {
                try
                {
                    string candidate_pdb = Path.ChangeExtension(url, "pdb");
                    string pdb           = pdb_files.FirstOrDefault(n => n == candidate_pdb);

                    steps.Add(
                        new DebugItem
                    {
                        Url  = url,
                        Data = Task.WhenAll(client.GetByteArrayAsync(url, token), pdb != null ? client.GetByteArrayAsync(pdb, token) : Task.FromResult <byte[]>(null))
                    });
                }
                catch (Exception e)
                {
                    logger.LogDebug($"Failed to read {url} ({e.Message})");
                }
            }

            foreach (DebugItem step in steps)
            {
                AssemblyInfo assembly = null;
                try
                {
                    byte[][] bytes = await step.Data.ConfigureAwait(false);

                    assembly = new AssemblyInfo(step.Url, bytes[0], bytes[1]);
                }
                catch (Exception e)
                {
                    logger.LogDebug($"Failed to load {step.Url} ({e.Message})");
                }
                if (assembly == null)
                {
                    continue;
                }

                if (GetAssemblyByUnqualifiedName(assembly.AssemblyNameUnqualified) != null)
                {
                    logger.LogDebug($"Skipping loading {assembly.Name} into the debug store, as it already exists");
                    continue;
                }

                assemblies.Add(assembly);
                foreach (SourceFile source in assembly.Sources)
                {
                    yield return(source);
                }
            }
        }
Esempio n. 49
0
 /// Initializes a new instance of the class.
 public App()
 {
     Properties["Authors"] = "Cédric Belin <*****@*****.**>";
     Properties["License"] = OpenSourceLicenses.GnuGeneralPublicLicenseV3;
     Properties["Product"] = new AssemblyInfo(GetType().Assembly).Product;
 }
        private static StartupHandlerInfo[] GetSubscribedTypes(
            string filePath, List <AssemblyInfo> cachedTypesInfo, ref bool cacheHasBeenUpdated)
        {
            string assemblyName = Path.GetFileNameWithoutExtension(filePath);

            foreach (string assemblyToIgnore in AssembliesToIgnore)
            {
                if (assemblyName == assemblyToIgnore || assemblyName.StartsWith(assemblyToIgnore + ",") ||
                    (assemblyToIgnore.EndsWith(".") && assemblyName.StartsWith(assemblyToIgnore)))
                {
                    return(null);
                }
            }

            DateTime modificationDate = C1File.GetLastWriteTime(filePath);

            var cachedInfo = cachedTypesInfo.FirstOrDefault(asm => asm.AssemblyName == assemblyName);

            if (cachedInfo != null)
            {
                if (cachedInfo.LastModified == modificationDate)
                {
                    string[] subscribedTypesNames = cachedInfo.SubscribedTypes;
                    if (subscribedTypesNames.Length == 0)
                    {
                        return(new StartupHandlerInfo[0]);
                    }

                    var asm = Assembly.LoadFrom(filePath);
                    return((from typeName in subscribedTypesNames
                            let type = asm.GetType(typeName)
                                       where  type != null
                                       let attribute = type.GetCustomAttributes(false)
                                                       .OfType <ApplicationStartupAttribute>()
                                                       .FirstOrDefault()
                                                       where attribute != null
                                                       select new StartupHandlerInfo(type, attribute)).ToArray());
                }

                // Removing cache entry if it is obsolete
                cachedTypesInfo.Remove(cachedInfo);
            }

            Assembly assembly;

            try
            {
                assembly = Assembly.LoadFrom(filePath);
            }
            catch (ReflectionTypeLoadException ex)
            {
                Log.LogWarning(LogTitle, $"Failed to load assembly '{filePath}'");
                if (ex.LoaderExceptions != null && ex.LoaderExceptions.Length > 0)
                {
                    Log.LogError(LogTitle, ex.LoaderExceptions[0]);
                }

                return(null);
            }

            if (!AssemblyFacade.AssemblyPotentiallyUsesType(assembly, typeof(ApplicationStartupAttribute)))
            {
                return(null);
            }

            Type[] types;

            if (!TryGetTypes(assembly, out types))
            {
                return(new StartupHandlerInfo[0]);
            }

            var result = GetSubscribedTypes(types);

            var newCacheEntry = new AssemblyInfo
            {
                AssemblyName    = assembly.GetName().Name,
                LastModified    = modificationDate,
                SubscribedTypes = result.Select(sh => sh.Type.FullName).ToArray()
            };

            cachedTypesInfo.Add(newCacheEntry);

            cacheHasBeenUpdated = true;

            return(result);
        }
Esempio n. 51
0
 public static MemoryStream Compile(AssemblyInfo assemblyInfo, IEnumerable <SyntaxTree> trees, IEnumerable <MetadataReference> references, ILogger logger = null)
 {
     return(Compile(assemblyInfo.Title, assemblyInfo, trees, references, logger));
 }
Esempio n. 52
0
 static string SuiteName(AssemblyInfo assembly)
 {
     return(Path.GetFileName(assembly.Location));
 }
Esempio n. 53
0
 private static SyntaxTree GetAssemblyInfo(AssemblyInfo info)
 {
     return(SyntaxFactory.CompilationUnit()
            .WithUsings(
                SyntaxFactory.List(
                    new[]
     {
         SyntaxFactory.UsingDirective(
             SyntaxFactory.QualifiedName(
                 SyntaxFactory.IdentifierName("System"),
                 SyntaxFactory.IdentifierName("Reflection"))),
         SyntaxFactory.UsingDirective(
             SyntaxFactory.QualifiedName(
                 SyntaxFactory.QualifiedName(
                     SyntaxFactory.IdentifierName("System"),
                     SyntaxFactory.IdentifierName("Runtime")),
                 SyntaxFactory.IdentifierName("InteropServices"))),
         SyntaxFactory.UsingDirective(
             SyntaxFactory.QualifiedName(
                 SyntaxFactory.QualifiedName(
                     SyntaxFactory.IdentifierName("System"),
                     SyntaxFactory.IdentifierName("Runtime")),
                 SyntaxFactory.IdentifierName("Versioning")))
     }))
            .WithAttributeLists(
                SyntaxFactory.List(
                    new[]
     {
         SyntaxFactory.AttributeList(
             SyntaxFactory.SingletonSeparatedList(
                 SyntaxFactory.Attribute(
                     SyntaxFactory.IdentifierName("TargetFramework"))
                 .WithArgumentList(
                     SyntaxFactory.AttributeArgumentList(
                         SyntaxFactory.SeparatedList <AttributeArgumentSyntax>(
                             new SyntaxNodeOrToken[] {
             SyntaxFactory.AttributeArgument(
                 SyntaxFactory.LiteralExpression(
                     SyntaxKind.StringLiteralExpression,
                     SyntaxFactory.Literal(".NETFramework,Version=v4.5"))),
             SyntaxFactory.Token(SyntaxKind.CommaToken),
             SyntaxFactory.AttributeArgument(
                 SyntaxFactory.LiteralExpression(
                     SyntaxKind.StringLiteralExpression,
                     SyntaxFactory.Literal(".NET Framework 4.5")))
             .WithNameEquals(
                 SyntaxFactory.NameEquals(
                     SyntaxFactory.IdentifierName("FrameworkDisplayName")))
         })))))
         .WithTarget(
             SyntaxFactory.AttributeTargetSpecifier(
                 SyntaxFactory.Token(SyntaxKind.AssemblyKeyword))),
         SyntaxFactory.AttributeList(
             SyntaxFactory.SingletonSeparatedList(
                 SyntaxFactory.Attribute(
                     SyntaxFactory.IdentifierName("AssemblyTitle"))
                 .WithArgumentList(
                     SyntaxFactory.AttributeArgumentList(
                         SyntaxFactory.SingletonSeparatedList(
                             SyntaxFactory.AttributeArgument(
                                 SyntaxFactory.LiteralExpression(
                                     SyntaxKind.StringLiteralExpression,
                                     SyntaxFactory.Literal(info.Title))))))))
         .WithTarget(
             SyntaxFactory.AttributeTargetSpecifier(
                 SyntaxFactory.Token(SyntaxKind.AssemblyKeyword))),
         SyntaxFactory.AttributeList(
             SyntaxFactory.SingletonSeparatedList(
                 SyntaxFactory.Attribute(
                     SyntaxFactory.IdentifierName("AssemblyProduct"))
                 .WithArgumentList(
                     SyntaxFactory.AttributeArgumentList(
                         SyntaxFactory.SingletonSeparatedList(
                             SyntaxFactory.AttributeArgument(
                                 SyntaxFactory.LiteralExpression(
                                     SyntaxKind.StringLiteralExpression,
                                     SyntaxFactory.Literal(info.Product))))))))
         .WithTarget(
             SyntaxFactory.AttributeTargetSpecifier(
                 SyntaxFactory.Token(SyntaxKind.AssemblyKeyword))),
         SyntaxFactory.AttributeList(
             SyntaxFactory.SingletonSeparatedList(
                 SyntaxFactory.Attribute(
                     SyntaxFactory.IdentifierName("AssemblyCopyright"))
                 .WithArgumentList(
                     SyntaxFactory.AttributeArgumentList(
                         SyntaxFactory.SingletonSeparatedList(
                             SyntaxFactory.AttributeArgument(
                                 SyntaxFactory.LiteralExpression(
                                     SyntaxKind.StringLiteralExpression,
                                     SyntaxFactory.Literal(info.Copyright))))))))
         .WithTarget(
             SyntaxFactory.AttributeTargetSpecifier(
                 SyntaxFactory.Token(SyntaxKind.AssemblyKeyword))),
         SyntaxFactory.AttributeList(
             SyntaxFactory.SingletonSeparatedList(
                 SyntaxFactory.Attribute(
                     SyntaxFactory.IdentifierName("ComVisible"))
                 .WithArgumentList(
                     SyntaxFactory.AttributeArgumentList(
                         SyntaxFactory.SingletonSeparatedList(
                             SyntaxFactory.AttributeArgument(
                                 SyntaxFactory.LiteralExpression(info.ComVisible
                                                     ? SyntaxKind.TrueLiteralExpression
                                                     : SyntaxKind.FalseLiteralExpression)))))))
         .WithTarget(
             SyntaxFactory.AttributeTargetSpecifier(
                 SyntaxFactory.Token(SyntaxKind.AssemblyKeyword))),
         SyntaxFactory.AttributeList(
             SyntaxFactory.SingletonSeparatedList(
                 SyntaxFactory.Attribute(
                     SyntaxFactory.IdentifierName("Guid"))
                 .WithArgumentList(
                     SyntaxFactory.AttributeArgumentList(
                         SyntaxFactory.SingletonSeparatedList(
                             SyntaxFactory.AttributeArgument(
                                 SyntaxFactory.LiteralExpression(
                                     SyntaxKind.StringLiteralExpression,
                                     SyntaxFactory.Literal(info.Guid))))))))
         .WithTarget(
             SyntaxFactory.AttributeTargetSpecifier(
                 SyntaxFactory.Token(SyntaxKind.AssemblyKeyword))),
         SyntaxFactory.AttributeList(
             SyntaxFactory.SingletonSeparatedList(
                 SyntaxFactory.Attribute(
                     SyntaxFactory.IdentifierName("AssemblyVersion"))
                 .WithArgumentList(
                     SyntaxFactory.AttributeArgumentList(
                         SyntaxFactory.SingletonSeparatedList(
                             SyntaxFactory.AttributeArgument(
                                 SyntaxFactory.LiteralExpression(
                                     SyntaxKind.StringLiteralExpression,
                                     SyntaxFactory.Literal(info.Version))))))))
         .WithTarget(
             SyntaxFactory.AttributeTargetSpecifier(
                 SyntaxFactory.Token(SyntaxKind.AssemblyKeyword))),
         SyntaxFactory.AttributeList(
             SyntaxFactory.SingletonSeparatedList(
                 SyntaxFactory.Attribute(
                     SyntaxFactory.IdentifierName("AssemblyFileVersion"))
                 .WithArgumentList(
                     SyntaxFactory.AttributeArgumentList(
                         SyntaxFactory.SingletonSeparatedList(
                             SyntaxFactory.AttributeArgument(
                                 SyntaxFactory.LiteralExpression(
                                     SyntaxKind.StringLiteralExpression,
                                     SyntaxFactory.Literal(info.FileVersion))))))))
         .WithTarget(
             SyntaxFactory.AttributeTargetSpecifier(
                 SyntaxFactory.Token(SyntaxKind.AssemblyKeyword)))
     }))
            .NormalizeWhitespace()
            .SyntaxTree);
 }
Esempio n. 54
0
 public void AssemblyCompleted(AssemblyInfo assembly, AssemblyResult result)
 {
     Console.WriteLine(result.Summary);
     Console.WriteLine();
 }
 public void OnAssemblyEnd(AssemblyInfo assembly)
 {
     _output.AssemblyEnd(assembly);
 }
 public void OnAssemblyStart(AssemblyInfo assembly)
 {
     _output.AssemblyStart(assembly);
 }
Esempio n. 57
0
 public void Create(AssemblyInfo o)
 {
     ExecuteNonQuery(string.Format("INSERT INTO AssemblyInfo(ID, Name, Description, Project, Configuration, Company, Product, Copyright, Trademark, Culture, Version, FileVersion, ComVisibility) VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}')",
                                   o.ID.ToString(), o.Name, o.Description, o.Project, o.Configuration, o.Company, o.Product, o.Copyright, o.Trademark, o.Culture, o.Version, o.FileVersion, o.ComVisibility));
 }
Esempio n. 58
0
 public void AssemblyStarted(AssemblyInfo assembly)
 {
     Message("testSuiteStarted name='{0}'", SuiteName(assembly));
 }
Esempio n. 59
0
 public void AssemblyEnd(AssemblyInfo assembly)
 {
 }
Esempio n. 60
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            WriteVerbose("Plugin Registration intiated");

            if (UseSplitAssembly)
            {
                if (!File.Exists(ProjectFilePath))
                {
                    throw new Exception("Project File Path is required if you want to split assembly.");
                }
                if (RegistrationType == RegistrationTypeEnum.Delsert)
                {
                    throw new Exception("Registration type 'Remove Plugin Types and Steps which are not in mapping and Upsert' will not work when 'Split Assembly' is enabled.");
                }
                if (!File.Exists(MappingFile))
                {
                    throw new Exception("Mapping Json Path is required if you want to split assembly.");
                }
            }

            var assemblyInfo = AssemblyInfo.GetAssemblyInfo(AssemblyPath);

            WriteVerbose($"Assembly Name: {assemblyInfo.AssemblyName}");
            WriteVerbose($"Assembly Version: {assemblyInfo.Version}");

            using (var context = new CIContext(OrganizationService))
            {
                var pluginRegistrationHelper = new PluginRegistrationHelper(OrganizationService, context, WriteVerbose, WriteWarning);
                WriteVerbose("PluginRegistrationHelper intiated");
                Assembly pluginAssembly   = null;
                Guid     pluginAssemblyId = Guid.Empty;

                if (File.Exists(MappingFile))
                {
                    pluginAssembly   = pluginRegistrationHelper.ReadMappingFile(MappingFile);
                    pluginAssemblyId = pluginAssembly.Id ?? Guid.Empty;
                }
                else
                {
                    pluginAssemblyId = pluginRegistrationHelper.UpsertPluginAssembly(pluginAssembly, assemblyInfo, SolutionName, RegistrationType);
                    WriteVerbose($"UpsertPluginAssembly {pluginAssemblyId} completed");
                    WriteVerbose("Plugin Registration completed");
                    return;
                }

                if (pluginAssembly == null)
                {
                    WriteVerbose("Plugin Registration completed");
                    return;
                }

                if (pluginAssembly.PluginTypes == null)
                {
                    WriteVerbose("No mapping found for types.");
                    WriteVerbose("Plugin Registration completed");
                    return;
                }

                if (RegistrationType == RegistrationTypeEnum.Delsert)
                {
                    WriteVerbose($"RemoveComponentsNotInMapping {assemblyInfo.AssemblyName} started");
                    pluginRegistrationHelper.RemoveComponentsNotInMapping(pluginAssembly);
                    WriteVerbose($"RemoveComponentsNotInMapping {assemblyInfo.AssemblyName} completed");
                    RegistrationType = RegistrationTypeEnum.Upsert;
                }

                if (UseSplitAssembly)
                {
                    foreach (var type in pluginAssembly.PluginTypes)
                    {
                        UploadSplitAssembly(assemblyInfo, pluginRegistrationHelper, type);
                    }
                }
                else
                {
                    WriteVerbose($"UpsertPluginAssembly {pluginAssemblyId} started");
                    pluginAssemblyId = pluginRegistrationHelper.UpsertPluginAssembly(pluginAssembly, assemblyInfo, SolutionName, RegistrationType);
                    WriteVerbose($"UpsertPluginAssembly {pluginAssemblyId} completed");

                    foreach (var type in pluginAssembly.PluginTypes)
                    {
                        pluginRegistrationHelper.UpsertPluginTypeAndSteps(pluginAssemblyId, type, SolutionName, RegistrationType);
                    }
                }
            }
            WriteVerbose("Plugin Registration completed");
        }