0

Im new to C# .net platform. When I was debugging code with breakpoints I found a class (IndexJob belongs to dtsearch namespace) with only method declarations. It was new for me to see a class with method declarations. I know that interface and other abstract classes will do this, but this class is not a abstract class and also i did not found this class inside the solution, but I think it was invoked through some assemblies.

using System;
using System.Collections.Specialized;
using System.Runtime.ExceptionServices;

namespace dtSearch.Engine
{
    public class IndexJob : NetJobBase
    {
        protected CApiIndexJobForNet* indexJob;

        public IndexJob();

        public bool ActionAdd { get; set; }
        ...
        ...


        public void AbortThread();
        protected DateTime ConvertToDateTime(dtsFileDate fileDate);
        ....
        ....
        public static IndexInfo GetIndexInfo(string indexPath);
        public void ExecuteInThread();
    }
}

What I want to get cleared is:

1.) What type of a class is this which can declare methods inside itself
2.) Where will be the definitions of these methods

Vijay Wilson
  • 516
  • 7
  • 21
  • This code as is would not compile, they would have to be marked `abstract`, `extern` or `partial`, otherwise a method body _has_ to be defined – maccettura Oct 04 '18 at 13:58
  • 4
    Maybe this is only the metadata information extracted from the debugged assembly? Visual Studio can show you that information without having the source code. I see there are no `private` members, so it looks like that. – dymanoid Oct 04 '18 at 13:58
  • This won't compile. `dtSearch` is a third-party library distributed as a binary. Were you looking at the metadata generated by Visual Studio perhaps? Did you hit `F12` to see the definition? – Panagiotis Kanavos Oct 04 '18 at 13:59
  • 1
    Where did you "find" it? What you are looking at is the _metadata_ for a class, not the implementation of a class. I'm pretty sure that you didn't find this in a source file – Flydog57 Oct 04 '18 at 13:59
  • When you compile an assembly (exe or dll file) a manifest is implicitly created. This manifest contains the namespaces, classnames and signatures of the methods that were declared "to be exported". Generally you use "public", but it's not always that simple, there is more to it. The assembly will also contain MSIL (microsoft intermediate language) code (think of it like bytecode in java). What you are doing is inspecting the manifest of an external assembly. You have the MSIL (you can execute it) but you can't see the source code. – pid Oct 04 '18 at 14:04
  • @Panagiotis Kanavos yes I pressed F12 to see the definition – Vijay Wilson Oct 04 '18 at 14:14
  • @dymanoid Thank you I got cleared. – Vijay Wilson Oct 04 '18 at 14:16
  • @pid Thank you I got cleared – Vijay Wilson Oct 04 '18 at 14:16

0 Answers0