dotnet / dotnet/csharpstandard

CallerMemberNameAttribute on parameter of attribute constructor referenced by a local function or its type parameter

Open
#1,553 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
815
Forks
99
Avg merge
1d 14h
Merged PRs (30d)
16

Description

(I'll reformat this to match the issue template next weekend, if not sooner.)

```csharp
using System;
using System.Runtime.CompilerServices;

public class MAttribute : Attribute {
public MAttribute(
[CallerMemberName]string? name = null) {
}
}

class C {
void Fun1() {
void Fun2<[M]T>(){}
}
}
```

SharpLab shows this being lowered to `void Fun2<[M("Fun2")]T>(){}` but the draft seems to require `void Fun2<[M("Fun1")]T>(){}` because Fun2 as a local function is not a function member. Now is that a compiler bug or a spec bug?

_Originally posted by @KalleOlaviNiemitalo in https://github.com/dotnet/csharpstandard/pull/1548#issuecomment-3794804052_

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.