tva*_*son 7

如果我这样做,我会搜索所有文件中的字符串"(这个" - 您的搜索字符串可能会因您的格式选项而异.

编辑:经过一些实验,以下似乎使用"在文件中查找"(Ctrl-Shift-F)高精度地为我工作

  • 搜索字符串:" \( this [A-Za-z]"(当然减去报价)
  • 匹配案例:未选中
  • 匹配整个单词:未选中
  • 使用:正则表达式
  • 看看这些文件类型:"*.cs"


Mar*_*ell 6

我将使用反射查看生成的程序集; 迭代遍历静态类型寻找方法[ExtensionAttribute]...

static void ShowExtensionMethods(Assembly assembly)
{
    foreach (Type type in assembly.GetTypes())
    {
        if (type.IsClass && !type.IsGenericTypeDefinition
            && type.BaseType == typeof(object)
            && type.GetConstructors().Length == 0)
        {
            foreach (MethodInfo method in type.GetMethods(
                BindingFlags.Static |
                BindingFlags.Public | BindingFlags.NonPublic))
            {
                ParameterInfo[] args;

                if ((args = method.GetParameters()).Length > 0 &&
                    HasAttribute(method,
                      "System.Runtime.CompilerServices.ExtensionAttribute"))
                {
                    Console.WriteLine(type.FullName + "." + method.Name);
                    Console.WriteLine("\tthis " + args[0].ParameterType.Name
                        + " " + args[0].Name);
                    for (int i = 1; i < args.Length; i++)
                    {
                        Console.WriteLine("\t" + args[i].ParameterType.Name
                            + " " + args[i].Name);
                    }
                }
            }
        }
    }
}
static bool HasAttribute(MethodInfo method, string fullName)
{
    foreach(Attribute attrib in method.GetCustomAttributes(false))
    {
        if (attrib.GetType().FullName == fullName) return true;
    }
    return false;
}
Run Code Online (Sandbox Code Playgroud)