Пример #1
0
 public PexMePostProcessor(IPexComponent host)
     : base(host)
 {
     this.host = host;
     this.pmd = host.GetService<IPexMeDynamicDatabase>() as PexMeDynamicDatabase;
     this.psd = host.GetService<IPexMeStaticDatabase>() as PexMeStaticDatabase;
     this.pdw = new PexMeDumpWriter(host);
     this.currAssembly = this.pmd.Services.CurrentAssembly.Assembly.Assembly;
     var nestingdepth = System.Environment.GetEnvironmentVariable("PEXME_NESTED_DEPTH");
     if (nestingdepth != null)
         ndepth = Convert.ToInt32(nestingdepth, 10);
 }
Пример #2
0
        /// <summary>
        /// Initializes DUCover.
        /// </summary>
        public static void Initialize(AssemblyEx assembly)
        {
            if (!bLoggerInitialized)
            {
                InitializeLogger();
                bLoggerInitialized = true;
                logger = LogManager.GetCurrentClassLogger();
            }

            //Check whether intialization information is required for this assembly
            var shortname = assembly.ShortName;
            if (DUCoverConstants.SystemAssemblies.Contains(shortname))
                return;

            //Analyzes all classes and methods and collects all entities.
            DeclEntityCollector.CollectAllDeclEntitiesInAssembly(assembly);

            //Populate all Def-Use tables
            PopulateAllDUCoverTables();
        }
Пример #3
0
        public static bool TryGetTypeExFromName(IPexComponent host, AssemblyEx assembly, string typename, out TypeEx typeEx)
        {
            if(typeExCache.TryGetValue(typename, out typeEx))
                return true;

            typeEx = null;
            foreach (var assemtype in assembly.TypeDefinitions)
            {
                if (assemtype.FullName == typename)
                {
                    typeEx = assemtype.Instantiate(GetGenericTypeParameters(host, assemtype));
                    typeExCache.Add(typename, typeEx);
                    return true;
                }
            }
            return false;
        }
 public override bool TryGetAssemblySetupTeardownMethods(AssemblyEx assembly, out Method setup, out Method teardown)
 {
     setup = teardown = null;
     return false;
 }
 /// <inheritdoc/>
 public override bool TryGetAssemblySetupTeardownMethods(AssemblyEx assembly, out Method setup, out Method teardown)
 {
     // xUnit.net does not have an assembly setup and teardown
     setup = teardown = null;
     return false;
 }
Пример #6
0
 protected override void Initialize()
 {
     base.Initialize();
     this.currAssembly = this.Services.CurrentAssembly.Assembly.Assembly;
     this.Log.LogMessage("MSeqGenRecommender", "MSeqGenRecommender initialized");
     this.LoadExplorableCandidates();
 }
Пример #7
0
        /// <summary>
        /// Retrieves the PUT for the method we are looking for in the current assembly
        /// </summary>
        /// <param name="method"></param>
        /// <returns></returns>
        public static bool TryRetrievePUT(IPexComponent host, AssemblyEx assembly, Method method, out Method putmethod)
        {
            //Get the class name of the target class that is including
            //the method we are looking for
            TypeEx declaringType;
            bool bresult = method.TryGetDeclaringType(out declaringType);
            SafeDebug.Assume(bresult, "Failed to get the declaring type!!!");

            string tclassname = null;
            var declaringTypeDef = declaringType.Definition;
            if (declaringTypeDef.GenericTypeParametersCount == 0)
            {
                tclassname = declaringType.ShortName.ToString();
            }
            else
            {
                tclassname = declaringType.ShortName.ToString();
                tclassname = tclassname.Substring(0, tclassname.IndexOf('`'));

                foreach (var param in declaringTypeDef.GenericTypeParameters)
                {
                    tclassname = tclassname + param.Name;
                }
            }
            tclassname = tclassname + "Test";

            foreach (var classdef in assembly.TypeDefinitions)
            {
                if(classdef.ShortName != tclassname)
                    continue;

                //TODO: To be more robust, we can later replace
                //this piece of code by actually checking whether there
                //is a method call to the method of the library we are looking for
                foreach (var mdef in classdef.DeclaredInstanceMethods)
                {
                    if (mdef.ShortName == method.ShortName)
                    {
                        bool isPexMethod = false;
                        foreach (var attr in mdef.DeclaredAttributes)
                        {
                            if (attr.SerializableName.ToString().Contains("PexMethodAttribute"))
                            {
                                isPexMethod = true;
                                break;
                            }
                        }

                        if (isPexMethod)
                        {
                            putmethod = mdef.Instantiate(MethodOrFieldAnalyzer.GetGenericTypeParameters(host, classdef),
                                MethodOrFieldAnalyzer.GetGenericMethodParameters(host, mdef));
                            return true;
                        }
                    }
                }
            }

            putmethod = null;
            return false;
        }