Search code examples
c#.netasp.net-coredecompiling

What's meaning of `<>c.<>9`? I can't find any declaration of them, where are they from?


Here is an ASP.NET Core nuget package decompiled by JustDecompile, I can't understand the usage of <>c.<>9. I found that they have no declaration, it's very strange, the Nuget package name is Microsoft.Extensions.FileProviders.Physical and the class file name is PhysicalFilesWatcher.

JustDecompile screenshot


Solution

  • This is a part of some identifier in some compiler generated code (C# does not allow developer to use < and > in identifier names, while the IL does). There are multiple language features in C# which are expanded by compiler into code, for example await's, auto-properties, yield return's, closures and others.

    UPD

    In this case based on my decompilation it seems that it is compiler generated code for this Action lambda:

    private static readonly Action<object> _cancelTokenSource = state => ((CancellationTokenSource)state).Cancel();
    

    Which is initialized in generated static constructor via something like this:

    PhysicalFilesWatcher._cancelTokenSource = new Action<object>((object) PhysicalFilesWatcher.'<>c.<>9, __methodptr(<. cctor>b__43_0));
    
    [CompilerGenerated]
    [Serializable]
    private sealed class <>c
    {
      public static readonly PhysicalFilesWatcher.<>c <>9;
    
      static <>c()
      {
        PhysicalFilesWatcher.<>c <>9 = new PhysicalFilesWatcher.<>c();
      }
    
      public <>c()
      {
        base..ctor();
      }
    
      internal void <. cctor>b__43_0(object state)
      {
        ((CancellationTokenSource) state).Cancel();
      }
    }