Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/csharp/misc/cs0809.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,37 @@ public class C : Base
}
}
```

## Methods recognized as obsolete

Note that the compiler warning `CS0809` will lead to no [`CS0618`](../language-reference/compiler-messages/cs0618.md) warning when actually calling the obsolete method.
<br/>In the following example compiler will not warn about the method `Test` being obsolete, because the declaration that is recognized by compiler when calling is in the base class `Base`, not the derived class `Derived`:

```csharp
class Base
{
public virtual void Test() {}
}

class Derived : Base
{
[System.Obsolete()]
public override void Test() { }
}

static class Program
{
public static void Main()
{
Derived derived = new();
b.Foo(); // No CS0618
}
}
```

To fix this add the `Obsolete` attribute to base class as well.

## See also

- [CS0618](../language-reference/compiler-messages/cs0618.md)
- [CS0672](./cs0672.md)