Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# 9's target-typed new doesn't work with System.Runtime.CompilerServices.CallerMemberName attribute #50475

Closed
Edward-Alchikha opened this issue Jan 14, 2021 · 4 comments
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@Edward-Alchikha
Copy link

Version Used:
.NET 5.0.102 on Ubuntu 20.04

Steps to Reproduce:

using System;
using System.Runtime.CompilerServices;

namespace ConsoleApp1
{
    class Test
    {
        public string Name { get; }
        
        public Test([CallerMemberName] string name = "")
        {
            Name = name;
        }
    }

    class Program
    {
        private static Test test1 = new Test();
        private static Test test2 = new();
        
        static void Main()
        {
            Console.WriteLine($"1: {test1.Name}, 2: {test2.Name}");
        }
    }
}

Expected Behavior:
It should output "1: test1, 2: test2"

Actual Behavior:
It actually outputs "1: test1, 2: "

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 14, 2021
@Youssef1313
Copy link
Member

#49547

@HobbsCode
Copy link

The problem was recently addressed. The code in question performs correctly when running against master on sharplab.

@Edward-Alchikha
Copy link
Author

Looking at #49547, it looks like this has been fixed in master since at least November 22, but in .NET 5.0.102 (released January 12) it's not fixed. When will this fix make it to a release?

@jaredpar
Copy link
Member

This will be released with VS 16.9 and it's accompanying .NET SDK release (believe that will be the 5.0.200 series).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

4 participants