Giter Site home page Giter Site logo

Asp.Net Core - Consider Changing Dependency from Microsoft.AspNetCore.Mvc to Microsoft.AspNetCore.Mvc.Core about aspnet-api-versioning HOT 7 CLOSED

dotnet avatar dotnet commented on May 22, 2024
Asp.Net Core - Consider Changing Dependency from Microsoft.AspNetCore.Mvc to Microsoft.AspNetCore.Mvc.Core

from aspnet-api-versioning.

Comments (7)

commonsensesoftware avatar commonsensesoftware commented on May 22, 2024 1

A quick update on this issue. It appears that referencing only Microsoft.AspNetCore.Mvc.Core should be fine. Updating the references with in project.json model can be a pain. Due to transitive dependencies, a few things had to change for test projects. I'm looking forward to converting back to *.csproj when VS2017 is released as soon as I have time.

I've got a few items queued up. I'll include this change and it should go out in the 1.1.0 release. I'm hoping to have that done within the next week (maybe lesss).

from aspnet-api-versioning.

AdamDotNet avatar AdamDotNet commented on May 22, 2024

I cloned the repository and took a stab at this. The only changes were project.json from the main .Net Core project:
"Microsoft.AspNetCore.Mvc": "1.0.0" => "Microsoft.AspNetCore.Mvc.Core": "1.0.0"

And the two unit test projects had some
IApplicationBuilder.AddMvc() => IApplicationBuilder.AddMvcCore()
class [TestController] : Controller => class [TestController] : ControllerBase

Everything compiled, but 34 tests of tests started failed because of getting NotAcceptable (406 I think) status codes back from the server instead of whatever code the test was expecting. I don't understand why at the moment.

from aspnet-api-versioning.

AdamDotNet avatar AdamDotNet commented on May 22, 2024

At this point, I've seen two results:

Take the following test:
_a_query_string_versioned_Controller_per_namespace._get_should_return_200

At one point, I saw that it returned 4 possible actions to select with the error message (notice all 4 are exactly the same):

Multiple actions matched. The following actions matched route data and had all constraints satisfied:

Microsoft.AspNetCore.Mvc.ByNamespace.Controllers.V1.AgreementsController.Get (Microsoft.AspNetCore.Mvc.Acceptance.Tests)
Microsoft.AspNetCore.Mvc.ByNamespace.Controllers.V1.AgreementsController.Get (Microsoft.AspNetCore.Mvc.Acceptance.Tests)
Microsoft.AspNetCore.Mvc.ByNamespace.Controllers.V1.AgreementsController.Get (Microsoft.AspNetCore.Mvc.Acceptance.Tests)
Microsoft.AspNetCore.Mvc.ByNamespace.Controllers.V1.AgreementsController.Get (Microsoft.AspNetCore.Mvc.Acceptance.Tests)

For now, I might leave that as a debugging oddity. The second result I've seen is perhaps what should have worked. See the class:

Microsoft.AspNetCore.Mvc.Versioning.ApiVersionActionSelector.SelectBestCandidate

The branch else if ( finalMatches.Count == 1 ) is hit and a single action descriptor is returned. After that, ReportApiVersionsAttribute does its thing, then the debugger reports I'm in external code, and suddenly the test fails with HTTP 406, Not Acceptable.

This is a head scratcher for me because by all means the code appeared to succeed.

from aspnet-api-versioning.

commonsensesoftware avatar commonsensesoftware commented on May 22, 2024

I'm definitely in support of the fewest number of dependencies. I'm trying to remember the details, but I seem to remember there was some reason why *.Mvc was needed over *.MvcCore. It's possible that things have changed in 1.1 from 1.0. It's definitely worth investigating.

Do you have the latest changes? There were a couple of flakey tests that took me a long time to figure out why. Ultimately, it was a mistake and bug on my part. That has since been resolved. The latest codebase should run the tests reliably for any changes you make.

I'll look at dropping the dependencies down a level in the next release. There's no sense in claiming the library needs more than it does.

from aspnet-api-versioning.

AdamDotNet avatar AdamDotNet commented on May 22, 2024

I'll try latest code again when I get settled back in after the holiday break and then report back.

from aspnet-api-versioning.

AdamDotNet avatar AdamDotNet commented on May 22, 2024

I'm fairly novice to Git style source control... but I just did a fork of the Master branch to https://github.com/AdamDotNet/aspnet-api-versioning (note that I didn't check in my changes to my fork yet)

I then reapplied the changes to MvcCore.

The same result of the 34 unit tests failing still occurs.

from aspnet-api-versioning.

AdamDotNet avatar AdamDotNet commented on May 22, 2024

One thing I forgot to mention is I didn't have the exact same .Net Core SDK installed, so global.json was changed to

"sdk": { "version": "1.0.0-preview2-003131" }

This is just a slightly newer version of the .Net Core 1.0.0 SDK.

from aspnet-api-versioning.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.