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 @@ -159,7 +159,7 @@
<Compile Include="TestCases\ILPretty\Issue3524.cs" />
<Compile Include="TestCases\ILPretty\Issue3552.cs" />
<Compile Include="TestCases\Pretty\ExpandParamsArgumentsDisabled.cs" />
<Compile Include="TestCases\Pretty\ExtensionProperties.cs" />
<Compile Include="TestCases\Pretty\ExtensionEverything.cs" />
<Compile Include="TestCases\Pretty\Issue3452.cs" />
<Compile Include="TestCases\Pretty\Issue3541.cs" />
<Compile Include="TestCases\Pretty\Issue3571_C.cs" />
Expand Down
2 changes: 1 addition & 1 deletion ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ public async Task Issue3598([ValueSource(nameof(roslyn4OrNewerOptions))] Compile
}

[Test]
public async Task ExtensionProperties([ValueSource(nameof(roslyn4OrNewerOptions))] CompilerOptions cscOptions)
public async Task ExtensionEverything([ValueSource(nameof(roslyn4OrNewerOptions))] CompilerOptions cscOptions)
{
await RunForLibrary(cscOptions: cscOptions | CompilerOptions.Preview | CompilerOptions.NullableEnable);
}
Expand Down
110 changes: 110 additions & 0 deletions ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExtensionEverything.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
internal static class EmptyGroups
{
extension(int)
{
}

extension(int x)
{
}

extension(int y)
{
}

extension<T>(IEnumerable<T>)
{
}

extension<T>(IEnumerable<T> x)
{
}

extension<T>(IEnumerable<T> y)
{
}

extension<TKey, TValue>(Dictionary<TKey, TValue>)
{
}

extension<TKey, TValue>(Dictionary<TKey, TValue> x)
{
}

extension<TKey, TValue>(Dictionary<TKey, TValue> y)
{
}
}

internal static class ExtensionEverything
{
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 CastElementAt<T2>(int index) where T2 : T
{
return (T2)(object)collection.ElementAt(index);
}

public static void StaticExtension()
{
}
}

extension(ExtensionEverythingTestUseSites.Point point)
{
public double Magnitude => Math.Sqrt(point.X * point.X + point.Y * point.Y);
}
}

internal class ExtensionEverythingTestUseSites
{
public record struct Point(int X, int Y);

public static void TestExtensionProperty()
{
Point point = new Point(3, 4);
Console.WriteLine(point.X);
Console.WriteLine(point.Y);
// TODO implement use-site transformation
//Console.WriteLine(point.Magnitude);
}

public static void TestExtensionMethods()
{
List<string> collection = new List<string>();
// TODO implement use-site transformation
//Console.WriteLine(collection.IsEmpty);
collection.AddIfNotNull("Hello");
collection.AddIfNotNull(null);
//Console.WriteLine(collection.IsEmpty);
//Console.WriteLine(collection.Test);
//collection.Test = 100;
//List<string>.StaticExtension();
}
}
}

This file was deleted.

Loading
Loading