Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Visual Studio's C# intellisense be given a hint to display a certain method overload first?

I have two methods that are overloads of each other

public class Car
{
   public int GetPrice(string vinNumber)
   {
      string make = Database.GetMake(vinNumber);  // expensive operation
      string model = Database.GetModel(vinNumber);   // expensive operation
      int year = Database.GetYear(vinNumber);   // expensive operation

      return this.GetPrice(make, model, year);
   }

   public int GetPrice(string make, string model, int year)
   {
      // Calculate value and return
   }
}

In my example, the GetPrice(make, model, year) overload is cheap to execute but the GetPrice(vinNumber) method is expensive. The problem is that the expensive method has the fewest parameters and it shows up first in the C# intellisense.

Both methods are valid, but I want to encourage people to call the cheap method. But people tend to not look through all the overloads in Intellisense before choosing a method to call, and the expensive one is being called too often in my company's codebase.

Is there a way to tell Visual Studio to give "intellisense priority" to a particular method so it shows up first?

like image 574
Mike Avatar asked Dec 15 '09 02:12

Mike


2 Answers

  1. The Summary tag in XML comments shows up in Intellisense.
  2. You could decorate the method with the Obsolete tag, which will also generate a warning or error depending on settings.

    [System.Obsolete("use GetPrice(make, model, year)")]
    
like image 148
phloopy Avatar answered Sep 19 '22 15:09

phloopy


Don't think so.

Unless you write a intellisense plugin ( like Resharper) and hijack the default intellisense and create a program for users to assign the priority.

like image 37
Graviton Avatar answered Sep 19 '22 15:09

Graviton