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

Edit and Continue for members of generic types #11036

Closed
jnm2 opened this issue Sep 5, 2018 · 5 comments
Closed

Edit and Continue for members of generic types #11036

jnm2 opened this issue Sep 5, 2018 · 5 comments

Comments

@jnm2
Copy link
Contributor

jnm2 commented Sep 5, 2018

Modifying or adding a method in a generic type is not currently supported: https://github.com/dotnet/roslyn/blob/main/docs/wiki/EnC-Supported-Edits.md#not-supported-edits This seems like a big-ticket item, but please consider implementing it.

It comes up a lot for me. Right now, for example, I'm debugging an application and want to try eight permutations in a generic class's constructor. Building and setting up the scenario eight times is not as fun as EnC would be.

(Opened from dotnet/roslyn#29667 to track runtime work per @tmat's request.)

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the Future milestone Jan 31, 2020
@danroth27
Copy link
Member

@danroth27
Copy link
Member

@mikelle-rogers

@AaronRobinsonMSFT
Copy link
Member

@jnm2 Is the following transform representative of your desired scenario? We're trying to understand the cost/scope of possible improvements and we want to make sure we understand the specific ask here.

// Before
class Foo<T>
{
    public Foo(T a)
    {
        Console.WriteLine("Unknown");
    }
}
public class Program
{
    public static void Main()
    {
        var s = new Foo<string>("1");
        var i = new Foo<int>(2);
        Console.WriteLine(3);
    }
}
// After
class Foo<T>
{
    public Foo(T a)
    {
        if (typeof(T) == typeof(int))
        {
            Console.WriteLine(a);
        }
        else if (typeof(T) == typeof(string))
        {
            Console.WriteLine(a);
        }
        else
        {
            Console.WriteLine("Unknown");
        }
    }
}
public class Program
{
    public static void Main()
    {
        var s = new Foo<string>("1");
        var i = new Foo<int>(2);
        Console.WriteLine(3);
    }
}

@jnm2
Copy link
Contributor Author

jnm2 commented Feb 5, 2023

@AaronRobinsonMSFT Yes, that could be representative. In the cases I remember, I didn't reference typeof(T) in the edits, but theoretically that could happen I suppose.

@AaronRobinsonMSFT
Copy link
Member

Completed with #85269

@ghost ghost locked as resolved and limited conversation to collaborators Jun 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants