Browse Source

Rename test case to "ExtensionEverything"

pull/3680/head
Siegfried Pammer 3 months ago
parent
commit
35c88b048f
  1. 2
      ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
  2. 2
      ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
  3. 69
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExtensionEverything.cs
  4. 38
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExtensionProperties.cs

2
ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj

@ -159,7 +159,7 @@ @@ -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" />

2
ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs

@ -560,7 +560,7 @@ namespace ICSharpCode.Decompiler.Tests @@ -560,7 +560,7 @@ namespace ICSharpCode.Decompiler.Tests
}
[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);
}

69
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExtensionEverything.cs

@ -0,0 +1,69 @@ @@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
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);
Console.WriteLine(point.Magnitude);
}
public static void TestExtensionMethods()
{
List<string> collection = new List<string>();
Console.WriteLine(collection.IsEmpty);
collection.AddIfNotNull("Hello");
collection.AddIfNotNull(null);
Console.WriteLine(collection.IsEmpty);
Console.WriteLine(collection.Test);
collection.Test = 100;
List<string>.StaticExtension();
}
}
}

38
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExtensionProperties.cs

@ -1,38 +0,0 @@ @@ -1,38 +0,0 @@
using System.Collections.Generic;
using System.Linq;
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
internal static class ExtensionProperties
{
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…
Cancel
Save