Esempio n. 1
0
            /// <summary>
            /// Returns the diff between the IL contents of this assembly against the specified assembly.
            /// </summary>
            internal AssemblyContents Diff(AssemblyContents other)
            {
                var diffedContents = new AssemblyContents()
                {
                    FullName = this.FullName,
                    Modules  = new List <ModuleContents>()
                };

                var diffedModules = GetUnion(this.Modules, other.Modules);

                foreach (var module in diffedModules)
                {
                    var thisModule  = this.Modules.FirstOrDefault(m => m.Equals(module));
                    var otherModule = other.Modules.FirstOrDefault(m => m.Equals(module));
                    if (thisModule is null)
                    {
                        diffedContents.Modules.Add(module.Clone(DiffStatus.Added));
                    }
                    else if (otherModule is null)
                    {
                        diffedContents.Modules.Add(module.Clone(DiffStatus.Removed));
                    }
                    else
                    {
                        diffedContents.Modules.Add(thisModule.Diff(otherModule));
                    }
                }

                return(diffedContents);
            }
Esempio n. 2
0
        private void OnItemInteraction(EEInteractableItem item, SLabel label)
        {
            AssemblyContents cont = _assemblyMap[_assemblySelected];
            NamespaceMap     map  = cont.Namespaces.FirstOrDefault(n => n.Namespace == _namespaceDropdown.Selected.ReadableName);
            Type             type = map?.Types.FirstOrDefault(t => t.Name == item.Label.ReadableName);

            SelectedType = type;
            OnTypeSelected?.Invoke(type);
        }
Esempio n. 3
0
        /// <inheritdoc/>
        protected internal override void VisitAssembly(AssemblyInfo assembly)
        {
            if (!this.ContentMap.ContainsKey(assembly.FullName))
            {
                var contents = new AssemblyContents()
                {
                    FullName = assembly.FullName,
                    Modules  = new List <ModuleContents>()
                };

                this.ContentMap.Add(assembly.FullName, contents);
            }

            base.VisitAssembly(assembly);
        }
Esempio n. 4
0
        /// <summary>
        /// Returns the IL contents of the specified assembly as JSON.
        /// </summary>
        private string GetJson(AssemblyContents contents)
        {
            try
            {
                contents.Resolve();
                return(JsonSerializer.Serialize(contents, new JsonSerializerOptions()
                {
                    DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
                    Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
                    WriteIndented = true
                }));
            }
            catch (Exception ex)
            {
                this.Logger.WriteLine(LogSeverity.Error, $"Unable to serialize IL to JSON. {ex.Message}");
            }

            return(string.Empty);
        }
Esempio n. 5
0
        private void LoadAssemblyTypes(Assembly ass, int namespaceLevels, Predicate <Type> filter)
        {
            Type[] types = UTAssembly.GetTypesFromAssemblies(ass);
            if (filter != null)
            {
                types = types.Where(e => filter(e)).ToArray();
            }

            string[] nsps = UTType.NamespacesFromTypes(types, namespaceLevels);

            List <NamespaceMap> maps = new List <NamespaceMap>();

            foreach (string s in nsps)
            {
                NamespaceMap map = new NamespaceMap(
                    s,
                    types.Where(t => t.Namespace == null ? s == "_NoNamespace" : t.Namespace.SeparatorLevelPrune('.', namespaceLevels) == s).ToArray()
                    );

                maps.Add(map);
            }

            _assemblyMap[ass] = new AssemblyContents(maps.ToArray());
        }