Skip to content
Draft
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
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<PackageVersion Include="K4os.Compression.LZ4" Version="1.3.8" />
<PackageVersion Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
<PackageVersion Include="McMaster.Extensions.Hosting.CommandLine" Version="4.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.14.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.0.0-2.final" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic" Version="5.0.0-2.final" />
<PackageVersion Include="Microsoft.DiaSymReader.Converter.Xml" Version="1.1.0-beta2-22171-02" />
<PackageVersion Include="Microsoft.DiaSymReader" Version="1.4.0" />
<PackageVersion Include="Microsoft.DiaSymReader.Native" Version="17.0.0-beta1.21524.1" />
Expand Down
2 changes: 1 addition & 1 deletion ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ internal static async Task Initialize()

await vswhereToolset.Fetch().ConfigureAwait(false);
await RefAssembliesToolset.Fetch("5.0.0", sourcePath: "ref/net5.0").ConfigureAwait(false);
await RefAssembliesToolset.Fetch("10.0.0-preview.4.25258.110", sourcePath: "ref/net10.0").ConfigureAwait(false);
await RefAssembliesToolset.Fetch("10.0.0-rc.2.25502.107", sourcePath: "ref/net10.0").ConfigureAwait(false);


#if DEBUG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
<None Include="TestCases\Disassembler\Pretty\InterfaceImplAttributes.il" />
<None Include="TestCases\Disassembler\Pretty\SortMembers.expected.il" />
<None Include="TestCases\Disassembler\Pretty\SortMembers.il" />
<None Include="TestCases\ILPretty\ExtensionEncodingV2.il" />
<None Include="testcases\ilpretty\ExtensionEncodingV1.il" />
<None Include="TestCases\ILPretty\GuessAccessors.cs" />
<None Include="TestCases\ILPretty\GuessAccessors.il" />
<None Include="TestCases\ILPretty\Issue2260SwitchString.il" />
Expand Down Expand Up @@ -145,6 +147,8 @@
<Compile Include="ProjectDecompiler\TargetFrameworkTests.cs" />
<Compile Include="ProjectDecompiler\WholeProjectDecompilerTests.cs" />
<Compile Include="TestAssemblyResolver.cs" />
<Compile Include="TestCases\ILPretty\ExtensionEncodingV2.cs" />
<Compile Include="TestCases\ILPretty\ExtensionEncodingV1.cs" />
<Compile Include="TestCases\ILPretty\Issue3344CkFinite.cs" />
<Compile Include="TestCases\ILPretty\Issue3421.cs" />
<Compile Include="TestCases\ILPretty\Issue3465.cs" />
Expand Down
16 changes: 16 additions & 0 deletions ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,22 @@ public async Task MonoFixed()
await Run();
}

[Test]
public async Task ExtensionEncodingV1()
{
// uses Microsoft.Net.Compilers.Toolset 5.0.0-2.25380.108
// see ExtensionEncodingV1.il for details
await Run();
}

[Test]
public async Task ExtensionEncodingV2()
{
// uses Microsoft.Net.Compilers.Toolset 5.0.0-2.25451.107
// see ExtensionEncodingV2.il for details
await Run();
}

async Task Run([CallerMemberName] string testName = null, DecompilerSettings settings = null,
AssemblerOptions assemblerOptions = AssemblerOptions.Library)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Collections.Generic;
using System.Linq;

namespace ICSharpCode.Decompiler.Tests.TestCases.ILPretty
{
internal static class ExtensionPropertiesV1
{
extension<T>(ICollection<T> collection) where T : notnull
{
public bool IsEmpty => collection.Count == 0;

public int Test {
get {
return 42;
}
set {
}
}

public void AddIfNotNull(T item)
{
if (item != null)
{
collection.Add(item);
}
}

public T2 Cast<T2>(int index) where T2 : T
{
return (T2)(object)collection.ElementAt(index);
}

public static void StaticExtension()
{
}
}
}
}
253 changes: 253 additions & 0 deletions ICSharpCode.Decompiler.Tests/TestCases/ILPretty/ExtensionEncodingV1.il
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
// To extend use:
// see https://lab.razor.fyi/#fVHNbhMxEFYRqrBP0CcYbpsDVlioVDU_UrSNUBCqImVPnHC8k8TgtRd7tiSqcuMh-gbceQBeihdA66bJNlK5WDPzfTPffGP-65TzqXdLL0uhwtndaR20XcJsEwjLHm9nInPGoCLtbBAf0KLX6j-MSVnWJOcGjzhXWi6tC6RVeBoRmStwZKXZBH1M-6Tt96NSvvIoC22XT9VFLsO30OPcyhJDJRXCJJutpK8aIXGFypWVNuhFjoFCfDMZMIipR6INv-VMW0JvpYFAkrQCZWQIMF4T2qCdnXpXoSeNgbNbzhg-AP18mEwOl-nnQ1D7rAM_VugRcrgE68jWxnAW-1lVz41WMHfOwCSMy4o2MGj3iszVlmAwgG6Ptzq0JWgMQBzDlvgQMY9Uewvv017Mt_ENezzm2_aoG6cLGBXFZHHt6Lo2JslBE5adhnPfpBeQNCV4PYBm_QjtMNZadlQUkddpaT_SylPIZKB-ng6TxoK2Ba7390nhEvKD6s5JkqedxM2_oqJOS2tssERLI0ruh0TJR2K7P4z-ZjHef2RyMNcsueVsy7f87NW56Irum1Sk5-8uuuJt9-LjM20-sxd3P__-_rN4-fzLyfrkHw
// created using https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet-tools/NuGet/Microsoft.Net.Compilers.Toolset/overview/5.0.0-2.25380.108

.class private auto ansi abstract sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.ExtensionPropertiesV1
extends [System.Runtime]System.Object
{
.custom instance void [System.Runtime]System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = (
01 00 01 00 00
)
.custom instance void [System.Runtime]System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = (
01 00 00 00 00
)
.custom instance void [System.Runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = (
01 00 00 00
)
// Nested Types
.class nested public auto ansi sealed specialname beforefieldinit '<>E__0`1'<T>
extends [System.Runtime]System.Object
{
// Methods
.method private hidebysig specialname static
void '<Extension>$' (
class [System.Runtime]System.Collections.Generic.ICollection`1<!T> collection
) cil managed
{
.custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = (
01 00 00 00
)
// Method begins at RVA 0x209d
// Header size: 1
// Code size: 1 (0x1)
.maxstack 8

IL_0000: ret
} // end of method '<>E__0`1'::'<Extension>$'

.method public hidebysig specialname
instance bool get_IsEmpty () cil managed
{
// Method begins at RVA 0x209f
// Header size: 1
// Code size: 2 (0x2)
.maxstack 8

IL_0000: ldnull
IL_0001: throw
} // end of method '<>E__0`1'::get_IsEmpty

.method public hidebysig specialname
instance int32 get_Test () cil managed
{
// Method begins at RVA 0x209f
// Header size: 1
// Code size: 2 (0x2)
.maxstack 8

IL_0000: ldnull
IL_0001: throw
} // end of method '<>E__0`1'::get_Test

.method public hidebysig specialname
instance void set_Test (
int32 'value'
) cil managed
{
// Method begins at RVA 0x209f
// Header size: 1
// Code size: 2 (0x2)
.maxstack 8

IL_0000: ldnull
IL_0001: throw
} // end of method '<>E__0`1'::set_Test

.method public hidebysig
instance void AddIfNotNull (
!T item
) cil managed
{
// Method begins at RVA 0x209f
// Header size: 1
// Code size: 2 (0x2)
.maxstack 8

IL_0000: ldnull
IL_0001: throw
} // end of method '<>E__0`1'::AddIfNotNull

.method public hidebysig
instance !!T2 Cast<(!T) T2> (
int32 index
) cil managed
{
.param type T2
.custom instance void [System.Runtime]System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = (
01 00 00 00 00
)
// Method begins at RVA 0x209f
// Header size: 1
// Code size: 2 (0x2)
.maxstack 8

IL_0000: ldnull
IL_0001: throw
} // end of method '<>E__0`1'::Cast

.method public hidebysig static
void StaticExtension () cil managed
{
// Method begins at RVA 0x209f
// Header size: 1
// Code size: 2 (0x2)
.maxstack 8

IL_0000: ldnull
IL_0001: throw
} // end of method '<>E__0`1'::StaticExtension

// Properties
.property instance bool IsEmpty()
{
.get instance bool ICSharpCode.Decompiler.Tests.TestCases.ILPretty.ExtensionPropertiesV1/'<>E__0`1'::get_IsEmpty()
}
.property instance int32 Test()
{
.get instance int32 ICSharpCode.Decompiler.Tests.TestCases.ILPretty.ExtensionPropertiesV1/'<>E__0`1'::get_Test()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.ILPretty.ExtensionPropertiesV1/'<>E__0`1'::set_Test(int32)
}

} // end of class <>E__0`1


// Methods
.method public hidebysig static
bool get_IsEmpty<T> (
class [System.Runtime]System.Collections.Generic.ICollection`1<!!T> collection
) cil managed
{
// Method begins at RVA 0x2050
// Header size: 1
// Code size: 10 (0xa)
.maxstack 8

IL_0000: ldarg.0
IL_0001: callvirt instance int32 class [System.Runtime]System.Collections.Generic.ICollection`1<!!T>::get_Count()
IL_0006: ldc.i4.0
IL_0007: ceq
IL_0009: ret
} // end of method ExtensionProperties::get_IsEmpty

.method public hidebysig static
int32 get_Test<T> (
class [System.Runtime]System.Collections.Generic.ICollection`1<!!T> collection
) cil managed
{
// Method begins at RVA 0x205b
// Header size: 1
// Code size: 4 (0x4)
.maxstack 8

IL_0000: nop
IL_0001: ldc.i4.s 42
IL_0003: ret
} // end of method ExtensionProperties::get_Test

.method public hidebysig static
void set_Test<T> (
class [System.Runtime]System.Collections.Generic.ICollection`1<!!T> collection,
int32 'value'
) cil managed
{
// Method begins at RVA 0x2060
// Header size: 1
// Code size: 2 (0x2)
.maxstack 8

IL_0000: nop
IL_0001: ret
} // end of method ExtensionProperties::set_Test

.method public hidebysig static
void AddIfNotNull<T> (
class [System.Runtime]System.Collections.Generic.ICollection`1<!!T> collection,
!!T item
) cil managed
{
.custom instance void [System.Runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = (
01 00 00 00
)
// Method begins at RVA 0x2064
// Header size: 12
// Code size: 25 (0x19)
.maxstack 2
.locals init (
[0] bool
)

IL_0000: nop
IL_0001: ldarg.1
IL_0002: box !!T
IL_0007: ldnull
IL_0008: cgt.un
IL_000a: stloc.0
IL_000b: ldloc.0
IL_000c: brfalse.s IL_0018

IL_000e: nop
IL_000f: ldarg.0
IL_0010: ldarg.1
IL_0011: callvirt instance void class [System.Runtime]System.Collections.Generic.ICollection`1<!!T>::Add(!0)
IL_0016: nop
IL_0017: nop

IL_0018: ret
} // end of method ExtensionProperties::AddIfNotNull

.method public hidebysig static
!!T2 Cast<T, (!!T) T2> (
class [System.Runtime]System.Collections.Generic.ICollection`1<!!T> collection,
int32 index
) cil managed
{
.custom instance void [System.Runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = (
01 00 00 00
)
// Method begins at RVA 0x2089
// Header size: 1
// Code size: 19 (0x13)
.maxstack 8

IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldarg.1
IL_0003: call !!0 [System.Linq]System.Linq.Enumerable::ElementAt<!!T>(class [System.Runtime]System.Collections.Generic.IEnumerable`1<!!0>, int32)
IL_0008: box !!T
IL_000d: unbox.any !!T2
IL_0012: ret
} // end of method ExtensionProperties::Cast

.method public hidebysig static
void StaticExtension<T> () cil managed
{
// Method begins at RVA 0x2060
// Header size: 1
// Code size: 2 (0x2)
.maxstack 8

IL_0000: nop
IL_0001: ret
} // end of method ExtensionProperties::StaticExtension

} // end of class ICSharpCode.Decompiler.Tests.TestCases.ILPretty.ExtensionPropertiesV1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Collections.Generic;
using System.Linq;
namespace ICSharpCode.Decompiler.Tests.TestCases.ILPretty
{
internal static class ExtensionPropertiesV2
{
extension<T>(ICollection<T> collection) where T : notnull
{
public bool IsEmpty => collection.Count == 0;
public int Test {
get {
return 42;
}
set {
}
}
public void AddIfNotNull(T item)
{
if (item != null)
{
collection.Add(item);
}
}
public T2 Cast<T2>(int index) where T2 : T
{
return (T2)(object)collection.ElementAt(index);
}
public static void StaticExtension()
{
}
}
}
}
Loading
Loading