Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add analyzer to Razor.Diagnostic.Analzyers that detects scenarios where a pooled object or pooled array escapes its scope #10878

Open
DustinCampbell opened this issue Sep 11, 2024 · 0 comments

Comments

@DustinCampbell
Copy link
Member

Common Razor object pooling patterns should be detectable with an analyzer. For example, for any PooledObject<T> declared within a using statement, it should be possible to detect scenarios where the object is allowed to escape beyond the using's scope. For example, in the following code, an analyzer could detect the fact list escapes its scope and report an error.

List<int> M()
{
    using var _ = ListPool<int>.GetPooledObject(out var list);
    
    // use list...

    return list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants