what are <-Cannon> .ctor etc means when I get result

Hi,
When I run performance profiler and output data to csv or excel. I saw some very weird words added into method names such as

<Startup>b__3<__Canon>()
Startup()
It<__Canon>(Func<T>)
ResolveAll<__Canon>()
<ResolveAll>b__9<__Canon>()
ResolveAllServices()
<Initialize>b__2<__Canon>()
Initialize()
TryResolveAll<__Canon>()
CreateShell(bool isVisible)
.ctor(IContainer container)


what does ".cctor()", or <_Canon> or b_numbers means
does any body know? or where i can find reference for these? is that possible to show as my normal methods names?

Thanks

Comments

  • Jessica RJessica R Posts: 1,256 Rose Gold 4
    Hello and thank you for your post!

    When you see cctor() method in the results, it essentially means that the method is a constructor

    I'm not so sure about <_Canon> or b_numbers -- did these methods come from an assembly that you do not have source for and used the integrated "decompile" option on?

    Jessica Ramos | Product Support Engineer | Redgate Software

    Have you visited our Help Center?


  • dene.boultondene.boulton Posts: 42 Bronze 1
    System.__Canon is an internal mscorlib type used to make the canonical instantiation of a generic type.

    b_ is a compiler generated backing field.
    Simple example:

    Public string MyString { get; set; }

    so becomes something like:

    private string b_MyString;
    public string get_MyString() { return b_MyString; }
    public void set_MyString(string value) { b_MyString = value; }
    Dene Boulton
    Red Gate
  • Thanks a lot for reply.

    what about these in the "class"

    ConfigService+<>c__DisplayClass10
    ConfigService+<>c__DisplayClass16
    ConfigService+<>c__DisplayClass5<T>
    ConfigService+<>c__DisplayClassd


    what do these mean? thanks a lot
  • dene.boultondene.boulton Posts: 42 Bronze 1
    Those are also compiler generated classes; for certain code the compiler needs to introduce actual constructs for things like classes, backing fields, variables etc.
    Examples of when this is done are: lamba functions, anonymous functions, for keywords like Async and yield.

    <> is used at the start of the generated construct names to avoid any collisions with "defined" code; <> is reserved for the compiler for this very purpose.
    Dene Boulton
    Red Gate
Sign In or Register to comment.