-3

I am trying to read some code. It has these interfaces but inside of them there are only 'empty' looking Tasks. These are being called in other .cs files but I can't see any logic happening.

Example:

     public interface IProductSubmitter
     {
     Task SubmitAsync(); 
     }

When I F12 on the method it doesn't go anywhere. This is the 'end' of the road.

In another method it's used like so:

   private IProductSubmitter Submitter {get;}

   public async Task SubmitProductAsync(Product product)
   {
      await this.Submitter.SubmitAsync(); 
      ...
   }

Any pointers in the right direction would be great. I already went over C# interfaces but those seem to contain logic inside the Tasks.

Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
halois
  • 21
  • 3
  • 2
    You need to find the implementations of these interfaces to see what's actually going on - an interface just defines a contract. – NWard Jul 06 '16 at 17:51
  • 4
    Most important/direct pointer you can get: read a C# tutorial – Camilo Terevinto Jul 06 '16 at 17:51
  • 1
    Interfaces do not contains logic, only a contract or API that a class that implements the interface has to publicly expose. In this case it's an asynchronous method that is being expose. You really need to hunt down the implementing class to see the real logic. – juharr Jul 06 '16 at 17:52
  • 1
    If you are familiar with interfaces, you should know that an interface is basically just saying "I am going to allow you to do something specific.". This interface says "I am going to have a `SubmitAsync()` method of `Task` type". The actual *logic* for the method will be in whatever class actually *implements* the interface. – Glorin Oakenfoot Jul 06 '16 at 17:52
  • For the logic, try right click the method name -> "View call hierarchy" -> "Implements". – enkryptor Jul 06 '16 at 17:53

1 Answers1

3

F12 in Visual Studio goes to the definition of a member, not the implementation. That's why you're brought to the interface, not the class that implements the interface.

If you want to easily get to the implementation, see Is there a way to navigate to real implementation of method behind an interface?.

Community
  • 1
  • 1
Jacob
  • 77,566
  • 24
  • 149
  • 228