diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 8f3a4382f2..c33ff7cb55 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "cake.tool": { - "version": "3.1.0", + "version": "3.2.0", "commands": [ "dotnet-cake" ] diff --git a/.editorconfig b/.editorconfig index a709d6bbf4..c20801b14d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -20,4 +20,14 @@ indent_size = 4 [*.js] indent_style = tab -indent_size = 2 \ No newline at end of file +indent_size = 2 + +# Verify settings +[*.{received,verified}.{txt,xml,json,cake}] +charset = "utf-8-bom" +end_of_line = lf +indent_size = unset +indent_style = unset +insert_final_newline = false +tab_width = unset +trim_trailing_whitespace = false \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index 4cfbb10890..75b9c6b431 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18,7 +18,7 @@ # # Merging from the command prompt will add diff markers to the files if there # are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following +# the diff markers are never inserted). Diff markers may cause the following # file extensions to fail to load in VS. An alternative would be to treat # these files as binary and thus will always conflict and require user # intervention with every merge. To do so, just uncomment the entries below @@ -47,9 +47,9 @@ ############################################################################### # diff behavior for common document formats -# +# # Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the +# is only available from the command line. Turn it on by uncommenting the # entries below. ############################################################################### #*.doc diff=astextplain @@ -61,4 +61,13 @@ #*.pdf diff=astextplain #*.PDF diff=astextplain #*.rtf diff=astextplain -#*.RTF diff=astextplain \ No newline at end of file +#*.RTF diff=astextplain + +############################################################################### +# Verify files +############################################################################### + +*.verified.txt text eol=lf working-tree-encoding=UTF-8 +*.verified.xml text eol=lf working-tree-encoding=UTF-8 +*.verified.json text eol=lf working-tree-encoding=UTF-8 +*.verified.cake text eol=lf working-tree-encoding=UTF-8 \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d5111f6d32..1209ef9f18 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,10 +20,13 @@ jobs: with: fetch-depth: 0 - - name: Install .NET SDK 6.0.x + - name: Install .NET SDK 6.0.x - 8.0.x uses: actions/setup-dotnet@v3 with: - dotnet-version: '6.0.x' + dotnet-version: | + 6.0.x + 7.0.x + 8.0.x - name: Install .NET Core SDK (global.json) uses: actions/setup-dotnet@v3 @@ -46,4 +49,5 @@ jobs: arguments: | CAKE_NETCOREAPP_6_0_VERSION_OS: ${{ steps.build-cake.outputs.CAKE_NETCOREAPP_6_0_VERSION_OS }} CAKE_NETCOREAPP_7_0_VERSION_OS: ${{ steps.build-cake.outputs.CAKE_NETCOREAPP_7_0_VERSION_OS }} - + CAKE_NETCOREAPP_8_0_VERSION_OS: ${{ steps.build-cake.outputs.CAKE_NETCOREAPP_8_0_VERSION_OS }} + ValidateGitHubActionsProvider: true diff --git a/.gitignore b/.gitignore index 9bc26f7992..98ea8ea147 100644 --- a/.gitignore +++ b/.gitignore @@ -94,4 +94,7 @@ Thumbs.db .DS_Store # Generated Assembly info -AssemblyInfo.Generated.cs \ No newline at end of file +AssemblyInfo.Generated.cs + +# Verify +*.received \ No newline at end of file diff --git a/GitVersion.yml b/GitVersion.yml index e34c9bf3b0..08f41c59b1 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1,4 +1,4 @@ -next-version: 3.0.0 +next-version: 4.0.0 branches: master: regex: main diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 314cf10802..c9017d820a 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,3 +1,14 @@ +### New in 4.0.0 (Released 2023/11/18) + +* 4266 Update LatestPotentialBreakingChange to 4.0.0. +* 4132 Add File APIs for setting timestamps (creation time, last write time, last access time). +* 4250 Update System.Collections.Immutable to 8.0.0. +* 4260 Unzip alias should support overwrite files. +* 4251 Update System.Reflection.Metadata 8.0.0. +* 4249 Update Microsoft.Extensions.DependencyInjection to 8.0.0. +* 4197 Execution of Cake script fails if an addin defines an alias that uses nullable reference types in its signature. +* 4150 Cake script is contributing unactionable diagnostics in VS Code Problems pane. + ### New in 3.2.0 (Released 2023/11/10) * 4225 Add DotNetRemovePackage alias for dotnet remove package command. diff --git a/build.cake b/build.cake index 41a4007690..4871764dc1 100644 --- a/build.cake +++ b/build.cake @@ -3,7 +3,7 @@ // Install .NET Core Global tools. #tool "dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=5.12.0" -#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitReleaseManager.Tool&version=0.13.0" +#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitReleaseManager.Tool&version=0.16.0" #tool "dotnet:https://api.nuget.org/v3/index.json?package=sign&version=0.9.1-beta.23530.1&prerelease" // Load other scripts. @@ -108,7 +108,7 @@ Task("Run-Unit-Tests") () => GetFiles("./src/**/*.Tests.csproj"), (parameters, project, context) => { - foreach(var framework in new[] { "net6.0", "net7.0" }) + foreach(var framework in new[] { "net6.0", "net7.0", "net8.0" }) { FilePath testResultsPath = MakeAbsolute(parameters.Paths.Directories.TestResults .CombineWithFilePath($"{project.GetFilenameWithoutExtension()}_{framework}_TestResults.xml")); @@ -368,7 +368,8 @@ Task("Run-Integration-Tests") .DoesForEach( parameters => new[] { GetFiles($"{parameters.Paths.Directories.IntegrationTestsBinTool.FullPath}/**/net6.0/**/Cake.dll").Single(), - GetFiles($"{parameters.Paths.Directories.IntegrationTestsBinTool.FullPath}/**/net7.0/**/Cake.dll").Single() + GetFiles($"{parameters.Paths.Directories.IntegrationTestsBinTool.FullPath}/**/net7.0/**/Cake.dll").Single(), + GetFiles($"{parameters.Paths.Directories.IntegrationTestsBinTool.FullPath}/**/net8.0/**/Cake.dll").Single() }, (parameters, cakeAssembly, context) => { diff --git a/global.json b/global.json index 52954cc8d6..05239f3b96 100644 --- a/global.json +++ b/global.json @@ -3,7 +3,7 @@ "src" ], "sdk": { - "version": "7.0.403", + "version": "8.0.100", "rollForward": "latestFeature" } } \ No newline at end of file diff --git a/src/Cake.Common.Tests/Cake.Common.Tests.csproj b/src/Cake.Common.Tests/Cake.Common.Tests.csproj index 77e3c8f9af..252d2ff0b3 100644 --- a/src/Cake.Common.Tests/Cake.Common.Tests.csproj +++ b/src/Cake.Common.Tests/Cake.Common.Tests.csproj @@ -16,8 +16,8 @@ - - + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Cake.Common/IO/ZipAliases.cs b/src/Cake.Common/IO/ZipAliases.cs index 42188b9a4c..cb91063e62 100644 --- a/src/Cake.Common/IO/ZipAliases.cs +++ b/src/Cake.Common/IO/ZipAliases.cs @@ -135,14 +135,27 @@ public static void Zip(this ICakeContext context, DirectoryPath rootPath, FilePa /// [CakeMethodAlias] public static void Unzip(this ICakeContext context, FilePath zipFile, DirectoryPath outputPath) + => context.Unzip(zipFile, outputPath, false); + + /// + /// Unzips the specified file. + /// + /// The context. + /// Zip file to unzip. + /// Output path to unzip into. + /// Flag for if files should be overwritten in output. + /// + /// + /// Unzip("Cake.zip", "./cake", true); + /// + /// + [CakeMethodAlias] + public static void Unzip(this ICakeContext context, FilePath zipFile, DirectoryPath outputPath, bool overwriteFiles) { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } + ArgumentNullException.ThrowIfNull(context); var zipper = new Zipper(context.FileSystem, context.Environment, context.Log); - zipper.Unzip(zipFile, outputPath); + zipper.Unzip(zipFile, outputPath, overwriteFiles); } } } \ No newline at end of file diff --git a/src/Cake.Common/IO/Zipper.cs b/src/Cake.Common/IO/Zipper.cs index 0b0df02353..252b7fd54b 100644 --- a/src/Cake.Common/IO/Zipper.cs +++ b/src/Cake.Common/IO/Zipper.cs @@ -204,22 +204,25 @@ public void Zip(DirectoryPath rootPath, FilePath outputPath, IEnumerableZip file path. /// Output directory path. public void Unzip(FilePath zipPath, DirectoryPath outputPath) + => Unzip(zipPath, outputPath, false); + + /// + /// Unzips the specified file to the specified output path. + /// + /// Zip file path. + /// Output directory path. + /// Flag for if files should be overwritten in output. + public void Unzip(FilePath zipPath, DirectoryPath outputPath, bool overwriteFiles) { - if (zipPath == null) - { - throw new ArgumentNullException(nameof(zipPath)); - } - if (outputPath == null) - { - throw new ArgumentNullException(nameof(outputPath)); - } + ArgumentNullException.ThrowIfNull(zipPath); + ArgumentNullException.ThrowIfNull(outputPath); // Make root path and output file path absolute. zipPath = zipPath.MakeAbsolute(_environment); outputPath = outputPath.MakeAbsolute(_environment); - _log.Verbose("Unzipping file {0} to {1}", zipPath.FullPath, outputPath.FullPath); - ZipFile.ExtractToDirectory(zipPath.FullPath, outputPath.FullPath); + _log.Verbose("Unzipping file {0} to {1} (overwrite files: {2})", zipPath.FullPath, outputPath.FullPath, overwriteFiles); + ZipFile.ExtractToDirectory(zipPath.FullPath, outputPath.FullPath, overwriteFiles); } private string GetRelativePath(DirectoryPath root, Path path) diff --git a/src/Cake.Core.Tests/Cake.Core.Tests.csproj b/src/Cake.Core.Tests/Cake.Core.Tests.csproj index 617f0a86cd..5e487992f3 100644 --- a/src/Cake.Core.Tests/Cake.Core.Tests.csproj +++ b/src/Cake.Core.Tests/Cake.Core.Tests.csproj @@ -14,8 +14,10 @@ - - + + + + all runtime; build; native; contentfiles; analyzers @@ -24,7 +26,6 @@ - \ No newline at end of file diff --git a/src/Cake.Core.Tests/Data/MethodAliasGeneratorData.cs b/src/Cake.Core.Tests/Data/MethodAliasGeneratorData.cs index 5faca2b3eb..c81008e33e 100644 --- a/src/Cake.Core.Tests/Data/MethodAliasGeneratorData.cs +++ b/src/Cake.Core.Tests/Data/MethodAliasGeneratorData.cs @@ -246,5 +246,21 @@ public static dynamic NonGeneric_ExtensionMethodWithDynamicReturnValue(this ICak { throw new NotImplementedException(); } + + [CakeMethodAlias] +#nullable enable + public static void NonGeneric_ExtensionMethodWithNullableParameter(this ICakeContext context, string? parameter) +#nullable disable + { + throw new NotImplementedException(); + } + + [CakeMethodAlias] +#nullable enable + public static string? NonGeneric_ExtensionMethodWithNullableReturnValue(this ICakeContext context) +#nullable disable + { + throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/src/Cake.Core.Tests/Data/PropertyAliasGeneratorData.cs b/src/Cake.Core.Tests/Data/PropertyAliasGeneratorData.cs index 06542fc8e4..bcfc01a80f 100644 --- a/src/Cake.Core.Tests/Data/PropertyAliasGeneratorData.cs +++ b/src/Cake.Core.Tests/Data/PropertyAliasGeneratorData.cs @@ -123,5 +123,13 @@ public static int Cached_Obsolete_ExplicitError_WithMessage(this ICakeContext co { throw new NotImplementedException(); } + + [CakePropertyAlias(Cache = true)] +#nullable enable + public static string? Cached_Nullable_Type(this ICakeContext context) +#nullable disable + { + throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/src/Cake.Core.Tests/Exceptions/CustomeExitCodeTests.cs b/src/Cake.Core.Tests/Exceptions/CustomeExitCodeTests.cs deleted file mode 100644 index 38b37db0e7..0000000000 --- a/src/Cake.Core.Tests/Exceptions/CustomeExitCodeTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Xunit; - -namespace Cake.Core.Tests.Exceptions -{ - public class CustomeExitCodeTests - { - [Fact] - public void Should_Return_Default_ExitCode() - { - var exception = new CakeException(); - Assert.Equal(1, exception.ExitCode); - } - - [Fact] - public void Should_Return_Custom_ExitCode() - { - var exception = new CakeException(5); - Assert.Equal(5, exception.ExitCode); - } - } -} diff --git a/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Generic_Methods_name=Generic_ExtensionMethod.verified.cake b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Generic_Methods_name=Generic_ExtensionMethod.verified.cake new file mode 100644 index 0000000000..32e48d1be2 --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Generic_Methods_name=Generic_ExtensionMethod.verified.cake @@ -0,0 +1,3 @@ +[System.Diagnostics.DebuggerStepThrough] +public void Generic_ExtensionMethod() + => Cake.Core.Tests.Data.MethodAliasGeneratorData.Generic_ExtensionMethod(Context); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Generic_Methods_name=Generic_ExtensionMethodWithGenericReturnValue.verified.cake b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Generic_Methods_name=Generic_ExtensionMethodWithGenericReturnValue.verified.cake new file mode 100644 index 0000000000..6ed38f7ff1 --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Generic_Methods_name=Generic_ExtensionMethodWithGenericReturnValue.verified.cake @@ -0,0 +1,3 @@ +[System.Diagnostics.DebuggerStepThrough] +public TTest Generic_ExtensionMethodWithGenericReturnValue(TTest value) + => Cake.Core.Tests.Data.MethodAliasGeneratorData.Generic_ExtensionMethodWithGenericReturnValue(Context, value); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Generic_ExtensionMethodWithGenericReturnValueAndTypeParamConstraints b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Generic_Methods_name=Generic_ExtensionMethodWithGenericReturnValueAndTypeParamConstraints.verified.cake similarity index 59% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Generic_ExtensionMethodWithGenericReturnValueAndTypeParamConstraints rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Generic_Methods_name=Generic_ExtensionMethodWithGenericReturnValueAndTypeParamConstraints.verified.cake index 2c686ebe56..460f1bef3c 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Generic_ExtensionMethodWithGenericReturnValueAndTypeParamConstraints +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Generic_Methods_name=Generic_ExtensionMethodWithGenericReturnValueAndTypeParamConstraints.verified.cake @@ -2,6 +2,4 @@ public TOut Generic_ExtensionMethodWithGenericReturnValueAndTypeParamConstraints(TIn arg) where TIn : class, new() where TOut : System.Collections.ArrayList, System.IDisposable -{ - return Cake.Core.Tests.Data.MethodAliasGeneratorData.Generic_ExtensionMethodWithGenericReturnValueAndTypeParamConstraints(Context, arg); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.Generic_ExtensionMethodWithGenericReturnValueAndTypeParamConstraints(Context, arg); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Generic_Methods_name=Generic_ExtensionMethodWithParameter.verified.cake b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Generic_Methods_name=Generic_ExtensionMethodWithParameter.verified.cake new file mode 100644 index 0000000000..243e4c734a --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Generic_Methods_name=Generic_ExtensionMethodWithParameter.verified.cake @@ -0,0 +1,3 @@ +[System.Diagnostics.DebuggerStepThrough] +public void Generic_ExtensionMethodWithParameter(TTest value) + => Cake.Core.Tests.Data.MethodAliasGeneratorData.Generic_ExtensionMethodWithParameter(Context, value); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithDynamicReturnValue.verified.cake b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithDynamicReturnValue.verified.cake new file mode 100644 index 0000000000..176b3d095a --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithDynamicReturnValue.verified.cake @@ -0,0 +1,3 @@ +[System.Diagnostics.DebuggerStepThrough] +public dynamic NonGeneric_ExtensionMethodWithDynamicReturnValue() + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithDynamicReturnValue(Context); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithGenericCollectionOfNestedType b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithGenericCollectionOfNestedType.verified.cake similarity index 63% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithGenericCollectionOfNestedType rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithGenericCollectionOfNestedType.verified.cake index 63f1d940ff..3df11a5ceb 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithGenericCollectionOfNestedType +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithGenericCollectionOfNestedType.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithGenericCollectionOfNestedType(System.Collections.Generic.ICollection items) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericCollectionOfNestedType(Context, items); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericCollectionOfNestedType(Context, items); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithGenericExpressionArrayParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithGenericExpressionArrayParameter.verified.cake similarity index 60% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithGenericExpressionArrayParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithGenericExpressionArrayParameter.verified.cake index 4f2f20600c..0473c84c68 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithGenericExpressionArrayParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithGenericExpressionArrayParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithGenericExpressionArrayParameter(System.Linq.Expressions.Expression>[] expression) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericExpressionArrayParameter(Context, expression); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericExpressionArrayParameter(Context, expression); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithGenericExpressionParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithGenericExpressionParameter.verified.cake similarity index 60% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithGenericExpressionParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithGenericExpressionParameter.verified.cake index d6938025dd..6fab8485d2 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithGenericExpressionParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithGenericExpressionParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithGenericExpressionParameter(System.Linq.Expressions.Expression> expression) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericExpressionParameter(Context, expression); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericExpressionParameter(Context, expression); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithGenericExpressionParamsArrayParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithGenericExpressionParamsArrayParameter.verified.cake similarity index 60% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithGenericExpressionParamsArrayParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithGenericExpressionParamsArrayParameter.verified.cake index adef40989b..e0fc61c506 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithGenericExpressionParamsArrayParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithGenericExpressionParamsArrayParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithGenericExpressionParamsArrayParameter(params System.Linq.Expressions.Expression>[] expression) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericExpressionParamsArrayParameter(Context, expression); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericExpressionParamsArrayParameter(Context, expression); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithGenericParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithGenericParameter.verified.cake similarity index 54% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithGenericParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithGenericParameter.verified.cake index b0cc1889fd..72fbd4a722 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithGenericParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithGenericParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithGenericParameter(System.Action value) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericParameter(Context, value); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericParameter(Context, value); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithNoParameters.verified.cake b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithNoParameters.verified.cake new file mode 100644 index 0000000000..ca74b8c2c7 --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithNoParameters.verified.cake @@ -0,0 +1,3 @@ +[System.Diagnostics.DebuggerStepThrough] +public void NonGeneric_ExtensionMethodWithNoParameters() + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithNoParameters(Context); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithNullableParameter.verified.cake b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithNullableParameter.verified.cake new file mode 100644 index 0000000000..756f9ffafc --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithNullableParameter.verified.cake @@ -0,0 +1,3 @@ +[System.Diagnostics.DebuggerStepThrough] +public void NonGeneric_ExtensionMethodWithNullableParameter(System.String? parameter) + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithNullableParameter(Context, parameter); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithNullableReturnValue.verified.cake b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithNullableReturnValue.verified.cake new file mode 100644 index 0000000000..a2ed6d19ac --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithNullableReturnValue.verified.cake @@ -0,0 +1,3 @@ +[System.Diagnostics.DebuggerStepThrough] +public System.String? NonGeneric_ExtensionMethodWithNullableReturnValue() + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithNullableReturnValue(Context); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalBooleanParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalBooleanParameter.verified.cake similarity index 54% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalBooleanParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalBooleanParameter.verified.cake index 0e55a933cf..a582e31fdb 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalBooleanParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalBooleanParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithOptionalBooleanParameter(System.Int32 value, System.Boolean flag = false) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalBooleanParameter(Context, value, flag); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalBooleanParameter(Context, value, flag); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalCharParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalCharParameter.verified.cake similarity index 54% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalCharParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalCharParameter.verified.cake index b4a6ae2b04..a89ab1efed 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalCharParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalCharParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithOptionalCharParameter(System.String s, System.Char c = 's') -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalCharParameter(Context, s, c); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalCharParameter(Context, s, c); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalDecimalParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalDecimalParameter.verified.cake similarity index 57% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalDecimalParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalDecimalParameter.verified.cake index 4fee401a0b..bf6d48a86e 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalDecimalParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalDecimalParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithOptionalDecimalParameter(System.String s, System.Decimal value = (System.Decimal)12.12) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalDecimalParameter(Context, s, value); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalDecimalParameter(Context, s, value); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalEnumParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalEnumParameter.verified.cake similarity index 59% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalEnumParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalEnumParameter.verified.cake index 5219816d75..9b9f861896 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalEnumParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalEnumParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithOptionalEnumParameter(System.Int32 value, System.AttributeTargets targets = (System.AttributeTargets)4) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalEnumParameter(Context, value, targets); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalEnumParameter(Context, value, targets); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableBooleanParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableBooleanParameter.verified.cake similarity index 59% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableBooleanParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableBooleanParameter.verified.cake index 5fc4d9a697..ed9dc89338 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableBooleanParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableBooleanParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithOptionalNullableBooleanParameter(System.String s, System.Nullable value = (System.Boolean)false) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableBooleanParameter(Context, s, value); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableBooleanParameter(Context, s, value); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableCharParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableCharParameter.verified.cake similarity index 58% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableCharParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableCharParameter.verified.cake index 49504fb8ee..b883d52848 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableCharParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableCharParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithOptionalNullableCharParameter(System.String s, System.Nullable value = (System.Char)'s') -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableCharParameter(Context, s, value); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableCharParameter(Context, s, value); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableDecimalParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableDecimalParameter.verified.cake similarity index 59% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableDecimalParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableDecimalParameter.verified.cake index 9d4cd6c2d8..96bfe95405 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableDecimalParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableDecimalParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithOptionalNullableDecimalParameter(System.String s, System.Nullable value = (System.Decimal)123.12) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableDecimalParameter(Context, s, value); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableDecimalParameter(Context, s, value); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableDoubleParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableDoubleParameter.verified.cake similarity index 60% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableDoubleParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableDoubleParameter.verified.cake index b6ab059a48..ff56f6e3e0 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableDoubleParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableDoubleParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithOptionalNullableDoubleParameter(System.String s, System.Nullable value = (System.Double)1234567890.12) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableDoubleParameter(Context, s, value); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableDoubleParameter(Context, s, value); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableEnumParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableEnumParameter.verified.cake similarity index 61% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableEnumParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableEnumParameter.verified.cake index 1bdc60c744..e7fa4aeeb1 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableEnumParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableEnumParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithOptionalNullableEnumParameter(System.String s, System.Nullable targets = (System.AttributeTargets)4) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableEnumParameter(Context, s, targets); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableEnumParameter(Context, s, targets); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableLongParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableLongParameter.verified.cake similarity index 59% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableLongParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableLongParameter.verified.cake index c8b25f8cae..53d3146e72 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableLongParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableLongParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithOptionalNullableLongParameter(System.String s, System.Nullable value = (System.Int64)1234567890) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableLongParameter(Context, s, value); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableLongParameter(Context, s, value); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableTParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableTParameter.verified.cake similarity index 58% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableTParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableTParameter.verified.cake index 5df7b4ef28..83efdef1d6 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalNullableTParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalNullableTParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithOptionalNullableTParameter(System.String s, System.Nullable value = (System.Int32)0) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableTParameter(Context, s, value); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableTParameter(Context, s, value); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalObjectParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalObjectParameter.verified.cake similarity index 54% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalObjectParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalObjectParameter.verified.cake index 82c9bac65f..921c14ade0 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalObjectParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalObjectParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithOptionalObjectParameter(System.Int32 value, System.Object option = null) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalObjectParameter(Context, value, option); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalObjectParameter(Context, value, option); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalStringParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalStringParameter.verified.cake similarity index 60% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalStringParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalStringParameter.verified.cake index 1b8260d784..855d08957c 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOptionalStringParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOptionalStringParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithOptionalStringParameter(System.Int32 value, System.String s = "there is a \"string\" here and a \t tab") -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalStringParameter(Context, value, s); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalStringParameter(Context, value, s); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOutputParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOutputParameter.verified.cake similarity index 52% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOutputParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOutputParameter.verified.cake index 800ce262a6..c6f8631591 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithOutputParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithOutputParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithOutputParameter(out System.IDisposable arg) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOutputParameter(Context, out arg); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOutputParameter(Context, out arg); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithParameter.verified.cake similarity index 51% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithParameter.verified.cake index 196d594e5b..5ace2e0914 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithParameter(System.Int32 value) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithParameter(Context, value); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithParameter(Context, value); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithParameterArray b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithParameterArray.verified.cake similarity index 53% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithParameterArray rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithParameterArray.verified.cake index c265f0b697..8d44f06ec5 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithParameterArray +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithParameterArray.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithParameterArray(params System.Int32[] values) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithParameterArray(Context, values); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithParameterArray(Context, values); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithParameterAttributes b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithParameterAttributes.verified.cake similarity index 70% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithParameterAttributes rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithParameterAttributes.verified.cake index 39391cc7f4..f3ae8f531d 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithParameterAttributes +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithParameterAttributes.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithParameterAttributes([System.Runtime.CompilerServices.CallerMemberName] System.String memberName = "", [System.Runtime.CompilerServices.CallerFilePath] System.String sourceFilePath = "", [System.Runtime.CompilerServices.CallerLineNumber] System.Int32 sourceLineNumber = (System.Int32)0) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithParameterAttributes(Context, memberName, sourceFilePath, sourceLineNumber); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithParameterAttributes(Context, memberName, sourceFilePath, sourceLineNumber); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithReservedKeywordParameter b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithReservedKeywordParameter.verified.cake similarity index 51% rename from src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithReservedKeywordParameter rename to src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithReservedKeywordParameter.verified.cake index c16ac53884..f3fc73d725 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithReservedKeywordParameter +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithReservedKeywordParameter.verified.cake @@ -1,5 +1,3 @@ [System.Diagnostics.DebuggerStepThrough] public void NonGeneric_ExtensionMethodWithReservedKeywordParameter(System.Int32 @new) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithReservedKeywordParameter(Context, @new); -} \ No newline at end of file + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithReservedKeywordParameter(Context, @new); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithReturnValue.verified.cake b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithReturnValue.verified.cake new file mode 100644 index 0000000000..3af6e2ae3e --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Non_Generic_Methods_name=ExtensionMethodWithReturnValue.verified.cake @@ -0,0 +1,3 @@ +[System.Diagnostics.DebuggerStepThrough] +public System.String NonGeneric_ExtensionMethodWithReturnValue() + => Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithReturnValue(Context); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Obsolete_Methods_name=Obsolete_ExplicitError_WithMessage.verified.cake b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Obsolete_Methods_name=Obsolete_ExplicitError_WithMessage.verified.cake new file mode 100644 index 0000000000..a87e6874ad --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Obsolete_Methods_name=Obsolete_ExplicitError_WithMessage.verified.cake @@ -0,0 +1,3 @@ +[System.Diagnostics.DebuggerStepThrough] +public void Obsolete_ExplicitError_WithMessage() + => throw new Cake.Core.CakeException("The alias Obsolete_ExplicitError_WithMessage has been made obsolete. Please use Foo.Bar instead."); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Obsolete_Methods_name=Obsolete_ExplicitWarning_WithMessage.verified.cake b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Obsolete_Methods_name=Obsolete_ExplicitWarning_WithMessage.verified.cake new file mode 100644 index 0000000000..c617650e9c --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Obsolete_Methods_name=Obsolete_ExplicitWarning_WithMessage.verified.cake @@ -0,0 +1,5 @@ +[System.Diagnostics.DebuggerStepThrough] +public void Obsolete_ExplicitWarning_WithMessage() +#pragma warning disable 0618 + => Cake.Core.Tests.Data.MethodAliasGeneratorData.Obsolete_ExplicitWarning_WithMessage(Context); +#pragma warning restore 0618 \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Obsolete_Methods_name=Obsolete_ImplicitWarning_NoMessage.verified.cake b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Obsolete_Methods_name=Obsolete_ImplicitWarning_NoMessage.verified.cake new file mode 100644 index 0000000000..ace37bde77 --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Obsolete_Methods_name=Obsolete_ImplicitWarning_NoMessage.verified.cake @@ -0,0 +1,5 @@ +[System.Diagnostics.DebuggerStepThrough] +public void Obsolete_ImplicitWarning_NoMessage() +#pragma warning disable 0618 + => Cake.Core.Tests.Data.MethodAliasGeneratorData.Obsolete_ImplicitWarning_NoMessage(Context); +#pragma warning restore 0618 \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Obsolete_Methods_name=Obsolete_ImplicitWarning_WithMessage.verified.cake b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Obsolete_Methods_name=Obsolete_ImplicitWarning_WithMessage.verified.cake new file mode 100644 index 0000000000..1962dbc49e --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/MethodAliasGeneratorTests.TheGeneratorMethod.Should_Return_Correct_Generated_Code_For_Obsolete_Methods_name=Obsolete_ImplicitWarning_WithMessage.verified.cake @@ -0,0 +1,5 @@ +[System.Diagnostics.DebuggerStepThrough] +public void Obsolete_ImplicitWarning_WithMessage() +#pragma warning disable 0618 + => Cake.Core.Tests.Data.MethodAliasGeneratorData.Obsolete_ImplicitWarning_WithMessage(Context); +#pragma warning restore 0618 \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Obsolete_Properties_name=Cached_Obsolete_ExplicitError_WithMessage.verified.cake b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Obsolete_Properties_name=Cached_Obsolete_ExplicitError_WithMessage.verified.cake new file mode 100644 index 0000000000..d25430c7c4 --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Obsolete_Properties_name=Cached_Obsolete_ExplicitError_WithMessage.verified.cake @@ -0,0 +1,5 @@ +[Obsolete("Please use Foo.Bar instead.", true)] +public System.Int32 Cached_Obsolete_ExplicitError_WithMessage +#pragma warning disable CS0618 + => Cake.Core.Tests.Data.PropertyAliasGeneratorData.Cached_Obsolete_ExplicitError_WithMessage(Context); +#pragma warning restore CS0618 \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Obsolete_Properties_name=Cached_Obsolete_ExplicitWarning_WithMessage.verified.cake b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Obsolete_Properties_name=Cached_Obsolete_ExplicitWarning_WithMessage.verified.cake new file mode 100644 index 0000000000..15df323b2b --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Obsolete_Properties_name=Cached_Obsolete_ExplicitWarning_WithMessage.verified.cake @@ -0,0 +1,6 @@ +private System.Int32? _Cached_Obsolete_ExplicitWarning_WithMessage; +[Obsolete("Please use Foo.Bar instead.", false)] +public System.Int32 Cached_Obsolete_ExplicitWarning_WithMessage +#pragma warning disable CS0618 + => _Cached_Obsolete_ExplicitWarning_WithMessage ??= Cake.Core.Tests.Data.PropertyAliasGeneratorData.Cached_Obsolete_ExplicitWarning_WithMessage(Context); +#pragma warning restore CS0618 \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Obsolete_Properties_name=Cached_Obsolete_ImplicitWarning_NoMessage.verified.cake b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Obsolete_Properties_name=Cached_Obsolete_ImplicitWarning_NoMessage.verified.cake new file mode 100644 index 0000000000..6758a9c930 --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Obsolete_Properties_name=Cached_Obsolete_ImplicitWarning_NoMessage.verified.cake @@ -0,0 +1,6 @@ +private System.Int32? _Cached_Obsolete_ImplicitWarning_NoMessage; +[Obsolete] +public System.Int32 Cached_Obsolete_ImplicitWarning_NoMessage +#pragma warning disable CS0618 + => _Cached_Obsolete_ImplicitWarning_NoMessage ??= Cake.Core.Tests.Data.PropertyAliasGeneratorData.Cached_Obsolete_ImplicitWarning_NoMessage(Context); +#pragma warning restore CS0618 \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Obsolete_Properties_name=Cached_Obsolete_ImplicitWarning_WithMessage.verified.cake b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Obsolete_Properties_name=Cached_Obsolete_ImplicitWarning_WithMessage.verified.cake new file mode 100644 index 0000000000..ffea761aa4 --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Obsolete_Properties_name=Cached_Obsolete_ImplicitWarning_WithMessage.verified.cake @@ -0,0 +1,6 @@ +private System.Int32? _Cached_Obsolete_ImplicitWarning_WithMessage; +[Obsolete("Please use Foo.Bar instead.", false)] +public System.Int32 Cached_Obsolete_ImplicitWarning_WithMessage +#pragma warning disable CS0618 + => _Cached_Obsolete_ImplicitWarning_WithMessage ??= Cake.Core.Tests.Data.PropertyAliasGeneratorData.Cached_Obsolete_ImplicitWarning_WithMessage(Context); +#pragma warning restore CS0618 \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Properties_name=Cached_Dynamic_Type.verified.cake b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Properties_name=Cached_Dynamic_Type.verified.cake new file mode 100644 index 0000000000..ee26752285 --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Properties_name=Cached_Dynamic_Type.verified.cake @@ -0,0 +1,3 @@ +private dynamic _Cached_Dynamic_Type; +public dynamic Cached_Dynamic_Type + => _Cached_Dynamic_Type ??= Cake.Core.Tests.Data.PropertyAliasGeneratorData.Cached_Dynamic_Type(Context); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Properties_name=Cached_Nullable_Type.verified.cake b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Properties_name=Cached_Nullable_Type.verified.cake new file mode 100644 index 0000000000..247a2cb74c --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Properties_name=Cached_Nullable_Type.verified.cake @@ -0,0 +1,3 @@ +private System.String? _Cached_Nullable_Type; +public System.String? Cached_Nullable_Type + => _Cached_Nullable_Type ??= Cake.Core.Tests.Data.PropertyAliasGeneratorData.Cached_Nullable_Type(Context); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Properties_name=Cached_Reference_Type.verified.cake b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Properties_name=Cached_Reference_Type.verified.cake new file mode 100644 index 0000000000..f76291c846 --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Properties_name=Cached_Reference_Type.verified.cake @@ -0,0 +1,3 @@ +private System.String _Cached_Reference_Type; +public System.String Cached_Reference_Type + => _Cached_Reference_Type ??= Cake.Core.Tests.Data.PropertyAliasGeneratorData.Cached_Reference_Type(Context); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Properties_name=Cached_Value_Type.verified.cake b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Properties_name=Cached_Value_Type.verified.cake new file mode 100644 index 0000000000..87cd6a7249 --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Cached_Properties_name=Cached_Value_Type.verified.cake @@ -0,0 +1,3 @@ +private System.Boolean? _Cached_Value_Type; +public System.Boolean Cached_Value_Type + => _Cached_Value_Type ??= Cake.Core.Tests.Data.PropertyAliasGeneratorData.Cached_Value_Type(Context); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Non_Cached_Obsolete_Properties_name=NonCached_Obsolete_ExplicitError_WithMessage.verified.cake b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Non_Cached_Obsolete_Properties_name=NonCached_Obsolete_ExplicitError_WithMessage.verified.cake new file mode 100644 index 0000000000..a13ad1d445 --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Non_Cached_Obsolete_Properties_name=NonCached_Obsolete_ExplicitError_WithMessage.verified.cake @@ -0,0 +1,5 @@ +[Obsolete("Please use Foo.Bar instead.", true)] +public System.Int32 NonCached_Obsolete_ExplicitError_WithMessage +#pragma warning disable CS0618 + => Cake.Core.Tests.Data.PropertyAliasGeneratorData.NonCached_Obsolete_ExplicitError_WithMessage(Context); +#pragma warning restore CS0618 \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Non_Cached_Obsolete_Properties_name=NonCached_Obsolete_ExplicitWarning_WithMessage.verified.cake b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Non_Cached_Obsolete_Properties_name=NonCached_Obsolete_ExplicitWarning_WithMessage.verified.cake new file mode 100644 index 0000000000..16d4002b73 --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Non_Cached_Obsolete_Properties_name=NonCached_Obsolete_ExplicitWarning_WithMessage.verified.cake @@ -0,0 +1,5 @@ +[Obsolete("Please use Foo.Bar instead.", false)] +public System.Int32 NonCached_Obsolete_ExplicitWarning_WithMessage +#pragma warning disable CS0618 + => Cake.Core.Tests.Data.PropertyAliasGeneratorData.NonCached_Obsolete_ExplicitWarning_WithMessage(Context); +#pragma warning restore CS0618 \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Non_Cached_Obsolete_Properties_name=NonCached_Obsolete_ImplicitWarning_NoMessage.verified.cake b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Non_Cached_Obsolete_Properties_name=NonCached_Obsolete_ImplicitWarning_NoMessage.verified.cake new file mode 100644 index 0000000000..c770e57722 --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Non_Cached_Obsolete_Properties_name=NonCached_Obsolete_ImplicitWarning_NoMessage.verified.cake @@ -0,0 +1,5 @@ +[Obsolete] +public System.Int32 NonCached_Obsolete_ImplicitWarning_NoMessage +#pragma warning disable CS0618 + => Cake.Core.Tests.Data.PropertyAliasGeneratorData.NonCached_Obsolete_ImplicitWarning_NoMessage(Context); +#pragma warning restore CS0618 \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Non_Cached_Obsolete_Properties_name=NonCached_Obsolete_ImplicitWarning_WithMessage.verified.cake b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Non_Cached_Obsolete_Properties_name=NonCached_Obsolete_ImplicitWarning_WithMessage.verified.cake new file mode 100644 index 0000000000..cc739cad85 --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Non_Cached_Obsolete_Properties_name=NonCached_Obsolete_ImplicitWarning_WithMessage.verified.cake @@ -0,0 +1,5 @@ +[Obsolete("Please use Foo.Bar instead.", false)] +public System.Int32 NonCached_Obsolete_ImplicitWarning_WithMessage +#pragma warning disable CS0618 + => Cake.Core.Tests.Data.PropertyAliasGeneratorData.NonCached_Obsolete_ImplicitWarning_WithMessage(Context); +#pragma warning restore CS0618 \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Non_Cached_Properties_name=NonCached_Dynamic_Type.verified.cake b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Non_Cached_Properties_name=NonCached_Dynamic_Type.verified.cake new file mode 100644 index 0000000000..2d9c520175 --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Non_Cached_Properties_name=NonCached_Dynamic_Type.verified.cake @@ -0,0 +1,2 @@ +public dynamic NonCached_Dynamic_Type + => Cake.Core.Tests.Data.PropertyAliasGeneratorData.NonCached_Dynamic_Type(Context); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Non_Cached_Properties_name=NonCached_Value_Type.verified.cake b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Non_Cached_Properties_name=NonCached_Value_Type.verified.cake new file mode 100644 index 0000000000..3a339fd775 --- /dev/null +++ b/src/Cake.Core.Tests/Expectations/PropertyAliasGeneratorTests.TheGenerateMethod.Should_Return_Correct_Generated_Code_For_Non_Cached_Properties_name=NonCached_Value_Type.verified.cake @@ -0,0 +1,2 @@ +public System.Int32 NonCached_Value_Type + => Cake.Core.Tests.Data.PropertyAliasGeneratorData.NonCached_Value_Type(Context); \ No newline at end of file diff --git a/src/Cake.Core.Tests/Fixtures/MethodAliasGeneratorFixture.cs b/src/Cake.Core.Tests/Fixtures/MethodAliasGeneratorFixture.cs index 3917db8fe8..eae535d452 100644 --- a/src/Cake.Core.Tests/Fixtures/MethodAliasGeneratorFixture.cs +++ b/src/Cake.Core.Tests/Fixtures/MethodAliasGeneratorFixture.cs @@ -13,32 +13,13 @@ namespace Cake.Core.Tests.Fixtures { public sealed class MethodAliasGeneratorFixture { - private readonly Assembly _assembly; private readonly MethodInfo[] _methods; public MethodAliasGeneratorFixture() { - _assembly = typeof(MethodAliasGeneratorFixture).GetTypeInfo().Assembly; _methods = typeof(MethodAliasGeneratorData).GetMethods(); } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times")] - public string GetExpectedCode(string name) - { - var resource = string.Concat("Cake.Core.Tests.Unit.Scripting.CodeGen.Expected.Methods.", name); - using (var stream = _assembly.GetManifestResourceStream(resource)) - { - if (stream == null) - { - throw new InvalidOperationException("Could not load manifest resource stream."); - } - using (var reader = new StreamReader(stream)) - { - return reader.ReadToEnd().NormalizeGeneratedCode(); - } - } - } - public string Generate(string name) { var method = _methods.SingleOrDefault(x => x.Name == name); diff --git a/src/Cake.Core.Tests/Fixtures/PropertyAliasGeneratorFixture.cs b/src/Cake.Core.Tests/Fixtures/PropertyAliasGeneratorFixture.cs index a65046b55c..05edf31455 100644 --- a/src/Cake.Core.Tests/Fixtures/PropertyAliasGeneratorFixture.cs +++ b/src/Cake.Core.Tests/Fixtures/PropertyAliasGeneratorFixture.cs @@ -22,23 +22,6 @@ public PropertyAliasGeneratorFixture() _methods = typeof(PropertyAliasGeneratorData).GetMethods(); } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times")] - public string GetExpectedData(string name) - { - var resource = string.Concat("Cake.Core.Tests.Unit.Scripting.CodeGen.Expected.Properties.", name); - using (var stream = _assembly.GetManifestResourceStream(resource)) - { - if (stream == null) - { - throw new InvalidOperationException("Could not load manifest resource stream."); - } - using (var reader = new StreamReader(stream)) - { - return reader.ReadToEnd().NormalizeGeneratedCode(); - } - } - } - public string Generate(string name) { var method = _methods.SingleOrDefault(x => x.Name == name); diff --git a/src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs b/src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs index 65cb681b09..54a72754a1 100644 --- a/src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs +++ b/src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs @@ -39,7 +39,9 @@ public void Should_Return_Correct_Result_For_CoreClr() Assert.Equal(".NETStandard,Version=v2.0", framework.FullName); #else var expect = string.Concat(".NETCoreApp,Version=v", -#if NET7_0 +#if NET8_0 + "8.0"); +#elif NET7_0 "7.0"); #elif NET6_0 "6.0"); diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Generic_ExtensionMethod b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Generic_ExtensionMethod deleted file mode 100644 index 3dc2260389..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Generic_ExtensionMethod +++ /dev/null @@ -1,5 +0,0 @@ -[System.Diagnostics.DebuggerStepThrough] -public void Generic_ExtensionMethod() -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.Generic_ExtensionMethod(Context); -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Generic_ExtensionMethodWithGenericReturnValue b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Generic_ExtensionMethodWithGenericReturnValue deleted file mode 100644 index 98ad68a1b4..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Generic_ExtensionMethodWithGenericReturnValue +++ /dev/null @@ -1,5 +0,0 @@ -[System.Diagnostics.DebuggerStepThrough] -public TTest Generic_ExtensionMethodWithGenericReturnValue(TTest value) -{ - return Cake.Core.Tests.Data.MethodAliasGeneratorData.Generic_ExtensionMethodWithGenericReturnValue(Context, value); -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Generic_ExtensionMethodWithParameter b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Generic_ExtensionMethodWithParameter deleted file mode 100644 index 44046190c2..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Generic_ExtensionMethodWithParameter +++ /dev/null @@ -1,5 +0,0 @@ -[System.Diagnostics.DebuggerStepThrough] -public void Generic_ExtensionMethodWithParameter(TTest value) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.Generic_ExtensionMethodWithParameter(Context, value); -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithArrayParameter b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithArrayParameter deleted file mode 100644 index cbf59c7a7f..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithArrayParameter +++ /dev/null @@ -1,5 +0,0 @@ -[System.Diagnostics.DebuggerStepThrough] -public void NonGeneric_ExtensionMethodWithArrayParameter(System.String[] values) -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithArrayParameter(Context, values); -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithDynamicReturnValue b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithDynamicReturnValue deleted file mode 100644 index 4f21aed07e..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithDynamicReturnValue +++ /dev/null @@ -1,5 +0,0 @@ -[System.Diagnostics.DebuggerStepThrough] -public dynamic NonGeneric_ExtensionMethodWithDynamicReturnValue() -{ - return Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithDynamicReturnValue(Context); -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithNoParameters b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithNoParameters deleted file mode 100644 index 4377daf9c0..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithNoParameters +++ /dev/null @@ -1,5 +0,0 @@ -[System.Diagnostics.DebuggerStepThrough] -public void NonGeneric_ExtensionMethodWithNoParameters() -{ - Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithNoParameters(Context); -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithReturnValue b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithReturnValue deleted file mode 100644 index 8075bdc12d..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/NonGeneric_ExtensionMethodWithReturnValue +++ /dev/null @@ -1,5 +0,0 @@ -[System.Diagnostics.DebuggerStepThrough] -public System.String NonGeneric_ExtensionMethodWithReturnValue() -{ - return Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithReturnValue(Context); -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Obsolete_ExplicitError_WithMessage b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Obsolete_ExplicitError_WithMessage deleted file mode 100644 index d180837ad1..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Obsolete_ExplicitError_WithMessage +++ /dev/null @@ -1,5 +0,0 @@ -[System.Diagnostics.DebuggerStepThrough] -public void Obsolete_ExplicitError_WithMessage() -{ - throw new Cake.Core.CakeException("The alias Obsolete_ExplicitError_WithMessage has been made obsolete. Please use Foo.Bar instead."); -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Obsolete_ExplicitWarning_WithMessage b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Obsolete_ExplicitWarning_WithMessage deleted file mode 100644 index e436ddede9..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Obsolete_ExplicitWarning_WithMessage +++ /dev/null @@ -1,8 +0,0 @@ -[System.Diagnostics.DebuggerStepThrough] -public void Obsolete_ExplicitWarning_WithMessage() -{ - Context.Log.Warning("Warning: The alias Obsolete_ExplicitWarning_WithMessage has been made obsolete. Please use Foo.Bar instead."); -#pragma warning disable 0618 - Cake.Core.Tests.Data.MethodAliasGeneratorData.Obsolete_ExplicitWarning_WithMessage(Context); -#pragma warning restore 0618 -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Obsolete_ImplicitWarning_NoMessage b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Obsolete_ImplicitWarning_NoMessage deleted file mode 100644 index 1523fa310d..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Obsolete_ImplicitWarning_NoMessage +++ /dev/null @@ -1,8 +0,0 @@ -[System.Diagnostics.DebuggerStepThrough] -public void Obsolete_ImplicitWarning_NoMessage() -{ - Context.Log.Warning("Warning: The alias Obsolete_ImplicitWarning_NoMessage has been made obsolete."); -#pragma warning disable 0618 - Cake.Core.Tests.Data.MethodAliasGeneratorData.Obsolete_ImplicitWarning_NoMessage(Context); -#pragma warning restore 0618 -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Obsolete_ImplicitWarning_WithMessage b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Obsolete_ImplicitWarning_WithMessage deleted file mode 100644 index 4ab4b9ea47..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Methods/Obsolete_ImplicitWarning_WithMessage +++ /dev/null @@ -1,8 +0,0 @@ -[System.Diagnostics.DebuggerStepThrough] -public void Obsolete_ImplicitWarning_WithMessage() -{ - Context.Log.Warning("Warning: The alias Obsolete_ImplicitWarning_WithMessage has been made obsolete. Please use Foo.Bar instead."); -#pragma warning disable 0618 - Cake.Core.Tests.Data.MethodAliasGeneratorData.Obsolete_ImplicitWarning_WithMessage(Context); -#pragma warning restore 0618 -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Dynamic_Type b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Dynamic_Type deleted file mode 100644 index b57a1679d3..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Dynamic_Type +++ /dev/null @@ -1,13 +0,0 @@ -private dynamic _Cached_Dynamic_Type; -public dynamic Cached_Dynamic_Type -{ - [System.Diagnostics.DebuggerStepThrough] - get - { - if (_Cached_Dynamic_Type==null) - { - _Cached_Dynamic_Type = Cake.Core.Tests.Data.PropertyAliasGeneratorData.Cached_Dynamic_Type(Context); - } - return _Cached_Dynamic_Type; - } -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Obsolete_ExplicitError_WithMessage b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Obsolete_ExplicitError_WithMessage deleted file mode 100644 index 0d109964de..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Obsolete_ExplicitError_WithMessage +++ /dev/null @@ -1,8 +0,0 @@ -public System.Int32 Cached_Obsolete_ExplicitError_WithMessage -{ - [System.Diagnostics.DebuggerStepThrough] - get - { - throw new Cake.Core.CakeException("The alias Cached_Obsolete_ExplicitError_WithMessage has been made obsolete. Please use Foo.Bar instead."); - } -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Obsolete_ExplicitWarning_WithMessage b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Obsolete_ExplicitWarning_WithMessage deleted file mode 100644 index a54cb38ce5..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Obsolete_ExplicitWarning_WithMessage +++ /dev/null @@ -1,17 +0,0 @@ -private System.Int32? _Cached_Obsolete_ExplicitWarning_WithMessage; -[Obsolete("Please use Foo.Bar instead.")] -public System.Int32 Cached_Obsolete_ExplicitWarning_WithMessage -{ - [System.Diagnostics.DebuggerStepThrough] - get - { - Context.Log.Warning("Warning: The alias Cached_Obsolete_ExplicitWarning_WithMessage has been made obsolete. Please use Foo.Bar instead."); - if (_Cached_Obsolete_ExplicitWarning_WithMessage==null) - { -#pragma warning disable CS0618 - _Cached_Obsolete_ExplicitWarning_WithMessage = Cake.Core.Tests.Data.PropertyAliasGeneratorData.Cached_Obsolete_ExplicitWarning_WithMessage(Context); -#pragma warning restore CS0618 - } - return _Cached_Obsolete_ExplicitWarning_WithMessage.Value; - } -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Obsolete_ImplicitWarning_NoMessage b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Obsolete_ImplicitWarning_NoMessage deleted file mode 100644 index 0b5db4d12e..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Obsolete_ImplicitWarning_NoMessage +++ /dev/null @@ -1,17 +0,0 @@ -private System.Int32? _Cached_Obsolete_ImplicitWarning_NoMessage; -[Obsolete] -public System.Int32 Cached_Obsolete_ImplicitWarning_NoMessage -{ - [System.Diagnostics.DebuggerStepThrough] - get - { - Context.Log.Warning("Warning: The alias Cached_Obsolete_ImplicitWarning_NoMessage has been made obsolete."); - if (_Cached_Obsolete_ImplicitWarning_NoMessage==null) - { -#pragma warning disable CS0618 - _Cached_Obsolete_ImplicitWarning_NoMessage = Cake.Core.Tests.Data.PropertyAliasGeneratorData.Cached_Obsolete_ImplicitWarning_NoMessage(Context); -#pragma warning restore CS0618 - } - return _Cached_Obsolete_ImplicitWarning_NoMessage.Value; - } -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Obsolete_ImplicitWarning_WithMessage b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Obsolete_ImplicitWarning_WithMessage deleted file mode 100644 index ffb6c8c272..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Obsolete_ImplicitWarning_WithMessage +++ /dev/null @@ -1,17 +0,0 @@ -private System.Int32? _Cached_Obsolete_ImplicitWarning_WithMessage; -[Obsolete("Please use Foo.Bar instead.")] -public System.Int32 Cached_Obsolete_ImplicitWarning_WithMessage -{ - [System.Diagnostics.DebuggerStepThrough] - get - { - Context.Log.Warning("Warning: The alias Cached_Obsolete_ImplicitWarning_WithMessage has been made obsolete. Please use Foo.Bar instead."); - if (_Cached_Obsolete_ImplicitWarning_WithMessage==null) - { -#pragma warning disable CS0618 - _Cached_Obsolete_ImplicitWarning_WithMessage = Cake.Core.Tests.Data.PropertyAliasGeneratorData.Cached_Obsolete_ImplicitWarning_WithMessage(Context); -#pragma warning restore CS0618 - } - return _Cached_Obsolete_ImplicitWarning_WithMessage.Value; - } -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Reference_Type b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Reference_Type deleted file mode 100644 index 203e42b432..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Reference_Type +++ /dev/null @@ -1,13 +0,0 @@ -private System.String _Cached_Reference_Type; -public System.String Cached_Reference_Type -{ - [System.Diagnostics.DebuggerStepThrough] - get - { - if (_Cached_Reference_Type==null) - { - _Cached_Reference_Type = Cake.Core.Tests.Data.PropertyAliasGeneratorData.Cached_Reference_Type(Context); - } - return _Cached_Reference_Type; - } -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Value_Type b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Value_Type deleted file mode 100644 index 159ad45343..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/Cached_Value_Type +++ /dev/null @@ -1,13 +0,0 @@ -private System.Boolean? _Cached_Value_Type; -public System.Boolean Cached_Value_Type -{ - [System.Diagnostics.DebuggerStepThrough] - get - { - if (_Cached_Value_Type==null) - { - _Cached_Value_Type = Cake.Core.Tests.Data.PropertyAliasGeneratorData.Cached_Value_Type(Context); - } - return _Cached_Value_Type.Value; - } -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/NonCached_Dynamic_Type b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/NonCached_Dynamic_Type deleted file mode 100644 index 8afeee8917..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/NonCached_Dynamic_Type +++ /dev/null @@ -1,8 +0,0 @@ -public dynamic NonCached_Dynamic_Type -{ - [System.Diagnostics.DebuggerStepThrough] - get - { - return Cake.Core.Tests.Data.PropertyAliasGeneratorData.NonCached_Dynamic_Type(Context); - } -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/NonCached_Obsolete_ExplicitError_WithMessage b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/NonCached_Obsolete_ExplicitError_WithMessage deleted file mode 100644 index 981d8ef161..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/NonCached_Obsolete_ExplicitError_WithMessage +++ /dev/null @@ -1,8 +0,0 @@ -public System.Int32 NonCached_Obsolete_ExplicitError_WithMessage -{ - [System.Diagnostics.DebuggerStepThrough] - get - { - throw new Cake.Core.CakeException("The alias NonCached_Obsolete_ExplicitError_WithMessage has been made obsolete. Please use Foo.Bar instead."); - } -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/NonCached_Obsolete_ExplicitWarning_WithMessage b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/NonCached_Obsolete_ExplicitWarning_WithMessage deleted file mode 100644 index 4fc0eb5f89..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/NonCached_Obsolete_ExplicitWarning_WithMessage +++ /dev/null @@ -1,9 +0,0 @@ -public System.Int32 NonCached_Obsolete_ExplicitWarning_WithMessage -{ - [System.Diagnostics.DebuggerStepThrough] - get - { - Context.Log.Warning("Warning: The alias NonCached_Obsolete_ExplicitWarning_WithMessage has been made obsolete. Please use Foo.Bar instead."); - return Cake.Core.Tests.Data.PropertyAliasGeneratorData.NonCached_Obsolete_ExplicitWarning_WithMessage(Context); - } -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/NonCached_Obsolete_ImplicitWarning_NoMessage b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/NonCached_Obsolete_ImplicitWarning_NoMessage deleted file mode 100644 index 93e9bb7369..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/NonCached_Obsolete_ImplicitWarning_NoMessage +++ /dev/null @@ -1,9 +0,0 @@ -public System.Int32 NonCached_Obsolete_ImplicitWarning_NoMessage -{ - [System.Diagnostics.DebuggerStepThrough] - get - { - Context.Log.Warning("Warning: The alias NonCached_Obsolete_ImplicitWarning_NoMessage has been made obsolete."); - return Cake.Core.Tests.Data.PropertyAliasGeneratorData.NonCached_Obsolete_ImplicitWarning_NoMessage(Context); - } -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/NonCached_Obsolete_ImplicitWarning_WithMessage b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/NonCached_Obsolete_ImplicitWarning_WithMessage deleted file mode 100644 index f6def61039..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/NonCached_Obsolete_ImplicitWarning_WithMessage +++ /dev/null @@ -1,9 +0,0 @@ -public System.Int32 NonCached_Obsolete_ImplicitWarning_WithMessage -{ - [System.Diagnostics.DebuggerStepThrough] - get - { - Context.Log.Warning("Warning: The alias NonCached_Obsolete_ImplicitWarning_WithMessage has been made obsolete. Please use Foo.Bar instead."); - return Cake.Core.Tests.Data.PropertyAliasGeneratorData.NonCached_Obsolete_ImplicitWarning_WithMessage(Context); - } -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/NonCached_Value_Type b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/NonCached_Value_Type deleted file mode 100644 index 877caa66bf..0000000000 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/Expected/Properties/NonCached_Value_Type +++ /dev/null @@ -1,8 +0,0 @@ -public System.Int32 NonCached_Value_Type -{ - [System.Diagnostics.DebuggerStepThrough] - get - { - return Cake.Core.Tests.Data.PropertyAliasGeneratorData.NonCached_Value_Type(Context); - } -} \ No newline at end of file diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/MethodAliasGeneratorTests.cs b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/MethodAliasGeneratorTests.cs index 464f84d199..743efb534c 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/MethodAliasGeneratorTests.cs +++ b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/MethodAliasGeneratorTests.cs @@ -2,14 +2,19 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Threading.Tasks; using Cake.Core.Scripting.CodeGen; using Cake.Core.Tests.Fixtures; +using VerifyXunit; using Xunit; +using static Cake.Core.Tests.VerifyConfig; namespace Cake.Core.Tests.Unit.Scripting.CodeGen { + [UsesVerify] public sealed class MethodAliasGeneratorTests { + [UsesVerify] public sealed class TheGeneratorMethod : IClassFixture { private readonly MethodAliasGeneratorFixture _fixture; @@ -30,42 +35,42 @@ public void Should_Throw_If_Method_Is_Null() } [Theory] - [InlineData("NonGeneric_ExtensionMethodWithNoParameters")] - [InlineData("NonGeneric_ExtensionMethodWithParameter")] - [InlineData("NonGeneric_ExtensionMethodWithGenericParameter")] - [InlineData("NonGeneric_ExtensionMethodWithGenericExpressionParameter")] - [InlineData("NonGeneric_ExtensionMethodWithGenericExpressionArrayParameter")] - [InlineData("NonGeneric_ExtensionMethodWithGenericExpressionParamsArrayParameter")] - [InlineData("NonGeneric_ExtensionMethodWithReturnValue")] - [InlineData("NonGeneric_ExtensionMethodWithParameterArray")] - [InlineData("NonGeneric_ExtensionMethodWithOptionalObjectParameter")] - [InlineData("NonGeneric_ExtensionMethodWithOptionalBooleanParameter")] - [InlineData("NonGeneric_ExtensionMethodWithOptionalStringParameter")] - [InlineData("NonGeneric_ExtensionMethodWithOptionalEnumParameter")] - [InlineData("NonGeneric_ExtensionMethodWithOptionalCharParameter")] - [InlineData("NonGeneric_ExtensionMethodWithOptionalDecimalParameter")] - [InlineData("NonGeneric_ExtensionMethodWithOptionalNullableTParameter")] - [InlineData("NonGeneric_ExtensionMethodWithOptionalNullableBooleanParameter")] - [InlineData("NonGeneric_ExtensionMethodWithOptionalNullableCharParameter")] - [InlineData("NonGeneric_ExtensionMethodWithOptionalNullableEnumParameter")] - [InlineData("NonGeneric_ExtensionMethodWithOptionalNullableDecimalParameter")] - [InlineData("NonGeneric_ExtensionMethodWithOptionalNullableLongParameter")] - [InlineData("NonGeneric_ExtensionMethodWithOptionalNullableDoubleParameter")] - [InlineData("NonGeneric_ExtensionMethodWithReservedKeywordParameter")] - [InlineData("NonGeneric_ExtensionMethodWithOutputParameter")] - [InlineData("NonGeneric_ExtensionMethodWithGenericCollectionOfNestedType")] - [InlineData("NonGeneric_ExtensionMethodWithParameterAttributes")] - [InlineData("NonGeneric_ExtensionMethodWithDynamicReturnValue")] - public void Should_Return_Correct_Generated_Code_For_Non_Generic_Methods(string name) + [InlineData("ExtensionMethodWithNoParameters")] + [InlineData("ExtensionMethodWithParameter")] + [InlineData("ExtensionMethodWithGenericParameter")] + [InlineData("ExtensionMethodWithGenericExpressionParameter")] + [InlineData("ExtensionMethodWithGenericExpressionArrayParameter")] + [InlineData("ExtensionMethodWithGenericExpressionParamsArrayParameter")] + [InlineData("ExtensionMethodWithReturnValue")] + [InlineData("ExtensionMethodWithParameterArray")] + [InlineData("ExtensionMethodWithOptionalObjectParameter")] + [InlineData("ExtensionMethodWithOptionalBooleanParameter")] + [InlineData("ExtensionMethodWithOptionalStringParameter")] + [InlineData("ExtensionMethodWithOptionalEnumParameter")] + [InlineData("ExtensionMethodWithOptionalCharParameter")] + [InlineData("ExtensionMethodWithOptionalDecimalParameter")] + [InlineData("ExtensionMethodWithOptionalNullableTParameter")] + [InlineData("ExtensionMethodWithOptionalNullableBooleanParameter")] + [InlineData("ExtensionMethodWithOptionalNullableCharParameter")] + [InlineData("ExtensionMethodWithOptionalNullableEnumParameter")] + [InlineData("ExtensionMethodWithOptionalNullableDecimalParameter")] + [InlineData("ExtensionMethodWithOptionalNullableLongParameter")] + [InlineData("ExtensionMethodWithOptionalNullableDoubleParameter")] + [InlineData("ExtensionMethodWithReservedKeywordParameter")] + [InlineData("ExtensionMethodWithOutputParameter")] + [InlineData("ExtensionMethodWithGenericCollectionOfNestedType")] + [InlineData("ExtensionMethodWithParameterAttributes")] + [InlineData("ExtensionMethodWithDynamicReturnValue")] + [InlineData("ExtensionMethodWithNullableParameter")] + [InlineData("ExtensionMethodWithNullableReturnValue")] + public Task Should_Return_Correct_Generated_Code_For_Non_Generic_Methods(string name) { - // Given - var expected = _fixture.GetExpectedCode(name); - - // When - var result = _fixture.Generate(name); + // Given / When + var result = _fixture.Generate("NonGeneric_" + name); // Then - Assert.Equal(expected, result); + return VerifyCake(result) + .UseParameters(name); } [Theory] @@ -73,16 +78,14 @@ public void Should_Return_Correct_Generated_Code_For_Non_Generic_Methods(string [InlineData("Generic_ExtensionMethodWithParameter")] [InlineData("Generic_ExtensionMethodWithGenericReturnValue")] [InlineData("Generic_ExtensionMethodWithGenericReturnValueAndTypeParamConstraints")] - public void Should_Return_Correct_Generated_Code_For_Generic_Methods(string name) + public Task Should_Return_Correct_Generated_Code_For_Generic_Methods(string name) { - // Given - var expected = _fixture.GetExpectedCode(name); - - // When + // Given / When var result = _fixture.Generate(name); // Then - Assert.Equal(expected, result); + return VerifyCake(result) + .UseParameters(name); } [Theory] @@ -90,16 +93,14 @@ public void Should_Return_Correct_Generated_Code_For_Generic_Methods(string name [InlineData("Obsolete_ImplicitWarning_WithMessage")] [InlineData("Obsolete_ExplicitWarning_WithMessage")] [InlineData("Obsolete_ExplicitError_WithMessage")] - public void Should_Return_Correct_Generated_Code_For_Obsolete_Methods(string name) + public Task Should_Return_Correct_Generated_Code_For_Obsolete_Methods(string name) { - // Given - var expected = _fixture.GetExpectedCode(name); - - // When + // Given / When var result = _fixture.Generate(name); // Then - Assert.Equal(expected, result); + return VerifyCake(result) + .UseParameters(name); } } } diff --git a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/PropertyAliasGeneratorTests.cs b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/PropertyAliasGeneratorTests.cs index af8ca01a83..77082d52d3 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/CodeGen/PropertyAliasGeneratorTests.cs +++ b/src/Cake.Core.Tests/Unit/Scripting/CodeGen/PropertyAliasGeneratorTests.cs @@ -3,14 +3,19 @@ // See the LICENSE file in the project root for more information. using System.Reflection; +using System.Threading.Tasks; using Cake.Core.Scripting.CodeGen; using Cake.Core.Tests.Fixtures; +using VerifyXunit; using Xunit; +using static Cake.Core.Tests.VerifyConfig; namespace Cake.Core.Tests.Unit.Scripting.CodeGen { + [UsesVerify] public sealed class PropertyAliasGeneratorTests { + [UsesVerify] public sealed class TheGenerateMethod : IClassFixture { private readonly PropertyAliasGeneratorFixture _fixture; @@ -113,32 +118,29 @@ public void Should_Throw_If_Property_Alias_Returns_Void() [Theory] [InlineData("NonCached_Value_Type")] [InlineData("NonCached_Dynamic_Type")] - public void Should_Return_Correct_Generated_Code_For_Non_Cached_Properties(string name) + public Task Should_Return_Correct_Generated_Code_For_Non_Cached_Properties(string name) { - // Given - var expected = _fixture.GetExpectedData(name); - - // When + // Given / When var result = _fixture.Generate(name); // Then - Assert.Equal(expected, result); + return VerifyCake(result) + .UseParameters(name); } [Theory] [InlineData("Cached_Reference_Type")] [InlineData("Cached_Value_Type")] [InlineData("Cached_Dynamic_Type")] - public void Should_Return_Correct_Generated_Code_For_Cached_Properties(string name) + [InlineData("Cached_Nullable_Type")] + public Task Should_Return_Correct_Generated_Code_For_Cached_Properties(string name) { - // Given - var expected = _fixture.GetExpectedData(name); - - // When + // Given / When var result = _fixture.Generate(name); // Then - Assert.Equal(expected, result); + return VerifyCake(result) + .UseParameters(name); } [Theory] @@ -146,16 +148,14 @@ public void Should_Return_Correct_Generated_Code_For_Cached_Properties(string na [InlineData("NonCached_Obsolete_ImplicitWarning_WithMessage")] [InlineData("NonCached_Obsolete_ExplicitWarning_WithMessage")] [InlineData("NonCached_Obsolete_ExplicitError_WithMessage")] - public void Should_Return_Correct_Generated_Code_For_Non_Cached_Obsolete_Properties(string name) + public Task Should_Return_Correct_Generated_Code_For_Non_Cached_Obsolete_Properties(string name) { - // Given - var expected = _fixture.GetExpectedData(name); - - // When + // Given / When var result = _fixture.Generate(name); // Then - Assert.Equal(expected, result); + return VerifyCake(result) + .UseParameters(name); } [Theory] @@ -163,16 +163,14 @@ public void Should_Return_Correct_Generated_Code_For_Non_Cached_Obsolete_Propert [InlineData("Cached_Obsolete_ImplicitWarning_WithMessage")] [InlineData("Cached_Obsolete_ExplicitWarning_WithMessage")] [InlineData("Cached_Obsolete_ExplicitError_WithMessage")] - public void Should_Return_Correct_Generated_Code_For_Cached_Obsolete_Properties(string name) + public Task Should_Return_Correct_Generated_Code_For_Cached_Obsolete_Properties(string name) { - // Given - var expected = _fixture.GetExpectedData(name); - - // When + // Given / When var result = _fixture.Generate(name); // Then - Assert.Equal(expected, result); + return VerifyCake(result) + .UseParameters(name); } } } diff --git a/src/Cake.Core.Tests/VerifyConfig.cs b/src/Cake.Core.Tests/VerifyConfig.cs new file mode 100644 index 0000000000..a32ee74f29 --- /dev/null +++ b/src/Cake.Core.Tests/VerifyConfig.cs @@ -0,0 +1,29 @@ +using System.Diagnostics.Contracts; +using System.Runtime.CompilerServices; +using VerifyTests; +using static VerifyXunit.Verifier; + +namespace Cake.Core.Tests +{ + public static class VerifyConfig + { + [ModuleInitializer] + public static void Init() + { + EmptyFiles.FileExtensions.AddTextExtension(Extensions.Cake); + DerivePathInfo(Expectations.Initialize); + } + + public static class Extensions + { + public const string Cake = "cake"; + } + + [Pure] + public static SettingsTask VerifyCake( + string target, + VerifySettings settings = null, + [CallerFilePath] string sourceFile = "") + => Verify(target, Extensions.Cake, settings, sourceFile); + } +} diff --git a/src/Cake.Core/Constants.cs b/src/Cake.Core/Constants.cs index e00914192d..76adf9bf79 100644 --- a/src/Cake.Core/Constants.cs +++ b/src/Cake.Core/Constants.cs @@ -11,7 +11,7 @@ internal static class Constants public const ConsoleColor DefaultConsoleColor = (ConsoleColor)(-1); public static readonly Version LatestBreakingChange = new Version(0, 26, 0); - public static readonly Version LatestPotentialBreakingChange = new Version(3, 0, 0); + public static readonly Version LatestPotentialBreakingChange = new Version(4, 0, 0); public static class Settings { diff --git a/src/Cake.Core/IO/File.cs b/src/Cake.Core/IO/File.cs index d100381ffc..3ee422e20a 100644 --- a/src/Cake.Core/IO/File.cs +++ b/src/Cake.Core/IO/File.cs @@ -62,5 +62,47 @@ public Stream Open(FileMode fileMode, FileAccess fileAccess, FileShare fileShare { return _file.Open(fileMode, fileAccess, fileShare); } + + /// + public IFile SetCreationTime(DateTime creationTime) + { + System.IO.File.SetCreationTime(Path.FullPath, creationTime); + return this; + } + + /// + public IFile SetCreationTimeUtc(DateTime creationTimeUtc) + { + System.IO.File.SetCreationTimeUtc(Path.FullPath, creationTimeUtc); + return this; + } + + /// + public IFile SetLastAccessTime(DateTime lastAccessTime) + { + System.IO.File.SetLastAccessTime(Path.FullPath, lastAccessTime); + return this; + } + + /// + public IFile SetLastAccessTimeUtc(DateTime lastAccessTimeUtc) + { + System.IO.File.SetLastAccessTimeUtc(Path.FullPath, lastAccessTimeUtc); + return this; + } + + /// + public IFile SetLastWriteTime(DateTime lastWriteTime) + { + System.IO.File.SetLastWriteTime(Path.FullPath, lastWriteTime); + return this; + } + + /// + public IFile SetLastWriteTimeUtc(DateTime lastWriteTimeUtc) + { + System.IO.File.SetLastWriteTimeUtc(Path.FullPath, lastWriteTimeUtc); + return this; + } } } \ No newline at end of file diff --git a/src/Cake.Core/IO/IFile.cs b/src/Cake.Core/IO/IFile.cs index 102eb8a06a..0bb6851b6e 100644 --- a/src/Cake.Core/IO/IFile.cs +++ b/src/Cake.Core/IO/IFile.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; using System.IO; namespace Cake.Core.IO @@ -55,5 +56,47 @@ public interface IFile : IFileSystemInfo /// The file share. /// A to the file. Stream Open(FileMode fileMode, FileAccess fileAccess, FileShare fileShare); + + /// + /// Sets the date and time that the file was created. + /// + /// A containing the value to set for the creation date and time of path. This value is expressed in local time. + /// A instance representing the specified path. + IFile SetCreationTime(DateTime creationTime) => this; + + /// + /// Sets the date and time, in Coordinated Universal Time (UTC), that the file was created. + /// + /// A containing the value to set for the creation date and time of path. This value is expressed in UTC time. + /// A instance representing the specified path. + IFile SetCreationTimeUtc(DateTime creationTimeUtc) => this; + + /// + /// Sets the date and time that the specified file or directory was last accessed. + /// + /// A containing the value to set for the last access date and time of path. This value is expressed in local time. + /// A instance representing the specified path. + IFile SetLastAccessTime(DateTime lastAccessTime) => this; + + /// + /// Sets the date and time, in Coordinated Universal Time (UTC), that the specified file or directory was last accessed. + /// + /// A containing the value to set for the last access date and time of path. This value is expressed in local time. + /// A instance representing the specified path. + IFile SetLastAccessTimeUtc(DateTime lastAccessTimeUtc) => this; + + /// + /// Sets the date and time that the specified file or directory was last written to. + /// + /// A containing the value to set for the last access date and time of path. This value is expressed in local time. + /// A instance representing the specified path. + IFile SetLastWriteTime(DateTime lastWriteTime) => this; + + /// + /// Sets the date and time, in Coordinated Universal Time (UTC), that the specified file or directory was last written to. + /// + /// A containing the value to set for the last access date and time of path. This value is expressed in local time. + /// A instance representing the specified path. + IFile SetLastWriteTimeUtc(DateTime lastWriteTimeUtc) => this; } -} \ No newline at end of file +} diff --git a/src/Cake.Core/Scripting/CodeGen/MethodAliasGenerator.cs b/src/Cake.Core/Scripting/CodeGen/MethodAliasGenerator.cs index 570d52b097..6dba303853 100644 --- a/src/Cake.Core/Scripting/CodeGen/MethodAliasGenerator.cs +++ b/src/Cake.Core/Scripting/CodeGen/MethodAliasGenerator.cs @@ -44,15 +44,18 @@ public static string Generate(MethodInfo method, out string hash) throw new ArgumentNullException(nameof(method)); } - var isFunction = method.ReturnType != typeof(void); var builder = new StringBuilder(); - var parameters = method.GetParameters().Skip(1).ToArray(); + var parameters = method.GetParameters()[1..]; + + // Method is obsolete? + var obsolete = method.GetCustomAttribute(); + var isObsolete = obsolete != null; // Generate method signature. builder.AppendLine("[System.Diagnostics.DebuggerStepThrough]"); builder.Append("public "); builder.Append(GetReturnType(method)); - builder.Append(" "); + builder.Append(' '); builder.Append(method.Name); if (method.IsGenericMethod) @@ -61,9 +64,9 @@ public static string Generate(MethodInfo method, out string hash) BuildGenericArguments(method, builder); } - builder.Append("("); + builder.Append('('); builder.Append(string.Concat(GetProxyParameters(parameters, true))); - builder.Append(")"); + builder.Append(')'); // if the method is generic, emit any constraints that might exist. if (method.IsGenericMethod) @@ -71,19 +74,16 @@ public static string Generate(MethodInfo method, out string hash) GenericParameterConstraintEmitter.BuildGenericConstraints(method, builder); } - hash = _hasher - .ComputeHash(Encoding.UTF8.GetBytes(builder.ToString())) - .Aggregate(new StringBuilder(), - (sb, b) => sb.AppendFormat("{0:x2}", b), - sb => sb.ToString()); + hash = Convert.ToHexString( + _hasher.ComputeHash(Encoding.UTF8.GetBytes(builder.ToString()))); builder.AppendLine(); - builder.Append("{"); - builder.AppendLine(); - // Method is obsolete? - var obsolete = method.GetCustomAttribute(); - var isObsolete = obsolete != null; + if (isObsolete && !obsolete.IsError) + { + builder.AppendLine("#pragma warning disable 0618"); + } + builder.Append(" => "); if (isObsolete) { var message = GetObsoleteMessage(method, obsolete); @@ -93,32 +93,13 @@ public static string Generate(MethodInfo method, out string hash) // Throw an exception. var exception = string.Format( CultureInfo.InvariantCulture, - " throw new Cake.Core.CakeException(\"{0}\");", message); + "throw new Cake.Core.CakeException(\"{0}\");", message); builder.AppendLine(exception); // End method. - builder.Append("}"); - builder.AppendLine(); builder.AppendLine(); return builder.ToString(); } - - builder.AppendLine(string.Format( - CultureInfo.InvariantCulture, - " Context.Log.Warning(\"Warning: {0}\");", message)); - } - - if (isObsolete) - { - builder.AppendLine("#pragma warning disable 0618"); - } - - builder.Append(" "); - - if (isFunction) - { - // Add return keyword. - builder.Append("return "); } // Call extension method. @@ -130,10 +111,9 @@ public static string Generate(MethodInfo method, out string hash) BuildGenericArguments(method, builder); } - builder.Append("("); + builder.Append('('); builder.Append(string.Concat(GetProxyParameters(parameters, false))); - builder.Append(");"); - builder.AppendLine(); + builder.AppendLine(");"); if (isObsolete) { @@ -141,8 +121,6 @@ public static string Generate(MethodInfo method, out string hash) } // End method. - builder.Append("}"); - builder.AppendLine(); builder.AppendLine(); return builder.ToString(); @@ -156,7 +134,10 @@ private static string GetReturnType(MethodInfo method) } var isDynamic = method.ReturnTypeCustomAttributes.GetCustomAttributes(typeof(DynamicAttribute), true).Any(); - return isDynamic ? "dynamic" : method.ReturnType.GetFullName(); + var isNullable = method.ReturnTypeCustomAttributes.GetCustomAttributes(true).Any(attr => attr.GetType().FullName == "System.Runtime.CompilerServices.NullableAttribute"); + return string.Concat( + isDynamic ? "dynamic" : method.ReturnType.GetFullName(), + isNullable ? "?" : string.Empty); } private static IEnumerable GetProxyParameters(IEnumerable parameters, bool includeType) @@ -183,14 +164,14 @@ private static IEnumerable GetProxyParameters(IEnumerable private static void BuildGenericArguments(MethodInfo method, StringBuilder builder) { - builder.Append("<"); + builder.Append('<'); var genericArguments = new List(); foreach (var argument in method.GetGenericArguments()) { genericArguments.Add(argument.Name); } builder.Append(string.Join(", ", genericArguments)); - builder.Append(">"); + builder.Append('>'); } private static string GetObsoleteMessage(MethodInfo method, ObsoleteAttribute attribute) diff --git a/src/Cake.Core/Scripting/CodeGen/ParameterEmitter.cs b/src/Cake.Core/Scripting/CodeGen/ParameterEmitter.cs index 68481b63d0..ff08343413 100644 --- a/src/Cake.Core/Scripting/CodeGen/ParameterEmitter.cs +++ b/src/Cake.Core/Scripting/CodeGen/ParameterEmitter.cs @@ -17,6 +17,15 @@ namespace Cake.Core.Scripting.CodeGen /// internal sealed class ParameterEmitter { + // filter out the any custom parameter attributes that will be emitted by other means. + private static readonly Type[] Exclusions = new[] + { + typeof(OptionalAttribute), + typeof(OutAttribute), + typeof(ParamArrayAttribute), + typeof(DecimalConstantAttribute), + }; + private static readonly ParameterFormatter _parameterFormatter = new ParameterFormatter(); internal static string Emit(ParameterInfo parameter, bool includeType) @@ -36,6 +45,7 @@ private static IEnumerable BuildParameterTokens(ParameterInfo parameter, } if (includeType) { + var isNullable = false; if (parameter.IsDefined(typeof(ParamArrayAttribute))) { yield return "params "; @@ -45,21 +55,17 @@ private static IEnumerable BuildParameterTokens(ParameterInfo parameter, var customAttrs = parameter.GetCustomAttributesData(); if (customAttrs.Count > 0) { - // filter out the any custom parameter attributes that will be emitted by other means. - var exclusions = new[] - { - typeof(OptionalAttribute), - typeof(OutAttribute), - typeof(ParamArrayAttribute), - typeof(DecimalConstantAttribute) - }; - - foreach (var item in customAttrs.Where(p => !exclusions.Contains(p.AttributeType))) + foreach (var item in customAttrs.Where(p => !Exclusions.Contains(p.AttributeType))) { var attributeType = item.AttributeType.GetFullName(); + if (item.AttributeType.FullName == "System.Runtime.CompilerServices.NullableAttribute") + { + isNullable = true; + continue; + } if (item.AttributeType.Name.EndsWith("Attribute", StringComparison.OrdinalIgnoreCase)) { - attributeType = attributeType.Substring(0, attributeType.LastIndexOf("Attribute", StringComparison.OrdinalIgnoreCase)); + attributeType = attributeType[..attributeType.LastIndexOf("Attribute", StringComparison.OrdinalIgnoreCase)]; } if (item.ConstructorArguments.Count < 1 && item.NamedArguments.Count < 1) @@ -101,6 +107,11 @@ private static IEnumerable BuildParameterTokens(ParameterInfo parameter, { yield return parameter.ParameterType.GetFullName(); } + + if (isNullable) + { + yield return "?"; + } yield return " "; } diff --git a/src/Cake.Core/Scripting/CodeGen/PropertyAliasGenerator.cs b/src/Cake.Core/Scripting/CodeGen/PropertyAliasGenerator.cs index 3df7afb01d..1b4ac99473 100644 --- a/src/Cake.Core/Scripting/CodeGen/PropertyAliasGenerator.cs +++ b/src/Cake.Core/Scripting/CodeGen/PropertyAliasGenerator.cs @@ -115,48 +115,27 @@ private static string GenerateCode(MethodInfo method, out string hash) { var builder = new StringBuilder(); - hash = GenerateCommonInitalCode(method, ref builder); - - builder.Append("{"); - builder.AppendLine(); - builder.AppendLine(" [System.Diagnostics.DebuggerStepThrough]"); - builder.Append(" get"); - builder.AppendLine(); - builder.AppendLine(" {"); - // Property is obsolete? var obsolete = method.GetCustomAttribute(); if (obsolete != null) { - var message = GetObsoleteMessage(method, obsolete); - - if (obsolete.IsError) - { - builder.Append(" throw new Cake.Core.CakeException(\""); - builder.Append(message); - builder.Append("\");"); - builder.AppendLine(); - builder.AppendLine(" }"); - builder.AppendLine("}"); - builder.AppendLine(); - builder.AppendLine(); - - return builder.ToString(); - } + AddObsoleteAttribute(builder, obsolete); + } - builder.AppendLine(string.Format( - CultureInfo.InvariantCulture, - " Context.Log.Warning(\"Warning: {0}\");", message)); + hash = GenerateCommonInitalCode(method, ref builder); + if (obsolete != null) + { + builder.AppendLine("#pragma warning disable CS0618"); } - builder.Append(" return "); + builder.AppendFormat(" => ", method.Name); builder.Append(method.GetFullName()); - builder.Append("(Context);"); - builder.AppendLine(); - builder.AppendLine(" }"); - builder.AppendLine("}"); - builder.AppendLine(); - builder.AppendLine(); + builder.AppendLine("(Context);"); + + if (obsolete != null) + { + builder.AppendLine("#pragma warning restore CS0618"); + } return builder.ToString(); } @@ -167,15 +146,14 @@ private static string GenerateCommonInitalCode(MethodInfo method, ref StringBuil var curPos = builder.Length; builder.Append("public "); builder.Append(GetReturnType(method)); - builder.Append(" "); + builder.Append(' '); builder.Append(method.Name); builder.AppendLine(); - hash = SHA256 - .ComputeHash(Encoding.UTF8.GetBytes(builder.ToString(curPos, builder.Length - curPos))) - .Aggregate(new StringBuilder(), - (sb, b) => sb.AppendFormat("{0:x2}", b), - sb => sb.ToString()); + hash = Convert.ToHexString( + SHA256 + .ComputeHash(Encoding.UTF8.GetBytes(builder.ToString(curPos, builder.Length - curPos)))); + return hash; } @@ -195,97 +173,59 @@ private static string GenerateCachedCode(MethodInfo method, out string hash) builder.Append(GetReturnType(method)); if (method.ReturnType.GetTypeInfo().IsValueType) { - builder.Append("?"); + builder.Append('?'); } builder.Append(" _"); builder.Append(method.Name); - builder.Append(";"); + builder.Append(';'); builder.AppendLine(); // Property if (obsolete != null) { - if (string.IsNullOrEmpty(obsolete.Message)) - { - builder.Append("[Obsolete]"); - } - else - { - builder.AppendFormat("[Obsolete(\"{0}\")]", obsolete.Message); - } - - builder.AppendLine(); + AddObsoleteAttribute(builder, obsolete); } hash = GenerateCommonInitalCode(method, ref builder); - builder.Append("{"); - builder.AppendLine(); - builder.AppendLine(" [System.Diagnostics.DebuggerStepThrough]"); - builder.AppendLine(" get"); - builder.Append(" {"); - builder.AppendLine(); - - // Property is obsolete? - if (obsolete != null) - { - var message = GetObsoleteMessage(method, obsolete); - builder.AppendLine(string.Format( - CultureInfo.InvariantCulture, - " Context.Log.Warning(\"Warning: {0}\");", message)); - } - - builder.AppendLine(string.Format( - CultureInfo.InvariantCulture, - " if (_{0}==null)", method.Name)); - - builder.Append(" {"); - builder.AppendLine(); if (obsolete != null) { builder.AppendLine("#pragma warning disable CS0618"); } - builder.AppendFormat(" _{0} = ", method.Name); + builder.AppendFormat(" => _{0} ??= ", method.Name); builder.Append(method.GetFullName()); - builder.Append("(Context);"); - builder.AppendLine(); + builder.AppendLine("(Context);"); if (obsolete != null) { builder.AppendLine("#pragma warning restore CS0618"); } - builder.Append(" }"); - builder.AppendLine(); - builder.AppendFormat(" return _{0}", method.Name); - if (method.ReturnType.GetTypeInfo().IsValueType) + return builder.ToString(); + } + + private static void AddObsoleteAttribute(StringBuilder builder, ObsoleteAttribute obsolete) + { + builder.Append("[Obsolete"); + + if (!string.IsNullOrEmpty(obsolete.Message)) { - builder.Append(".Value"); + builder.AppendFormat( + "(\"{0}\", {1})", + obsolete.Message, + obsolete.IsError ? "true" : "false"); } - builder.Append(";"); - builder.AppendLine(); - builder.Append(" }"); - builder.AppendLine(); - builder.Append("}"); - builder.AppendLine(); - builder.AppendLine(); - return builder.ToString(); + builder.AppendLine("]"); } private static string GetReturnType(MethodInfo method) { var isDynamic = method.ReturnTypeCustomAttributes.GetCustomAttributes(typeof(DynamicAttribute), true).Any(); - return isDynamic ? "dynamic" : method.ReturnType.GetFullName(); - } - - private static string GetObsoleteMessage(MethodInfo method, ObsoleteAttribute attribute) - { - const string format = "The alias {0} has been made obsolete. {1}"; - var message = string.Format( - CultureInfo.InvariantCulture, - format, method.Name, attribute.Message); - return message.Trim(); + var isNullable = method.ReturnTypeCustomAttributes.GetCustomAttributes(true).Any(attr => attr.GetType().FullName == "System.Runtime.CompilerServices.NullableAttribute"); + return string.Concat( + isDynamic ? "dynamic" : method.ReturnType.GetFullName(), + isNullable ? "?" : string.Empty); } } } \ No newline at end of file diff --git a/src/Cake.Core/Scripting/ScriptConventions.cs b/src/Cake.Core/Scripting/ScriptConventions.cs index 91d6115467..10d76814dc 100644 --- a/src/Cake.Core/Scripting/ScriptConventions.cs +++ b/src/Cake.Core/Scripting/ScriptConventions.cs @@ -125,6 +125,9 @@ private string GetFrameworkDefine() case ".NETCoreApp,Version=v7.0": return "NET7_0"; + case ".NETCoreApp,Version=v8.0": + return "NET8_0"; + default: Console.Error.WriteLine(_runtime.BuiltFramework.FullName); Console.Error.Flush(); diff --git a/src/Cake.DotNetTool.Module.Tests/Cake.DotNetTool.Module.Tests.csproj b/src/Cake.DotNetTool.Module.Tests/Cake.DotNetTool.Module.Tests.csproj index 049ca37bd7..36f0148820 100644 --- a/src/Cake.DotNetTool.Module.Tests/Cake.DotNetTool.Module.Tests.csproj +++ b/src/Cake.DotNetTool.Module.Tests/Cake.DotNetTool.Module.Tests.csproj @@ -16,8 +16,8 @@ - - + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Cake.Frosting.Template/Cake.Frosting.Template.csproj b/src/Cake.Frosting.Template/Cake.Frosting.Template.csproj index b2d7b86f2e..36aec71de6 100644 --- a/src/Cake.Frosting.Template/Cake.Frosting.Template.csproj +++ b/src/Cake.Frosting.Template/Cake.Frosting.Template.csproj @@ -5,7 +5,7 @@ Cake.Frosting.Template Cake.Frosting templates for the .NET SDK. Cake.Frosting templates for the .NET SDK. - net7.0 + net8.0 true false content diff --git a/src/Cake.Frosting.Template/templates/cakefrosting/.template.config/template.json b/src/Cake.Frosting.Template/templates/cakefrosting/.template.config/template.json index 46901ce9f3..e146824c5a 100644 --- a/src/Cake.Frosting.Template/templates/cakefrosting/.template.config/template.json +++ b/src/Cake.Frosting.Template/templates/cakefrosting/.template.config/template.json @@ -17,7 +17,7 @@ "type": "parameter", "description": "The target framework for the project.", "datatype": "choice", - "defaultValue": "net7.0", + "defaultValue": "net8.0", "replaces": "TargetFrameworkValue", "choices": [ { @@ -27,6 +27,10 @@ { "choice": "net7.0", "description": "Target .NET 7" + }, + { + "choice": "net8.0", + "description": "Target .NET 8" } ] } diff --git a/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj b/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj index e500faf181..ee2e8c5d54 100644 --- a/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj +++ b/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj @@ -8,9 +8,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Cake.Frosting/Cake.Frosting.csproj b/src/Cake.Frosting/Cake.Frosting.csproj index f5541fc85c..629957d9ff 100644 --- a/src/Cake.Frosting/Cake.Frosting.csproj +++ b/src/Cake.Frosting/Cake.Frosting.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj b/src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj index 6b46c84ff0..10ba35d167 100644 --- a/src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj +++ b/src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj @@ -15,8 +15,8 @@ - - + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Cake.Testing.Xunit/Cake.Testing.Xunit.csproj b/src/Cake.Testing.Xunit/Cake.Testing.Xunit.csproj index 4575a25519..178063f110 100644 --- a/src/Cake.Testing.Xunit/Cake.Testing.Xunit.csproj +++ b/src/Cake.Testing.Xunit/Cake.Testing.Xunit.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/Cake.Testing/FakeFile.cs b/src/Cake.Testing/FakeFile.cs index 5cc67671b2..e8705f1cf7 100644 --- a/src/Cake.Testing/FakeFile.cs +++ b/src/Cake.Testing/FakeFile.cs @@ -157,5 +157,41 @@ private long GetPosition(FileMode fileMode, out bool fileWasCreated) } throw new NotSupportedException(); } + + /// + public IFile SetCreationTime(DateTime creationTime) + { + return this; + } + + /// + public IFile SetCreationTimeUtc(DateTime creationTimeUtc) + { + return this; + } + + /// + public IFile SetLastAccessTime(DateTime lastAccessTime) + { + return this; + } + + /// + public IFile SetLastAccessTimeUtc(DateTime lastAccessTimeUtc) + { + return this; + } + + /// + public IFile SetLastWriteTime(DateTime lastWriteTime) + { + return this; + } + + /// + public IFile SetLastWriteTimeUtc(DateTime lastWriteTimeUtc) + { + return this; + } } -} \ No newline at end of file +} diff --git a/src/Cake.Tests/Cake.Tests.csproj b/src/Cake.Tests/Cake.Tests.csproj index 7990841020..5342cc1d6a 100644 --- a/src/Cake.Tests/Cake.Tests.csproj +++ b/src/Cake.Tests/Cake.Tests.csproj @@ -10,8 +10,8 @@ - - + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Cake/Cake.csproj b/src/Cake/Cake.csproj index 2b5607877d..2e101eb3cc 100644 --- a/src/Cake/Cake.csproj +++ b/src/Cake/Cake.csproj @@ -26,10 +26,11 @@ - - - + + + + diff --git a/src/Cake/Infrastructure/Scripting/ReferenceAssemblyResolver.cs b/src/Cake/Infrastructure/Scripting/ReferenceAssemblyResolver.cs index 3c20c2b706..aa84dd8655 100644 --- a/src/Cake/Infrastructure/Scripting/ReferenceAssemblyResolver.cs +++ b/src/Cake/Infrastructure/Scripting/ReferenceAssemblyResolver.cs @@ -24,8 +24,10 @@ IEnumerable TryGetReferenceAssemblies() foreach (var reference in #if NET6_0 Basic.Reference.Assemblies.Net60.References.All) -#else +#elif NET7_0 Basic.Reference.Assemblies.Net70.References.All) +#else + Basic.Reference.Assemblies.Net80.References.All) #endif { Assembly assembly; diff --git a/src/Directory.Build.props b/src/Directory.Build.props index df7179b480..b7c02cade1 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -6,6 +6,6 @@ - + diff --git a/src/Shared.msbuild b/src/Shared.msbuild index c394ab929a..5de0cd2088 100644 --- a/src/Shared.msbuild +++ b/src/Shared.msbuild @@ -1,7 +1,7 @@ - net6.0;net7.0 + net6.0;net7.0;net8.0 $(AssemblyName) Copyright (c) .NET Foundation and contributors Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström, Dave Glick, Pascal Berger, Jérémie Desautels, Enrico Campidoglio, C. Augusto Proiete, Nils Andresen, and contributors @@ -17,7 +17,7 @@ - + 2.0.0 $(DefineConstants);NETCORE portable diff --git a/src/SolutionInfo.cs b/src/SolutionInfo.cs index aba1fbe686..20711806f7 100644 --- a/src/SolutionInfo.cs +++ b/src/SolutionInfo.cs @@ -10,7 +10,7 @@ using System.Reflection; [assembly: AssemblyProduct("Cake")] -[assembly: AssemblyVersion("3.2.0.0")] -[assembly: AssemblyFileVersion("3.2.0.0")] -[assembly: AssemblyInformationalVersion("3.2.0-beta.1+1.Branch.release-3.2.0.Sha.0ccf2b8235eea0282aac1f2690975e9d3dd4b71f")] +[assembly: AssemblyVersion("4.0.0.0")] +[assembly: AssemblyFileVersion("4.0.0.0")] +[assembly: AssemblyInformationalVersion("4.0.0-beta.1+0.Branch.release-4.0.0.Sha.b11eb5fc9f203608d32c280b5e2b914eea3df379")] [assembly: AssemblyCopyright("Copyright (c) .NET Foundation and Contributors")] diff --git a/tests/integration/Cake.Common/Build/GitHubActions/ValidateGitHubActionsProvider.cake b/tests/integration/Cake.Common/Build/GitHubActions/ValidateGitHubActionsProvider.cake index 85afae1e8c..66075a10ad 100644 --- a/tests/integration/Cake.Common/Build/GitHubActions/ValidateGitHubActionsProvider.cake +++ b/tests/integration/Cake.Common/Build/GitHubActions/ValidateGitHubActionsProvider.cake @@ -21,7 +21,8 @@ Task("ValidateEnvironment") .DoesForEach( data => new [] { $"CAKE_{data.OS}_NETCOREAPP_6_0_VERSION", - $"CAKE_{data.OS}_NETCOREAPP_7_0_VERSION" + $"CAKE_{data.OS}_NETCOREAPP_7_0_VERSION", + $"CAKE_{data.OS}_NETCOREAPP_8_0_VERSION" }, (data, envKey) => Assert.Equal(data.GitVersion, EnvironmentVariable(envKey)) ); @@ -29,6 +30,7 @@ Task("ValidateEnvironment") Task("ValidatePath") .DoesForEach( new [] { + "Cake\\WTool\\Wtools\\Wnet8\\W0", "Cake\\WTool\\Wtools\\Wnet7\\W0", "Cake\\WTool\\Wtools\\Wnet6\\W0" }, @@ -38,8 +40,9 @@ Task("ValidatePath") Task("ValidateVariable") .DoesForEach( () => new [] { - $"CAKE_NETCOREAPP_6_0_VERSION_OS", - $"CAKE_NETCOREAPP_7_0_VERSION_OS" + "CAKE_NETCOREAPP_6_0_VERSION_OS", + "CAKE_NETCOREAPP_7_0_VERSION_OS", + "CAKE_NETCOREAPP_8_0_VERSION_OS" }, (data, varKey) => Assert.Equal(data.GitVersionAndOS, Argument(varKey)) ); diff --git a/tests/integration/Cake.Common/Tools/Command/CommandAliases.cake b/tests/integration/Cake.Common/Tools/Command/CommandAliases.cake index 835911d09d..34ecc2f4f4 100644 --- a/tests/integration/Cake.Common/Tools/Command/CommandAliases.cake +++ b/tests/integration/Cake.Common/Tools/Command/CommandAliases.cake @@ -31,9 +31,16 @@ Task("Cake.Common.Tools.Command.CommandAliases.CommandStandardOutput") List tools installed globally or locally. Usage: - dotnet tool list [options] + dotnet tool list [] [options] -Options:"; +Arguments: + The NuGet Package Id of the tool to list + +Options: + -g, --global List tools installed for the current user. + --local List the tools installed in the local tool manifest. + --tool-path The directory containing the tools to list. + -?, -h, --help Show command line help."; // When var exitCode = ctx.Command(settings.ToolExecutableNames, out var standardOutput, "tool list -h"); @@ -53,9 +60,16 @@ Task("Cake.Common.Tools.Command.CommandAliases.CommandStandardOutput.Settings") List tools installed globally or locally. Usage: - dotnet tool list [options] + dotnet tool list [] [options] + +Arguments: + The NuGet Package Id of the tool to list -Options:"; +Options: + -g, --global List tools installed for the current user. + --local List the tools installed in the local tool manifest. + --tool-path The directory containing the tools to list. + -?, -h, --help Show command line help."; // When var exitCode = ctx.Command(settings, out var standardOutput, "tool list -h"); @@ -75,9 +89,16 @@ Task("Cake.Common.Tools.Command.CommandAliases.CommandStandardOutput.SettingsCus List tools installed globally or locally. Usage: - dotnet tool list [options] + dotnet tool list [] [options] + +Arguments: + The NuGet Package Id of the tool to list -Options:"; +Options: + -g, --global List tools installed for the current user. + --local List the tools installed in the local tool manifest. + --tool-path The directory containing the tools to list. + -?, -h, --help Show command line help."; // When var exitCode = ctx.Command( diff --git a/tests/integration/Cake.Common/Tools/DotNet/DotNetAliases.cake b/tests/integration/Cake.Common/Tools/DotNet/DotNetAliases.cake index 66e835d469..63f9ef61f2 100644 --- a/tests/integration/Cake.Common/Tools/DotNet/DotNetAliases.cake +++ b/tests/integration/Cake.Common/Tools/DotNet/DotNetAliases.cake @@ -34,7 +34,7 @@ Task("Cake.Common.Tools.DotNet.DotNetAliases.DotNetBuild") // Given var path = Paths.Temp.Combine("./Cake.Common/Tools/DotNet"); var project = path.CombineWithFilePath("hwapp/hwapp.csproj"); - var assembly = path.CombineWithFilePath("hwapp/bin/Debug/net7.0/hwapp.dll"); + var assembly = path.CombineWithFilePath("hwapp/bin/Debug/net8.0/hwapp.dll"); // When DotNetBuild(project.FullPath); @@ -61,7 +61,7 @@ Task("Cake.Common.Tools.DotNet.DotNetAliases.DotNetVSTest") { // Given var path = Paths.Temp.Combine("./Cake.Common/Tools/DotNet"); - var assembly = path.CombineWithFilePath("hwapp.tests/bin/Debug/net7.0/hwapp.tests.dll"); + var assembly = path.CombineWithFilePath("hwapp.tests/bin/Debug/net8.0/hwapp.tests.dll"); // When DotNetVSTest(assembly.FullPath); @@ -184,7 +184,7 @@ Task("Cake.Common.Tools.DotNet.DotNetAliases.DotNetExecute") { // Given var path = Paths.Temp.Combine("./Cake.Common/Tools/DotNet"); - var assembly = path.CombineWithFilePath("hwapp/bin/Debug/net7.0/hwapp.dll"); + var assembly = path.CombineWithFilePath("hwapp/bin/Debug/net8.0/hwapp.dll"); // When DotNetExecute(assembly); @@ -197,7 +197,7 @@ Task("Cake.Common.Tools.DotNet.DotNetAliases.DotNetClean") // Given var path = Paths.Temp.Combine("./Cake.Common/Tools/DotNet"); var project = path.CombineWithFilePath("hwapp/hwapp.csproj"); - var assembly = path.CombineWithFilePath("hwapp/bin/Debug/net7.0/hwapp.dll"); + var assembly = path.CombineWithFilePath("hwapp/bin/Debug/net8.0/hwapp.dll"); Assert.True(System.IO.File.Exists(assembly.FullPath)); // When @@ -214,7 +214,7 @@ Task("Cake.Common.Tools.DotNet.DotNetAliases.DotNetMSBuild") // Given var path = Paths.Temp.Combine("./Cake.Common/Tools/DotNet"); var project = path.CombineWithFilePath("hwapp/hwapp.csproj"); - var assembly = path.CombineWithFilePath("hwapp/bin/Debug/net7.0/hwapp.dll"); + var assembly = path.CombineWithFilePath("hwapp/bin/Debug/net8.0/hwapp.dll"); // When DotNetMSBuild(project.FullPath); diff --git a/tests/integration/Cake.Core/Scripting/AddinDirective.cake b/tests/integration/Cake.Core/Scripting/AddinDirective.cake index 7ed5a21702..f9ee839f33 100644 --- a/tests/integration/Cake.Core/Scripting/AddinDirective.cake +++ b/tests/integration/Cake.Core/Scripting/AddinDirective.cake @@ -24,7 +24,8 @@ Task("Cake.Core.Scripting.AddinDirective.LoadTargetedAddin") cake switch { FilePath net6_0Path when net6_0Path.FullPath.Contains("net6.0") => "net6.0", - _ => "net7.0" + FilePath net7_0Path when net7_0Path.FullPath.Contains("net7.0") => "net7.0", + _ => "net8.0" } ); diff --git a/tests/integration/Cake.Core/Scripting/DefineDirective.cake b/tests/integration/Cake.Core/Scripting/DefineDirective.cake index 201d8dc6a2..9e55338918 100644 --- a/tests/integration/Cake.Core/Scripting/DefineDirective.cake +++ b/tests/integration/Cake.Core/Scripting/DefineDirective.cake @@ -52,6 +52,8 @@ Task("Cake.Core.Scripting.DefineDirective.Runtime") "6.0", #elif NET7_0 "7.0", +#elif NET8_0 + "8.0", #endif context.Environment.Runtime.BuiltFramework.FullName); }); @@ -68,7 +70,7 @@ Task("Cake.Core.Scripting.DefineDirective.Cake") Assert.True(cake); }); -#if NET6_0 || NET7_0 +#if NET6_0 || NET7_0 || NET8_0 Task("Cake.Core.Scripting.DefineDirective.C#9") .Does(() => { @@ -80,7 +82,7 @@ Task("Cake.Core.Scripting.DefineDirective.Cake") public record CSharpNine(bool IsNine); #endif -#if NET6_0 || NET7_0 +#if NET6_0 || NET7_0 || NET8_0 Task("Cake.Core.Scripting.DefineDirective.C#10") .Does(() => { @@ -97,7 +99,7 @@ public record CSharpNine(bool IsNine); #endif -#if NET7_0 +#if NET7_0 || NET8_0 Task("Cake.Core.Scripting.DefineDirective.C#11") .Does(() => { @@ -114,17 +116,33 @@ public record CSharpNine(bool IsNine); #endif +#if NET8_0 + Task("Cake.Core.Scripting.DefineDirective.C#12") + .Does(() => +{ + // Given / When / Then + int[] row0 = [1, 2, 3]; + int[] row1 = [4, 5, 6]; + int[] row2 = [7, 8, 9]; + int[] single = [..row0, ..row1, ..row2]; +}); + +#endif + ////////////////////////////////////////////////////////////////////////////// Task("Cake.Core.Scripting.DefineDirective") -#if NET6_0 || NET7_0 +#if NET6_0 || NET7_0 || NET8_0 .IsDependentOn("Cake.Core.Scripting.DefineDirective.C#9") #endif -#if NET6_0 || NET7_0 +#if NET6_0 || NET7_0 || NET8_0 .IsDependentOn("Cake.Core.Scripting.DefineDirective.C#10") #endif -#if NET7_0 +#if NET7_0 || NET8_0 .IsDependentOn("Cake.Core.Scripting.DefineDirective.C#11") +#endif +#if NET8_0 + .IsDependentOn("Cake.Core.Scripting.DefineDirective.C#12") #endif .IsDependentOn("Cake.Core.Scripting.DefineDirective.Defined") .IsDependentOn("Cake.Core.Scripting.DefineDirective.NotDefined") diff --git a/tests/integration/Cake.Frosting/build/Build.csproj b/tests/integration/Cake.Frosting/build/Build.csproj index 967a3cf7fc..cfa2e4c11c 100644 --- a/tests/integration/Cake.Frosting/build/Build.csproj +++ b/tests/integration/Cake.Frosting/build/Build.csproj @@ -2,7 +2,7 @@ Exe - net6.0;net7.0 + net6.0;net7.0;net8.0 true diff --git a/tests/integration/resources/Cake.Common/Tools/DotNet/hwapp.tests/hwapp.tests.csproj b/tests/integration/resources/Cake.Common/Tools/DotNet/hwapp.tests/hwapp.tests.csproj index 809b83300c..5ba87a6f84 100644 --- a/tests/integration/resources/Cake.Common/Tools/DotNet/hwapp.tests/hwapp.tests.csproj +++ b/tests/integration/resources/Cake.Common/Tools/DotNet/hwapp.tests/hwapp.tests.csproj @@ -1,15 +1,18 @@  - net7.0 + net8.0 false - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + diff --git a/tests/integration/resources/Cake.Common/Tools/DotNet/hwapp/hwapp.csproj b/tests/integration/resources/Cake.Common/Tools/DotNet/hwapp/hwapp.csproj index c54cbbeb30..b2fa4dff47 100644 --- a/tests/integration/resources/Cake.Common/Tools/DotNet/hwapp/hwapp.csproj +++ b/tests/integration/resources/Cake.Common/Tools/DotNet/hwapp/hwapp.csproj @@ -1,7 +1,7 @@  Exe - net7.0 + net8.0