Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
<Compile Include="TestCases\Pretty\Issue3571_B.cs" />
<Compile Include="TestCases\Pretty\Issue3571_A.cs" />
<Compile Include="TestCases\Pretty\Issue3576.cs" />
<Compile Include="TestCases\Pretty\Issue3584.cs" />
<None Include="TestCases\Ugly\NoLocalFunctions.Expected.cs" />
<None Include="TestCases\ILPretty\Issue3504.cs" />
<Compile Include="TestCases\ILPretty\MonoFixed.cs" />
Expand Down
6 changes: 6 additions & 0 deletions ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,12 @@ public async Task Issue3576([ValueSource(nameof(roslyn2OrNewerWithNet40Options))
await RunForLibrary(cscOptions: cscOptions);
}

[Test]
public async Task Issue3584([ValueSource(nameof(defaultOptions))] CompilerOptions cscOptions)
{
await RunForLibrary(cscOptions: cscOptions);
}

[Test]
public async Task AssemblyCustomAttributes([ValueSource(nameof(defaultOptions))] CompilerOptions cscOptions)
{
Expand Down
47 changes: 47 additions & 0 deletions ICSharpCode.Decompiler.Tests/TestCases/Pretty/Issue3584.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System.Collections;
using System.Collections.Generic;

namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
internal abstract class Issue4000<T> : IEnumerable<T>, IEnumerable
{
public int Length;

protected T[] results;

#if !ROSLYN4
public T this[int i] {
get {
if (i >= Length || i < 0)
{
return default(T);
}
if (results[i] != null && results[i].Equals(default(T)))
{
results[i] = CreateIthElement(i);
}
return results[i];
}
}
#endif

protected abstract T CreateIthElement(int i);

public IEnumerator<T> GetEnumerator()
{
for (int i = 0; i < Length; i++)
{
if (results[i] != null && results[i].Equals(default(T)))
{
results[i] = CreateIthElement(i);
}
yield return results[i];
}
}

IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}
2 changes: 2 additions & 0 deletions ICSharpCode.Decompiler/IL/ILTypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ public static IType InferType(this ILInstruction inst, ICompilation? compilation
default:
return SpecialType.UnknownType;
}
case DefaultValue defaultValue:
return defaultValue.Type;
case ILFunction func when func.DelegateType != null:
return func.DelegateType;
default:
Expand Down
9 changes: 0 additions & 9 deletions ICSharpCode.Decompiler/IL/Instructions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4355,15 +4355,6 @@ public IType Type {
set { type = value; InvalidateFlags(); }
}
public override StackType ResultType { get { return StackType.O; } }
protected override InstructionFlags ComputeFlags()
{
return base.ComputeFlags() | InstructionFlags.SideEffect | InstructionFlags.MayThrow;
}
public override InstructionFlags DirectFlags {
get {
return base.DirectFlags | InstructionFlags.SideEffect | InstructionFlags.MayThrow;
}
}
public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
{
WriteILRange(output, options);
Expand Down
2 changes: 1 addition & 1 deletion ICSharpCode.Decompiler/IL/Instructions.tt
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
CustomInvariant("CheckTargetSlot();")),

new OpCode("box", "Boxes a value.",
Unary, HasTypeOperand, MemoryAccess, MayThrow, ResultType("O")),
Unary, HasTypeOperand, ResultType("O")),
new OpCode("unbox", "Compute address inside box.",
Unary, HasTypeOperand, MayThrow, ResultType("Ref")),
new OpCode("unbox.any", "Unbox a value.",
Expand Down
Loading