Maybe you’re thinking of IDisposable with the using keyword. The problem with that is that you have to remember to use it in every call site. Nothing stops a caller from writing var x = new Foo() and walking away.
You can make it a compilation error via configuration of project, but I forget exactly how to do it. Some magic Microsoft thing. I made it an error in my last project and fixed it up
The editorconfig rules you’re referencing can turn code analyzer warnings into errors, but you still need a code analyzer to actually trigger the error.
Maybe you’re thinking of
IDisposablewith theusingkeyword. The problem with that is that you have to remember to use it in every call site. Nothing stops a caller from writingvar x = new Foo()and walking away.I am, but you can use a custom analyzer to stop it from compiling if misused. So you can actually stop a caller from writing that and walking away :)
You can make it a compilation error via configuration of project, but I forget exactly how to do it. Some magic Microsoft thing. I made it an error in my last project and fixed it up
https://www.jetbrains.com/help/resharper/Reference__Code_Annotation_Attributes.html#MustDisposeResourceAttribute
This one, I’m guessing? At least that’s the one I know.
It was an editorconfig file thing, but navigating the docs on mobile phone is horrendous so I can’t easily find it
https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options
There’s much more than is listed on that page
The editorconfig rules you’re referencing can turn code analyzer warnings into errors, but you still need a code analyzer to actually trigger the error.
Yeah I remember that project used Visual Studio on Windows. I’m not sure if it works outside of that environment