From 2403548ce3479a7481c866ed17da3b551f0d81bf Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 5 Aug 2020 22:10:32 +0200 Subject: [PATCH] Add tests for C# 9.0 lambda parameter discards --- ICSharpCode.Decompiler.Tests/Helpers/Tester.cs | 7 ++++--- ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs | 2 +- .../TestCases/Pretty/DelegateConstruction.cs | 12 ++++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs b/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs index b177b7ef9..6bc3c6a9f 100644 --- a/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs +++ b/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs @@ -251,15 +251,16 @@ namespace ICSharpCode.Decompiler.Tests.Helpers preprocessorSymbols.Add("VB11"); preprocessorSymbols.Add("VB14"); preprocessorSymbols.Add("VB15"); + + if (flags.HasFlag(CompilerOptions.Preview)) { + preprocessorSymbols.Add("CS90"); + } } else if (flags.HasFlag(CompilerOptions.UseMcs)) { preprocessorSymbols.Add("MCS"); } else { preprocessorSymbols.Add("LEGACY_CSC"); preprocessorSymbols.Add("LEGACY_VBC"); } - if (flags.HasFlag(CompilerOptions.Preview)) { - preprocessorSymbols.Add("CS90"); - } return preprocessorSymbols; } diff --git a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs index ceeae1d1a..fa6fc7ccf 100644 --- a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs +++ b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs @@ -155,7 +155,7 @@ namespace ICSharpCode.Decompiler.Tests [Test] public void DelegateConstruction([ValueSource(nameof(defaultOptionsWithMcs))] CompilerOptions cscOptions) { - RunForLibrary(cscOptions: cscOptions); + RunForLibrary(cscOptions: cscOptions | CompilerOptions.Preview); } [Test] diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.cs index a73252ee0..8d5f6fdab 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.cs @@ -428,6 +428,18 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty return () => valueTuple.RenamedString; } #endif + + public static Func Identity() + { + return (T _) => _; + } + +#if CS90 + public static Func LambdaParameterDiscard() + { + return (int _, int _, int _) => 0; + } +#endif } public class Issue1867