Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 void AddCodeMappings(ITextEditorUIContext uiContext, AvalonEditTextOutput output)
 {
     if (output == null)
         return;
     var cm = new CodeMappings(output.DebuggerMemberMappings);
     uiContext.AddOutputData(CodeMappingsConstants.CodeMappingsKey, cm);
 }
Ejemplo n.º 3
0
 public void OnShow(IShowContext ctx)
 {
     var uiCtx = (ITextEditorUIContext)ctx.UIContext;
     var output = new AvalonEditTextOutput();
     Write(output);
     uiCtx.SetOutput(output, null);
 }
Ejemplo n.º 4
0
 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);
     }
 }
Ejemplo n.º 5
0
		void AddCodeMappings(ITextEditorUIContext uiContext, AvalonEditTextOutput output) {
			if (output == null)
				return;
			var cm = new CodeMappings(output.DebuggerMemberMappings, serializedDnModuleCreator);
			uiContext.AddOutputData(CodeMappingsKey, cm);
		}
Ejemplo n.º 6
0
		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);
				}
			}
		}
Ejemplo n.º 7
0
 public object OnShow(IFileTabUIContext uiContext)
 {
     var ctx = (ITextEditorUIContext)uiContext;
     var output = new AvalonEditTextOutput();
     Write(output);
     ctx.SetOutput(output, null);
     return null;
 }
Ejemplo n.º 8
0
 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;
 }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
		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;
		}
Ejemplo n.º 11
0
        void Write(AvalonEditTextOutput output)
        {
            output.WriteLine(string.Format("dnSpy {0}", appWindow.AssemblyInformationalVersion), TextTokenKind.Text);

            //TODO: Add more stuff...
        }