title: Portable Class Library equivalent to MethodBase.GetCurrentMethod
body: <p>s there Portable Class Library equivalent to MethodBase.GetCurrentMethod?</p>
  
  <p>I'm new to PCLs.  I'm justing looking into whether I can use a PCL to hold some client code that will definitely be used on Silverlight and may be used elsewhere.  Having scanned the source, I can see plenty of calls to MethodBase.GetCurrentMethod which doesn't seem to exist in the PCL.</p>
  
  <p><em><strong></em> ** EDIT **</strong></p>
  
  <p>I've ripped this sample out of the library in question.  IsNullOrEmpty() was using String.IsNullOrWhiteSpace(String) which doesn't seem to be available, so that bit's a fudge.</p>
  
  <pre><code>using System;
  using System.Linq;
  using System.Reflection;
  using System.Linq.Expressions;
  
  namespace LinqToLdap.PCL
  {
      public static class QueryableExtensions
      {
          internal static bool IsNullOrEmpty(this String str)
          {
              return string.IsNullOrEmpty(str);
          }
  
          public static IQueryable&lt;TSource&gt; FilterWith&lt;TSource&gt;(this IQueryable&lt;TSource&gt; source, string filter)
          {
              if (source == null) throw new ArgumentNullException("source");
  
              if (filter.IsNullOrEmpty()) throw new Exception("Filters cannot be null, empty, or white-space.");
  
              if (!filter.StartsWith("("))
              {
                  filter = "(" + filter + ")";
              }
  
              return source.Provider.CreateQuery&lt;TSource&gt;(
                  Expression.Call(
                      null,
                      ((MethodInfo)MethodBase.GetCurrentMethod())
                          .MakeGenericMethod(new[] { typeof(TSource) }),
                      new[] { source.Expression, Expression.Constant(filter) }
                      )
                  );
          }
      }
  }
  </code></pre>