Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetFullName in TypeExtensions.cs not handling arrays correctly #1091

Closed
kcamp opened this issue Jul 21, 2016 · 2 comments · Fixed by #1093
Closed

GetFullName in TypeExtensions.cs not handling arrays correctly #1091

kcamp opened this issue Jul 21, 2016 · 2 comments · Fixed by #1093
Labels
Milestone

Comments

@kcamp
Copy link
Contributor

kcamp commented Jul 21, 2016

What You Are Seeing?

When creating a CakeMethodAlias method with a params System.Linq.Expressions.Expression<Func<string,string>> expressions parameter, the resulting Roslyn compilation fails.

Error: Roslyn.Compilers.CompilationErrorException: (1918,131): error CS0231: A params parameter must be the last parameter in a formal parameter list
   at Roslyn.Scripting.CommonScriptEngine.CompilationError(DiagnosticBag localDiagnostics, DiagnosticBag diagnostics)
   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)
   at Roslyn.Scripting.CommonScriptEngine.Execute[T](String code, String path, DiagnosticBag diagnostics, Session session, Boolean isInteractive)
   at Roslyn.Scripting.Session.Execute(String code)
   at Cake.Scripting.Roslyn.Stable.DefaultRoslynScriptSession.Execute(Script script) in C:\git\cake\src\Cake\Scripting\Roslyn\Stable\DefaultRoslynScriptSession.cs:line 31
   at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments) in C:\git\cake\src\Cake.Core\Scripting\ScriptRunner.cs:line 189
   at Cake.Commands.BuildCommand.Execute(CakeOptions options) in C:\git\cake\src\Cake\Commands\BuildCommand.cs:line 33
   at Cake.CakeApplication.Run(CakeOptions options) in C:\git\cake\src\Cake\CakeApplication.cs:line 46
   at Cake.Program.Main() in C:\git\cake\src\Cake\Program.cs:line 69

What is Expected?

I would expect the compilation to work as expected.

What version of Cake are you using?

0.14

Are you running on a 32 or 64 bit system?

x64

What environment are you running on? Windows? Linux? Mac?

Windows

Are you running on a CI Server? If so, which one?

No

How Did You Get This To Happen? (Steps to Reproduce)

Author a Cake add-in with the following method signature - actual implementation is obfuscated, it's the method signature that's causing the issue.

[CakeMethodAlias]
public static object DoSomething(this ICakeContext context, FilePath path, params Expression<Func<string, string>>[] properties)
{
    if (context == null)
    {
        throw new ArgumentNullException(nameof(context));
    }

    // implementation ...

    throw new NotImplementedException();
}

Output Log

https://gist.github.com/kcamp/b08e1b5527baf2216a8005628652dbef

Further investigation shows that the underlying code being serialized for Roslyn in RoslynCodeGenerator.cs is malformed.

public object DoSomething(Cake.Core.IO.FilePath path, params System.Linq.Expressions.Expression`1[[System.Func`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]][] properties)
{
    return My.NameSpace.ProjectAliases.DoSomething(Context, path, properties);
}
@kcamp
Copy link
Contributor Author

kcamp commented Jul 21, 2016

I have a fix for this and will submit a PR shortly

@devlead
Copy link
Member

devlead commented Jul 21, 2016

@kcamp thanks notifying us about this issue 👍 , for your PR please start Cake with -mono flag to so we see if mono has the same issue and it gets resolved there too.

@devlead devlead added this to the v0.15.0 milestone Jul 21, 2016
@devlead devlead added the Bug label Jul 21, 2016
kcamp added a commit to kcamp/cake that referenced this issue Jul 21, 2016
…methods are not being generated correctly for re-compilation
devlead added a commit that referenced this issue Jul 22, 2016
GH-1091 - Fix issue where array types appearing in aliased methods ar…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants