dotnet / dotnet/roslyn

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

Open
#85,560 0 comments 1 reaction 0 assignees View on GitHub
Area-Razor
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

Common Razor object pooling patterns should be detectable with an analyzer. For example, for any `PooledObject` 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.

```C#
List M()
{
using var _ = ListPool.GetPooledObject(out var list);

// use list...

return list;
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.