Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/icsharpcode/ILSpy into ic…
Browse files Browse the repository at this point in the history
…ons-refresh
  • Loading branch information
siegfriedpammer committed Sep 20, 2019
2 parents dbb34ac + 9398328 commit ccd8311
Show file tree
Hide file tree
Showing 36 changed files with 315 additions and 282 deletions.
2 changes: 1 addition & 1 deletion DecompilerNuGetDemos.workbook
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ platforms:
- DotNetCore
packages:
- id: ICSharpCode.Decompiler
version: 5.0.0.5066-preview4
version: 5.0.0.5124
---

Setup: load the references required to work with the decompiler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<PackAsTool>true</PackAsTool>
<AssemblyName>ilspycmd</AssemblyName>
<ToolCommandName>ilspycmd</ToolCommandName>
<Version>5.0.0-preview4</Version>
<Version>5.0.0.5124</Version>
<Description>Command-line decompiler using the ILSpy decompilation engine</Description>
<Copyright>Copyright 2011-2019 AlphaSierraPapa</Copyright>
<PackageProjectUrl>https://github.com/icsharpcode/ILSpy/</PackageProjectUrl>
Expand All @@ -28,7 +28,7 @@

<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.3.2" />
<PackageReference Include="ICSharpCode.Decompiler" Version="5.0.0.5066-preview4" />
<PackageReference Include="ICSharpCode.Decompiler" Version="5.0.0.5124" />

<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
<PackageReference Include="System.Runtime.Handles" Version="4.3.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0" />
<PackageReference Include="ICSharpCode.Decompiler" Version="5.0.0.5066-preview4" />
<PackageReference Include="ICSharpCode.Decompiler" Version="5.0.0.5124" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ public void Issue1325()
Run();
}

[Test]
public void Issue1681()
{
Run();
}

[Test]
public void Issue1454()
{
Expand Down
4 changes: 3 additions & 1 deletion ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ public void VariableNaming([ValueSource(nameof(defaultOptions))] CompilerOptions
[Test]
public void VariableNamingWithoutSymbols([ValueSource(nameof(defaultOptions))] CompilerOptions cscOptions)
{
RunForLibrary(cscOptions: cscOptions, decompilerSettings: new DecompilerSettings { UseDebugSymbols = false });
var settings = Tester.GetSettings(cscOptions);
settings.UseDebugSymbols = false;
RunForLibrary(cscOptions: cscOptions, decompilerSettings: settings);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ private static object GetObject()

private static void UnusedResultOfIsinst()
{
bool flag = GetObject() is TypeCode;
_ = (GetObject() is TypeCode);
}

private static bool BoolResultOfIsinst()
Expand Down
15 changes: 15 additions & 0 deletions ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue1681.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace ICSharpCode.Decompiler.Tests.TestCases.ILPretty
{
internal class BaseClass
{
public int importsClausePosition;
}

internal class Issue1681 : BaseClass
{
public void Test()
{
_ = importsClausePosition;
}
}
}
42 changes: 42 additions & 0 deletions ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue1681.il
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly ConsoleApp11
{
.ver 1:0:0:0
}
.module ConsoleApp11.exe
// MVID: {B973FCD6-A9C4-48A9-8291-26DDC248E208}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00020003 // ILONLY 32BITPREFERRED
// Image base: 0x000001C4B6C90000

.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.BaseClass
extends [mscorlib]System.Object
{

.field public int32 importsClausePosition

}

.class private auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.Issue1681
extends ICSharpCode.Decompiler.Tests.TestCases.ILPretty.BaseClass
{

.method public hidebysig instance void Test() cil managed
{
// Code size 18 (0x12)
.maxstack 8
ldarg.0
ldfld int32 class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.BaseClass::importsClausePosition
pop
ret
} // end of method Issue1681::Test

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@ private class C

private void Test(string text, C c)
{
#if ROSLYN
_ = c.Name;
#else
string name = c.Name;
#endif
}

private void Test2(string text, C c)
{
#if ROSLYN
_ = c.Text;
#else
string text2 = c.Text;
#endif
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@ private class C

private void Test(string text, C c)
{
#if ROSLYN
_ = c.Name;
#else
string name = c.Name;
#endif
}

private void Test2(string text, C c)
{
#if ROSLYN
_ = c.Text;
#else
string text2 = c.Text;
#endif
}
}
}
2 changes: 2 additions & 0 deletions ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,8 @@ enum EnumValueDisplayMode

EnumValueDisplayMode DetectBestEnumValueDisplayMode(ITypeDefinition typeDef, PEFile module)
{
if (settings.AlwaysShowEnumMemberValues)
return EnumValueDisplayMode.All;
if (typeDef.HasAttribute(KnownAttribute.Flags, inherit: false))
return EnumValueDisplayMode.All;
bool first = true;
Expand Down
5 changes: 5 additions & 0 deletions ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ internal ExpressionWithResolveResult ConvertVariable(ILVariable variable)
}

internal bool HidesVariableWithName(string name)
{
return HidesVariableWithName(currentFunction, name);
}

internal static bool HidesVariableWithName(ILFunction currentFunction, string name)
{
return currentFunction.Ancestors.OfType<ILFunction>().Any(HidesVariableOrNestedFunction);

Expand Down
27 changes: 17 additions & 10 deletions ICSharpCode.Decompiler/CSharp/Transforms/DeclareVariables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,23 @@ void EnsureExpressionStatementsAreValid(AstNode rootNode)
if (!IsValidInStatementExpression(stmt.Expression)) {
// fetch ILFunction
var function = stmt.Ancestors.SelectMany(a => a.Annotations.OfType<ILFunction>()).First(f => f.Parent == null);
// assign result to dummy variable
var type = stmt.Expression.GetResolveResult().Type;
var v = function.RegisterVariable(
VariableKind.StackSlot,
type,
AssignVariableNames.GenerateVariableName(function, type, stmt.Expression.Annotations.OfType<ILInstruction>().Where(AssignVariableNames.IsSupportedInstruction).FirstOrDefault())
);
stmt.Expression = new AssignmentExpression(
new IdentifierExpression(v.Name).WithRR(new ILVariableResolveResult(v, v.Type)),
stmt.Expression.Detach());
// if possible use C# 7.0 discard-assignment
if (context.Settings.Discards && !ExpressionBuilder.HidesVariableWithName(function, "_")) {
stmt.Expression = new AssignmentExpression(
new IdentifierExpression("_"), // no ResolveResult
stmt.Expression.Detach());
} else {
// assign result to dummy variable
var type = stmt.Expression.GetResolveResult().Type;
var v = function.RegisterVariable(
VariableKind.StackSlot,
type,
AssignVariableNames.GenerateVariableName(function, type, stmt.Expression.Annotations.OfType<ILInstruction>().Where(AssignVariableNames.IsSupportedInstruction).FirstOrDefault())
);
stmt.Expression = new AssignmentExpression(
new IdentifierExpression(v.Name).WithRR(new ILVariableResolveResult(v, v.Type)),
stmt.Expression.Detach());
}
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions ICSharpCode.Decompiler/DecompilerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,26 @@ public bool AlwaysCastTargetsOfExplicitInterfaceImplementationCalls {
}
}

bool alwaysShowEnumMemberValues = false;

/// <summary>
/// Gets/Sets whether to always show enum member values.
/// true: <c>enum Kind { A = 0, B = 1, C = 5 }</c>
/// false: <c>enum Kind { A, B, C = 5 }</c>
/// default: false
/// </summary>
[Category("Other")]
[Description("DecompilerSettings.AlwaysShowEnumMemberValues")]
public bool AlwaysShowEnumMemberValues {
get { return alwaysShowEnumMemberValues; }
set {
if (alwaysShowEnumMemberValues != value) {
alwaysShowEnumMemberValues = value;
OnPropertyChanged();
}
}
}

bool useDebugSymbols = true;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ static Dictionary<string, int> CollectReservedVariableNames(ILFunction function,
AddExistingName(reservedVariableNames, v.Name);
}
}
foreach (var f in rootFunction.Method.DeclaringTypeDefinition.Fields.Select(f => f.Name))
foreach (var f in rootFunction.Method.DeclaringTypeDefinition.GetFields().Select(f => f.Name))
AddExistingName(reservedVariableNames, f);
return reservedVariableNames;
}
Expand Down
2 changes: 2 additions & 0 deletions ILSpy.AddIn/Commands/OpenReferenceCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ protected override void OnExecute(object sender, EventArgs e)
OpenAssembliesInILSpy(parameters);
else
owner.ShowMessage("Could not find reference '{0}', please ensure the project and all references were built correctly!", reference.Name);
return;
}

// Handle NuGet references
var nugetRefItem = NuGetReferenceForILSpy.Detect(itemObject);
if (nugetRefItem != null) {
OpenAssembliesInILSpy(nugetRefItem.GetILSpyParameters());
return;
}

// Handle project references
Expand Down
16 changes: 0 additions & 16 deletions ILSpy.Package/ILSpy.Package.wapproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,6 @@
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|AnyCPU">
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
Expand Down
Binary file modified ILSpy.Package/Images/StoreLogo.backup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ILSpy.Package/Package-CI.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<Properties>
<DisplayName>ILSpy (CI)</DisplayName>
<PublisherDisplayName>ICSharpCode</PublisherDisplayName>
<PublisherDisplayName>CN=ICSharpCode Team</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>

Expand Down
2 changes: 1 addition & 1 deletion ILSpy.Package/Package-Local.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<Properties>
<DisplayName>ILSpy (Local)</DisplayName>
<PublisherDisplayName>ICSharpCode</PublisherDisplayName>
<PublisherDisplayName>CN=ICSharpCode Team</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>

Expand Down
6 changes: 3 additions & 3 deletions ILSpy.Package/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
IgnorableNamespaces="uap rescap">

<Identity
Name="ICSharpCode.ILSpy"
Publisher="CN=ICSharpCode"
Name="17310ICSharpCodeTeam.ILSpy"
Publisher="CN=2A240D0E-77E6-4732-9B57-AD934336A43E"
Version="$INSERTMAJORVERSION$.$INSERTMINORVERSION$.$INSERTREVISION$.0" />

<Properties>
<DisplayName>ILSpy</DisplayName>
<PublisherDisplayName>ICSharpCode</PublisherDisplayName>
<PublisherDisplayName>ICSharpCode Team</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>

Expand Down
Loading

0 comments on commit ccd8311

Please sign in to comment.