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

Code causing GenerateMethodCodeFixProvider crash. #10004

Closed
TonyValenti opened this issue Mar 23, 2016 · 1 comment
Closed

Code causing GenerateMethodCodeFixProvider crash. #10004

TonyValenti opened this issue Mar 23, 2016 · 1 comment
Milestone

Comments

@TonyValenti
Copy link

Version Used:
I am doing this in:
Visual Studio 2015 Update 1

Steps to Reproduce:

  1. Create a new console project.
  2. Paste this code in:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CrashVS {
    class Program {
        static void Main(string[] args) {
        }
    }

    public class DateFinder {


    }

    public class DateTimeFormula {

    }

    public interface IContainsAdjustments {

    }


    public static class DateFinderExtensions {
        public static T Offset<T>(this T DateFinder) where T : DateTimeFormula, IContainsAdjustments, new() {
            //The following line is incorrect.  Positioning your cursor on the red 
            //squiggly line causes "GenerateMethodCodeFixProvider" encountered an error and has been disabled.
            return DateFinder.Before<T, T>();
        }
    }
}
  1. There will be a red squiggly line under:
return DateFinder.Before<T, T>();
  1. Put your cursor on that line.
  2. VS will show the error attached error.

Expected Behavior:
No crash.

Actual Behavior:
Get a crash.

Here's a screenshot:
error

@Pilchie
Copy link
Member

Pilchie commented Mar 23, 2016

Repro can be simplified to:

public class C
{
}

public static class Ex
{
    public static T M1<T>(this T t) where T : C
    {
        //The following line is incorrect.  Positioning your cursor on the red 
        //squiggly line causes "GenerateMethodCodeFixProvider" encountered an error and has been disabled.
        return t.M<T, T>();
    }
}

@Pilchie Pilchie added this to the 1.3 milestone Mar 23, 2016
jmarolf added a commit to jmarolf/roslyn that referenced this issue May 6, 2016
Previouly we assumed that the type parameters in a method would not be of
the same `TypeSymbol` when generating a method and put them in a dictionary.
This causes exceptions when attempting to add to the dictionary and the
`TypeSymbol` is already added as a key. Now we use a list of instead of a
dictionary.

Fixes dotnet#10004
jmarolf added a commit to jmarolf/roslyn that referenced this issue May 8, 2016
Previouly we assumed that the type parameters in a method would not be of
the same TypeSymbol when generating a method and put them in a dictionary.
This causes exceptions when attempting to add to the dictionary and the
TypeSymbol is already added as a key. Now we use a list of instead of a
dictionary.

Fixes dotnet#10004
jmarolf added a commit that referenced this issue May 10, 2016
#11151)

Previouly we assumed that the type parameters in a method would not be of
the same TypeSymbol when generating a method and put them in a dictionary.
This causes exceptions when attempting to add to the dictionary and the
TypeSymbol is already added as a key. Now we use a list of instead of a
dictionary.

Fixes #10004
@jmarolf jmarolf removed their assignment Jan 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants