Пример #1
0
        public OptionsDialog()
        {
            InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            // These used to have [ImportMany(..., RequiredCreationPolicy = CreationPolicy.NonShared)], so they use their own
            // ExportProvider instance.
            // FIXME: Ideally, the export provider should be disposed when it's no longer needed.
            var ep = App.ExportProviderFactory.CreateExportProvider();
            this.optionPages = ep.GetExports <IControl, IOptionsMetadata>("OptionPages").ToArray();
            ILSpySettings settings = ILSpySettings.Load();
            var           tabItems = new List <TabItem>();
            foreach (var optionPage in optionPages.OrderBy(p => p.Metadata.Order))
            {
                TabItem tabItem = new TabItem();
                tabItem.Header  = MainWindow.GetResourceString(optionPage.Metadata.Title);
                tabItem.Content = optionPage.Value;
                tabItems.Add(tabItem);

                IOptionPage page = optionPage.Value as IOptionPage;
                if (page != null)
                {
                    page.Load(settings);
                }
            }
            tabControl.Items = tabItems;
        }
Пример #2
0
        public void Execute(SharpTreeNode[] selectedNodes)
        {
            if (!CurrentDebugger.IsDebugging)
            {
                AssemblyTreeNode n = selectedNodes[0] as AssemblyTreeNode;

                var      settings        = ILSpySettings.Load();
                XElement e               = settings["DebuggerSettings"];
                var      askForArguments = (bool?)e.Attribute("askForArguments");
                if (askForArguments.HasValue && askForArguments.Value)
                {
                    var window = new ExecuteProcessWindow {
                        Owner = MainWindow.Instance,
                        SelectedExecutable = n.LoadedAssembly.FileName
                    };
                    if (window.ShowDialog() == true)
                    {
                        string fileName = window.SelectedExecutable;

                        // execute the process
                        this.StartExecutable(fileName, window.WorkingDirectory, window.Arguments);
                    }
                }
                else
                {
                    this.StartExecutable(n.LoadedAssembly.FileName, null, null);
                }
            }
        }
Пример #3
0
        public OptionsDialog()
        {
            InitializeComponent();
            ILSpySettings settings = ILSpySettings.Load();
            var           creators = MefState.Instance.optionPages.OrderBy(p => p.Metadata.Order).ToArray();

            optionPages = creators.Select(p => p.Value.Create()).ToArray();
            for (int i = 0; i < creators.Length; i++)
            {
                TabItem tabItem = new TabItem();
                tabItem.Header  = creators[i].Metadata.Title;
                tabItem.Content = new ScrollViewer {
                    // Disable the horizontal scrollbar since some pages have textboxes and they
                    // will grow if the text doesn't fit and there's a horizontal scrollbar.
                    HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
                    VerticalScrollBarVisibility   = ScrollBarVisibility.Auto,
                    Content = optionPages[i],
                };
                tabControl.Items.Add(tabItem);

                optionPages[i].Load(settings);
            }

            foreach (var page in optionPages)
            {
                page.PropertyChanged += (s, e) => HasErrorUpdated();
            }
            HasErrorUpdated();
        }
Пример #4
0
 private SettingsManager()
 {
     settings = ILSpySettings.Load();
     Root     = settings[XName.Get("ILEdit")];
     if (Root.Elements().Count() == 0)
     {
         RestoreDefault();
     }
 }
Пример #5
0
        void Load()
        {
            try {
                disableSaveCounter++;

                Load(ILSpySettings.Load());
            }
            finally {
                disableSaveCounter--;
            }
        }
Пример #6
0
        void Load()
        {
            try {
                disableSaveCounter++;

                var settings = ILSpySettings.Load();
                var csx      = settings[SETTINGS_NAME];
                ShowTokens = (bool?)csx.Attribute("ShowTokens") ?? true;
            }
            finally {
                disableSaveCounter--;
            }
        }
Пример #7
0
        void LoadInternal()
        {
            ILSpySettings settings = ILSpySettings.Load();
            var           bpsx     = settings[SETTINGS_NAME];

            BreakpointManager.Instance.Clear();
            foreach (var bpx in bpsx.Elements("Breakpoint"))
            {
                uint?  token            = (uint?)bpx.Attribute("Token");
                string assemblyFullPath = SessionSettings.Unescape((string)bpx.Attribute("AssemblyFullPath"));
                string moduleFullPath   = SessionSettings.Unescape((string)bpx.Attribute("ModuleFullPath"));
                bool   isDynamic        = (bool?)bpx.Attribute("IsDynamic") ?? false;
                bool   isInMemory       = (bool?)bpx.Attribute("IsInMemory") ?? false;
                uint?  ilOffset         = (uint?)bpx.Attribute("ILOffset") ?? (uint?)bpx.Attribute("From");       //TODO: Remove "From" some time after this commit
                bool?  isEnabled        = (bool?)bpx.Attribute("IsEnabled");

                if (token == null)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(moduleFullPath))
                {
                    continue;
                }
                if (ilOffset == null)
                {
                    continue;
                }
                if (isEnabled == null)
                {
                    continue;
                }

                var snModule = new SerializedDnModule(moduleFullPath, isDynamic, isInMemory);
                var key      = MethodKey.Create(token.Value, snModule);

                if (!isInMemory)
                {
                    var s = SessionSettings.Unescape((string)bpx.Attribute("Method"));
                    if (s == null || s != GetMethodAsString(assemblyFullPath, key))
                    {
                        continue;
                    }
                }

                var bp = new ILCodeBreakpoint(assemblyFullPath, key, ilOffset.Value, isEnabled.Value);
                BreakpointManager.Instance.Add(bp);
            }
        }
        public LinqPadSpyContainer(Application currentApplication, Language decompiledLanguage)
        {
            if (currentApplication == null)
            {
                throw new ArgumentNullException("currentApplication");
            }
            if (decompiledLanguage == null)
            {
                throw new ArgumentNullException("decompiledLanguage");
            }

            this.decompiledLanguage = decompiledLanguage;

            this.currentApplication = currentApplication;

            // Initialize supported ILSpy languages. Values used for the combobox.
            Languages.Initialize(CompositionContainerBuilder.Container);

            this.CurrentAssemblyList = new AssemblyList("LINQPadAssemblyList", this.currentApplication);

            ICSharpCode.ILSpy.App.CompositionContainer = CompositionContainerBuilder.Container;

            CompositionContainerBuilder.Container.ComposeParts(this);

            // A hack to get around the global shared state of the Window object throughout ILSpy.
            ICSharpCode.ILSpy.MainWindow.SpyWindow = this;

            this.spySettings = ILSpySettings.Load();

            this.sessionSettings = new SessionSettings(this.spySettings)
            {
                ActiveAssemblyList = this.CurrentAssemblyList.ListName
            };

            SetUpDataContext();

            this.assemblyPath = LinqPadUtil.GetLastLinqPadQueryAssembly();

            this.decompilerTextView = GetDecompilerTextView();

            InitializeComponent();

            this.mainPane.Content = this.decompilerTextView;

            this.InitToolbar();

            this.Loaded += new RoutedEventHandler(this.MainWindowLoaded);
        }
Пример #9
0
        void LoadInternal()
        {
            ILSpySettings settings = ILSpySettings.Load();
            var           exs      = settings[SETTINGS_NAME];

            ExceptionManager.Instance.RestoreDefaults();
            foreach (var exx in exs.Elements("Exception"))
            {
                var  exceptionType      = (ExceptionType?)(int?)exx.Attribute("ExceptionType");
                var  fullName           = SessionSettings.Unescape((string)exx.Attribute("FullName"));
                bool?breakOnFirstChance = (bool?)exx.Attribute("BreakOnFirstChance");
                bool isOtherExceptions  = (bool?)exx.Attribute("IsOtherExceptions") ?? false;
                var  diffType           = (ExceptionDiffType?)(int?)exx.Attribute("DiffType");

                if (diffType == null)
                {
                    continue;
                }
                if (exceptionType == null || (int)exceptionType.Value < 0 || exceptionType.Value >= ExceptionType.Last)
                {
                    continue;
                }
                if (fullName == null)
                {
                    continue;
                }

                var key = new ExceptionInfoKey(exceptionType.Value, fullName);
                switch (diffType.Value)
                {
                case ExceptionDiffType.Remove:
                    ExceptionManager.Instance.Remove(key);
                    break;

                case ExceptionDiffType.AddOrUpdate:
                    if (breakOnFirstChance == null)
                    {
                        continue;
                    }
                    ExceptionManager.Instance.AddOrUpdate(key, breakOnFirstChance.Value, isOtherExceptions);
                    break;

                default:
                    Debug.Fail("Unknown ExceptionDiffType");
                    break;
                }
            }
        }
Пример #10
0
        public OptionsDialog()
        {
            InitializeComponent();
            ILSpySettings settings = ILSpySettings.Load();
            var           creators = MefState.Instance.optionPages.OrderBy(p => p.Metadata.Order).ToArray();

            optionPages = creators.Select(p => p.Value.Create()).ToArray();
            for (int i = 0; i < creators.Length; i++)
            {
                TabItem tabItem = new TabItem();
                tabItem.Header  = creators[i].Metadata.Title;
                tabItem.Content = optionPages[i];
                tabControl.Items.Add(tabItem);

                optionPages[i].Load(settings);
            }
        }
Пример #11
0
        public static bool GetIsShowDebugInfo(ILSpySettings settings)
        {
            if (settings == null)
            {
                settings = ILSpySettings.Load();
            }
            XElement   e = settings[ns + "ReadyToRunOptions"];
            XAttribute a = e.Attribute("IsShowDebugInfo");

            if (a == null)
            {
                return(true);
            }
            else
            {
                return((bool)a);
            }
        }
Пример #12
0
        public static string GetDisassemblyFormat(ILSpySettings settings)
        {
            if (settings == null)
            {
                settings = ILSpySettings.Load();
            }
            XElement   e = settings[ns + "ReadyToRunOptions"];
            XAttribute a = e.Attribute("DisassemblyFormat");

            if (a == null)
            {
                return(ReadyToRunOptions.intel);
            }
            else
            {
                return((string)a);
            }
        }
Пример #13
0
        public override void Execute(object parameter)
        {
            if (!CurrentDebugger.IsDebugging)
            {
                var      settings        = ILSpySettings.Load();
                XElement e               = settings["DebuggerSettings"];
                var      askForArguments = (bool?)e.Attribute("askForArguments");
                if (askForArguments.HasValue && askForArguments.Value)
                {
                    var window = new ExecuteProcessWindow {
                        Owner = MainWindow.Instance
                    };
                    if (window.ShowDialog() == true)
                    {
                        string fileName = window.SelectedExecutable;

                        // add it to references
                        MainWindow.Instance.OpenFiles(new [] { fileName }, false);

                        // execute the process
                        this.StartExecutable(fileName, window.WorkingDirectory, window.Arguments);
                    }
                }
                else
                {
                    OpenFileDialog dialog = new OpenFileDialog()
                    {
                        Filter           = ".NET Executable (*.exe) | *.exe",
                        RestoreDirectory = true,
                        DefaultExt       = "exe"
                    };
                    if (dialog.ShowDialog() == true)
                    {
                        string fileName = dialog.FileName;

                        // add it to references
                        MainWindow.Instance.OpenFiles(new [] { fileName }, false);

                        // execute the process
                        this.StartExecutable(fileName, null, null);
                    }
                }
            }
        }
        public OptionsDialog()
        {
            InitializeComponent();
            App.CompositionContainer.ComposeParts(this);
            ILSpySettings settings = ILSpySettings.Load();

            foreach (var optionPage in optionPages.OrderBy(p => p.Metadata.Order))
            {
                TabItem tabItem = new TabItem();
                tabItem.Header  = optionPage.Metadata.Title;
                tabItem.Content = optionPage.Value;
                tabControl.Items.Add(tabItem);

                IOptionPage page = optionPage.Value as IOptionPage;
                if (page != null)
                {
                    page.Load(settings);
                }
            }
        }
Пример #15
0
        public void Show()
        {
            if (!IsVisible)
            {
                // load debugger settings (to update context menu)
                ILSpySettings settings = ILSpySettings.Load();
                DebuggerSettings.Instance.Load(settings);
                DebuggerSettings.Instance.PropertyChanged += new PropertyChangedEventHandler(OnDebuggerSettingChanged);

                SwitchModuleColumn();
                MainWindow.Instance.ShowInBottomPane("Callstack", this);

                DebuggerService.DebugStarted += new EventHandler(OnDebugStarted);
                DebuggerService.DebugStopped += new EventHandler(OnDebugStopped);
                if (DebuggerService.IsDebuggerStarted)
                {
                    OnDebugStarted(null, EventArgs.Empty);
                }
            }
        }
Пример #16
0
        public override void Execute(object parameter)
        {
            if (!CurrentDebugger.IsDebugging)
            {
                var      settings     = ILSpySettings.Load();
                XElement e            = settings["DebuggerSettings"];
                var      showWarnings = (bool?)e.Attribute("showWarnings");
                if ((showWarnings.HasValue && showWarnings.Value) || !showWarnings.HasValue)
                {
                    MessageBox.Show("Warning: When attaching to an application, some local variables might not be available. If possible, use the \"Start Executable\" command.",
                                    "Attach to a process", MessageBoxButton.OK, MessageBoxImage.Warning);
                }

                var window = new AttachToProcessWindow {
                    Owner = MainWindow.Instance
                };
                if (window.ShowDialog() == true)
                {
                    StartAttaching(window.SelectedProcess);
                }
            }
        }
Пример #17
0
        void Load()
        {
            try {
                disableSaveCounter++;

                var settings = ILSpySettings.Load();
                var csx      = settings[SETTINGS_NAME];
                ShowModuleNames     = (bool?)csx.Attribute("ShowModuleNames") ?? true;
                ShowParameterTypes  = (bool?)csx.Attribute("ShowParameterTypes") ?? true;
                ShowParameterNames  = (bool?)csx.Attribute("ShowParameterNames") ?? true;
                ShowParameterValues = (bool?)csx.Attribute("ShowParameterValues") ?? false;
                ShowIP           = (bool?)csx.Attribute("ShowIP") ?? true;
                ShowOwnerTypes   = (bool?)csx.Attribute("ShowOwnerTypes") ?? true;
                ShowNamespaces   = (bool?)csx.Attribute("ShowNamespaces") ?? true;
                ShowTypeKeywords = (bool?)csx.Attribute("ShowTypeKeywords") ?? true;
                ShowTokens       = (bool?)csx.Attribute("ShowTokens") ?? false;
                ShowReturnTypes  = (bool?)csx.Attribute("ShowReturnTypes") ?? false;
            }
            finally {
                disableSaveCounter--;
            }
        }
Пример #18
0
        public void LoadInternal()
        {
            ILSpySettings settings = ILSpySettings.Load();
            var           bpsx     = settings["Breakpoints"];

            BookmarkManager.RemoveMarks <BreakpointBookmark>();
            foreach (var bpx in bpsx.Elements("Breakpoint"))
            {
                int?   token            = (int?)bpx.Attribute("Token");
                string moduleFullPath   = SessionSettings.Unescape((string)bpx.Attribute("ModuleFullPath"));
                string assemblyFullPath = SessionSettings.Unescape((string)bpx.Attribute("AssemblyFullPath"));
                uint?  from             = (uint?)bpx.Attribute("From");
                uint?  to                = (uint?)bpx.Attribute("To");
                bool?  isEnabled         = (bool?)bpx.Attribute("IsEnabled");
                int?   locationLine      = (int?)bpx.Attribute("LocationLine");
                int?   locationColumn    = (int?)bpx.Attribute("LocationColumn");
                int?   endLocationLine   = (int?)bpx.Attribute("EndLocationLine");
                int?   endLocationColumn = (int?)bpx.Attribute("EndLocationColumn");
                string methodFullName    = SessionSettings.Unescape((string)bpx.Attribute("MethodFullName"));

                if (token == null)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(moduleFullPath))
                {
                    continue;
                }
                if (assemblyFullPath == null)
                {
                    continue;
                }
                if (from == null || to == null || from.Value >= to.Value)
                {
                    continue;
                }
                if (isEnabled == null)
                {
                    continue;
                }
                if (locationLine == null || locationLine.Value < 1)
                {
                    continue;
                }
                if (locationColumn == null || locationColumn.Value < 1)
                {
                    continue;
                }
                if (endLocationLine == null || endLocationLine.Value < 1)
                {
                    continue;
                }
                if (endLocationColumn == null || endLocationColumn.Value < 1)
                {
                    continue;
                }
                var location    = new TextLocation(locationLine.Value, locationColumn.Value);
                var endLocation = new TextLocation(endLocationLine.Value, endLocationColumn.Value);
                if (location >= endLocation)
                {
                    continue;
                }

                ModuleDefMD loadedMod;
                try {
                    loadedMod = MainWindow.Instance.LoadAssembly(assemblyFullPath, moduleFullPath).ModuleDefinition as ModuleDefMD;
                }
                catch {
                    continue;
                }
                if (loadedMod == null)
                {
                    continue;
                }

                var method = loadedMod.ResolveToken(token.Value) as MethodDef;
                if (method == null)
                {
                    continue;
                }

                // Add an extra check to make sure that the file hasn't been re-created. This check
                // isn't perfect but should work most of the time unless the file was re-compiled
                // with the same tools and no methods were added or removed.
                if (method.FullName != methodFullName)
                {
                    continue;
                }

                if (MethodKey.Create(method) == null)
                {
                    continue;
                }
                var bpm = new BreakpointBookmark(method, location, endLocation, new ILRange(from.Value, to.Value), isEnabled.Value);
                BookmarkManager.AddMark(bpm);
            }
        }
Пример #19
0
 public override void Execute(object parameter)
 {
     MainWindow.Instance.ShowMessageIfUpdatesAvailableAsync(ILSpySettings.Load(), forceCheck: true);
 }