question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Best practice to use IResult in a class library

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
vijayrkncommented, Sep 30, 2022

If such a support were to exist, I would assume it needs to be more generic than just for Web projects. May be something for the project system backlog - https://github.com/dotnet/project-system?

0reactions
adityamandaleekacommented, Oct 1, 2022

Thanks @DamianEdwards. Closing this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IResult (from Asp) not found in standard 2.0 project
I did find a way that will work: HttpResponseMessage as produced by HttpClient.GetAsync is usable in .net core. Whether or not these classes...
Read more >
Dependency injection guidelines - .NET
This article provides general guidelines and best practices for implementing dependency injection in .NET applications.
Read more >
Test a .NET class library using Visual Studio
Learn how to use Visual Studio to create and run a unit test project for a .NET class library.
Read more >
Why no one recommends the use of the standard library's ...
Why no one recommends the use of the standard library's Result class but a custom sealed class approach? The Result class is so...
Read more >
ASP.NET Core Web API Best Practices
In this post, we are going to write about what we consider to be the best practices while developing the .NET Core Web...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found