Browse Source

C# 14 extensions: Add initial test case

pull/3530/head
Siegfried Pammer 5 months ago
parent
commit
685f21edb5
  1. 3
      ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
  2. 6
      ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
  3. 38
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExtensionProperties.cs

3
ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj

@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
<PropertyGroup>
<TargetFramework>net10.0-windows</TargetFramework>
<LangVersion>13</LangVersion>
<LangVersion>preview</LangVersion>
<RuntimeIdentifier Condition="$(IsWindowsX64) == true">win-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="$(IsWindowsARM64) == true">win-arm64</RuntimeIdentifier>
@ -146,6 +146,7 @@ @@ -146,6 +146,7 @@
<Compile Include="TestCases\ILPretty\Issue3442.cs" />
<Compile Include="TestCases\ILPretty\Issue3466.cs" />
<Compile Include="TestCases\ILPretty\Issue3524.cs" />
<Compile Include="TestCases\Pretty\ExtensionProperties.cs" />
<None Include="TestCases\ILPretty\Issue3504.cs" />
<Compile Include="TestCases\ILPretty\MonoFixed.cs" />
<Compile Include="TestCases\Pretty\Comparisons.cs" />

6
ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs

@ -527,6 +527,12 @@ namespace ICSharpCode.Decompiler.Tests @@ -527,6 +527,12 @@ namespace ICSharpCode.Decompiler.Tests
await RunForLibrary(cscOptions: cscOptions | CompilerOptions.NullableEnable);
}
[Test]
public async Task ExtensionProperties([ValueSource(nameof(roslyn4OrNewerOptions))] CompilerOptions cscOptions)
{
await RunForLibrary(cscOptions: cscOptions | CompilerOptions.Preview);
}
[Test]
public async Task NullPropagation([ValueSource(nameof(roslynOnlyOptions))] CompilerOptions cscOptions)
{

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

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
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