BADF00D / DisposableFixer

This is a Visual Studio Extension and NuGet package that should identify and fix problems as memleaks while using IDisposables.
Other
35 stars 7 forks source link

Accept RegisterForDispose() #68

Closed zuckerthoben closed 7 years ago

zuckerthoben commented 7 years ago

The extension does not accept the ASP.Net core feature RegisterForDispose. In an ASP.Net core Web Api you get unnecessary overhead when directly disposing your IDisposables in your controller actions before the response. With RegisterForDispose the Middleware automatically disposes the registered ressources after finishing the request.
See: https://andrewlock.net/four-ways-to-dispose-idisposables-in-asp-net-core/

BADF00D commented 7 years ago

So RegisterForDispose is a static method that keeps track of all IDisposables until they can disposed safely?

Can you provide the full qualified namespace for the class where the method is defined and the signature of the method? I only found the source for the old asp.net stack (line 674 and 694)

zuckerthoben commented 7 years ago

Src: https://github.com/aspnet/HttpAbstractions/blob/a78b194a84cfbc560a56d6d951eb71c8367d17bb/src/Microsoft.AspNetCore.Http.Abstractions/HttpResponse.cs

The summary of the method says: "Registers an object for disposal by the host once the request has finished processing". So yeah, thats what it does. It hooks into OnCompleted and that is fired after sending the response. To me that looks like exactly what you want when working with IDisposable in a Web Api.

BADF00D commented 7 years ago

Will be part of release 0.33