void WriteShortInfo(AvalonEditTextOutput output, string s) { if (string.IsNullOrEmpty(s)) return; const int MAX_SHORT_LEN = 128; if (s.Length > MAX_SHORT_LEN) s = s.Substring(0, MAX_SHORT_LEN) + "[...]"; output.WriteLine(string.Format(" {0}", s), TextTokenKind.Text); }
void AddCodeMappings(ITextEditorUIContext uiContext, AvalonEditTextOutput output) { if (output == null) return; var cm = new CodeMappings(output.DebuggerMemberMappings); uiContext.AddOutputData(CodeMappingsConstants.CodeMappingsKey, cm); }
public void OnShow(IShowContext ctx) { var uiCtx = (ITextEditorUIContext)ctx.UIContext; var output = new AvalonEditTextOutput(); Write(output); uiCtx.SetOutput(output, null); }
void Write(AvalonEditTextOutput output) { output.WriteLine(string.Format("dnSpy {0}", appWindow.AssemblyInformationalVersion), TextTokenKind.Text); output.WriteLine(); output.WriteLine(dnSpy_Resources.AboutScreen_LicenseInfo, TextTokenKind.Text); output.WriteLine(); output.WriteLine(dnSpy_Resources.AboutScreen_LoadedFiles, TextTokenKind.Text); foreach (var info in GetInfos()) { output.WriteLine(); WriteShortInfo(output, info.Name); WriteShortInfo(output, info.Copyright); WriteShortInfo(output, info.ShortDescription); } }
void AddCodeMappings(ITextEditorUIContext uiContext, AvalonEditTextOutput output) { if (output == null) return; var cm = new CodeMappings(output.DebuggerMemberMappings, serializedDnModuleCreator); uiContext.AddOutputData(CodeMappingsKey, cm); }
void WriteResourceFile(AvalonEditTextOutput output, string name, bool addNewLine = true) { if (addNewLine) output.WriteLine(); using (var stream = GetType().Assembly.GetManifestResourceStream(name)) using (var streamReader = new StreamReader(stream, Encoding.UTF8)) { for (;;) { var line = streamReader.ReadLine(); if (line == null) break; output.WriteLine(line, TextTokenKind.Text); } } }
public object OnShow(IFileTabUIContext uiContext) { var ctx = (ITextEditorUIContext)uiContext; var output = new AvalonEditTextOutput(); Write(output); ctx.SetOutput(output, null); return null; }
DecompileContext CreateDecompileContext() { var decompileContext = new DecompileContext(); var decompilationContext = new DecompilationContext(); decompilationContext.GetDisableAssemblyLoad = () => decompileFileTabContentFactory.FileManager.DisableAssemblyLoad(); decompilationContext.IsBodyModified = m => decompileFileTabContentFactory.MethodAnnotations.IsBodyModified(m); var output = new AvalonEditTextOutput(); var dispatcher = Dispatcher.CurrentDispatcher; decompileContext.DecompileNodeContext = new DecompileNodeContext(decompilationContext, language, output, dispatcher); return decompileContext; }
public void EndAsyncShow(IFileTabUIContext uiContext, object userData, IAsyncShowResult result) { var decompileContext = (DecompileContext)userData; var uiCtx = (ITextEditorUIContext)uiContext; IHighlightingDefinition highlighting; if (decompileContext.DecompileNodeContext.HighlightingDefinition != null) highlighting = decompileContext.DecompileNodeContext.HighlightingDefinition; else if (decompileContext.DecompileNodeContext.HighlightingExtension != null) highlighting = HighlightingManager.Instance.GetDefinitionByExtension(decompileContext.DecompileNodeContext.HighlightingExtension); else highlighting = decompileContext.DecompileNodeContext.Language.GetHighlightingDefinition(); AvalonEditTextOutput output; if (result.IsCanceled) { output = new AvalonEditTextOutput(); output.Write(dnSpy_Resources.DecompilationCanceled, TextTokenKind.Error); } else if (result.Exception != null) { output = new AvalonEditTextOutput(); output.Write(dnSpy_Resources.DecompilationException, TextTokenKind.Error); output.WriteLine(); output.Write(result.Exception.ToString(), TextTokenKind.Text); } else { output = decompileContext.CachedOutput; if (output == null) { output = (AvalonEditTextOutput)decompileContext.DecompileNodeContext.Output; decompileFileTabContentFactory.DecompilationCache.Cache(decompileContext.DecompileNodeContext.Language, nodes, output, highlighting); } } if (result.CanShowOutput) uiCtx.SetOutput(output, highlighting); }
DecompileContext CreateDecompileContext(IShowContext ctx) { var decompileContext = new DecompileContext(); var decompilationContext = new DecompilationContext(); decompilationContext.CalculateILRanges = true; decompilationContext.GetDisableAssemblyLoad = () => decompileFileTabContentFactory.FileManager.DisableAssemblyLoad(); decompilationContext.IsBodyModified = m => decompileFileTabContentFactory.MethodAnnotations.IsBodyModified(m); var output = new AvalonEditTextOutput(); var dispatcher = Dispatcher.CurrentDispatcher; decompileContext.DecompileNodeContext = new DecompileNodeContext(decompilationContext, language, output, dispatcher); if (ctx.IsRefresh) { decompileContext.SavedRefPos = ((ITextEditorUIContext)ctx.UIContext).SaveReferencePosition(); if (decompileContext.SavedRefPos != null) { ctx.OnShown = e => { if (e.Success && !e.HasMovedCaret) { e.HasMovedCaret = ((ITextEditorUIContext)ctx.UIContext).RestoreReferencePosition(decompileContext.SavedRefPos); if (!e.HasMovedCaret) { ((ITextEditorUIContext)ctx.UIContext).ScrollAndMoveCaretTo(1, 1); e.HasMovedCaret = true; } } }; } } return decompileContext; }
void Write(AvalonEditTextOutput output) { output.WriteLine(string.Format("dnSpy {0}", appWindow.AssemblyInformationalVersion), TextTokenKind.Text); //TODO: Add more stuff... }