{"action":"created","issue":{"url":"https://api.github.com/repos/cake-build/cake/issues/1285","repository_url":"https://api.github.com/repos/cake-build/cake","labels_url":"https://api.github.com/repos/cake-build/cake/issues/1285/labels{/name}","comments_url":"https://api.github.com/repos/cake-build/cake/issues/1285/comments","events_url":"https://api.github.com/repos/cake-build/cake/issues/1285/events","html_url":"https://github.com/cake-build/cake/issues/1285","id":183381732,"number":1285,"title":"Unable to use custom static classes with extension methods in cake scripts","user":{"login":"modernist","id":1212380,"avatar_url":"https://avatars.githubusercontent.com/u/1212380?v=3","gravatar_id":"","url":"https://api.github.com/users/modernist","html_url":"https://github.com/modernist","followers_url":"https://api.github.com/users/modernist/followers","following_url":"https://api.github.com/users/modernist/following{/other_user}","gists_url":"https://api.github.com/users/modernist/gists{/gist_id}","starred_url":"https://api.github.com/users/modernist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/modernist/subscriptions","organizations_url":"https://api.github.com/users/modernist/orgs","repos_url":"https://api.github.com/users/modernist/repos","events_url":"https://api.github.com/users/modernist/events{/privacy}","received_events_url":"https://api.github.com/users/modernist/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cake-build/cake/labels/Investigate","name":"Investigate","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-17T10:37:54Z","updated_at":"2016-10-25T14:46:28Z","closed_at":null,"body":"### What You Are Seeing?\r\nI have added a static class containing extension methods for the `AssemblyInforParseResult` class in order to simplify the instantiation of an `AssemblyInfoSettings` object. When running the build, I get the following message:\r\n~~~sh\r\nError: M:/Projects/Dev/CakeTest/common.cake(34,40): error CS1109: Extension methods must be defined in a top level static class; VersioningHelper is a nested class\r\n~~~\r\n### What is Expected?\r\nI would expect the build script to be compiled without errors.\r\nI am guessing this happens because Cake converts the entire cake.build into a single class that is then complied with Roslyn, thus my custom class turns into a nested class, and, correctly, the compiler doesn't allow declaring extension methods in it. I am able to circumvent this by creating a class library with the custom functionality and referencing it, but this is not very convenient as the cake script is no longer self-contained.\r\n\r\n### What version of Cake are you using? Are you running on a 32 or 64 bit system? What environment are you running on?  Windows? Linux? Mac? Are you running on a CI Server?  If so, which one?\r\nI am running Cake 0.16.2 on Windows (64bit), both locally and on (on-premise) TFS.\r\n\r\n### How Did You Get This To Happen? (Steps to Reproduce)\r\n\r\nAdd a static class containing extension methods to a cake script\r\n\r\n### Output Log\r\n~~~sh\r\nModule directory does not exist.\r\nAnalyzing build script...\r\nAnalyzing M:/Projects/Dev/CakeTest/build.cake...\r\nAnalyzing M:/Projects/Dev/CakeTest/common.cake...\r\nProcessing build script...\r\nInstalling addins...\r\nPackage Cake.FileHelpers has already been installed.\r\nThe addin Cake.FileHelpers will reference Cake.FileHelpers.dll.\r\nCreating script session...\r\nAdding reference to mscorlib.dll...\r\nAdding reference to System.dll...\r\nAdding reference to System.Core.dll...\r\nAdding reference to System.Data.dll...\r\nAdding reference to System.Xml.dll...\r\nAdding reference to System.Xml.Linq.dll...\r\nAdding reference to Cake.Core.dll...\r\nAdding reference to Cake.Common.dll...\r\nAdding reference to Cake.exe...\r\nAdding reference to Cake.FileHelpers.dll...\r\nImporting namespace Cake.Common...\r\nImporting namespace Cake.Common.Build...\r\nImporting namespace Cake.Common.Build.AppVeyor...\r\nImporting namespace Cake.Common.Build.AppVeyor.Data...\r\nImporting namespace Cake.Common.Build.BitbucketPipelines...\r\nImporting namespace Cake.Common.Build.BitbucketPipelines.Data...\r\nImporting namespace Cake.Common.Build.Bitrise...\r\nImporting namespace Cake.Common.Build.Bitrise.Data...\r\nImporting namespace Cake.Common.Build.ContinuaCI...\r\nImporting namespace Cake.Common.Build.ContinuaCI.Data...\r\nImporting namespace Cake.Common.Build.Jenkins...\r\nImporting namespace Cake.Common.Build.Jenkins.Data...\r\nImporting namespace Cake.Common.Build.TravisCI...\r\nImporting namespace Cake.Common.Build.TravisCI.Data...\r\nImporting namespace Cake.Common.Diagnostics...\r\nImporting namespace Cake.Common.IO...\r\nImporting namespace Cake.Common.IO.Paths...\r\nImporting namespace Cake.Common.Net...\r\nImporting namespace Cake.Common.Security...\r\nImporting namespace Cake.Common.Solution...\r\nImporting namespace Cake.Common.Solution.Project...\r\nImporting namespace Cake.Common.Solution.Project.Properties...\r\nImporting namespace Cake.Common.Solution.Project.XmlDoc...\r\nImporting namespace Cake.Common.Text...\r\nImporting namespace Cake.Common.Tools...\r\nImporting namespace Cake.Common.Tools.Cake...\r\nImporting namespace Cake.Common.Tools.Chocolatey...\r\nImporting namespace Cake.Common.Tools.Chocolatey.ApiKey...\r\nImporting namespace Cake.Common.Tools.Chocolatey.Config...\r\nImporting namespace Cake.Common.Tools.Chocolatey.Features...\r\nImporting namespace Cake.Common.Tools.Chocolatey.Install...\r\nImporting namespace Cake.Common.Tools.Chocolatey.Pack...\r\nImporting namespace Cake.Common.Tools.Chocolatey.Pin...\r\nImporting namespace Cake.Common.Tools.Chocolatey.Push...\r\nImporting namespace Cake.Common.Tools.Chocolatey.Sources...\r\nImporting namespace Cake.Common.Tools.Chocolatey.Upgrade...\r\nImporting namespace Cake.Common.Tools.DNU...\r\nImporting namespace Cake.Common.Tools.DNU.Build...\r\nImporting namespace Cake.Common.Tools.DNU.Pack...\r\nImporting namespace Cake.Common.Tools.DNU.Restore...\r\nImporting namespace Cake.Common.Tools.DotCover...\r\nImporting namespace Cake.Common.Tools.DotCover.Analyse...\r\nImporting namespace Cake.Common.Tools.DotCover.Cover...\r\nImporting namespace Cake.Common.Tools.DotNetCore...\r\nImporting namespace Cake.Common.Tools.DotNetCore.Build...\r\nImporting namespace Cake.Common.Tools.DotNetCore.Execute...\r\nImporting namespace Cake.Common.Tools.DotNetCore.Pack...\r\nImporting namespace Cake.Common.Tools.DotNetCore.Publish...\r\nImporting namespace Cake.Common.Tools.DotNetCore.Restore...\r\nImporting namespace Cake.Common.Tools.DotNetCore.Run...\r\nImporting namespace Cake.Common.Tools.DotNetCore.Test...\r\nImporting namespace Cake.Common.Tools.DupFinder...\r\nImporting namespace Cake.Common.Tools.Fixie...\r\nImporting namespace Cake.Common.Tools.GitLink...\r\nImporting namespace Cake.Common.Tools.GitReleaseManager...\r\nImporting namespace Cake.Common.Tools.GitReleaseManager.AddAssets...\r\nImporting namespace Cake.Common.Tools.GitReleaseManager.Close...\r\nImporting namespace Cake.Common.Tools.GitReleaseManager.Create...\r\nImporting namespace Cake.Common.Tools.GitReleaseManager.Export...\r\nImporting namespace Cake.Common.Tools.GitReleaseManager.Publish...\r\nImporting namespace Cake.Common.Tools.GitReleaseNotes...\r\nImporting namespace Cake.Common.Tools.GitVersion...\r\nImporting namespace Cake.Common.Tools.ILMerge...\r\nImporting namespace Cake.Common.Tools.ILRepack...\r\nImporting namespace Cake.Common.Tools.InspectCode...\r\nImporting namespace Cake.Common.Tools.MSBuild...\r\nImporting namespace Cake.Common.Tools.MSTest...\r\nImporting namespace Cake.Common.Tools.NSIS...\r\nImporting namespace Cake.Common.Tools.NuGet...\r\nImporting namespace Cake.Common.Tools.NuGet.Install...\r\nImporting namespace Cake.Common.Tools.NuGet.Pack...\r\nImporting namespace Cake.Common.Tools.NuGet.Push...\r\nImporting namespace Cake.Common.Tools.NuGet.Restore...\r\nImporting namespace Cake.Common.Tools.NuGet.SetApiKey...\r\nImporting namespace Cake.Common.Tools.NuGet.SetProxy...\r\nImporting namespace Cake.Common.Tools.NuGet.Sources...\r\nImporting namespace Cake.Common.Tools.NuGet.Update...\r\nImporting namespace Cake.Common.Tools.NUnit...\r\nImporting namespace Cake.Common.Tools.OctopusDeploy...\r\nImporting namespace Cake.Common.Tools.OpenCover...\r\nImporting namespace Cake.Common.Tools.ReportGenerator...\r\nImporting namespace Cake.Common.Tools.ReportUnit...\r\nImporting namespace Cake.Common.Tools.Roundhouse...\r\nImporting namespace Cake.Common.Tools.SignTool...\r\nImporting namespace Cake.Common.Tools.SpecFlow...\r\nImporting namespace Cake.Common.Tools.SpecFlow.StepDefinitionReport...\r\nImporting namespace Cake.Common.Tools.SpecFlow.TestExecutionReport...\r\nImporting namespace Cake.Common.Tools.TextTransform...\r\nImporting namespace Cake.Common.Tools.VSTest...\r\nImporting namespace Cake.Common.Tools.WiX...\r\nImporting namespace Cake.Common.Tools.WiX.Heat...\r\nImporting namespace Cake.Common.Tools.XBuild...\r\nImporting namespace Cake.Common.Tools.XUnit...\r\nImporting namespace Cake.Common.Xml...\r\nImporting namespace Cake.Core...\r\nImporting namespace Cake.Core.Diagnostics...\r\nImporting namespace Cake.Core.IO...\r\nImporting namespace Cake.Core.Scripting...\r\nImporting namespace Cake.FileHelpers...\r\nImporting namespace System...\r\nImporting namespace System.Collections.Generic...\r\nImporting namespace System.IO...\r\nImporting namespace System.Linq...\r\nImporting namespace System.Text...\r\nImporting namespace System.Threading.Tasks...\r\nCompiling build script...\r\nError: Roslyn.Compilers.CompilationErrorException: M:/Projects/Dev/CakeTest/common.cake(34,40): error CS1109: Extension methods must be defined in a top level static class; VersioningHelper is a nested class\r\n   at Roslyn.Scripting.CommonScriptEngine.CompilationError(DiagnosticBag localDiagnostics, DiagnosticBag diagnostics)\r\n   at Roslyn.Scripting.CommonScriptEngine.Compile(String code, String path, DiagnosticBag diagnostics, Session session, Type delegateType, Type returnType, CancellationToken cancellationToken, Boolean isInteractive, Boolean isExecute, CommonCompilation& compilation, Delegate& factory)\r\n   at Roslyn.Scripting.CommonScriptEngine.Execute[T](String code, String path, DiagnosticBag diagnostics, Session session, Boolean isInteractive)\r\n   at Roslyn.Scripting.Session.Execute(String code)\r\n   at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments)\r\n   at Cake.Commands.BuildCommand.Execute(CakeOptions options)\r\n   at Cake.CakeApplication.Run(CakeOptions options)\r\n   at Cake.Program.Main()\r\n~~~"},"comment":{"url":"https://api.github.com/repos/cake-build/cake/issues/comments/256056234","html_url":"https://github.com/cake-build/cake/issues/1285#issuecomment-256056234","issue_url":"https://api.github.com/repos/cake-build/cake/issues/1285","id":256056234,"user":{"login":"patriksvensson","id":357872,"avatar_url":"https://avatars.githubusercontent.com/u/357872?v=3","gravatar_id":"","url":"https://api.github.com/users/patriksvensson","html_url":"https://github.com/patriksvensson","followers_url":"https://api.github.com/users/patriksvensson/followers","following_url":"https://api.github.com/users/patriksvensson/following{/other_user}","gists_url":"https://api.github.com/users/patriksvensson/gists{/gist_id}","starred_url":"https://api.github.com/users/patriksvensson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patriksvensson/subscriptions","organizations_url":"https://api.github.com/users/patriksvensson/orgs","repos_url":"https://api.github.com/users/patriksvensson/repos","events_url":"https://api.github.com/users/patriksvensson/events{/privacy}","received_events_url":"https://api.github.com/users/patriksvensson/received_events","type":"User","site_admin":false},"created_at":"2016-10-25T14:46:28Z","updated_at":"2016-10-25T14:46:28Z","body":"Yes, if it requires Roslyn we can add this as soon as we unify the script engines."}}
{"actor":{"display_login":"patriksvensson"}}