dotnet / dotnet/docs

Clarify example in IDE0002 to include the class

Open
#31,798 1 comment 0 reactions 0 assignees View on GitHub
dotnet-fundamentals/svc
Dominant language
No language data
Stars
4.8k
Forks
6.1k
Avg merge
19h 10m
Merged PRs (30d)
268

Description

The example

```csharp
static void M1() { }
static void M2()
{
// IDE0002: 'C.M1' can be simplified to 'M1'
C.M1();

// Fixed code
M1();
}
```
presumably is in a class C, but a new developer or developer new to C# might not be able to draw that conclusion. For clarity's sake the example could include the class C:

```csharp
class C
{
static void M1() { }
static void M2()
{
// IDE0002: 'C.M1' can be simplified to 'M1'
C.M1();

// Fixed code
M1();
}
}
```

I don't know VB but I can add to the C# example in a PR if it's desired.

---
#### Document Details

⚠ *Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.*

* ID: b2f6c0c8-284b-1a50-e3fe-7f58c022d22d
* Version Independent ID: 92048a86-9b59-1539-9596-42f76d5e9733
* Content: [IDE0002: Simplify member access - .NET](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0002)
* Content Source: [docs/fundamentals/code-analysis/style-rules/ide0002.md](https://github.com/dotnet/docs/blob/main/docs/fundamentals/code-analysis/style-rules/ide0002.md)
* Product: **dotnet-fundamentals**
* GitHub Login: @gewarren
* Microsoft Alias: **gewarren**

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.