You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to have a new attribute (e.g. [AlternativeDisposeMethod]) that tells the analyzer that a certain method calls dispose internally and that can be applied to an instance method or an extension method and then (obviously) have the analyzer adjusted to respect it.
e.g. a Stream class could declare a Close() method that has this attribute:
public class Stream : IDisposable {
[AlternativeDisposeMethod]
public void Close() {
Dispose();
}
}
or a static type that has a dispose helper method:
public static class DisposableExtensions {
[AlternativeDisposeMethod]
public static void TryDispose(this IDisposable? disposable) {
if (disposable is null) return;
try {
disposable.Dispose();
} catch {
}
}
}
Describe suggestions on how to achieve the rule
The CA2000 analyzer rule is additionally checking for existence of this attribute and if it is found, treat it like the Dispose method was called.
Additional context
It's not only an analyzer extension but would also need a .NET extension.
The text was updated successfully, but these errors were encountered:
Analyzer
Diagnostic ID: CA2000
Describe the improvement
I would like to have a new attribute (e.g.
[AlternativeDisposeMethod]
) that tells the analyzer that a certain method calls dispose internally and that can be applied to an instance method or an extension method and then (obviously) have the analyzer adjusted to respect it.e.g. a
Stream
class could declare aClose()
method that has this attribute:or a static type that has a dispose helper method:
Describe suggestions on how to achieve the rule
The CA2000 analyzer rule is additionally checking for existence of this attribute and if it is found, treat it like the
Dispose
method was called.Additional context
It's not only an analyzer extension but would also need a .NET extension.
The text was updated successfully, but these errors were encountered: