Browse Source

Basic infrastructure for C# decompiler

pull/728/head
Daniel Grunwald 11 years ago
parent
commit
8235a93e4f
  1. 94
      ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
  2. 48
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
  3. 23
      ICSharpCode.Decompiler/CSharp/StatementBuilder.cs
  4. 5
      ICSharpCode.Decompiler/CecilExtensions.cs
  5. 14
      ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
  6. 8
      ICSharpCode.Decompiler/IL/ILReader.cs
  7. 13
      ICSharpCode.Decompiler/IL/Instructions/OpCode.cs
  8. 0
      ICSharpCode.Decompiler/TypesHierarchyHelpers.cs
  9. 102
      ILSpy.sln
  10. 5
      ILSpy/ILSpy.csproj
  11. 42
      ILSpy/Languages/CSharpLanguage.cs
  12. 2
      ILSpy/Options/DecompilerSettings.cs
  13. 21
      NRefactory/ICSharpCode.NRefactory.CSharp/Ast/DepthFirstAstVisitor.cs
  14. 20
      NRefactory/ICSharpCode.NRefactory.CSharp/Ast/ErrorNode.cs
  15. 12
      NRefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ErrorExpression.cs
  16. 3
      NRefactory/ICSharpCode.NRefactory.CSharp/Ast/IAstVisitor.cs
  17. 8
      NRefactory/ICSharpCode.NRefactory.CSharp/Ast/ObservableAstVisitor.cs
  18. 8
      NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs
  19. 7
      NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs
  20. 7
      NRefactory/ICSharpCode.NRefactory.CSharp/Resolver/ResolveVisitor.cs
  21. 7
      NRefactory/ICSharpCode.NRefactory.Cecil/CecilLoader.cs
  22. 2
      NRefactory/ICSharpCode.NRefactory.Cecil/ICSharpCode.NRefactory.Cecil.csproj

94
ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

@ -0,0 +1,94 @@ @@ -0,0 +1,94 @@
using ICSharpCode.Decompiler.IL;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
using ICSharpCode.NRefactory.Utils;
using Mono.Cecil;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ICSharpCode.Decompiler.CSharp
{
public class CSharpDecompiler
{
CecilLoader cecilLoader = new CecilLoader { IncludeInternalMembers = true, LazyLoad = true };
Dictionary<IUnresolvedEntity, MemberReference> entityDict = new Dictionary<IUnresolvedEntity, MemberReference>();
ICompilation compilation;
ITypeResolveContext mainAssemblyTypeResolveContext;
TypeSystemAstBuilder typeSystemAstBuilder;
StatementBuilder statementBuilder;
public CancellationToken CancellationToken { get; set; }
public CSharpDecompiler(ModuleDefinition module)
{
cecilLoader.OnEntityLoaded = (entity, mr) => {
// entityDict needs locking because the type system is multi-threaded and may be accessed externally
lock (entityDict)
entityDict[entity] = mr;
};
IUnresolvedAssembly mainAssembly = cecilLoader.LoadModule(module);
var referencedAssemblies = new List<IUnresolvedAssembly>();
foreach (var asmRef in module.AssemblyReferences) {
var asm = module.AssemblyResolver.Resolve(asmRef);
if (asm != null)
referencedAssemblies.Add(cecilLoader.LoadAssembly(asm));
}
compilation = new SimpleCompilation(mainAssembly, referencedAssemblies);
mainAssemblyTypeResolveContext = new SimpleTypeResolveContext(compilation.MainAssembly);
typeSystemAstBuilder = new TypeSystemAstBuilder();
typeSystemAstBuilder.AlwaysUseShortTypeNames = true;
typeSystemAstBuilder.AddAnnotations = true;
statementBuilder = new StatementBuilder();
}
MemberReference GetMemberReference(IMember member)
{
var unresolved = member.UnresolvedMember;
lock (entityDict) {
if (unresolved != null && entityDict.TryGetValue(unresolved, out var mr))
return mr;
}
return null;
}
ITypeDefinition GetTypeDefinition(TypeDefinition typeDef)
{
return compilation.MainAssembly.GetTypeDefinition(typeDef.GetFullTypeName());
}
IMethod GetMethod(MethodDefinition methodDef)
{
ITypeDefinition typeDef = GetTypeDefinition(methodDef.DeclaringType);
if (typeDef == null)
return null;
return typeDef.Methods.FirstOrDefault(m => GetMemberReference(m) == methodDef);
}
public EntityDeclaration Decompile(MethodDefinition methodDefinition)
{
if (methodDefinition == null)
throw new ArgumentNullException("methodDefinition");
var method = GetMethod(methodDefinition);
if (method == null)
throw new InvalidOperationException("Could not find method in NR type system");
var entityDecl = typeSystemAstBuilder.ConvertEntity(method);
if (methodDefinition.HasBody) {
var ilReader = new ILReader(methodDefinition.Body, CancellationToken);
var inst = ilReader.CreateBlocks(true);
var body = statementBuilder.Convert(inst);
var bodyBlock = body as BlockStatement ?? new BlockStatement { body };
entityDecl.AddChild(bodyBlock, Roles.Body);
}
return entityDecl;
}
}
}

48
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
using ICSharpCode.Decompiler.IL;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.TypeSystem;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ICSharpCode.Decompiler.CSharp
{
/// <summary>
/// Translates from ILAst to C# expressions.
/// </summary>
class ExpressionBuilder
{
struct ConvertedExpression(public readonly Expression Expression, public readonly IType Type) { }
public Expression Convert(ILInstruction inst)
{
var expr = TransformExpression(inst).Expression;
expr.AddAnnotation(inst);
return expr;
}
ConvertedExpression ConvertArgument(ILInstruction inst)
{
var cexpr = TransformExpression(inst);
cexpr.Expression.AddAnnotation(inst);
return cexpr;
}
ConvertedExpression TransformExpression(ILInstruction inst)
{
switch (inst.OpCode) {
default:
return ErrorExpression("OpCode not supported: " + inst.OpCode);
}
}
static ConvertedExpression ErrorExpression(string message)
{
var e = new ErrorExpression();
e.AddChild(new Comment(message, CommentType.MultiLine), Roles.Comment);
return new ConvertedExpression(e, SpecialType.UnknownType);
}
}
}

23
ICSharpCode.Decompiler/CSharp/StatementBuilder.cs

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
using ICSharpCode.Decompiler.IL;
using ICSharpCode.NRefactory.CSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ICSharpCode.Decompiler.CSharp
{
class StatementBuilder
{
readonly ExpressionBuilder exprBuilder = new ExpressionBuilder();
public Statement Convert(ILInstruction inst)
{
switch (inst.OpCode) {
default:
return new ExpressionStatement(exprBuilder.Convert(inst));
}
}
}
}

5
ICSharpCode.Decompiler/CecilExtensions.cs

@ -341,5 +341,10 @@ namespace ICSharpCode.Decompiler @@ -341,5 +341,10 @@ namespace ICSharpCode.Decompiler
throw new NotSupportedException(opcode.FlowControl.ToString());
}
}
public static ICSharpCode.NRefactory.TypeSystem.FullTypeName GetFullTypeName(this TypeDefinition typeDef)
{
return new ICSharpCode.NRefactory.TypeSystem.FullTypeName(typeDef.FullName);
}
}
}

14
ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

@ -63,9 +63,11 @@ @@ -63,9 +63,11 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Ast\TypesHierarchyHelpers.cs" />
<Compile Include="CSharp\CSharpDecompiler.cs" />
<Compile Include="CSharp\ExpressionBuilder.cs" />
<Compile Include="CSharp\StatementBuilder.cs" />
<Compile Include="TypesHierarchyHelpers.cs" />
<Compile Include="CecilExtensions.cs" />
<Compile Include="DecompilerSettings.cs" />
<Compile Include="Disassembler\DisassemblerHelpers.cs" />
<Compile Include="Disassembler\ILStructure.cs" />
<Compile Include="Disassembler\MethodBodyDisassembler.cs" />
@ -117,12 +119,16 @@ @@ -117,12 +119,16 @@
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
<Name>Mono.Cecil</Name>
</ProjectReference>
<ProjectReference Include="..\NRefactory\ICSharpCode.NRefactory.Cecil\ICSharpCode.NRefactory.Cecil.csproj">
<Project>{2b8f4f83-c2b3-4e84-a27b-8dee1be0e006}</Project>
<Name>ICSharpCode.NRefactory.Cecil</Name>
</ProjectReference>
<ProjectReference Include="..\NRefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj">
<Project>{53DCA265-3C3C-42F9-B647-F72BA678122B}</Project>
<Project>{53dca265-3c3c-42f9-b647-f72ba678122b}</Project>
<Name>ICSharpCode.NRefactory.CSharp</Name>
</ProjectReference>
<ProjectReference Include="..\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Project>{3b2a5653-ec97-4001-bb9b-d90f1af2c371}</Project>
<Name>ICSharpCode.NRefactory</Name>
</ProjectReference>
</ItemGroup>

8
ICSharpCode.Decompiler/IL/ILReader.cs

@ -119,7 +119,7 @@ namespace ICSharpCode.Decompiler.IL @@ -119,7 +119,7 @@ namespace ICSharpCode.Decompiler.IL
CreateBlocks(instructionInlining).WriteTo(output);
}
BlockContainer CreateBlocks(bool instructionInlining)
internal BlockContainer CreateBlocks(bool instructionInlining)
{
if (instructionBuilder == null)
ReadInstructions(null);
@ -382,9 +382,11 @@ namespace ICSharpCode.Decompiler.IL @@ -382,9 +382,11 @@ namespace ICSharpCode.Decompiler.IL
case ILOpCode.Ldloca_S:
return Ldloca(reader.ReadByte());
case ILOpCode.Leave:
return DecodeUnconditionalBranch(false, OpCode.Leave);
//return DecodeUnconditionalBranch(false, OpCode.Leave);
throw new NotImplementedException();
case ILOpCode.Leave_S:
return DecodeUnconditionalBranch(true, OpCode.Leave);
//return DecodeUnconditionalBranch(true, OpCode.Leave);
throw new NotImplementedException();
case ILOpCode.Localloc:
throw new NotImplementedException();
case ILOpCode.Mul:

13
ICSharpCode.Decompiler/IL/Instructions/OpCode.cs

@ -90,7 +90,6 @@ namespace ICSharpCode.Decompiler.IL @@ -90,7 +90,6 @@ namespace ICSharpCode.Decompiler.IL
/// <see cref="IL.Branch"/>
/// </summary>
Branch,
Leave,
/// <summary>
/// Breakpoint instruction.
/// </summary>
@ -222,9 +221,21 @@ namespace ICSharpCode.Decompiler.IL @@ -222,9 +221,21 @@ namespace ICSharpCode.Decompiler.IL
/// Test if object is instance of class or interface. <see cref="IL.IsInst"/>
/// </summary>
IsInst,
/// <summary>
/// Indirect load (ref/pointer dereference)
/// </summary>
LdInd,
/// <summary>
/// Unbox a value.
/// </summary>
UnboxAny,
/// <summary>
/// Creates an object instance and calls the constructor. <see cref="IL.CallInstruction"/>
/// </summary>
NewObj,
/// <summary>
/// Throws an exception. <see cref="IL.ThrowInstruction"/>
/// </summary>
Throw,
/// <summary>
/// A block of IL instructions. <see cref="IL.Block"/>

0
ICSharpCode.Decompiler/Ast/TypesHierarchyHelpers.cs → ICSharpCode.Decompiler/TypesHierarchyHelpers.cs

102
ILSpy.sln

@ -25,18 +25,22 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestPlugin", "TestPlugin\Te @@ -25,18 +25,22 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestPlugin", "TestPlugin\Te
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil.Pdb", "Mono.Cecil\symbols\pdb\Mono.Cecil.Pdb.csproj", "{63E6915C-7EA4-4D76-AB28-0D7191EEA626}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.VB", "NRefactory\ICSharpCode.NRefactory.VB\ICSharpCode.NRefactory.VB.csproj", "{7B82B671-419F-45F4-B778-D9286F996EFA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy.BamlDecompiler", "ILSpy.BamlDecompiler\ILSpy.BamlDecompiler.csproj", "{A6BAD2BA-76BA-461C-8B6D-418607591247}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy.BamlDecompiler.Tests", "ILSpy.BamlDecompiler\Tests\ILSpy.BamlDecompiler.Tests.csproj", "{1169E6D1-1899-43D4-A500-07CE4235B388}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.CSharp", "NRefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj", "{53DCA265-3C3C-42F9-B647-F72BA678122B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.Cecil", "NRefactory\ICSharpCode.NRefactory.Cecil\ICSharpCode.NRefactory.Cecil.csproj", "{2B8F4F83-C2B3-4E84-A27B-8DEE1BE0E006}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
net_4_5_Debug|Any CPU = net_4_5_Debug|Any CPU
net_4_5_Debug|x86 = net_4_5_Debug|x86
net_4_5_Release|Any CPU = net_4_5_Release|Any CPU
net_4_5_Release|x86 = net_4_5_Release|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
@ -45,6 +49,14 @@ Global @@ -45,6 +49,14 @@ Global
{1E85EFF9-E370-4683-83E4-8A3D063FF791}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E85EFF9-E370-4683-83E4-8A3D063FF791}.Debug|x86.ActiveCfg = Debug|x86
{1E85EFF9-E370-4683-83E4-8A3D063FF791}.Debug|x86.Build.0 = Debug|x86
{1E85EFF9-E370-4683-83E4-8A3D063FF791}.net_4_5_Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1E85EFF9-E370-4683-83E4-8A3D063FF791}.net_4_5_Debug|Any CPU.Build.0 = Debug|Any CPU
{1E85EFF9-E370-4683-83E4-8A3D063FF791}.net_4_5_Debug|x86.ActiveCfg = Debug|x86
{1E85EFF9-E370-4683-83E4-8A3D063FF791}.net_4_5_Debug|x86.Build.0 = Debug|x86
{1E85EFF9-E370-4683-83E4-8A3D063FF791}.net_4_5_Release|Any CPU.ActiveCfg = Release|Any CPU
{1E85EFF9-E370-4683-83E4-8A3D063FF791}.net_4_5_Release|Any CPU.Build.0 = Release|Any CPU
{1E85EFF9-E370-4683-83E4-8A3D063FF791}.net_4_5_Release|x86.ActiveCfg = Release|x86
{1E85EFF9-E370-4683-83E4-8A3D063FF791}.net_4_5_Release|x86.Build.0 = Release|x86
{1E85EFF9-E370-4683-83E4-8A3D063FF791}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E85EFF9-E370-4683-83E4-8A3D063FF791}.Release|Any CPU.Build.0 = Release|Any CPU
{1E85EFF9-E370-4683-83E4-8A3D063FF791}.Release|x86.ActiveCfg = Release|x86
@ -53,6 +65,12 @@ Global @@ -53,6 +65,12 @@ Global
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Debug|x86.ActiveCfg = Debug|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Debug|x86.Build.0 = Debug|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.net_4_5_Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.net_4_5_Debug|Any CPU.Build.0 = Debug|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.net_4_5_Debug|x86.ActiveCfg = Debug|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.net_4_5_Release|Any CPU.ActiveCfg = Release|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.net_4_5_Release|Any CPU.Build.0 = Release|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.net_4_5_Release|x86.ActiveCfg = Release|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Release|Any CPU.Build.0 = Release|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Release|x86.ActiveCfg = Release|Any CPU
@ -61,6 +79,12 @@ Global @@ -61,6 +79,12 @@ Global
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|Any CPU.Build.0 = net_4_0_Debug|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|x86.ActiveCfg = net_4_0_Debug|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|x86.Build.0 = net_4_0_Debug|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_5_Debug|Any CPU.ActiveCfg = net_4_0_Release|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_5_Debug|Any CPU.Build.0 = net_4_0_Release|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_5_Debug|x86.ActiveCfg = net_4_0_Release|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_5_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_5_Release|Any CPU.Build.0 = net_4_0_Release|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_5_Release|x86.ActiveCfg = net_4_0_Release|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|Any CPU.Build.0 = net_4_0_Release|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|x86.ActiveCfg = net_4_0_Release|Any CPU
@ -69,6 +93,12 @@ Global @@ -69,6 +93,12 @@ Global
{984CC812-9470-4A13-AFF9-CC44068D666C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{984CC812-9470-4A13-AFF9-CC44068D666C}.Debug|x86.ActiveCfg = Debug|Any CPU
{984CC812-9470-4A13-AFF9-CC44068D666C}.Debug|x86.Build.0 = Debug|Any CPU
{984CC812-9470-4A13-AFF9-CC44068D666C}.net_4_5_Debug|Any CPU.ActiveCfg = Debug|Any CPU
{984CC812-9470-4A13-AFF9-CC44068D666C}.net_4_5_Debug|Any CPU.Build.0 = Debug|Any CPU
{984CC812-9470-4A13-AFF9-CC44068D666C}.net_4_5_Debug|x86.ActiveCfg = Debug|Any CPU
{984CC812-9470-4A13-AFF9-CC44068D666C}.net_4_5_Release|Any CPU.ActiveCfg = Release|Any CPU
{984CC812-9470-4A13-AFF9-CC44068D666C}.net_4_5_Release|Any CPU.Build.0 = Release|Any CPU
{984CC812-9470-4A13-AFF9-CC44068D666C}.net_4_5_Release|x86.ActiveCfg = Release|Any CPU
{984CC812-9470-4A13-AFF9-CC44068D666C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{984CC812-9470-4A13-AFF9-CC44068D666C}.Release|Any CPU.Build.0 = Release|Any CPU
{984CC812-9470-4A13-AFF9-CC44068D666C}.Release|x86.ActiveCfg = Release|Any CPU
@ -77,6 +107,12 @@ Global @@ -77,6 +107,12 @@ Global
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|x86.ActiveCfg = Debug|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|x86.Build.0 = Debug|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.net_4_5_Debug|Any CPU.ActiveCfg = net_4_5_Debug|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.net_4_5_Debug|Any CPU.Build.0 = net_4_5_Debug|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.net_4_5_Debug|x86.ActiveCfg = net_4_5_Debug|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.net_4_5_Release|Any CPU.ActiveCfg = net_4_5_Release|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.net_4_5_Release|Any CPU.Build.0 = net_4_5_Release|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.net_4_5_Release|x86.ActiveCfg = net_4_5_Release|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|Any CPU.Build.0 = Release|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|x86.ActiveCfg = Release|Any CPU
@ -85,6 +121,14 @@ Global @@ -85,6 +121,14 @@ Global
{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}.Debug|x86.ActiveCfg = Debug|x86
{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}.Debug|x86.Build.0 = Debug|x86
{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}.net_4_5_Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}.net_4_5_Debug|Any CPU.Build.0 = Debug|Any CPU
{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}.net_4_5_Debug|x86.ActiveCfg = Debug|x86
{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}.net_4_5_Debug|x86.Build.0 = Debug|x86
{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}.net_4_5_Release|Any CPU.ActiveCfg = Release|Any CPU
{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}.net_4_5_Release|Any CPU.Build.0 = Release|Any CPU
{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}.net_4_5_Release|x86.ActiveCfg = Release|x86
{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}.net_4_5_Release|x86.Build.0 = Release|x86
{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}.Release|Any CPU.Build.0 = Release|Any CPU
{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}.Release|x86.ActiveCfg = Release|x86
@ -93,6 +137,12 @@ Global @@ -93,6 +137,12 @@ Global
{F32EBCC8-0E53-4421-867E-05B3D6E10C70}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F32EBCC8-0E53-4421-867E-05B3D6E10C70}.Debug|x86.ActiveCfg = Debug|Any CPU
{F32EBCC8-0E53-4421-867E-05B3D6E10C70}.Debug|x86.Build.0 = Debug|Any CPU
{F32EBCC8-0E53-4421-867E-05B3D6E10C70}.net_4_5_Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F32EBCC8-0E53-4421-867E-05B3D6E10C70}.net_4_5_Debug|Any CPU.Build.0 = Debug|Any CPU
{F32EBCC8-0E53-4421-867E-05B3D6E10C70}.net_4_5_Debug|x86.ActiveCfg = Debug|Any CPU
{F32EBCC8-0E53-4421-867E-05B3D6E10C70}.net_4_5_Release|Any CPU.ActiveCfg = Release|Any CPU
{F32EBCC8-0E53-4421-867E-05B3D6E10C70}.net_4_5_Release|Any CPU.Build.0 = Release|Any CPU
{F32EBCC8-0E53-4421-867E-05B3D6E10C70}.net_4_5_Release|x86.ActiveCfg = Release|Any CPU
{F32EBCC8-0E53-4421-867E-05B3D6E10C70}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F32EBCC8-0E53-4421-867E-05B3D6E10C70}.Release|Any CPU.Build.0 = Release|Any CPU
{F32EBCC8-0E53-4421-867E-05B3D6E10C70}.Release|x86.ActiveCfg = Release|Any CPU
@ -101,22 +151,28 @@ Global @@ -101,22 +151,28 @@ Global
{63E6915C-7EA4-4D76-AB28-0D7191EEA626}.Debug|Any CPU.Build.0 = net_4_0_Debug|Any CPU
{63E6915C-7EA4-4D76-AB28-0D7191EEA626}.Debug|x86.ActiveCfg = net_4_0_Debug|Any CPU
{63E6915C-7EA4-4D76-AB28-0D7191EEA626}.Debug|x86.Build.0 = net_4_0_Debug|Any CPU
{63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_4_5_Debug|Any CPU.ActiveCfg = net_4_0_Release|Any CPU
{63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_4_5_Debug|Any CPU.Build.0 = net_4_0_Release|Any CPU
{63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_4_5_Debug|x86.ActiveCfg = net_4_0_Release|Any CPU
{63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_4_5_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU
{63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_4_5_Release|Any CPU.Build.0 = net_4_0_Release|Any CPU
{63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_4_5_Release|x86.ActiveCfg = net_4_0_Release|Any CPU
{63E6915C-7EA4-4D76-AB28-0D7191EEA626}.Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU
{63E6915C-7EA4-4D76-AB28-0D7191EEA626}.Release|Any CPU.Build.0 = net_4_0_Release|Any CPU
{63E6915C-7EA4-4D76-AB28-0D7191EEA626}.Release|x86.ActiveCfg = net_4_0_Release|Any CPU
{63E6915C-7EA4-4D76-AB28-0D7191EEA626}.Release|x86.Build.0 = net_4_0_Release|Any CPU
{7B82B671-419F-45F4-B778-D9286F996EFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7B82B671-419F-45F4-B778-D9286F996EFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B82B671-419F-45F4-B778-D9286F996EFA}.Debug|x86.ActiveCfg = Debug|Any CPU
{7B82B671-419F-45F4-B778-D9286F996EFA}.Debug|x86.Build.0 = Debug|Any CPU
{7B82B671-419F-45F4-B778-D9286F996EFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B82B671-419F-45F4-B778-D9286F996EFA}.Release|Any CPU.Build.0 = Release|Any CPU
{7B82B671-419F-45F4-B778-D9286F996EFA}.Release|x86.ActiveCfg = Release|Any CPU
{7B82B671-419F-45F4-B778-D9286F996EFA}.Release|x86.Build.0 = Release|Any CPU
{A6BAD2BA-76BA-461C-8B6D-418607591247}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A6BAD2BA-76BA-461C-8B6D-418607591247}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A6BAD2BA-76BA-461C-8B6D-418607591247}.Debug|x86.ActiveCfg = Debug|x86
{A6BAD2BA-76BA-461C-8B6D-418607591247}.Debug|x86.Build.0 = Debug|x86
{A6BAD2BA-76BA-461C-8B6D-418607591247}.net_4_5_Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A6BAD2BA-76BA-461C-8B6D-418607591247}.net_4_5_Debug|Any CPU.Build.0 = Debug|Any CPU
{A6BAD2BA-76BA-461C-8B6D-418607591247}.net_4_5_Debug|x86.ActiveCfg = Debug|x86
{A6BAD2BA-76BA-461C-8B6D-418607591247}.net_4_5_Debug|x86.Build.0 = Debug|x86
{A6BAD2BA-76BA-461C-8B6D-418607591247}.net_4_5_Release|Any CPU.ActiveCfg = Release|Any CPU
{A6BAD2BA-76BA-461C-8B6D-418607591247}.net_4_5_Release|Any CPU.Build.0 = Release|Any CPU
{A6BAD2BA-76BA-461C-8B6D-418607591247}.net_4_5_Release|x86.ActiveCfg = Release|x86
{A6BAD2BA-76BA-461C-8B6D-418607591247}.net_4_5_Release|x86.Build.0 = Release|x86
{A6BAD2BA-76BA-461C-8B6D-418607591247}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A6BAD2BA-76BA-461C-8B6D-418607591247}.Release|Any CPU.Build.0 = Release|Any CPU
{A6BAD2BA-76BA-461C-8B6D-418607591247}.Release|x86.ActiveCfg = Release|x86
@ -125,6 +181,14 @@ Global @@ -125,6 +181,14 @@ Global
{1169E6D1-1899-43D4-A500-07CE4235B388}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1169E6D1-1899-43D4-A500-07CE4235B388}.Debug|x86.ActiveCfg = Debug|x86
{1169E6D1-1899-43D4-A500-07CE4235B388}.Debug|x86.Build.0 = Debug|x86
{1169E6D1-1899-43D4-A500-07CE4235B388}.net_4_5_Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1169E6D1-1899-43D4-A500-07CE4235B388}.net_4_5_Debug|Any CPU.Build.0 = Debug|Any CPU
{1169E6D1-1899-43D4-A500-07CE4235B388}.net_4_5_Debug|x86.ActiveCfg = Debug|x86
{1169E6D1-1899-43D4-A500-07CE4235B388}.net_4_5_Debug|x86.Build.0 = Debug|x86
{1169E6D1-1899-43D4-A500-07CE4235B388}.net_4_5_Release|Any CPU.ActiveCfg = Release|Any CPU
{1169E6D1-1899-43D4-A500-07CE4235B388}.net_4_5_Release|Any CPU.Build.0 = Release|Any CPU
{1169E6D1-1899-43D4-A500-07CE4235B388}.net_4_5_Release|x86.ActiveCfg = Release|x86
{1169E6D1-1899-43D4-A500-07CE4235B388}.net_4_5_Release|x86.Build.0 = Release|x86
{1169E6D1-1899-43D4-A500-07CE4235B388}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1169E6D1-1899-43D4-A500-07CE4235B388}.Release|Any CPU.Build.0 = Release|Any CPU
{1169E6D1-1899-43D4-A500-07CE4235B388}.Release|x86.ActiveCfg = Release|x86
@ -133,10 +197,28 @@ Global @@ -133,10 +197,28 @@ Global
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Debug|x86.ActiveCfg = Debug|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Debug|x86.Build.0 = Debug|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.net_4_5_Debug|Any CPU.ActiveCfg = net_4_5_Debug|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.net_4_5_Debug|Any CPU.Build.0 = net_4_5_Debug|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.net_4_5_Debug|x86.ActiveCfg = net_4_5_Debug|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.net_4_5_Release|Any CPU.ActiveCfg = net_4_5_Release|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.net_4_5_Release|Any CPU.Build.0 = net_4_5_Release|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.net_4_5_Release|x86.ActiveCfg = net_4_5_Release|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Release|Any CPU.Build.0 = Release|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Release|x86.ActiveCfg = Release|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Release|x86.Build.0 = Release|Any CPU
{2B8F4F83-C2B3-4E84-A27B-8DEE1BE0E006}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2B8F4F83-C2B3-4E84-A27B-8DEE1BE0E006}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2B8F4F83-C2B3-4E84-A27B-8DEE1BE0E006}.Debug|x86.ActiveCfg = Debug|Any CPU
{2B8F4F83-C2B3-4E84-A27B-8DEE1BE0E006}.net_4_5_Debug|Any CPU.ActiveCfg = net_4_5_Debug|Any CPU
{2B8F4F83-C2B3-4E84-A27B-8DEE1BE0E006}.net_4_5_Debug|Any CPU.Build.0 = net_4_5_Debug|Any CPU
{2B8F4F83-C2B3-4E84-A27B-8DEE1BE0E006}.net_4_5_Debug|x86.ActiveCfg = net_4_5_Debug|Any CPU
{2B8F4F83-C2B3-4E84-A27B-8DEE1BE0E006}.net_4_5_Release|Any CPU.ActiveCfg = net_4_5_Release|Any CPU
{2B8F4F83-C2B3-4E84-A27B-8DEE1BE0E006}.net_4_5_Release|Any CPU.Build.0 = net_4_5_Release|Any CPU
{2B8F4F83-C2B3-4E84-A27B-8DEE1BE0E006}.net_4_5_Release|x86.ActiveCfg = net_4_5_Release|Any CPU
{2B8F4F83-C2B3-4E84-A27B-8DEE1BE0E006}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2B8F4F83-C2B3-4E84-A27B-8DEE1BE0E006}.Release|Any CPU.Build.0 = Release|Any CPU
{2B8F4F83-C2B3-4E84-A27B-8DEE1BE0E006}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

5
ILSpy/ILSpy.csproj

@ -151,15 +151,15 @@ @@ -151,15 +151,15 @@
<Compile Include="GuessFileType.cs" />
<Compile Include="ContextMenuEntry.cs" />
<Compile Include="Languages\ILAstLanguage.cs" />
<Compile Include="Languages\ILLanguage.cs" />
<Compile Include="ILSpySettings.cs" />
<Compile Include="Images\AccessOverlayIcon.cs" />
<Compile Include="Images\MemberIcon.cs" />
<Compile Include="Images\TypeIcon.cs" />
<Compile Include="IPane.cs" />
<Compile Include="ISmartTextOutput.cs" />
<Compile Include="Languages\Language.cs" />
<Compile Include="Images\Images.cs" />
<Compile Include="Languages\ILLanguage.cs" />
<Compile Include="Languages\Language.cs" />
<Compile Include="Languages\Languages.cs" />
<Compile Include="LoadedAssembly.cs" />
<Compile Include="NativeMethods.cs" />
@ -178,6 +178,7 @@ @@ -178,6 +178,7 @@
<Compile Include="OpenListDialog.xaml.cs">
<DependentUpon>OpenListDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Options\DecompilerSettings.cs" />
<Compile Include="Options\DecompilerSettingsPanel.xaml.cs">
<DependentUpon>DecompilerSettingsPanel.xaml</DependentUpon>
<SubType>Code</SubType>

42
ILSpy/Languages/CSharpLanguage.cs

@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*
using System;
using System.Collections;
using System.Collections.Generic;
@ -28,11 +28,11 @@ using System.Threading.Tasks; @@ -28,11 +28,11 @@ using System.Threading.Tasks;
using System.Xml;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Ast.Transforms;
using ICSharpCode.ILSpy.Options;
using ICSharpCode.ILSpy.XmlDoc;
using ICSharpCode.NRefactory.CSharp;
using Mono.Cecil;
using ICSharpCode.Decompiler.CSharp;
namespace ICSharpCode.ILSpy
{
@ -44,13 +44,14 @@ namespace ICSharpCode.ILSpy @@ -44,13 +44,14 @@ namespace ICSharpCode.ILSpy
{
string name = "C#";
bool showAllMembers = false;
Predicate<IAstTransform> transformAbortCondition = null;
//Predicate<IAstTransform> transformAbortCondition = null;
public CSharpLanguage()
{
}
#if DEBUG
/*
internal static IEnumerable<CSharpLanguage> GetDebugLanguages()
{
DecompilerContext context = new DecompilerContext(ModuleDefinition.CreateModule("dummy", ModuleKind.Dll));
@ -69,6 +70,7 @@ namespace ICSharpCode.ILSpy @@ -69,6 +70,7 @@ namespace ICSharpCode.ILSpy
showAllMembers = true
};
}
*/
#endif
public override string Name
@ -89,6 +91,9 @@ namespace ICSharpCode.ILSpy @@ -89,6 +91,9 @@ namespace ICSharpCode.ILSpy
public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options)
{
WriteCommentLine(output, TypeToString(method.DeclaringType, includeNamespace: true));
CSharpDecompiler decompiler = new CSharpDecompiler(method.Module);
output.WriteLine(decompiler.Decompile(method).ToString());
/*
AstBuilder codeDomBuilder = CreateAstBuilder(options, currentType: method.DeclaringType, isSingleMember: true);
if (method.IsConstructor && !method.IsStatic && !method.DeclaringType.IsValueType) {
// also fields and other ctors so that the field initializers can be shown as such
@ -97,9 +102,10 @@ namespace ICSharpCode.ILSpy @@ -97,9 +102,10 @@ namespace ICSharpCode.ILSpy
} else {
codeDomBuilder.AddMethod(method);
RunTransformsAndGenerateCode(codeDomBuilder, output, options);
}
}*/
}
/*
class SelectCtorTransform : IAstTransform
{
readonly MethodDefinition ctorDef;
@ -135,7 +141,9 @@ namespace ICSharpCode.ILSpy @@ -135,7 +141,9 @@ namespace ICSharpCode.ILSpy
}
}
}
*/
/*
public override void DecompileProperty(PropertyDefinition property, ITextOutput output, DecompilationOptions options)
{
WriteCommentLine(output, TypeToString(property.DeclaringType, includeNamespace: true));
@ -217,7 +225,7 @@ namespace ICSharpCode.ILSpy @@ -217,7 +225,7 @@ namespace ICSharpCode.ILSpy
AddXmlDocTransform.Run(astBuilder.SyntaxTree);
}
astBuilder.GenerateCode(output);
}
}*/
public static string GetPlatformDisplayName(ModuleDefinition module)
{
@ -256,7 +264,7 @@ namespace ICSharpCode.ILSpy @@ -256,7 +264,7 @@ namespace ICSharpCode.ILSpy
return module.Architecture.ToString();
}
}
/*
public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
{
if (options.FullDecompilation && options.SaveAsProjectDirectory != null) {
@ -299,10 +307,10 @@ namespace ICSharpCode.ILSpy @@ -299,10 +307,10 @@ namespace ICSharpCode.ILSpy
codeDomBuilder.AddAssembly(assembly.ModuleDefinition, onlyAssemblyLevel: !options.FullDecompilation);
codeDomBuilder.RunTransformations(transformAbortCondition);
codeDomBuilder.GenerateCode(output);
}
}
}
}
}
*/
#region WriteProjectFile
void WriteProjectFile(TextWriter writer, IEnumerable<Tuple<string, string>> files, ModuleDefinition module)
{
@ -428,6 +436,7 @@ namespace ICSharpCode.ILSpy @@ -428,6 +436,7 @@ namespace ICSharpCode.ILSpy
#endregion
#region WriteCodeFilesInProject
/*
bool IncludeTypeWhenDecompilingProject(TypeDefinition type, DecompilationOptions options)
{
if (type.Name == "<Module>" || AstBuilder.MemberIsHidden(type, options.DecompilerSettings))
@ -486,7 +495,7 @@ namespace ICSharpCode.ILSpy @@ -486,7 +495,7 @@ namespace ICSharpCode.ILSpy
});
AstMethodBodyBuilder.PrintNumberOfUnhandledOpcodes();
return files.Select(f => Tuple.Create("Compile", f.Key)).Concat(WriteAssemblyInfo(module, options, directories));
}
}*/
#endregion
#region WriteResourceFilesInProject
@ -566,7 +575,7 @@ namespace ICSharpCode.ILSpy @@ -566,7 +575,7 @@ namespace ICSharpCode.ILSpy
return fileName;
}
#endregion
/*
AstBuilder CreateAstBuilder(DecompilationOptions options, ModuleDefinition currentModule = null, TypeDefinition currentType = null, bool isSingleMember = false)
{
if (currentModule == null)
@ -612,7 +621,7 @@ namespace ICSharpCode.ILSpy @@ -612,7 +621,7 @@ namespace ICSharpCode.ILSpy
astType.AcceptVisitor(new CSharpOutputVisitor(w, FormattingOptionsFactory.CreateAllman()));
return w.ToString();
}
*/
public override string FormatPropertyName(PropertyDefinition property, bool? isIndexer)
{
if (property == null)
@ -643,7 +652,7 @@ namespace ICSharpCode.ILSpy @@ -643,7 +652,7 @@ namespace ICSharpCode.ILSpy
} else
return property.Name;
}
/*
public override string FormatTypeName(TypeDefinition type)
{
if (type == null)
@ -656,7 +665,7 @@ namespace ICSharpCode.ILSpy @@ -656,7 +665,7 @@ namespace ICSharpCode.ILSpy
{
return showAllMembers || !AstBuilder.MemberIsHidden(member, new DecompilationOptions().DecompilerSettings);
}
*/
public override MemberReference GetOriginalCodeLocation(MemberReference member)
{
if (showAllMembers || !DecompilerSettingsPanel.CurrentDecompilerSettings.AnonymousMethods)
@ -672,7 +681,7 @@ namespace ICSharpCode.ILSpy @@ -672,7 +681,7 @@ namespace ICSharpCode.ILSpy
EventDefinition ed = member as EventDefinition;
FieldDefinition fd = member as FieldDefinition;
if (md != null || pd != null || ed != null || fd != null) {
AstBuilder b = new AstBuilder(new DecompilerContext(member.Module) { Settings = new DecompilerSettings { UsingDeclarations = false } });
/*AstBuilder b = new AstBuilder(new DecompilerContext(member.Module) { Settings = new DecompilerSettings { UsingDeclarations = false } });
b.DecompileMethodBodies = false;
if (md != null)
b.AddMethod(md);
@ -688,11 +697,10 @@ namespace ICSharpCode.ILSpy @@ -688,11 +697,10 @@ namespace ICSharpCode.ILSpy
StringWriter w = new StringWriter();
b.GenerateCode(new PlainTextOutput(w));
return Regex.Replace(w.ToString(), @"\s+", " ").TrimEnd();
return Regex.Replace(w.ToString(), @"\s+", " ").TrimEnd();*/
}
return base.GetTooltip(member);
}
}
}
*/

2
ICSharpCode.Decompiler/DecompilerSettings.cs → ILSpy/Options/DecompilerSettings.cs

@ -20,7 +20,7 @@ using System; @@ -20,7 +20,7 @@ using System;
using System.ComponentModel;
using ICSharpCode.NRefactory.CSharp;
namespace ICSharpCode.Decompiler
namespace ICSharpCode.ILSpy.Options
{
/// <summary>
/// Settings for the decompiler.

21
NRefactory/ICSharpCode.NRefactory.CSharp/Ast/DepthFirstAstVisitor.cs

@ -51,7 +51,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -51,7 +51,7 @@ namespace ICSharpCode.NRefactory.CSharp
// Older NR versions (before VisitNullNode was introduced) didn't call VisitChildren() with null nodes;
// so changing this might break VisitChildren() overrides that expect the node to be part of the AST.
}
public virtual void VisitSyntaxTree (SyntaxTree syntaxTree)
{
VisitChildren (syntaxTree);
@ -622,6 +622,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -622,6 +622,11 @@ namespace ICSharpCode.NRefactory.CSharp
VisitChildren (namedExpression);
}
public virtual void VisitErrorNode(AstNode errorNode)
{
VisitChildren(errorNode);
}
public virtual void VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern)
{
VisitChildren (placeholder);
@ -1223,7 +1228,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1223,7 +1228,12 @@ namespace ICSharpCode.NRefactory.CSharp
{
return VisitChildren (namedExpression);
}
public virtual T VisitErrorNode(AstNode errorNode)
{
return VisitChildren(errorNode);
}
public virtual T VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern)
{
return VisitChildren (placeholder);
@ -1825,7 +1835,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1825,7 +1835,12 @@ namespace ICSharpCode.NRefactory.CSharp
{
return VisitChildren (namedExpression, data);
}
public virtual S VisitErrorNode(AstNode errorNode, T data)
{
return VisitChildren(errorNode, data);
}
public virtual S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern, T data)
{
return VisitChildren (placeholder, data);

20
NRefactory/ICSharpCode.NRefactory.CSharp/Ast/ErrorNode.cs

@ -57,22 +57,22 @@ namespace ICSharpCode.NRefactory.CSharp @@ -57,22 +57,22 @@ namespace ICSharpCode.NRefactory.CSharp
public ErrorNode ()
{
}
public override void AcceptVisitor (IAstVisitor visitor)
public override void AcceptVisitor(IAstVisitor visitor)
{
visitor.VisitErrorNode(this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
return default (T);
return visitor.VisitErrorNode(this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
// nothing
return default (S);
return visitor.VisitErrorNode(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
var o = other as ErrorNode;

12
NRefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ErrorExpression.cs

@ -106,21 +106,19 @@ namespace ICSharpCode.NRefactory.CSharp @@ -106,21 +106,19 @@ namespace ICSharpCode.NRefactory.CSharp
public override void AcceptVisitor (IAstVisitor visitor)
{
// nothing
visitor.VisitErrorNode(this);
}
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
{
// nothing
return default (T);
return visitor.VisitErrorNode(this);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
// nothing
return default(S);
return visitor.VisitErrorNode(this, data);
}
protected internal override bool DoMatch (AstNode other, PatternMatching.Match match)
{
var o = other as ErrorExpression;

3
NRefactory/ICSharpCode.NRefactory.CSharp/Ast/IAstVisitor.cs

@ -148,6 +148,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -148,6 +148,7 @@ namespace ICSharpCode.NRefactory.CSharp
void VisitIdentifier(Identifier identifier);
void VisitNullNode(AstNode nullNode);
void VisitErrorNode(AstNode errorNode);
void VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern);
}
@ -279,6 +280,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -279,6 +280,7 @@ namespace ICSharpCode.NRefactory.CSharp
S VisitIdentifier(Identifier identifier);
S VisitNullNode(AstNode nullNode);
S VisitErrorNode(AstNode errorNode);
S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern);
}
@ -410,6 +412,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -410,6 +412,7 @@ namespace ICSharpCode.NRefactory.CSharp
S VisitIdentifier(Identifier identifier, T data);
S VisitNullNode(AstNode nullNode, T data);
S VisitErrorNode(AstNode errorNode, T data);
S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern, T data);
}
}

8
NRefactory/ICSharpCode.NRefactory.CSharp/Ast/ObservableAstVisitor.cs

@ -48,7 +48,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -48,7 +48,11 @@ namespace ICSharpCode.NRefactory.CSharp
void IAstVisitor.VisitNullNode(AstNode nullNode)
{
}
void IAstVisitor.VisitErrorNode(AstNode nullNode)
{
}
public event Action<SyntaxTree> EnterSyntaxTree, LeaveSyntaxTree;
void IAstVisitor.VisitSyntaxTree(SyntaxTree unit)
@ -614,7 +618,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -614,7 +618,7 @@ namespace ICSharpCode.NRefactory.CSharp
{
Visit(EnterDirectionExpression, LeaveDirectionExpression, directionExpression);
}
public event Action<MemberReferenceExpression> EnterMemberReferenceExpression, LeaveMemberReferenceExpression;
void IAstVisitor.VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression)

8
NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs

@ -2223,8 +2223,14 @@ namespace ICSharpCode.NRefactory.CSharp @@ -2223,8 +2223,14 @@ namespace ICSharpCode.NRefactory.CSharp
void IAstVisitor.VisitNullNode(AstNode nullNode)
{
}
void IAstVisitor.VisitErrorNode(AstNode errorNode)
{
StartNode(errorNode);
EndNode(errorNode);
}
#endregion
#region Pattern Nodes
public void VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern)
{

7
NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs

@ -218,7 +218,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -218,7 +218,12 @@ namespace ICSharpCode.NRefactory.CSharp
{
return null;
}
CodeObject IAstVisitor<CodeObject>.VisitErrorNode(AstNode errorNode)
{
return null;
}
CodeObject IAstVisitor<CodeObject>.VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression)
{
return MakeSnippetExpression(anonymousMethodExpression);

7
NRefactory/ICSharpCode.NRefactory.CSharp/Resolver/ResolveVisitor.cs

@ -3960,7 +3960,12 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -3960,7 +3960,12 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
{
return null;
}
ResolveResult IAstVisitor<ResolveResult>.VisitErrorNode(AstNode errorNode)
{
return null;
}
ResolveResult IAstVisitor<ResolveResult>.VisitPatternPlaceholder(AstNode placeholder, ICSharpCode.NRefactory.PatternMatching.Pattern pattern)
{
return null;

7
NRefactory/ICSharpCode.NRefactory.Cecil/CecilLoader.cs

@ -32,6 +32,8 @@ using Mono.Cecil; @@ -32,6 +32,8 @@ using Mono.Cecil;
namespace ICSharpCode.NRefactory.TypeSystem
{
using BlobReader = ICSharpCode.NRefactory.TypeSystem.Implementation.BlobReader;
/// <summary>
/// Allows loading an IProjectContent from an already compiled assembly.
/// </summary>
@ -64,7 +66,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -64,7 +66,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// If you access the Cecil objects directly in your application, you may need to take the same lock.
/// </remarks>
public bool LazyLoad { get; set; }
/// <summary>
/// This delegate gets executed whenever an entity was loaded.
/// </summary>
@ -74,6 +76,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -74,6 +76,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Warning: if delay-loading is used and the type system is accessed by multiple threads,
/// the callback may be invoked concurrently on multiple threads.
/// </remarks>
[CLSCompliant(false)]
public Action<IUnresolvedEntity, MemberReference> OnEntityLoaded { get; set; }
/// <summary>
@ -424,7 +427,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -424,7 +427,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
return false;
}
#endregion
#region Read Attributes
#region Assembly Attributes
static readonly ITypeReference assemblyVersionAttributeTypeRef = typeof(System.Reflection.AssemblyVersionAttribute).ToTypeReference();

2
NRefactory/ICSharpCode.NRefactory.Cecil/ICSharpCode.NRefactory.Cecil.csproj

@ -91,7 +91,7 @@ @@ -91,7 +91,7 @@
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>
</ProjectReference>
<ProjectReference Include="..\..\cecil\Mono.Cecil.csproj">
<ProjectReference Include="..\..\Mono.Cecil\Mono.Cecil.csproj">
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
<Name>Mono.Cecil</Name>
</ProjectReference>

Loading…
Cancel
Save