Obsoletion warning is not shown for obsolete overrides of non-obsolete base members #8937
Replies: 2 comments
-
According to the language specification, the invocation binds to the original method, not the override. Since the original method is not obsolete, no warning is given. |
Beta Was this translation helpful? Give feedback.
-
This footgun is now at least documented correctly. But I would like to see the restriction lifted, per my earlier comment in the linked issue:
It's also already used in the BCL: for |
Beta Was this translation helpful? Give feedback.
-
Champion issue: #8938
Version Used: VS 16.0 Preview 2
Steps to Reproduce:
Expected Behavior: The call to
M
will result in a warning about using an obsolete member.Actual Behavior: QuickInfo will show "[deprecated]" for
Derived.M()
, but no warning is emitted for the call.This is important for
Span<T>
, which overridesEquals
andGetHashCode
. Both of those are guaranteed to throw, and the obsoletion attribute of these methods contains important information about using these methods (e.g. to use==
instead ofEquals
).Beta Was this translation helpful? Give feedback.
All reactions