public void Get_All_PublicNonVirtual_Methods() { MethodQuery query = new MethodQuery("public !virtual * *( * )"); var matches = query.GetMethods(myTestClass); Assert.AreEqual(6, matches.Count, "All Public, Non Virtual methods"); }
public void Can_Get_Constructor_By_Name() { MethodQuery query = new MethodQuery("* ClassWithManyMethods()"); var matches = query.GetMethods(myTestClass); Assert.AreEqual(1, matches.Count, "Should be able to get default ctor"); }
public void Get_All_Non_Public_Methods() { MethodQuery query = new MethodQuery("!public * *( * )"); var matches = query.GetMethods(myTestClass); Assert.AreEqual(19, matches.Count, "Non public methods"); }
public void Get_Method_By_Name() { MethodQuery query = new MethodQuery("* * ProtectedVoid1( * )"); var matches = query.GetMethods(myTestClass); Assert.AreEqual(1, matches.Count); }
public void Get_Generic_Method_Fails_If_ParameterCount_Is_Different() { MethodQuery query = new MethodQuery("public Func<int> GenericMethod<T>(T a)"); var matches = query.GetMethods(myTestClass); Assert.AreEqual(0, matches.Count); }
public void Get_Generic_Method() { MethodQuery query = new MethodQuery("public Func<int> GenericMethod<T>(T a, int b)"); var matches = query.GetMethods(myTestClass); Assert.AreEqual(1, matches.Count); Assert.AreEqual("GenericMethod", matches[0].Name); }
public void Get_Private_Static_Void1() { MethodQuery query = new MethodQuery(" private static void *( ) "); var matches = query.GetMethods(myTestClass); Assert.AreEqual(2, matches.Count); Assert.AreEqual("PrivateStaticVoid1", matches[0].Name); }
public void Get_ProtectedInternalVirtual_Void_Methods() { MethodQuery query = new MethodQuery("protected internal virtual void *() "); var matches = query.GetMethods(myTestClass); Assert.AreEqual(2, matches.Count); Assert.AreEqual("ProtectedInteralVirtualVoid1", matches[0].Name); }
public void Get_Internal_Static_Void_Methods() { MethodQuery query = new MethodQuery("internal static void *()"); var matches = query.GetMethods(myTestClass); Assert.AreEqual(2, matches.Count); Assert.AreEqual("InternalStaticVoid1", matches[0].Name); }
public void Get_Protected_Void_Methods() { MethodQuery query = new MethodQuery("protected void *()"); var matches = query.GetMethods(myTestClass); Assert.AreEqual(4, matches.Count); Assert.AreEqual("ProtectedVoid1", matches[0].Name); }
public void Get_Method_With_GenericReturnType_With_Partial_TypeNames() { MethodQuery query = new MethodQuery("IList<Exception> MethodWithGenericReturnType()"); var matches = query.GetMethods(myTestClass); Assert.AreEqual(1, matches.Count); Assert.AreEqual("MethodWithGenericReturnType", matches[0].Name); }
public void Get_Method_With_GenericArgument_With_Partial_TypeNames() { MethodQuery query = new MethodQuery("void DisposeToolsHandlers(IList<Exception> exceptions_in_out)"); var matches = query.GetMethods(myTestClass); Assert.AreEqual(1, matches.Count); Assert.AreEqual("DisposeToolsHandlers", matches[0].Name); }
public void Get_Method_With_ArgumentArray_And_Return_Type() { MethodQuery query = new MethodQuery("string GetString(byte[] bytes)"); var matches = query.GetMethods(myTestClass); Assert.AreEqual(1, matches.Count); Assert.AreEqual("GetString", matches[0].Name); }
public override void Execute() { base.Execute(); if (!IsValid) { Help(); return; } if (ExtractAndValidateTypeQuery(myParsedArgs.TypeAndInnerQuery) == false) { return; } List <MethodDefinition> methodsToSearch = new List <MethodDefinition>(); Writer.SetCurrentSheet(mySearchHeader); LoadAssemblies(myParsedArgs.Queries1, (cecilAssembly, file) => { using (PdbInformationReader pdbReader = new PdbInformationReader(myParsedArgs.SymbolServer)) { foreach (var type in myTypeQueries.GetMatchingTypes(cecilAssembly)) { myMethodQuery.GetMethods(type).ForEach( (method) => { var fileLine = pdbReader.GetFileLine(method); Writer.PrintRow("{0,-60}; {1,-100}; {2}; {3}", () => GetFileInfoWhenEnabled(fileLine.Key), type.Print(), method.Print(MethodPrintOption.Full), Path.GetFileName(file), fileLine.Key ); lock (methodsToSearch) { methodsToSearch.Add(method); } }); } } }); if (methodsToSearch.Count == 0) { Out.WriteLine("Error: No methods to query found. Aborting query."); return; } Writer.PrintRow("", null); Writer.PrintRow("", null); Writer.SetCurrentSheet(myResultHeader); LoadAssemblies(myParsedArgs.Queries2, (cecilAssembly, file) => { using (UsageQueryAggregator aggregator = new UsageQueryAggregator(myParsedArgs.SymbolServer)) { new WhoUsesMethod(aggregator, methodsToSearch); aggregator.Analyze(cecilAssembly); aggregator.MethodMatches.ForEach((result) => { Writer.PrintRow("{0,-60};{1,-100}; {2}; {3}; {4}; {5}", () => GetFileInfoWhenEnabled(result.SourceFileName), result.Match.DeclaringType.FullName, result.Match.Print(MethodPrintOption.Full), result.Annotations.Item, Path.GetFileName(file), result.SourceFileName, result.LineNumber ); }); } }); }