Exemple #1
0
        private static string ExecuteMethodThroughReflection(string macro)
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            MacroEvaluator.\u003CExecuteMethodThroughReflection\u003Ec__AnonStoreyA4 reflectionCAnonStoreyA4 = new MacroEvaluator.\u003CExecuteMethodThroughReflection\u003Ec__AnonStoreyA4();
            Match match = new Regex("ExecuteMethod: (?<type>.*)\\.(?<method>.*)").Match(macro);

            // ISSUE: reference to a compiler-generated field
            reflectionCAnonStoreyA4.typename = match.Groups["type"].ToString();
            string name = match.Groups["method"].ToString();
            // ISSUE: reference to a compiler-generated method
            MethodInfo method = ((IEnumerable <Assembly>)EditorAssemblies.loadedAssemblies).Select <Assembly, System.Type>(new Func <Assembly, System.Type>(reflectionCAnonStoreyA4.\u003C\u003Em__1D5)).Where <System.Type>((Func <System.Type, bool>)(t => t != null)).First <System.Type>().GetMethod(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

            if (method == null)
            {
                // ISSUE: reference to a compiler-generated field
                throw new ArgumentException(string.Format("cannot find method {0} in type {1}", (object)name, (object)reflectionCAnonStoreyA4.typename));
            }
            if (method.GetParameters().Length > 0)
            {
                throw new ArgumentException("You can only invoke static methods with no arguments");
            }
            object obj = method.Invoke((object)null, new object[0]);

            if (obj == null)
            {
                return("Null");
            }
            return(obj.ToString());
        }
 private static string ExecuteMethodThroughReflection(string macro)
 {
   // ISSUE: object of a compiler-generated type is created
   // ISSUE: variable of a compiler-generated type
   MacroEvaluator.\u003CExecuteMethodThroughReflection\u003Ec__AnonStoreyA4 reflectionCAnonStoreyA4 = new MacroEvaluator.\u003CExecuteMethodThroughReflection\u003Ec__AnonStoreyA4();
   Match match = new Regex("ExecuteMethod: (?<type>.*)\\.(?<method>.*)").Match(macro);
   // ISSUE: reference to a compiler-generated field
   reflectionCAnonStoreyA4.typename = match.Groups["type"].ToString();
   string name = match.Groups["method"].ToString();
   // ISSUE: reference to a compiler-generated method
   MethodInfo method = ((IEnumerable<Assembly>) EditorAssemblies.loadedAssemblies).Select<Assembly, System.Type>(new Func<Assembly, System.Type>(reflectionCAnonStoreyA4.\u003C\u003Em__1D5)).Where<System.Type>((Func<System.Type, bool>) (t => t != null)).First<System.Type>().GetMethod(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
   if (method == null)
   {
     // ISSUE: reference to a compiler-generated field
     throw new ArgumentException(string.Format("cannot find method {0} in type {1}", (object) name, (object) reflectionCAnonStoreyA4.typename));
   }
   if (method.GetParameters().Length > 0)
     throw new ArgumentException("You can only invoke static methods with no arguments");
   object obj = method.Invoke((object) null, new object[0]);
   if (obj == null)
     return "Null";
   return obj.ToString();
 }