Lucyper
Lucyper

Reputation: 1079

How decompile .net dll to project c# [CompilerGenerated]

when decompile dll using dotpeek I am getting this code

      [CompilerGenerated]
    private static class <Importuj>o__SiteContainer0
    {
      public static CallSite<Func<CallSite, object, Worksheet>> <>p__Site1;
      public static CallSite<Func<CallSite, object, bool>> <>p__Site2;
      public static CallSite<Func<CallSite, object, object, object>> <>p__Site3;
      public static CallSite<Func<CallSite, object, Range>> <>p__Site4;
      public static CallSite<Func<CallSite, object, bool>> <>p__Site5;
      public static CallSite<ImportExcel.<Importuj>o__SiteContainer0.<>q__SiteDelegate6> <>p__Site7;
      public static CallSite<Func<CallSite, object, object>> <>p__Site8;
      public static CallSite<Func<CallSite, object, Range>> <>p__Site9;

...

}

how fix this and build project ??

Upvotes: 0

Views: 1249

Answers (1)

Jeff Mercado
Jeff Mercado

Reputation: 134801

First you need to understand what the role is of this compiler generated class is, what it is, and how it relates to the code it was generated for.

In the case of these call site objects, they are typically used for code that utilizes dynamic values. Without going into full detail, this information is needed for the runtime to be able to do the magic that it does when it comes to working with dynamic.

e.g.,

dynamic something = ...;
// any code that involves the variable `something` will generate call site information

Generally speaking, when the runtime is required to reference a dynamic variable as if it was some specific type or object, it will create a call site object. It will do this for every subexpression that involves the dynamic variable.

int someInt = something.SomeInt; // some property that returns int
// CallSite<Func<CallSite, Object, Int32>>

something.SomeMethod();          // some object that has some method `SomeMethod()`
// CallSite<Func<CallSite, Object, Object>>

SomeValue x = something[123];    // some indexer that takes an int,
                                 // that returns something that might be SomeValue
// CallSite<Func<CallSite, Object, Int32, Object>>
//     and CallSite<Func<CallSite, Object, SomeValue>>

Knowing this, find out where those fields are used and try to convert the expressions involving that field to using dynamic following these patterns.

Upvotes: 3

Related Questions