Closed jchannon closed 9 years ago
missing using
statement?
Nope, thats under the Nancy namespace
OK, something weird going on there. We may have an oddity in how the usings work with script packs.
I see the problem. In the code above, Response
is a reference to the static class Response
. When you write that same code in a module, Response
is a reference to the instance property NancyModule.Response
.
The ambiguity of not enforcing this.
strikes again (/cc @damianh :wink:).
Try this instead:
pack.Module(m => m.Get["/redirect"] = _ => m.Response.AsRedirect("http://google.com"));
I get `ERROR: Script execution failed: (1,14):
Works for me. Is this mono?
Yup! Happy days :)
On 24 March 2015 at 11:38, Adam Ralph notifications@github.com wrote:
Works for me. Is this mono?
Reply to this email directly or view it on GitHub https://github.com/adamralph/scriptcs-nancy/issues/113#issuecomment-85459135 .
Works for me under mono. But on Windows.
Actually no it doesn't. I have exactly the same error.
The mono engine is blowing up on the nested lambda. You can work around it like this
Action<NancyModule> addRoute = m =>
m.Get["/redirect"] = _ => m.Response.AsRedirect("http://google.com");
pack.Module(m => addRoute(m));
In all honesty, there's little appetite fix things like this in the mono engine at the moment, given that the focus is now to move to the new x-plat Roslyn (https://github.com/scriptcs/scriptcs-engines) so we can dump the Mono engine.
Fair enough.
This also errors for me but not sure why?
pack.Get("/test", _ => new {Key = "bob"});
If I put this in my script and new it up that its fine so I assume maybe its the scriptcs mono engine not liking anonymous types
public class MyTest
{
public string Key {get;set;}
}
:ok_hand: your diagnosis is spot on. It doesn't like anonymous types and they don't like it.
It only has a small circle of friends.
So how far is the scriptcs roslyn stuff in terms of readiness (if that makes any sense at all)?
On 24 March 2015 at 15:15, Adam Ralph notifications@github.com wrote:
[image: :ok_hand:] your diagnosis is spot on. It doesn't like anonymous types and they don't like it.
It only has a small circle of friends.
Reply to this email directly or view it on GitHub https://github.com/adamralph/scriptcs-nancy/issues/113#issuecomment-85546754 .
It's close. We're working with @dotnet to close the gaps. You can try it out yourself now, but we don't have it on NuGet yet.
@filipw do you mind chiming in and giving @jchannon instructions for how to try out the new C# engine?
Good luck with the mono compiler... :stuck_out_tongue_winking_eye:
WTF, even MS is X-Plat these days, you guys are so enterprise!
Roslyn is not x-plat
Our code is x-plat. But our upstream dep (built by MS) is not..
Bloody MS :smile:
@jchannon I guess I can close this since there's nothing that can be done in the script pack?
You could raise an issue for the mono engine deficiencies over at https://github.com/scriptcs/scriptcs but as I say, it's doubtful they'll get fixed.
I am unable to use
pack.Get("/redirect", _ => Response.AsRedirect("http://google.com"));
as it errors witherror CS0117:
Nancy.Response' does not contain a definition forAsRedirect'