Example #1
0
        /// <summary>
        /// Returns a list of all strings inside of the method
        /// </summary>
        /// <param name="method"></param>
        /// <returns></returns>
        public static List <string> GetMethodStrings(this MethodDef method)
        {
            List <string> methodStrings = new List <string>();

            if (method.Body != null && method.HasStrings())
            {
                foreach (var instruction in method.Body.Instructions)
                {
                    if (instruction.OpCode == OpCodes.Ldstr)
                    {
                        methodStrings.Add(instruction.ToString());
                    }
                }
            }

            return(methodStrings);
        }