Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Nancy 2.0.0-clinteastwood feedback #2659

Closed
4 of 12 tasks
thecodejunkie opened this issue Dec 22, 2016 · 8 comments
Closed
4 of 12 tasks

Nancy 2.0.0-clinteastwood feedback #2659

thecodejunkie opened this issue Dec 22, 2016 · 8 comments

Comments

@thecodejunkie
Copy link
Member

thecodejunkie commented Dec 22, 2016

If you find any problems, please open an issue and provide as much information, as possible, to help us identify your problem. Alternatively, feel free to submit a pull-request if you think you can help resolve the problem. If you need a guiding hand, on how to get started with pull-requests, please have a look at our contributing guidelines. Make sure you don't miss the style guidelines, I won't :D

NOTE: Because Nancy 2.0-clinteastwood is a pre-release, you are going to have to install packages using the -pre toggle, i.e install-package Nancy -pre

Please use this issue for posting comments that are not directly related to any specific reported bug or pull-request.

TODO

The following is a list of identified task that needs to be performed in the wake of the 2.0.0-clinteastwood release and should be completed before 2.0.0-dangermouse is released. Edit the TODO-list and add items as they are found, add links to pull-requests that are sent to close them

Planned changes

Known limitations

  • Some packages may install AsyncUsageAnalyzers as a dependency. This should be safe to be removed and will not be included in 2.0.0-dangermouse as it will be marked as a build dependency in all projects
  • The Nancy.Hosting.Aspnet package will not apply *.config transformations`, to wire up the hosting, you will have to apply it yourself
  • The Nancy.ViewEngines.Razor package will not apply *.config transformations` to wire up the view engines configuration options, you will have to apply it yourself
  • The build providers for Nancy.ViewEngines.Razor are missing from the NuGet package, causing problems with syntax highlighting in Nancy Razor views
@danbarua
Copy link
Contributor

This compiles, but throws a run-time NullReferenceException:

pipelines.BeforeRequest.AddItemToStartOfPipeline((ctx, _) =>
{
    // do stuff
    // Func<NancyContext, Response>, Func<NancyContext, CancellationToken, Response>
    return null;
});

This works:

pipelines.BeforeRequest.AddItemToStartOfPipeline((ctx, _) =>
{
    //do stuff
    // Func<NancyContext, CancellationToken, Task<Response>>
    return Task<Response>.FromResult((Response)null);
});

It took a bit of bashing my head against the wall until I figured it out which is neither super-duper nor happy.

@thecodejunkie
Copy link
Member Author

@danbarua thanks. I've opened #2665 because I want to give the pipeline stuff an overhaul as soon as we've had the time to look at the bootstrapper (which will happen as soon as I've moved us to the new csproj format and that's happening now in #2720)

YAK SHAVING! 😄

@IASamoylov
Copy link

This code throw an exception, is this bug?

public class BaseModule : NancyModule
{
    public BaseModule(string url) : base(url)
    {
        //Custom logic
    }
}

public class A : BaseModule
{
    public A() : base("urlA")
    {
      
    }
}

public class B : NancyModule
{
    public B()
    {
      
    }
}
System.InvalidOperationException occurred
  HResult=0x80131509
  Message=Something went wrong when trying to satisfy one of the dependencies during composition, make sure that you've registered all new dependencies in the container and inspect the innerexception for more details.
  Source=<Cannot evaluate the exception source>
  StackTrace:
   at Nancy.Bootstrapper.NancyBootstrapperBase`1.SafeGetNancyEngineInstance()
   at Nancy.Bootstrapper.NancyBootstrapperBase`1.GetEngine()
   at Nancy.Owin.NancyMiddleware.UseNancy(NancyOptions options)
   at Nancy.Owin.DelegateExtensions.UseNancy(Action`1 builder, NancyOptions options)
   at PiggyBank.Site.Startup.<>c.<Configure>b__2_0(Action`1 x) in E:\visual_studio\piggy-bank\source\PiggyBank.Site\Startup.cs:line 31
   at Microsoft.AspNetCore.Builder.OwinExtensions.UseOwin(IApplicationBuilder builder, Action`1 pipeline)
   at PiggyBank.Site.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) in E:\visual_studio\piggy-bank\source\PiggyBank.Site\Startup.cs:line 31

Inner Exception 1:
TinyIoCResolutionException: Unable to resolve type: Nancy.NancyEngine

Inner Exception 2:
TinyIoCResolutionException: Unable to resolve type: Nancy.Routing.DefaultRequestDispatcher

Inner Exception 3:
TinyIoCResolutionException: Unable to resolve type: Nancy.Routing.DefaultRouteResolver

Inner Exception 4:
TinyIoCResolutionException: Unable to resolve type: Nancy.Routing.RouteCache

Inner Exception 5:
TinyIoCResolutionException: Unable to resolve type: BaseModule

Inner Exception 6:
TinyIoCResolutionException: Unable to resolve type: System.String

Inner Exception 7:
TinyIoCResolutionException: Unable to resolve type: System.Char[]

Inner Exception 8:
ArgumentNullException: Value cannot be null.

@khellang
Copy link
Member

It's because the base module doesn't have a constructor that the IoC container can satisfy. It doesn't know how to handle string. If the BaseModule Isn't supposed to be called by itself, I suggest you make it abstract...

@zwcloud
Copy link

zwcloud commented Jul 26, 2017

Old:

Get["post/{id}"] = Get["old/post/{id}"] = p =>{};

New(2.0):

?

@SlowLogicBoy
Copy link

Get("post/{id}", MyMethod);
Get("old/post/{id}", MyMethod);

@zwcloud
Copy link

zwcloud commented Jul 26, 2017

Get("post/{id}", MyMethod);
Get("old/post/{id}", MyMethod);

That usage adds some indirection. I personally don't like that. Not a problem though.

@jeff-pang
Copy link
Contributor

jeff-pang commented Aug 11, 2017

Maybe it is possible to have some method overloads for fluent expression? example:

Get("post/{id}")
.Get("old/post/{id}")
.Post("whatever/{id}", p => { return HttpStatusCode.Ok });

An alternate expression

Get("post/{id}")
.Get("old/post/{id}")
.Post("whatever/{id}")
.Do(p => { return HttpStatusCode.Ok });

I can take a stab at PR if this is desirable

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants