Skip to content

Commit ada6a9e

Browse files
committed
Document IDISP0011
Fix #449
1 parent a048f67 commit ada6a9e

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

documentation/IDISP011.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,26 @@ Don't return disposed instance.
1515

1616
## Motivation
1717

18-
ADD MOTIVATION HERE
18+
In the below example the `FileStream` is disposed and not usable
19+
20+
```cs
21+
public FileStream M(string fileName)
22+
{
23+
using var stream = File.OpenRead(fileName);
24+
return stream;
25+
}
26+
```
1927

2028
## How to fix violations
2129

22-
ADD HOW TO FIX VIOLATIONS HERE
30+
Don't dispose an instance that is returned. Caller is responsible for disposing.
31+
32+
```cs
33+
public FileStream M(string fileName)
34+
{
35+
return File.OpenRead(fileName);
36+
}
37+
```
2338

2439
<!-- start generated config severity -->
2540
## Configure severity

0 commit comments

Comments
 (0)