Add analyzer to Razor.Diagnostic.Analzyers that detects scenarios where a pooled object or pooled array escapes its scope
Open
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
Assessment
This issue has not been assessed yet.