controlflow / resharper-heapview

ReSharper Heap Allocations Viewer plugin
MIT License
303 stars 28 forks source link

False positive "Possible boxing allocation" when casting a `class` constrained generic variable #95

Closed zenorbi closed 1 year ago

zenorbi commented 2 years ago

Given the following code, the variable foo is definitely a reference type, but I get a warning for

Possible boxing allocation: type testing 'TFoo' value for 'IDisposable' type possibly requires boxing of value type

void GenericMethod<TFoo>(TFoo foo) where TFoo : class
{
    if (foo is IDisposable disposable)
    {

    }
}
controlflow commented 1 year ago

Thanks for reporting! Fixed during boxing analyzer rewrite.