Skip to content

Best practice to use IResult in a class library #44250

@lt-gerjan

Description

@lt-gerjan

What is the best way to use the new IResult type in a class library?

I did abstract / port some code to a shared library (2 edge api's, one shared api lib) but I really struggled to get the IResult type and Results factory in the lib.

My first reaction was to find it in nuget packages like Microsoft.AspNetCore.Http, Microsoft.AspNetCore.Http.Extensions or Microsoft.AspNetCore.Http.Abstractions but no success.

Then I remembered that the whole distribution of frameworks did change. In the old days everything was distributed via NuGet but now the frameworks/app models are distributed as SDK that you install on your machine. So the dlls are right there but how to reference it?

I think the Nuget packages above are not updated anymore, thats correct?

One way to fix it, is to change the csproject to <Project Sdk="Microsoft.NET.Sdk.Web"> and then it works.

But it does feel a bit 'heavy', only when you want to reference 1 type and access one factory.

So whats best practice on this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions