Skip to content
Merged
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 @@ -158,6 +158,7 @@
<Compile Include="TestCases\Pretty\Issue3571_C.cs" />
<Compile Include="TestCases\Pretty\Issue3571_B.cs" />
<Compile Include="TestCases\Pretty\Issue3571_A.cs" />
<Compile Include="TestCases\Pretty\Issue3576.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 @@ -696,6 +696,12 @@ public async Task Issue3571_C([ValueSource(nameof(roslyn2OrNewerWithNet40Options
await RunForLibrary(cscOptions: cscOptions);
}

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

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

namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
internal static class Issue3576
{
public static Issue3576_Camera GetOrCreate(long key, int frameCount, Dictionary<long, (Issue3576_Camera, int)> cache)
{
if (!cache.TryGetValue(key, out var value))
{
Issue3576_GameObject issue3576_GameObject = new Issue3576_GameObject();
value = (issue3576_GameObject.AddComponent<Issue3576_Camera>(), frameCount);
value.Item1.Property = 1;
issue3576_GameObject.SetActive(value: false);
cache[key] = value;
}
else
{
value.Item2 = frameCount;
cache[key] = value;
}
return value.Item1;
}
}
internal sealed class Issue3576_Camera
{
public int Property { get; set; }
}
internal sealed class Issue3576_GameObject
{
public T AddComponent<T>()
{
throw null;
}
public void SetActive(bool value)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ void IStatementTransform.Run(Block block, int pos, StatementTransformContext con
// anon = new { A = 5 } { 3,4,5 } is invalid syntax.
if (newObjInst.Method.DeclaringType.ContainsAnonymousType())
return;
// Tuples cannot have initializers
if (TupleTransform.MatchTupleConstruction(newObjInst, out _))
return;
instType = newObjInst.Method.DeclaringType;
break;
case DefaultValue defaultVal:
Expand Down
Loading