Skip to content
Permalink
Browse files

Merge branch 'master' of https://github.com/icsharpcode/ILSpy into fi…

…xed-buffers
  • Loading branch information...
siegfriedpammer committed May 5, 2019
2 parents 2e00285 + 1f0bb19 commit 59e57b67c85b9b3f5919ad57e6b08641326bebbb
Showing with 3,862 additions and 277 deletions.
  1. +1 −1 BuildTools/tidy.py
  2. +7 −7 ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs
  3. +1 −0 ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs
  4. +16 −0 ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
  5. +9 −1 ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstantsTests.cs
  6. +3 −0 ICSharpCode.Decompiler.Tests/TestCases/Pretty/RefLocalsAndReturns.cs
  7. +19 −3 ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
  8. +3 −0 ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs
  9. +58 −58 ICSharpCode.Decompiler/DecompilerSettings.cs
  10. +2 −2 ILSpy.AddIn/Utils.cs
  11. +53 −0 ILSpy.BamlDecompiler/Handlers/Records/StaticResourceIdHandler.cs
  12. +52 −0 ILSpy.BamlDecompiler/Handlers/Records/StaticResourceStartHandler.cs
  13. +2 −0 ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj
  14. +2 −2 ILSpy.sln
  15. +10 −9 ILSpy/AboutPage.cs
  16. +2 −1 ILSpy/Analyzers/AnalyzeCommand.cs
  17. +2 −2 ILSpy/Analyzers/Builtin/MethodOverriddenByAnalyzer.cs
  18. +1 −0 ILSpy/App.xaml.cs
  19. +2 −1 ILSpy/Commands/BrowseBackCommand.cs
  20. +2 −1 ILSpy/Commands/BrowseForwardCommand.cs
  21. +3 −1 ILSpy/Commands/CheckForUpdatesCommand.cs
  22. +3 −2 ILSpy/Commands/DecompileAllCommand.cs
  23. +2 −2 ILSpy/Commands/DisassembleAllCommand.cs
  24. +2 −2 ILSpy/Commands/ExitCommand.cs
  25. +1 −1 ILSpy/Commands/ExportCommandAttribute.cs
  26. +2 −2 ILSpy/Commands/GeneratePdbContextMenuEntry.cs
  27. +3 −2 ILSpy/Commands/OpenCommand.cs
  28. +2 −2 ILSpy/Commands/OpenFromGacCommand.cs
  29. +3 −1 ILSpy/Commands/OpenListCommand.cs
  30. +3 −2 ILSpy/Commands/RefreshCommand.cs
  31. +2 −1 ILSpy/Commands/RemoveAssembliesWithLoadErrors.cs
  32. +2 −1 ILSpy/Commands/SaveCommand.cs
  33. +3 −1 ILSpy/Commands/ShowDebugSteps.cs
  34. +5 −4 ILSpy/Commands/SortAssemblyListCommand.cs
  35. +1 −1 ILSpy/ContextMenuEntry.cs
  36. +5 −4 ILSpy/Controls/ResourceObjectTable.xaml
  37. +4 −3 ILSpy/Controls/ResourceStringTable.xaml
  38. +10 −7 ILSpy/CreateListDialog.xaml
  39. +8 −7 ILSpy/DebugSteps.xaml
  40. +1 −1 ILSpy/DebugSteps.xaml.cs
  41. +10 −0 ILSpy/ILSpy.csproj
  42. +4 −4 ILSpy/Languages/CSharpLanguage.cs
  43. +13 −11 ILSpy/MainWindow.xaml
  44. +22 −16 ILSpy/MainWindow.xaml.cs
  45. +9 −5 ILSpy/NugetPackageBrowserDialog.xaml
  46. +14 −10 ILSpy/OpenFromGacDialog.xaml
  47. +13 −9 ILSpy/OpenListDialog.xaml
  48. +2 −1 ILSpy/Options/DecompilerSettingsPanel.xaml
  49. +10 −3 ILSpy/Options/DecompilerSettingsPanel.xaml.cs
  50. +18 −17 ILSpy/Options/DisplaySettingsPanel.xaml
  51. +1 −1 ILSpy/Options/DisplaySettingsPanel.xaml.cs
  52. +3 −2 ILSpy/Options/MiscSettingsPanel.xaml
  53. +1 −1 ILSpy/Options/MiscSettingsPanel.xaml.cs
  54. +4 −3 ILSpy/Options/OptionsDialog.xaml
  55. +3 −2 ILSpy/Options/OptionsDialog.xaml.cs
  56. +1,883 −0 ILSpy/Properties/Resources.Designer.cs
  57. +729 −0 ILSpy/Properties/Resources.resx
  58. +732 −0 ILSpy/Properties/Resources.zh-Hans.resx
  59. +2 −2 ILSpy/README.txt
  60. +20 −16 ILSpy/Search/SearchPane.cs
  61. +6 −5 ILSpy/Search/SearchPane.xaml
  62. +4 −4 ILSpy/TextView/DecompilerTextView.cs
  63. +3 −2 ILSpy/TextView/DecompilerTextView.xaml
  64. +4 −2 ILSpy/TextView/EditorCommands.cs
  65. +3 −2 ILSpy/TextView/FoldingCommands.cs
  66. +7 −6 ILSpy/TreeNodes/AssemblyTreeNode.cs
  67. +2 −1 ILSpy/TreeNodes/CopyFullyQualifiedNameContextMenuEntry.cs
  68. +2 −2 ILSpy/TreeNodes/DerivedTypesTreeNode.cs
  69. +2 −1 ILSpy/TreeNodes/ReferenceFolderTreeNode.cs
  70. +2 −1 ILSpy/TreeNodes/ResourceListTreeNode.cs
  71. +2 −1 ILSpy/TreeNodes/ResourceNodes/CursorResourceEntryNode.cs
  72. +2 −1 ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs
  73. +2 −1 ILSpy/TreeNodes/ResourceNodes/ImageResourceEntryNode.cs
  74. +2 −1 ILSpy/TreeNodes/ResourceNodes/ResourceTreeNode.cs
  75. +2 −1 ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs
  76. +6 −4 ILSpy/TreeNodes/SearchMsdnContextMenuEntry.cs
  77. +3 −2 ILSpy/TreeNodes/ThreadingSupport.cs
  78. +3 −2 README.md
@@ -22,7 +22,7 @@ def main():
if '\\obj\\' in root:
continue
for filename in files:
if filename.lower().endswith('.cs'):
if filename.lower().endswith('.cs') and not filename.lower().endswith('resources.designer.cs'):
if not check(os.path.join(root, filename)):
ok = False
print('Tidy check: {}'.format('successful' if ok else 'failed'))
@@ -329,8 +329,8 @@ void RunCS([CallerMemberName] string testName = null, CompilerOptions options =

Tester.RunAndCompareOutput(testFileName, outputFile.PathToAssembly, decompiledOutputFile.PathToAssembly, decompiledCodeFile);

File.Delete(decompiledCodeFile);
File.Delete(decompiledOutputFile.PathToAssembly);
Tester.RepeatOnIOError(() => File.Delete(decompiledCodeFile));
Tester.RepeatOnIOError(() => File.Delete(decompiledOutputFile.PathToAssembly));
} finally {
if (outputFile != null)
outputFile.TempFiles.Delete();
@@ -354,8 +354,8 @@ void RunVB([CallerMemberName] string testName = null, CompilerOptions options =

Tester.RunAndCompareOutput(testFileName, outputFile.PathToAssembly, decompiledOutputFile.PathToAssembly, decompiledCodeFile);

File.Delete(decompiledCodeFile);
File.Delete(decompiledOutputFile.PathToAssembly);
Tester.RepeatOnIOError(() => File.Delete(decompiledCodeFile));
Tester.RepeatOnIOError(() => File.Delete(decompiledOutputFile.PathToAssembly));
} finally {
if (outputFile != null)
outputFile.TempFiles.Delete();
@@ -375,9 +375,9 @@ void RunIL(string testFileName, CompilerOptions options = CompilerOptions.UseDeb
decompiledOutputFile = Tester.CompileCSharp(decompiledCodeFile, options);

Tester.RunAndCompareOutput(testFileName, outputFile, decompiledOutputFile.PathToAssembly, decompiledCodeFile);
File.Delete(decompiledCodeFile);
File.Delete(decompiledOutputFile.PathToAssembly);

Tester.RepeatOnIOError(() => File.Delete(decompiledCodeFile));
Tester.RepeatOnIOError(() => File.Delete(decompiledOutputFile.PathToAssembly));
} finally {
if (decompiledOutputFile != null)
decompiledOutputFile.TempFiles.Delete();
@@ -5,6 +5,7 @@
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.VisualBasic;
@@ -518,5 +518,21 @@ public static void RunAndCompareOutput(string testFileName, string outputFile, s
Assert.Fail(b.ToString());
}
}

internal static void RepeatOnIOError(Action action, int numTries = 5)
{
for (int i = 0; i < numTries - 1; i++) {
try {
action();
return;
} catch (IOException) {
} catch (UnauthorizedAccessException) {
// potential virus scanner problem
}
Thread.Sleep(10);
}
// If the last try still fails, don't catch the exception
action();
}
}
}
@@ -1,4 +1,6 @@
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
using System.Threading.Tasks;

namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
internal class ConstantsTests
{
@@ -24,6 +26,12 @@ public void SByte_BitmaskingInCondition(sbyte v)
Test((v | 0x123) == 0);
}

public void Enum_Flag_Check(TaskCreationOptions v)
{
Test((v & TaskCreationOptions.AttachedToParent) != 0);
Test((v & TaskCreationOptions.AttachedToParent) == 0);
}

private void Test(bool expr)
{
}
@@ -4,6 +4,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
internal class RefLocalsAndReturns
{
public delegate ref T RefFunc<T>();
public delegate ref readonly T ReadOnlyRefFunc<T>();

public ref struct RefStruct
{
private int dummy;
@@ -1,4 +1,4 @@
// Copyright (c) 2014 Daniel Grunwald
// Copyright (c) 2014 Daniel Grunwald
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
@@ -699,8 +699,8 @@ TranslatedExpression TranslateCeq(Comp inst, out bool negateOutput)
}

// Special case comparisons with enum and char literals
left = AdjustConstantExpressionToType(left, right.Type);
right = AdjustConstantExpressionToType(right, left.Type);
left = TryUniteEqualityOperandType(left, right);
right = TryUniteEqualityOperandType(right, left);

if (IsSpecialCasedReferenceComparisonWithNull(left, right)) {
// When comparing a string/delegate with null, the C# compiler generates a reference comparison.
@@ -763,6 +763,22 @@ TranslatedExpression TranslateCeq(Comp inst, out bool negateOutput)
.WithRR(rr);
}

TranslatedExpression TryUniteEqualityOperandType(TranslatedExpression left, TranslatedExpression right)
{
// Special case for enum flag check "(enum & EnumType.SomeValue) == 0"
// so that the const 0 value is printed as 0 integer and not as enum type, e.g. EnumType.None
if (left.ResolveResult.IsCompileTimeConstant &&
left.ResolveResult.Type.IsCSharpPrimitiveIntegerType() &&
(left.ResolveResult.ConstantValue as int?) == 0 &&
NullableType.GetUnderlyingType(right.Type).Kind == TypeKind.Enum &&
right.Expression is BinaryOperatorExpression binaryExpr &&
binaryExpr.Operator == BinaryOperatorType.BitwiseAnd)
{
return AdjustConstantExpressionToType(left, compilation.FindType(KnownTypeCode.Int32));
} else
return AdjustConstantExpressionToType(left, right.Type);
}

bool IsSpecialCasedReferenceComparisonWithNull(TranslatedExpression lhs, TranslatedExpression rhs)
{
if (lhs.Type.Kind == TypeKind.Null)
@@ -1440,6 +1440,9 @@ DelegateDeclaration ConvertDelegate(IMethod invokeMethod, Modifiers modifiers)
decl.AddAnnotation(new TypeResolveResult(d));
}
decl.ReturnType = ConvertType(invokeMethod.ReturnType);
if (invokeMethod.ReturnTypeIsRefReadOnly && decl.ReturnType is ComposedType ct && ct.HasRefSpecifier) {
ct.HasReadOnlySpecifier = true;
}
decl.Name = d.Name;

int outerTypeParameterCount = (d.DeclaringTypeDefinition == null) ? 0 : d.DeclaringTypeDefinition.TypeParameterCount;
Oops, something went wrong.

0 comments on commit 59e57b6

Please sign in to comment.
You can’t perform that action at this time.