Browse Source

Rip out LogWindow and DecompilerEventSource

pull/848/head
Siegfried Pammer 8 years ago
parent
commit
0644de6fd3
  1. 26
      ICSharpCode.Decompiler/DecompilerEventSource.cs
  2. 8
      ICSharpCode.Decompiler/DotNetCore/DotNetCorePathFinder.cs
  3. 2
      ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
  4. 1
      ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs
  5. 2
      ICSharpCode.Decompiler/Output/TextTokenWriter.cs
  6. 9
      ILSpy/Commands/SortAssemblyListCommand.cs
  7. 5
      ILSpy/ILSpy.csproj
  8. 8
      ILSpy/LoadedAssembly.cs
  9. 13
      ILSpy/LogWindow.xaml
  10. 74
      ILSpy/LogWindow.xaml.cs
  11. 1
      ILSpy/TextView/DecompilerTextView.cs

26
ICSharpCode.Decompiler/DecompilerEventSource.cs

@ -1,26 +0,0 @@ @@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Tracing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.Decompiler.TypeSystem.Implementation;
using Mono.Cecil;
namespace ICSharpCode.Decompiler
{
[EventSource(Name = "DecompilerEventSource")]
public sealed class DecompilerEventSource : EventSource
{
public static DecompilerEventSource Log = new DecompilerEventSource();
[Event(1, Level = EventLevel.Informational)]
public void Info(string text)
{
WriteEvent(1, text);
}
}
}

8
ICSharpCode.Decompiler/DotNetCore/DotNetCorePathFinder.cs

@ -48,11 +48,8 @@ namespace ICSharpCode.Decompiler @@ -48,11 +48,8 @@ namespace ICSharpCode.Decompiler
this.targetFrameworkId = targetFrameworkId;
this.version = version;
DecompilerEventSource.Log.Info($"Looking for {assemblyName}.deps.json in {basePath}");
var depsJsonFileName = Path.Combine(basePath, $"{assemblyName}.deps.json");
if (!File.Exists(depsJsonFileName)) {
DecompilerEventSource.Log.Info($"{assemblyName}.deps.json not found.");
return;
}
@ -72,11 +69,7 @@ namespace ICSharpCode.Decompiler @@ -72,11 +69,7 @@ namespace ICSharpCode.Decompiler
public string TryResolveDotNetCore(AssemblyNameReference name)
{
DecompilerEventSource.Log.Info($"TryResolveDotNetCore: {assemblyName}, version: {version}, reference: {name}");
foreach (var basePath in packageBasePaths) {
DecompilerEventSource.Log.Info($"TryResolveDotNetCore: scanning {basePath}...");
if (File.Exists(Path.Combine(basePath, name.Name + ".dll"))) {
return Path.Combine(basePath, name.Name + ".dll");
} else if (File.Exists(Path.Combine(basePath, name.Name + ".exe"))) {
@ -106,7 +99,6 @@ namespace ICSharpCode.Decompiler @@ -106,7 +99,6 @@ namespace ICSharpCode.Decompiler
{
if (dotnetBasePath == null) return null;
var basePath = Path.Combine(dotnetBasePath, "shared\\Microsoft.NETCore.App", version);
DecompilerEventSource.Log.Info($"Fallback: use {basePath}");
if (File.Exists(Path.Combine(basePath, name.Name + ".dll"))) {
return Path.Combine(basePath, name.Name + ".dll");
} else if (File.Exists(Path.Combine(basePath, name.Name + ".exe"))) {

2
ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

@ -47,7 +47,6 @@ @@ -47,7 +47,6 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Collections.Immutable" Version="1.3.0" />
<PackageReference Include="System.Diagnostics.Tracing" Version="4.3.0" />
<PackageReference Include="System.ValueTuple" Version="4.3.0" />
</ItemGroup>
@ -259,7 +258,6 @@ @@ -259,7 +258,6 @@
<Compile Include="Documentation\IdStringMemberReference.cs" />
<Compile Include="Documentation\IdStringProvider.cs" />
<Compile Include="Documentation\XmlDocumentationProvider.cs" />
<Compile Include="DecompilerEventSource.cs" />
<Compile Include="DotNetCore\DotNetCorePathFinder.cs" />
<Compile Include="DotNetCore\DotNetCorePathFinderExtensions.cs" />
<Compile Include="IL\ControlFlow\AsyncAwaitDecompiler.cs" />

1
ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs

@ -50,7 +50,6 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -50,7 +50,6 @@ namespace ICSharpCode.Decompiler.IL.Transforms
ILTransformContext context;
string[] currentFieldNames;
Dictionary<ILVariable, string> mapping;
Dictionary<string, int> reservedVariableNames;
const char maxLoopVariableName = 'n';

2
ICSharpCode.Decompiler/Output/TextTokenWriter.cs

@ -40,8 +40,6 @@ namespace ICSharpCode.Decompiler @@ -40,8 +40,6 @@ namespace ICSharpCode.Decompiler
bool firstUsingDeclaration;
bool lastUsingDeclaration;
TextLocation? lastEndOfLine;
public bool FoldBraces = false;
public TextTokenWriter(ITextOutput output, DecompilerSettings settings, IDecompilerTypeSystem typeSystem)

9
ILSpy/Commands/SortAssemblyListCommand.cs

@ -36,13 +36,4 @@ namespace ICSharpCode.ILSpy @@ -36,13 +36,4 @@ namespace ICSharpCode.ILSpy
return string.Compare(x.ShortName, y.ShortName, StringComparison.CurrentCulture);
}
}
[ExportMainMenuCommand(Menu = "_View", Header = "_Output", MenuIcon = "Images/ViewCode.png", MenuCategory = "View")]
sealed class ShowLog : SimpleCommand
{
public override void Execute(object parameter)
{
LogWindow.Instance.Show();
}
}
}

5
ILSpy/ILSpy.csproj

@ -162,10 +162,6 @@ @@ -162,10 +162,6 @@
<DependentUpon>SearchPane.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="LogWindow.xaml.cs">
<DependentUpon>LogWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Commands\SimpleCommand.cs" />
<Compile Include="SearchStrategies.cs" />
<Compile Include="TaskHelper.cs" />
@ -299,7 +295,6 @@ @@ -299,7 +295,6 @@
<Page Include="Options\OptionsDialog.xaml" />
<Page Include="SearchPane.xaml" />
<Page Include="TextView\DecompilerTextView.xaml" />
<Page Include="LogWindow.xaml" />
<Page Include="themes\generic.xaml" />
</ItemGroup>

8
ILSpy/LoadedAssembly.cs

@ -244,11 +244,8 @@ namespace ICSharpCode.ILSpy @@ -244,11 +244,8 @@ namespace ICSharpCode.ILSpy
LoadedAssembly LookupReferencedAssemblyInternal(string fullName)
{
DecompilerEventSource.Log.Info($"Looking for {fullName}...");
foreach (LoadedAssembly asm in assemblyList.GetAssemblies()) {
if (asm.AssemblyDefinition != null && fullName.Equals(asm.AssemblyDefinition.FullName, StringComparison.OrdinalIgnoreCase)) {
DecompilerEventSource.Log.Info($"Found in list of loaded assemblies.");
return asm;
}
}
@ -256,13 +253,10 @@ namespace ICSharpCode.ILSpy @@ -256,13 +253,10 @@ namespace ICSharpCode.ILSpy
return null;
if (!App.Current.Dispatcher.CheckAccess()) {
DecompilerEventSource.Log.Info($"Retry on UI thread...");
// Call this method on the GUI thread.
return (LoadedAssembly)App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Func<string, LoadedAssembly>(LookupReferencedAssembly), fullName);
}
DecompilerEventSource.Log.Info($"Detected target framework: {TargetFrameworkId}.");
var targetFramework = TargetFrameworkId.Split(new[] { ",Version=v" }, StringSplitOptions.None);
var name = AssemblyNameReference.Parse(fullName);
string file = null;
@ -288,10 +282,8 @@ namespace ICSharpCode.ILSpy @@ -288,10 +282,8 @@ namespace ICSharpCode.ILSpy
file = Path.Combine(dir, name.Name + ".exe");
}
if (file != null) {
DecompilerEventSource.Log.Info($"Success - Loading {file}...");
return assemblyList.OpenAssembly(file, true);
} else {
DecompilerEventSource.Log.Info($"Warning - Failed to resolve {name.FullName}...");
return null;
}
}

13
ILSpy/LogWindow.xaml

@ -1,13 +0,0 @@ @@ -1,13 +0,0 @@
<UserControl x:Class="ICSharpCode.ILSpy.LogWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ICSharpCode.ILSpy"
xmlns:ae="http://icsharpcode.net/sharpdevelop/avalonedit"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<ae:TextEditor x:Name="log" FontFamily="Consolas" FontSize="10pt" IsReadOnly="True" />
</Grid>
</UserControl>

74
ILSpy/LogWindow.xaml.cs

@ -1,74 +0,0 @@ @@ -1,74 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using ICSharpCode.AvalonEdit;
namespace ICSharpCode.ILSpy
{
partial class LogWindow : UserControl, IPane
{
static LogWindow instance;
public static LogWindow Instance {
get {
if (instance == null) {
App.Current.VerifyAccess();
instance = new LogWindow();
}
return instance;
}
}
readonly AvalonEditEventListener listener;
private LogWindow()
{
InitializeComponent();
this.listener = new AvalonEditEventListener(this.log);
}
public void Show()
{
if (!IsVisible) {
MainWindow.Instance.ShowInBottomPane("Output", this);
}
}
public void Closed()
{
}
class AvalonEditEventListener : EventListener
{
private TextEditor editor;
public AvalonEditEventListener(TextEditor editor)
{
this.editor = editor ?? throw new ArgumentNullException(nameof(editor));
}
protected override void OnEventSourceCreated(EventSource eventSource)
{
if (eventSource.Name == "DecompilerEventSource")
EnableEvents(eventSource, EventLevel.LogAlways, EventKeywords.All);
}
protected override void OnEventWritten(EventWrittenEventArgs eventData)
{
editor.Dispatcher.InvokeAsync(() => WriteToLog(eventData));
}
private void WriteToLog(EventWrittenEventArgs eventData)
{
editor.AppendText(eventData.Payload[0] + Environment.NewLine);
editor.ScrollToEnd();
}
}
}
}

1
ILSpy/TextView/DecompilerTextView.cs

@ -498,7 +498,6 @@ namespace ICSharpCode.ILSpy.TextView @@ -498,7 +498,6 @@ namespace ICSharpCode.ILSpy.TextView
if (i > 0)
textOutput.WriteLine();
DecompilerEventSource.Log.Info($"Decompilation started...");
context.Options.CancellationToken.ThrowIfCancellationRequested();
nodes[i].Decompile(context.Language, textOutput, context.Options);
}

Loading…
Cancel
Save