From 06243c8244e907cf3765890a0e7a51bb6e99855e Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 4 Oct 2020 18:04:22 +0200 Subject: [PATCH 01/12] Fix #2177: PDB Generation is confused by enhanced using statements (cherry picked from commit 65a5af2c990530983695032d10203eecae2b6b5f) --- .../CSharp/SequencePointBuilder.cs | 60 +++++++++++-------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs b/ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs index 44515dc0f..e781098e0 100644 --- a/ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs @@ -112,34 +112,43 @@ namespace ICSharpCode.Decompiler.CSharp public override void VisitBlockStatement(BlockStatement blockStatement) { - ILInstruction blockContainer = blockStatement.Annotations.OfType().FirstOrDefault(); - if (blockContainer != null) + // enhanced using variables need special-casing here, because we omit the block syntax from the + // text output, so we cannot use positions of opening/closing braces here. + bool isEnhancedUsing = blockStatement.Parent is UsingStatement us && us.IsEnhanced; + if (!isEnhancedUsing) { - StartSequencePoint(blockStatement.LBraceToken); - int intervalStart; - if (blockContainer.Parent is TryCatchHandler handler && !handler.ExceptionSpecifierILRange.IsEmpty) + var blockContainer = blockStatement.Annotation(); + if (blockContainer != null) { - // if this block container is part of a TryCatchHandler, do not steal the exception-specifier IL range - intervalStart = handler.ExceptionSpecifierILRange.End; + StartSequencePoint(blockStatement.LBraceToken); + int intervalStart; + if (blockContainer.Parent is TryCatchHandler handler && !handler.ExceptionSpecifierILRange.IsEmpty) + { + // if this block container is part of a TryCatchHandler, do not steal the + // exception-specifier IL range + intervalStart = handler.ExceptionSpecifierILRange.End; + } + else + { + intervalStart = blockContainer.StartILOffset; + } + // The end will be set to the first sequence point candidate location before the first + // statement of the function when the seqeunce point is adjusted + int intervalEnd = intervalStart + 1; + + Interval interval = new Interval(intervalStart, intervalEnd); + List intervals = new List(); + intervals.Add(interval); + current.Intervals.AddRange(intervals); + current.Function = blockContainer.Ancestors.OfType().FirstOrDefault(); + EndSequencePoint(blockStatement.LBraceToken.StartLocation, blockStatement.LBraceToken.EndLocation); } else { - intervalStart = blockContainer.StartILOffset; + // Ideally, we'd be able to address this case. Blocks that are not the top-level function + // block have no ILInstruction annotations. It isn't clear to me how to determine the il range. + // For now, do not add the opening brace sequence in this case. } - // The end will be set to the first sequence point candidate location before the first statement of the function when the seqeunce point is adjusted - int intervalEnd = intervalStart + 1; - - Interval interval = new Interval(intervalStart, intervalEnd); - List intervals = new List(); - intervals.Add(interval); - current.Intervals.AddRange(intervals); - current.Function = blockContainer.Ancestors.OfType().FirstOrDefault(); - EndSequencePoint(blockStatement.LBraceToken.StartLocation, blockStatement.LBraceToken.EndLocation); - } - else - { - // Ideally, we'd be able to address this case. Blocks that are not the top-level function block have no ILInstruction annotations. It isn't clear to me how to determine the il range. - // For now, do not add the opening brace sequence in this case. } foreach (var stmt in blockStatement.Statements) @@ -147,7 +156,7 @@ namespace ICSharpCode.Decompiler.CSharp VisitAsSequencePoint(stmt); } var implicitReturn = blockStatement.Annotation(); - if (implicitReturn != null) + if (implicitReturn != null && !isEnhancedUsing) { StartSequencePoint(blockStatement.RBraceToken); AddToSequencePoint(implicitReturn.Leave); @@ -263,7 +272,10 @@ namespace ICSharpCode.Decompiler.CSharp usingStatement.ResourceAcquisition.AcceptVisitor(this); VisitAsSequencePoint(usingStatement.EmbeddedStatement); AddToSequencePoint(usingStatement); - EndSequencePoint(usingStatement.StartLocation, usingStatement.RParToken.EndLocation); + if (usingStatement.IsEnhanced) + EndSequencePoint(usingStatement.StartLocation, usingStatement.ResourceAcquisition.EndLocation); + else + EndSequencePoint(usingStatement.StartLocation, usingStatement.RParToken.EndLocation); } public override void VisitForeachStatement(ForeachStatement foreachStatement) From 2612a06a110a4a467aab32091ae22530ea53d80c Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 4 Oct 2020 21:15:13 +0200 Subject: [PATCH 02/12] Fix #2174: Some compilers produce display class ctors with unused local variables (cherry picked from commit 71b54e87a0e7ae31ba646d1406398dff03c57eb0) --- .../IL/Transforms/TransformDisplayClassUsage.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/IL/Transforms/TransformDisplayClassUsage.cs b/ICSharpCode.Decompiler/IL/Transforms/TransformDisplayClassUsage.cs index 7c0dc8f98..3bf2fe91e 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/TransformDisplayClassUsage.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/TransformDisplayClassUsage.cs @@ -442,7 +442,11 @@ namespace ICSharpCode.Decompiler.IL.Transforms if (def.RelativeVirtualAddress == 0) return false; var body = file.Reader.GetMethodBody(def.RelativeVirtualAddress); - if (!body.LocalSignature.IsNil || body.ExceptionRegions.Length != 0) + // some compilers produce ctors with unused local variables + // see https://github.com/icsharpcode/ILSpy/issues/2174 + //if (!body.LocalSignature.IsNil) + // return false; + if (body.ExceptionRegions.Length != 0) return false; var reader = body.GetILReader(); if (reader.Length < 7) From 0dcb9d384ad2d0dd90d3e0b56d11a29b536c27ea Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 7 Oct 2020 18:54:42 +0200 Subject: [PATCH 03/12] Fix #2183: incorrect version in binding redirect for AvalonEdit --- ILSpy/Properties/app.config.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ILSpy/Properties/app.config.template b/ILSpy/Properties/app.config.template index 002d8a13d..1eb8c6d87 100644 --- a/ILSpy/Properties/app.config.template +++ b/ILSpy/Properties/app.config.template @@ -14,7 +14,7 @@ - + From a81714f70761faadeab5770f284dff81ef380795 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 7 Oct 2020 20:17:08 +0200 Subject: [PATCH 04/12] Fix #2180: Restrict the `(uint?)-1` special case to casts to integer types. This avoids the risk of stack overflows when converting to an unexpected nullable type (such as `Nullable`). --- ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs b/ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs index 41900b0e6..170c4d2db 100644 --- a/ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs +++ b/ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs @@ -502,7 +502,8 @@ namespace ICSharpCode.Decompiler.CSharp .WithRR(new ByReferenceResolveResult(elementRR, ReferenceKind.Ref)); } if (this.ResolveResult.IsCompileTimeConstant && this.ResolveResult.ConstantValue != null - && NullableType.IsNullable(targetType) && !utype.Equals(targetUType)) + && NullableType.IsNullable(targetType) && !utype.Equals(targetUType) + && targetUType.GetStackType().IsIntegerType()) { // Casts like `(uint?)-1` are only valid in an explicitly unchecked context, but we // don't have logic to ensure such a context (usually we emit into an implicitly unchecked context). From 103a6461e4b34a48bd0e7390366ad9889022b047 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 7 Oct 2020 20:29:05 +0200 Subject: [PATCH 05/12] Relax ExpressionBuilder invariant for lifted instructions with unknown result type. --- .../CSharp/ExpressionBuilder.cs | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs index 1cd72dc03..f77afe924 100644 --- a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs @@ -167,16 +167,19 @@ namespace ICSharpCode.Decompiler.CSharp } else if (inst is ILiftableInstruction liftable && liftable.IsLifted) { - Debug.Assert(NullableType.IsNullable(cexpr.Type)); - IType underlying = NullableType.GetUnderlyingType(cexpr.Type); - if (liftable.UnderlyingResultType.IsIntegerType()) + if (liftable.UnderlyingResultType != StackType.Unknown) { - Debug.Assert(underlying.GetStackType().IsIntegerType(), "IL instructions of integer type must convert into C# expressions of integer type"); - Debug.Assert(underlying.GetSign() != Sign.None, "Must have a sign specified for zero/sign-extension"); - } - else - { - Debug.Assert(underlying.GetStackType() == liftable.UnderlyingResultType); + Debug.Assert(NullableType.IsNullable(cexpr.Type)); + IType underlying = NullableType.GetUnderlyingType(cexpr.Type); + if (liftable.UnderlyingResultType.IsIntegerType()) + { + Debug.Assert(underlying.GetStackType().IsIntegerType(), "IL instructions of integer type must convert into C# expressions of integer type"); + Debug.Assert(underlying.GetSign() != Sign.None, "Must have a sign specified for zero/sign-extension"); + } + else + { + Debug.Assert(underlying.GetStackType() == liftable.UnderlyingResultType); + } } } else if (inst.ResultType == StackType.Ref) From 47685c4b576829690d259e7cf9dc6cab1d3590d7 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 7 Oct 2020 20:47:26 +0200 Subject: [PATCH 06/12] Fix weird casts to `nint` when writing to fields of unknown type. --- .../ICSharpCode.Decompiler.Tests.csproj | 2 + .../ILPrettyTestRunner.cs | 6 ++ .../TestCases/ILPretty/UnknownTypes.cs | 12 ++++ .../TestCases/ILPretty/UnknownTypes.il | 59 +++++++++++++++++++ ICSharpCode.Decompiler/IL/ILReader.cs | 3 +- 5 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 ICSharpCode.Decompiler.Tests/TestCases/ILPretty/UnknownTypes.cs create mode 100644 ICSharpCode.Decompiler.Tests/TestCases/ILPretty/UnknownTypes.il diff --git a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj index 4345dfb83..84f9da9bb 100644 --- a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj +++ b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj @@ -62,6 +62,8 @@ + + diff --git a/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs index 487ee8be1..f1cf6ffd3 100644 --- a/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs +++ b/ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs @@ -140,6 +140,12 @@ namespace ICSharpCode.Decompiler.Tests Run(settings: new DecompilerSettings { SwitchExpressions = false }); } + [Test] + public void UnknownTypes() + { + Run(); + } + [Test] public void Issue1145() { diff --git a/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/UnknownTypes.cs b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/UnknownTypes.cs new file mode 100644 index 000000000..c77ae5e14 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/UnknownTypes.cs @@ -0,0 +1,12 @@ +internal class UnknownTypes +{ + private readonly IInterface memberField; + + public override bool CanExecute(CallbackQuery message) + { + return ((IInterface)(object)memberField).Execute(new SomeClass { + ChatId = StaticClass.GetChatId(message), + MessageId = StaticClass.GetMessageId(message) + }); + } +} diff --git a/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/UnknownTypes.il b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/UnknownTypes.il new file mode 100644 index 000000000..69c743fa4 --- /dev/null +++ b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/UnknownTypes.il @@ -0,0 +1,59 @@ +#define CORE_ASSEMBLY "System.Runtime" + +.assembly extern CORE_ASSEMBLY +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....: + .ver 4:0:0:0 +} +.assembly extern UnknownAssembly +{ + .publickeytoken = (01 02 03 04 05 06 07 08 ) + .ver 1:0:0:0 +} + +.class private auto ansi beforefieldinit UnknownTypes + extends [System.Private.CoreLib]System.Object +{ + .field private initonly class [UnknownAssembly]IInterface memberField + + // Methods + .method public hidebysig specialname rtspecialname + instance void .ctor () cil managed + { + // Method begins at RVA 0x206e + // Code size 8 (0x8) + .maxstack 8 + + IL_0000: ldarg.0 + IL_0001: call instance void [CORE_ASSEMBLY]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method UnknownTypes::.ctor + + .method public hidebysig virtual + instance bool CanExecute ( + class [UnknownAssembly]CallbackQuery message + ) cil managed + { + // Method begins at RVA 0x4dbc + // Code size 44 (0x2c) + .maxstack 8 + + IL_0000: ldarg.0 + IL_0001: ldfld class [UnknownAssembly]IInterface UnknownTypes::memberField + IL_0006: newobj instance void [UnknownAssembly]SomeClass::.ctor() + IL_000b: dup + IL_000d: ldarg.1 + IL_000e: call int64 [UnknownAssembly]StaticClass::GetChatId(class [UnknownAssembly]CallbackQuery) + IL_0013: stfld int64 [UnknownAssembly]SomeClass::ChatId + IL_0018: dup + IL_001a: ldarg.1 + IL_001b: call int32 [UnknownAssembly]StaticClass::GetMessageId(class [UnknownAssembly]CallbackQuery) + IL_0020: conv.i8 + IL_0021: stfld int64 [UnknownAssembly]SomeClass::MessageId + IL_0026: callvirt instance !1 class [UnknownAssembly]IInterface`2::Execute(!0) + IL_002b: ret + } // end of method CanExecute + + +} // end of class UnknownTypes diff --git a/ICSharpCode.Decompiler/IL/ILReader.cs b/ICSharpCode.Decompiler/IL/ILReader.cs index d4d2498a8..ac0c1527a 100644 --- a/ICSharpCode.Decompiler/IL/ILReader.cs +++ b/ICSharpCode.Decompiler/IL/ILReader.cs @@ -1312,7 +1312,8 @@ namespace ICSharpCode.Decompiler.IL return PopPointer(); default: // field in unresolved type - if (PeekStackType() == StackType.O) + var stackType = PeekStackType(); + if (stackType == StackType.O || stackType == StackType.Unknown) return Pop(); else return PopPointer(); From 2530c9a2cea6f13eea019499a23f3233f84bf642 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 7 Oct 2020 22:36:38 +0200 Subject: [PATCH 07/12] #2182: Do not inline switch value, in case variable is reused. --- .../IL/Transforms/SwitchOnStringTransform.cs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/IL/Transforms/SwitchOnStringTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/SwitchOnStringTransform.cs index 0fffa2a28..be3114ace 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/SwitchOnStringTransform.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/SwitchOnStringTransform.cs @@ -213,6 +213,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms var values = new List<(string, ILInstruction)>(); var uniqueValues = new HashSet(); int numberOfUniqueMatchesWithCurrentVariable = 0; + HashSet caseBlocks = new HashSet(); + caseBlocks.Add((Block)instructions[i].Parent); bool AddSwitchSection(string value, ILInstruction inst) { @@ -308,6 +310,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms if (!AddSwitchSection(value, block)) return false; } + caseBlocks.Add(currentCaseBlock); currentCaseBlock = nextCaseBlock as Block; } while (currentCaseBlock != null); @@ -316,7 +319,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms return false; context.Step(nameof(SimplifyCascadingIfStatements), instructions[i]); // if the switchValueVar is used in other places as well, do not eliminate the store. - if (switchValueVar.LoadCount > numberOfUniqueMatchesWithCurrentVariable) + if (switchValueVar.LoadCount > numberOfUniqueMatchesWithCurrentVariable || !ValidateUsesOfSwitchValueVariable(switchValueVar, caseBlocks)) { keepAssignmentBefore = true; removeExtraLoad = false; // prevent loads from being deleted after detecting that @@ -355,6 +358,23 @@ namespace ICSharpCode.Decompiler.IL.Transforms return true; } + private bool ValidateUsesOfSwitchValueVariable(ILVariable switchValueVar, HashSet caseBlocks) + { + foreach (var use in switchValueVar.LoadInstructions) + { + bool isValid = false; + foreach (var caseBlock in caseBlocks) + { + if (use.IsDescendantOf(caseBlock)) + isValid = true; + } + if (!isValid) + return false; + } + + return true; + } + bool SimplifyCSharp1CascadingIfStatements(InstructionCollection instructions, ref int i) { if (i < 1) From 22b3838e7263c62456bb1a02ab3f0124ab15713b Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Thu, 8 Oct 2020 21:22:51 +0200 Subject: [PATCH 08/12] run azure-pipelines/appveyor on all branches we treat as release branches: master and release/* --- BuildTools/appveyor-ilspycmd-install.ps1 | 9 ++++++--- BuildTools/appveyor-install.ps1 | 6 +++--- BuildTools/pipelines-install.ps1 | 6 +++--- BuildTools/update-assemblyinfo.ps1 | 6 +++--- appveyor.yml | 2 +- azure-pipelines.yml | 4 ++-- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/BuildTools/appveyor-ilspycmd-install.ps1 b/BuildTools/appveyor-ilspycmd-install.ps1 index 41691695a..0d549c7a7 100644 --- a/BuildTools/appveyor-ilspycmd-install.ps1 +++ b/BuildTools/appveyor-ilspycmd-install.ps1 @@ -3,6 +3,9 @@ $ErrorActionPreference = "Stop" $baseCommit = "e17b4bfedf4dc747b105396224cd726bdca500ad"; $baseCommitRev = 1; +# make sure this matches artifacts-only branches list in appveyor.yml! +$masterBranches = '^(master|release/.+)$'; + $globalAssemblyInfoTemplateFile = "ILSpy/Properties/AssemblyInfo.template.cs"; $versionParts = @{}; @@ -18,10 +21,10 @@ if ($versionName -ne "null") { } else { $versionName = ""; } -if ($env:APPVEYOR_REPO_BRANCH -ne 'master') { - $branch = "-$env:APPVEYOR_REPO_BRANCH"; -} else { +if ($env:APPVEYOR_REPO_BRANCH -match $masterBranches) { $branch = ""; +} else { + $branch = "-$env:APPVEYOR_REPO_BRANCH"; } $revision = [Int32]::Parse((git rev-list --count "$baseCommit..HEAD")) + $baseCommitRev; diff --git a/BuildTools/appveyor-install.ps1 b/BuildTools/appveyor-install.ps1 index 0b922deb8..a69ff0732 100644 --- a/BuildTools/appveyor-install.ps1 +++ b/BuildTools/appveyor-install.ps1 @@ -3,8 +3,8 @@ $ErrorActionPreference = "Stop" $baseCommit = "d779383cb85003d6dabeb976f0845631e07bf463"; $baseCommitRev = 1; -# make sure this list matches artifacts-only branches list in appveyor.yml! -$masterBranches = @("master", "5.0.x"); +# make sure this matches artifacts-only branches list in appveyor.yml! +$masterBranches = '^(master|release/.+)$'; $globalAssemblyInfoTemplateFile = "ILSpy/Properties/AssemblyInfo.template.cs"; @@ -21,7 +21,7 @@ if ($versionName -ne "null") { } else { $versionName = ""; } -if ($masterBranches -contains $env:APPVEYOR_REPO_BRANCH) { +if ($env:APPVEYOR_REPO_BRANCH -match $masterBranches) { $branch = ""; } else { $branch = "-$env:APPVEYOR_REPO_BRANCH"; diff --git a/BuildTools/pipelines-install.ps1 b/BuildTools/pipelines-install.ps1 index 4e3dda35e..718e13f0e 100644 --- a/BuildTools/pipelines-install.ps1 +++ b/BuildTools/pipelines-install.ps1 @@ -3,8 +3,8 @@ $ErrorActionPreference = "Stop" $baseCommit = "d779383cb85003d6dabeb976f0845631e07bf463"; $baseCommitRev = 1; -# make sure this list matches artifacts-only branches list in azure-pipelines.yml! -$masterBranches = @("master", "5.0.x"); +# make sure this matches artifacts-only branches list in appveyor.yml! +$masterBranches = '^(master|release/.+)$'; $globalAssemblyInfoTemplateFile = "ILSpy/Properties/AssemblyInfo.template.cs"; @@ -21,7 +21,7 @@ if ($versionName -ne "null") { } else { $versionName = ""; } -if ($masterBranches -contains $env:BUILD_SOURCEBRANCHNAME) { +if ($env:BUILD_SOURCEBRANCHNAME -match $masterBranches) { $branch = ""; } else { $branch = "-$env:BUILD_SOURCEBRANCHNAME"; diff --git a/BuildTools/update-assemblyinfo.ps1 b/BuildTools/update-assemblyinfo.ps1 index dbfa5f911..f7fa079b1 100644 --- a/BuildTools/update-assemblyinfo.ps1 +++ b/BuildTools/update-assemblyinfo.ps1 @@ -3,8 +3,8 @@ $baseCommit = "d779383cb85003d6dabeb976f0845631e07bf463"; $baseCommitRev = 1; -# make sure this list matches artifacts-only branches list in appveyor.yml! -$masterBranches = @("master", "5.0.x"); +# make sure this matches artifacts-only branches list in appveyor.yml! +$masterBranches = '^(master|release/.+)$'; $globalAssemblyInfoTemplateFile = "ILSpy/Properties/AssemblyInfo.template.cs"; @@ -112,7 +112,7 @@ try { $branchName = gitBranch; $gitCommitHash = gitCommitHash; - if ($masterBranches -contains $branchName) { + if ($branchName -match $masterBranches) { $postfixBranchName = ""; } else { $postfixBranchName = "-$branchName"; diff --git a/appveyor.yml b/appveyor.yml index 7bc77bb58..8b9b0dd07 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -45,7 +45,7 @@ for: - branches: only: - master - - 5.0.x + - /release\/*/ artifacts: - path: ILSpy_binaries.zip name: ILSpy %APPVEYOR_REPO_BRANCH% %ILSPY_VERSION_NUMBER% binaries diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e45b45d2d..a17e464da 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,10 +1,10 @@ trigger: - master -- 5.0.x +- release/* pr: - master -- 5.0.x +- release/* variables: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true From 12668300f648d7d66dda92fea25dfb45f3f80864 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Thu, 8 Oct 2020 21:29:23 +0200 Subject: [PATCH 09/12] Set version number to 6.2.1 --- ILSpy/Properties/AssemblyInfo.template.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ILSpy/Properties/AssemblyInfo.template.cs b/ILSpy/Properties/AssemblyInfo.template.cs index e8a9aa640..f7ad286cc 100644 --- a/ILSpy/Properties/AssemblyInfo.template.cs +++ b/ILSpy/Properties/AssemblyInfo.template.cs @@ -37,10 +37,10 @@ using System.Runtime.InteropServices; internal static class RevisionClass { public const string Major = "6"; - public const string Minor = "3"; - public const string Build = "0"; + public const string Minor = "2"; + public const string Build = "1"; public const string Revision = "$INSERTREVISION$"; - public const string VersionName = "preview1"; + public const string VersionName = null; public const string FullVersion = Major + "." + Minor + "." + Build + ".$INSERTREVISION$$INSERTBRANCHPOSTFIX$$INSERTVERSIONNAMEPOSTFIX$"; } From 2b13e57102f5d8a357754d4f8a005a9e60693648 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Thu, 8 Oct 2020 21:55:34 +0200 Subject: [PATCH 10/12] Fix pipelines-install.ps1 --- BuildTools/pipelines-install.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/BuildTools/pipelines-install.ps1 b/BuildTools/pipelines-install.ps1 index 718e13f0e..7e73f3c60 100644 --- a/BuildTools/pipelines-install.ps1 +++ b/BuildTools/pipelines-install.ps1 @@ -4,7 +4,7 @@ $baseCommit = "d779383cb85003d6dabeb976f0845631e07bf463"; $baseCommitRev = 1; # make sure this matches artifacts-only branches list in appveyor.yml! -$masterBranches = '^(master|release/.+)$'; +$masterBranches = '^refs/heads/(master|release/.+)$'; $globalAssemblyInfoTemplateFile = "ILSpy/Properties/AssemblyInfo.template.cs"; @@ -21,7 +21,8 @@ if ($versionName -ne "null") { } else { $versionName = ""; } -if ($env:BUILD_SOURCEBRANCHNAME -match $masterBranches) { + +if ($env:BUILD_SOURCEBRANCH -match $masterBranches) { $branch = ""; } else { $branch = "-$env:BUILD_SOURCEBRANCHNAME"; From 46e1e3e1444ce785eb587d1eced0c9b076ba3ca1 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Thu, 8 Oct 2020 23:00:51 +0200 Subject: [PATCH 11/12] Move dotnet-format installation to Agent.ToolsDirectory to prevent its nupkg from being added to our release zip. --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a17e464da..e087c1aea 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -52,7 +52,7 @@ jobs: inputs: command: 'custom' custom: 'tool' - arguments: 'install dotnet-format --tool-path BuildTools' + arguments: 'install dotnet-format --tool-path $(Agent.ToolsDirectory)/dotnet-format' - script: pwsh .\BuildTools\pipelines-install.ps1 displayName: Install @@ -94,7 +94,7 @@ jobs: - script: python BuildTools\tidy.py displayName: Tab check - - script: .\BuildTools\dotnet-format --check --verbosity diagnostic ILSpy.sln + - script: $(Agent.ToolsDirectory)\dotnet-format\dotnet-format --check --verbosity diagnostic ILSpy.sln displayName: dotnet-format check - task: CopyFiles@2 From 31b4e6ae6ae4e4ea7ce52e8d4c959c1aee7f941c Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 9 Oct 2020 12:37:08 +0200 Subject: [PATCH 12/12] Fix #2185: Fix MemberIsHidden-check for local function display structs: Async State Machines that looked like local function display structs were not hidden once local function decompilation was disabled. This led to code duplication in the generated pdb. --- ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs index 8b798edb1..10c422d3a 100644 --- a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs +++ b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs @@ -286,8 +286,8 @@ namespace ICSharpCode.Decompiler.CSharp var methodSemantics = module.MethodSemanticsLookup.GetSemantics(methodHandle).Item2; if (methodSemantics != 0 && methodSemantics != System.Reflection.MethodSemanticsAttributes.Other) return true; - if (LocalFunctionDecompiler.IsLocalFunctionMethod(module, methodHandle)) - return settings.LocalFunctions; + if (settings.LocalFunctions && LocalFunctionDecompiler.IsLocalFunctionMethod(module, methodHandle)) + return true; if (settings.AnonymousMethods && methodHandle.HasGeneratedName(metadata) && methodHandle.IsCompilerGenerated(metadata)) return true; if (settings.AsyncAwait && AsyncAwaitDecompiler.IsCompilerGeneratedMainMethod(module, methodHandle)) @@ -299,8 +299,8 @@ namespace ICSharpCode.Decompiler.CSharp name = metadata.GetString(type.Name); if (!type.GetDeclaringType().IsNil) { - if (LocalFunctionDecompiler.IsLocalFunctionDisplayClass(module, typeHandle)) - return settings.LocalFunctions; + if (settings.LocalFunctions && LocalFunctionDecompiler.IsLocalFunctionDisplayClass(module, typeHandle)) + return true; if (settings.AnonymousMethods && IsClosureType(type, metadata)) return true; if (settings.YieldReturn && YieldReturnDecompiler.IsCompilerGeneratorEnumerator(typeHandle, metadata))