P
Peter Strøiman
Hi.
I have a class with two similar methods.
One returns an object implementing IDisposible (and it MUST be disposed)
The other doesn't return anything.
When using the class, it is quite easy to mistakenly call the first method
when you intended to use the second. This leads to a ressource leak.
In most modern day programming languages (in my case C#) it is legal to call
a function and disregard the return value.
Is there any attributes I can place on my function that will let the
compiler generate an error (or at least a warning) if you call
the first method and disregard the return value.
Thanks in advance,
Peter Strøiman
I have a class with two similar methods.
One returns an object implementing IDisposible (and it MUST be disposed)
The other doesn't return anything.
When using the class, it is quite easy to mistakenly call the first method
when you intended to use the second. This leads to a ressource leak.
In most modern day programming languages (in my case C#) it is legal to call
a function and disregard the return value.
Is there any attributes I can place on my function that will let the
compiler generate an error (or at least a warning) if you call
the first method and disregard the return value.
Thanks in advance,
Peter Strøiman