dotnet / dotnet/csharpstandard

Obsolete member accessing another obsolete member

Open
#701 6 comments 0 reactions 0 assignees View on GitHub
help wanted type: bug
Dominant language
C#
Stars
815
Forks
99
Avg merge
1d 14h
Merged PRs (30d)
16

Description

If an obsolete member accesses another obsolete member, Microsoft's C# compilers do not issue the warning required by [C# 6.0 §21.5.4](https://github.com/dotnet/csharpstandard/blob/V6-standard/standard/attributes.md#2154-the-obsolete-attribute). Should this suppression be part of the C# standard? If not, does the standard allow it as an extension (which would then have to be defined in the conformance document)?

For example:

```csharp
static class Demo
{
[System.Obsolete]
static void M() {}

[System.Obsolete]
static void N()
{
M(); // no warning about accessing obsolete M, because N is also obsolete
}

static void O()
{
N(); // warning issued
}
}
```

At least the following compiler versions behave this way:

* Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.9149\
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727\
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.
* Microsoft (R) Visual C# Compiler version 4.8.4084.0\
for C# 5\
Copyright (C) Microsoft Corporation. All rights reserved.
* Microsoft (R) Visual C# Compiler version 2.10.0.0 (b9fb1610)\
Copyright (C) Microsoft Corporation. All rights reserved

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.