Exemplo n.º 1
0
        AssemblySettingsCommand(IAssemblyFileNode asmNode, AssemblyOptions newOptions)
        {
            this.asmNode     = asmNode;
            this.newOptions  = newOptions;
            this.origOptions = new AssemblyOptions(asmNode.DnSpyFile.AssemblyDef);

            if (newOptions.Name != origOptions.Name)
            {
                this.assemblyRefInfos = RefFinder.FindAssemblyRefsToThisModule(asmNode.DnSpyFile.ModuleDef).Where(a => AssemblyNameComparer.NameAndPublicKeyTokenOnly.Equals(a, asmNode.DnSpyFile.AssemblyDef)).Select(a => new AssemblyRefInfo(a)).ToArray();
            }
        }
Exemplo n.º 2
0
 protected AddNetModuleToAssemblyCommand(IUndoCommandManager undoCommandManager, IDnSpyFileNode asmNode, IModuleFileNode modNode, bool modNodeWasCreated)
 {
     this.undoCommandManager = undoCommandManager;
     if (!(asmNode is IAssemblyFileNode))
     {
         asmNode = (IAssemblyFileNode)asmNode.TreeNode.Parent.Data;
     }
     this.asmNode           = (IAssemblyFileNode)asmNode;
     this.modNode           = modNode;
     this.modNodeWasCreated = modNodeWasCreated;
 }
Exemplo n.º 3
0
        void SearchAssemblyInternal(IAssemblyFileNode asmNode)
        {
            if (asmNode == null)
            {
                return;
            }
            var asm = asmNode.DnSpyFile.AssemblyDef;

            Debug.Assert(asm != null);
            if (asm == null)
            {
                return;
            }
            var res = options.Filter.GetResult(asm);

            if (res.FilterType == FilterType.Hide)
            {
                return;
            }
            CheckCustomAttributes(asmNode.DnSpyFile, asm, null);

            if (res.IsMatch && IsMatch(asm.FullName, asmNode.DnSpyFile))
            {
                options.OnMatch(new SearchResult {
                    Context                = options.Context,
                    Object                 = asm,
                    NameObject             = asm,
                    ObjectImageReference   = options.DotNetImageManager.GetImageReference(asmNode.DnSpyFile.ModuleDef),
                    LocationObject         = null,
                    LocationImageReference = new ImageReference(),
                    DnSpyFile              = asmNode.DnSpyFile,
                });
            }

            if (asmNode.TreeNode.LazyLoading)
            {
                options.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => {
                    asmNode.TreeNode.EnsureChildrenLoaded();
                }));
            }
            var modChildren = asmNode.TreeNode.DataChildren.OfType <IModuleFileNode>().ToArray();

            foreach (var node in asmNode.TreeNode.DataChildren)
            {
                options.CancellationToken.ThrowIfCancellationRequested();
                var modNode = node as IModuleFileNode;
                if (modNode != null)
                {
                    SearchModule(modNode.DnSpyFile);
                }
            }
        }
Exemplo n.º 4
0
 RemoveNetModuleFromAssemblyCommand(Lazy <IUndoCommandManager> undoCommandManager, IModuleFileNode modNode)
 {
     this.undoCommandManager = undoCommandManager;
     this.asmNode            = (IAssemblyFileNode)modNode.TreeNode.Parent.Data;
     Debug.Assert(this.asmNode != null);
     this.modNode     = modNode;
     this.removeIndex = asmNode.TreeNode.DataChildren.ToList().IndexOf(modNode);
     Debug.Assert(this.removeIndex > 0);
     Debug.Assert(asmNode.DnSpyFile.AssemblyDef != null &&
                  asmNode.DnSpyFile.AssemblyDef.Modules.IndexOf(modNode.DnSpyFile.ModuleDef) == this.removeIndex);
     this.removeIndexDnSpyFile = asmNode.DnSpyFile.Children.IndexOf(modNode.DnSpyFile);
     Debug.Assert(this.removeIndexDnSpyFile >= 0);
 }
Exemplo n.º 5
0
        void SearchAssemblyInternal(IAssemblyFileNode asmNode)
        {
            if (asmNode == null)
                return;
            var asm = asmNode.DnSpyFile.AssemblyDef;
            Debug.Assert(asm != null);
            if (asm == null)
                return;
            var res = options.Filter.GetResult(asm);
            if (res.FilterType == FilterType.Hide)
                return;
            CheckCustomAttributes(asmNode.DnSpyFile, asm, null);

            if (res.IsMatch && IsMatch(asm.FullName, asmNode.DnSpyFile)) {
                options.OnMatch(new SearchResult {
                    Context = options.Context,
                    Object = asm,
                    NameObject = asm,
                    ObjectImageReference = options.DotNetImageManager.GetImageReference(asmNode.DnSpyFile.ModuleDef),
                    LocationObject = null,
                    LocationImageReference = new ImageReference(),
                    DnSpyFile = asmNode.DnSpyFile,
                });
            }

            if (asmNode.TreeNode.LazyLoading) {
                options.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => {
                    asmNode.TreeNode.EnsureChildrenLoaded();
                }));
            }
            var modChildren = asmNode.TreeNode.DataChildren.OfType<IModuleFileNode>().ToArray();

            foreach (var node in asmNode.TreeNode.DataChildren) {
                options.CancellationToken.ThrowIfCancellationRequested();
                var modNode = node as IModuleFileNode;
                if (modNode != null)
                    SearchModule(modNode.DnSpyFile);
            }
        }
Exemplo n.º 6
0
        public void Execute(IDataContext context, DelegateExecute nextExecute)
        {
            ISolution solution = context.GetData <ISolution>(JetBrains.ProjectModel.DataContext.DataConstants.SOLUTION);

            if (solution == null)
            {
                return;
            }

            var assemblyExplorerManager = SolutionEx.GetComponent <IAssemblyExplorerManager>(solution);
            var assemblyExplorer        = assemblyExplorerManager.Opened;

            if (assemblyExplorer == null)
            {
                return;
            }

#if DP10
            Assembly asm        = Assembly.GetExecutingAssembly();
            Stream   iconStream = asm.GetManifestResourceStream("JetBrains.DotPeek.Plugins.Console.Console.png");
            var      decoder    = new PngBitmapDecoder(iconStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
            var      icon       = decoder.Frames[0];

            //var icon = new BitmapImage(new Uri(@"pack://application:,,,/JetBrains.DotPeek.Plugins.Console.1.0;Console.png", UriKind.RelativeOrAbsolute));
            //Assembly asm = Assembly.GetExecutingAssembly();
            //Stream iconStream = asm.GetManifestResourceStream("Console.png");
            //BitmapImage bitmap = new BitmapImage();
            //bitmap.BeginInit();
            //bitmap.StreamSource = iconStream;
            //bitmap.EndInit();
            //icon.Source = bitmap;
#elif DP11 || DP12
            IThemedIconManager themedIconManager = SolutionEx.GetComponent <IThemedIconManager>(solution);
            var icon = themedIconManager.GetIcon <ConsoleThemedIcons.Console>().CurrentImageSource;
#endif

            var console       = new ConsoleToolWindow(assemblyExplorerManager);
            var consoleWindow = new Window
            {
                Title   = "Console",
                Icon    = icon,
                Content = console,
                Width   = 640,
                Height  = 520,
                WindowStartupLocation = WindowStartupLocation.CenterScreen,
                ResizeMode            = ResizeMode.CanResize
            };
            consoleWindow.Show();

            // Do we have an assembly node selected somewhere? If so, load the assembly in the console
            var data = context.GetData(TreeModelBrowser.TREE_MODEL_NODES);
            if (data != null)
            {
                var node = data.FirstOrDefault();
                if (node != null)
                {
                    IAssemblyFile     assemblyFile     = null;
                    IAssemblyFileNode assemblyFileNode = node.DataValue as IAssemblyFileNode;
                    if (assemblyFileNode != null)
                    {
                        assemblyFile = ExplorerNodeEx.GetAssemblyFile(assemblyFileNode);
                    }
                    else
                    {
                        AssemblyReferenceNode assemblyReferenceNode = node.DataValue as AssemblyReferenceNode;
                        if (assemblyReferenceNode != null)
                        {
#if DP10
                            IAssembly assemblyResolveResult = ModuleReferencesResolveStoreEx.ResolveResult(assemblyReferenceNode.Reference);
#elif DP11 || DP12
                            IAssembly assemblyResolveResult = ModuleReferencesResolveStoreEx.GetModuleToAssemblyResolveResult(assemblyReferenceNode.Reference);
#endif
                            if (assemblyResolveResult != null)
                            {
                                assemblyFile = Enumerable.FirstOrDefault(assemblyResolveResult.GetFiles());
                            }
                        }
                    }

                    AssemblyInfoCache component = SolutionEx.TryGetComponent <AssemblyInfoCache>(solution);
#if DP10
                    if (component != null && assemblyFile.Location.ExistsFile)
                    {
                        console.LoadAssemblies(new[] { assemblyFile.Location.FullPath });
                    }
#elif DP11 || DP12
                    if (component != null && assemblyFile.Location.ExistsFile && !AssemblyExplorerUtil.AssemblyIsBroken(assemblyFile.Location, component))
                    {
                        console.LoadAssemblies(new[] { assemblyFile.Location.FullPath });
                    }
#endif
                }
            }
        }
Exemplo n.º 7
0
		RemoveNetModuleFromAssemblyCommand(Lazy<IUndoCommandManager> undoCommandManager, IModuleFileNode modNode) {
			this.undoCommandManager = undoCommandManager;
			this.asmNode = (IAssemblyFileNode)modNode.TreeNode.Parent.Data;
			Debug.Assert(this.asmNode != null);
			this.modNode = modNode;
			this.removeIndex = asmNode.TreeNode.DataChildren.ToList().IndexOf(modNode);
			Debug.Assert(this.removeIndex > 0);
			Debug.Assert(asmNode.DnSpyFile.AssemblyDef != null &&
				asmNode.DnSpyFile.AssemblyDef.Modules.IndexOf(modNode.DnSpyFile.ModuleDef) == this.removeIndex);
			this.removeIndexDnSpyFile = asmNode.DnSpyFile.Children.IndexOf(modNode.DnSpyFile);
			Debug.Assert(this.removeIndexDnSpyFile >= 0);
		}
Exemplo n.º 8
0
		protected AddNetModuleToAssemblyCommand(IUndoCommandManager undoCommandManager, IDnSpyFileNode asmNode, IModuleFileNode modNode, bool modNodeWasCreated) {
			this.undoCommandManager = undoCommandManager;
			if (!(asmNode is IAssemblyFileNode))
				asmNode = (IAssemblyFileNode)asmNode.TreeNode.Parent.Data;
			this.asmNode = (IAssemblyFileNode)asmNode;
			this.modNode = modNode;
			this.modNodeWasCreated = modNodeWasCreated;
		}
Exemplo n.º 9
0
		AssemblySettingsCommand(IAssemblyFileNode asmNode, AssemblyOptions newOptions) {
			this.asmNode = asmNode;
			this.newOptions = newOptions;
			this.origOptions = new AssemblyOptions(asmNode.DnSpyFile.AssemblyDef);

			if (newOptions.Name != origOptions.Name)
				this.assemblyRefInfos = RefFinder.FindAssemblyRefsToThisModule(asmNode.DnSpyFile.ModuleDef).Where(a => AssemblyNameComparer.NameAndPublicKeyTokenOnly.Equals(a, asmNode.DnSpyFile.AssemblyDef)).Select(a => new AssemblyRefInfo(a)).ToArray();
		}