Beispiel #1
0
        protected void FieldRefresh(object sender, StoreRefreshDataEventArgs e)
        {
            var data       = new List <object>();
            var columnList = new List <string>();

            try
            {
                if (cbDataSource.SelectedIndex == 0)
                {
                    columnList = Util.GetInstance().GetColumnOfTable(cbTable.SelectedItem.Value);
                }
                else
                {
                    columnList = Util.GetInstance().GetColumnOfTable(cbView.SelectedItem.Value);
                }
            }
            catch
            {
            }

            foreach (string item in columnList)
            {
                data.Add(new { Name = item });
            }

            FieldStore.DataSource = data;
            FieldStore.DataBind();
        }
Beispiel #2
0
        /// <summary>
        /// Deletes the specified field.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken" /> used to propagate notifications that the operation should be canceled.</param>
        public async Task DeleteAsync(Field field, CancellationToken cancellationToken)
        {
            // in transaction
            await FieldStore.DeleteAsync(field, cancellationToken);

            //await DeleteAsync(field, transactionOrchestrator, cancellationToken);
            IndexStore.Delete("");
            AuditReportProvider.Log(/*TransactionOrchestrator*/);
        }
Beispiel #3
0
        private Field.Store GetFromStoreEnum(FieldStore store)
        {
            if (store == FieldStore.Store)
            {
                return(Field.Store.YES);
            }

            return(Field.Store.NO);
        }
Beispiel #4
0
        public void ShouldReturnValue()
        {
            var store = new FieldStore();

            var docId     = Utils.RandomInteger();
            var fieldName = Utils.RandomString();
            var value     = Utils.RandomString();

            store.SetValue(docId, fieldName, value);

            Assert.AreEqual(value, store.GetValue(docId, fieldName));
        }
Beispiel #5
0
        public void ShouldReturnNullIfDoesNotExist()
        {
            var store = new FieldStore();

            var docId = Utils.RandomInteger();

            Assert.IsNull(store.GetValue(docId, Utils.RandomString()));

            store.SetValue(docId, Utils.RandomString(), Utils.RandomString());

            Assert.IsNull(store.GetValue(5, Utils.RandomString()));
        }
Beispiel #6
0
 private Field.Store GetLucentFieldStore(FieldStore fieldStore)
 {
     switch (fieldStore)
     {
         case FieldStore.Compress:
             return Field.Store.COMPRESS;
         case FieldStore.No:
             return Field.Store.NO;
         default:
             return Field.Store.YES;
     }
 }
        protected void AddField(string name, string value, FieldStore store, FieldIndex index, float? boost = null) {
            if(string.IsNullOrEmpty(value)) {
                return;
            }

            Field.Store fieldStore = GetFromStoreEnum(store);
            Field.Index fieldIndex = GetFromIndexEnum(index);

            var field = new Field(name, value, fieldStore, fieldIndex);

            if (boost != null) {
                field.Boost = (float)boost;
            }

            _document.Add(field);
        }
Beispiel #8
0
        private bool IsEligibleForLooping(MethodSignatureSequence seq, Field field,
                                          Dictionary <string, Method> writeMethods, FieldStore fs, out string loop_method)
        {
            string prevMethod = "";
            int    numTimes   = 1;

            foreach (var method in seq.Sequence)
            {
                if (method == prevMethod)
                {
                    numTimes++;
                }
                else
                {
                    numTimes = 1;
                }

                if (numTimes >= PexMeConstants.LOOP_THRESHOLD)
                {
                    //Check whether this loop_method modifies the culprit field
                    //exactly by ONE (We current handle only INCREMENT_BY_ONE CASE)
                    if (!writeMethods.ContainsKey(method))
                    {
                        continue;
                    }

                    var wm = writeMethods[method];
                    FieldModificationType fmt;
                    if (!fs.PreciseModificationTypeDictionary.TryGetValue(wm, out fmt))
                    {
                        continue;
                    }

                    if (fmt != FieldModificationType.INCREMENT_ONE)
                    {
                        continue;
                    }
                    loop_method = method;
                    return(true);
                }

                prevMethod = method;
            }

            loop_method = "";
            return(false);
        }
        /// <summary>
        /// Function the retrieves associated Persistent store for each MethodStore
        /// </summary>
        /// <param name="ms"></param>
        /// <param name="pms"></param>
        /// <returns></returns>
        public static bool TryGetPersistentFieldStore(IPexComponent host, FieldStore fs, out PersistentFieldStore pfs)
        {
            pfs = new PersistentFieldStore();

            pfs.FieldName = MethodOrFieldAnalyzer.GetPersistentStringFormOfField(fs.FieldName);
            //foreach(var value in fs.FieldValues)
            //    pfs.FieldValues.Add(value);

            //TODO: Performance can be improved via caching over here
            foreach (var m in fs.ReadMethods)
            {
                pfs.ReadMethods.Add(MethodOrFieldAnalyzer.GetPersistentStringFormOfMethod(m));
            }

            foreach (var typeex in fs.WriteMethods.Keys)
            {
                HashSet <string> wmethods = new HashSet <string>();
                pfs.WriteMethods.Add(MethodOrFieldAnalyzer.GetPersistentStringFormOfTypeEx(typeex), wmethods);

                SafeSet <Method> methods;
                bool             bresult = fs.WriteMethods.TryGetValue(typeex, out methods);
                SafeDebug.Assume(bresult, "Failed to get associated set of methods for a type");

                var assemblyname = typeex.Definition.Module.Assembly.Location;
                var typename     = typeex.FullName;

                foreach (var m in methods)
                {
                    wmethods.Add(assemblyname + PexMeConstants.PexMePersistenceFormSeparator
                                 + typename + PexMeConstants.PexMePersistenceFormSeparator + MethodOrFieldAnalyzer.GetMethodSignature(m));
                }
            }

            foreach (var m in fs.ModificationTypeDictionary.Keys)
            {
                var value = fs.ModificationTypeDictionary[m];
                pfs.ModificationTypeDictionary.Add(MethodOrFieldAnalyzer.GetPersistentStringFormOfMethod(m), value);
            }

            foreach (var m in fs.PreciseModificationTypeDictionary.Keys)
            {
                var value = fs.PreciseModificationTypeDictionary[m];
                pfs.PreciseModificationTypeDictionary.Add(MethodOrFieldAnalyzer.GetPersistentStringFormOfMethod(m), value);
            }

            return(true);
        }
Beispiel #10
0
        public FieldStore LookupOrAdd(RuntimeTypeHandle type, uint key)
        {
            if (_fields.TryGetValue(key, out FieldStore? v))
            {
                return(v);
            }
            lock (_lock)
            {
                if (_fields.TryGetValue(key, out FieldStore? v2))
                {
                    return(v2);
                }

                FieldStore s = FieldStore.Create(type);
                _fields.Add(key, s);
                return(s);
            }
        }
Beispiel #11
0
        protected void AddField(string name, string value, FieldStore store, FieldIndex index, float?boost = null)
        {
            if (string.IsNullOrEmpty(value))
            {
                return;
            }

            Field.Store fieldStore = GetFromStoreEnum(store);
            Field.Index fieldIndex = GetFromIndexEnum(index);

            var field = new Field(name, value, fieldStore, fieldIndex);

            if (boost != null)
            {
                field.Boost = (float)boost;
            }

            _document.Add(field);
        }
        /// <summary>
        /// Parses each record and stores into internal dictionary
        /// </summary>
        /// <param name="assemblyname"></param>
        /// <param name="typename"></param>
        /// <param name="fieldname"></param>
        /// <param name="fmttype"></param>
        /// <param name="methodname"></param>
        private static void ParseRecord(IPexComponent host, string assemblyname, string typename, string fieldname, string fmttype, string methodname)
        {
            Field field;

            if (!MethodOrFieldAnalyzer.TryGetField(host, assemblyname, typename, fieldname, out field))
            {
                host.Log.LogWarning(WikiTopics.MissingWikiTopic, "PredefinedEffects", "Failed to load field: " + fieldname);
                return;
            }

            FieldModificationType fmt = FieldStore.GetModificationTypeFromString(fmttype);

            Method method;

            if (!MethodOrFieldAnalyzer.TryGetMethod(host, assemblyname, typename, methodname, out method))
            {
                host.Log.LogWarning(WikiTopics.MissingWikiTopic, "PredefinedEffects", "Failed to load method: " + methodname);
                return;
            }

            //storing into the effects store
            PreDefinedMethodEffectsStore pdme = new PreDefinedMethodEffectsStore(field, fmt);
            List <Method> suggestedMethods;
            PreDefinedMethodEffectsStore existingPdme;

            if (!effectsStore.TryGetValue(pdme, out existingPdme))
            {
                suggestedMethods         = new List <Method>();
                pdme.suggestedmethodList = suggestedMethods;
                effectsStore.Add(pdme, pdme);
            }
            else
            {
                suggestedMethods = existingPdme.suggestedmethodList;
            }

            suggestedMethods.Add(method);
        }
        private Field.Store GetFromStoreEnum(FieldStore store) {
            if(store==FieldStore.Store) {
                return Field.Store.YES;
            }

            return Field.Store.NO;
        }
Beispiel #14
0
 /// <summary>
 /// Gets the field for the specified identifier.
 /// </summary>
 /// <param name="id">The field identifier.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>The field.</returns>
 public async Task <Field> FindByIdAsync(string id, CancellationToken cancellationToken)
 {
     return(await FieldStore.FindByIdAsync(id, cancellationToken));
 }
Beispiel #15
0
 /// <summary>
 /// Gets the field for the specified identifier.
 /// </summary>
 /// <param name="name">The field name.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>The field.</returns>
 public async Task <Field> FindByNameAsync(string name, CancellationToken cancellationToken)
 {
     return(await FieldStore.FindByNameAsync(name, cancellationToken));
 }
Beispiel #16
0
 /// <summary>
 /// Gets all fields.
 /// </summary>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>All fields.</returns>
 public async Task <IList <Field> > FindAllAsync(CancellationToken cancellationToken)
 {
     return(await FieldStore.FindAllAsync(cancellationToken));
 }
Beispiel #17
0
 /// <summary>
 /// Sets the Store value based on the corresponding-Enumeration value
 /// </summary>
 /// <remarks>Enumerations were used to define the FieldStore because of the few allowable types permitted in the declaration of an attribute</remarks>
 /// <param name="store">The index value of the field describing how the field will be indexed in the document</param>
 private void SetFieldStore(FieldStore store)
 {
     switch (store) {
         default:
         case FieldStore.No:
             _store = Field.Store.NO;
             break;
         case FieldStore.Yes:
             _store = Field.Store.YES;
             break;
         case FieldStore.Compress:
             _store = Field.Store.COMPRESS;
             break;
     }
 }
Beispiel #18
0
 /// <summary>
 /// Creates an instance of the FieldAttribute for a Tokenized field
 /// </summary>
 /// <param name="store"></param>
 public FieldAttribute(FieldStore store)
 {
     SetFieldStore(store);
 }
Beispiel #19
0
 /// <summary>
 /// Creates an instance of the FieldAttribute
 /// </summary>
 /// <param name="index">The way the Field will be Indexed in the Document of an Index</param>
 /// <param name="store">The way the field will be Stored in the Document of the Index</param>
 public FieldAttribute(FieldIndex index, FieldStore store)
 {
     SetFieldIndex(index);
     SetFieldStore(store);
 }
 public StoreAttribute(FieldStore store)
 {
     Store = store;
 }
 public static Field.Store ToFieldStore(this FieldStore store)
 {
     return((store == FieldStore.YES) ? Field.Store.YES : Field.Store.NO);
 }
        /// <summary>
        /// Function that retrieves associated method store
        /// </summary>
        /// <param name="pms"></param>
        /// <param name="ms"></param>
        /// <returns></returns>
        public static bool TryGetFieldStore(IPexComponent host, PersistentFieldStore pfs, out FieldStore fs)
        {
            fs = new FieldStore();

            bool bresult = MethodOrFieldAnalyzer.TryGetFieldFromPersistentStringForm(host, pfs.FieldName, out fs.FieldName);

            SafeDebug.Assume(bresult, "Failed to get field from the persistent store");

            fs.FieldValues.AddRange(pfs.FieldValues);

            //TODO: Performance can be improved via caching over here
            foreach (var mname in pfs.ReadMethods)
            {
                Method m;
                bresult = MethodOrFieldAnalyzer.TryGetMethodFromPersistentStringForm(host, mname, out m);
                SafeDebug.Assume(bresult, "Failed to get method from persistent string form ");
                fs.ReadMethods.Add(m);
            }

            foreach (var typeex in pfs.WriteMethods.Keys)
            {
                SafeSet <Method> wmethods = new SafeSet <Method>();
                TypeEx           typeEx;
                bresult = MethodOrFieldAnalyzer.TryGetTypeExFromPersistentStringForm(host, typeex, out typeEx);
                SafeDebug.Assume(bresult, "Failed to get type from persistent string form " + typeex);

                fs.WriteMethods.Add(typeEx, wmethods);

                HashSet <string> methods;
                bresult = pfs.WriteMethods.TryGetValue(typeex, out methods);
                SafeDebug.Assume(bresult, "Failed to get associated set of methods for a type " + typeex);

                foreach (var m in methods)
                {
                    Method method;
                    bresult = MethodOrFieldAnalyzer.TryGetMethodFromPersistentStringForm(host, m, out method);
                    SafeDebug.Assume(bresult, "Failed to get method from string form " + m);
                    wmethods.Add(method);
                }
            }

            foreach (var m in pfs.ModificationTypeDictionary.Keys)
            {
                var    value = pfs.ModificationTypeDictionary[m];
                Method method;
                bresult = MethodOrFieldAnalyzer.TryGetMethodFromPersistentStringForm(host, m, out method);
                SafeDebug.Assume(bresult, "Failed to get method from string form " + m);
                fs.ModificationTypeDictionary.Add(method, value);
            }

            foreach (var m in pfs.PreciseModificationTypeDictionary.Keys)
            {
                var    value = pfs.PreciseModificationTypeDictionary[m];
                Method method;
                bresult = MethodOrFieldAnalyzer.TryGetMethodFromPersistentStringForm(host, m, out method);
                SafeDebug.Assume(bresult, "Failed to get method from string form " + m);
                fs.PreciseModificationTypeDictionary.Add(method, value);
            }

            return(true);
        }
 public IXDescriptorProperty(string name, string value, byte[] binaryValue, FieldFlags flags, FieldStore store, FieldIndex index)
 {
     this.Name        = name;
     this.StringValue = (binaryValue == null) ? value : null;
     this.BinaryValue = (binaryValue == null) ? null : binaryValue;
     this.Flags       = flags;
     this.Store       = store;
     this.Index       = index;
 }
Beispiel #24
0
        /// <summary>
        /// Dumps entire database into different persistent stores (files)
        /// </summary>
        /// <param name="pmd"></param>
        public void DumpDynamicDatabase(PexMeDynamicDatabase pmd)
        {
            if (!Directory.Exists(PexMeConstants.PexMeStorageDirectory))
            {
                Directory.CreateDirectory(PexMeConstants.PexMeStorageDirectory);
            }

            //Dumping only the contents of factory suggestion store for time being
            //as the classes in extended reflection are not serializable
            try
            {
                DumpFactorySuggestionStore(pmd);
            }
            catch (Exception ex)
            {
                pmd.Log.LogErrorFromException(ex, WikiTopics.MissingWikiTopic, "dumpwriter",
                                              "Failed to dump dynamic factory suggestion store");
            }

            if (PexMeConstants.ENABLE_DYNAMICDB_STORAGE)
            {
                //Dump the dynamic field store that includes information of which method modify which fields
                try
                {
                    var             filename           = Path.Combine(PexMeConstants.PexMeStorageDirectory, PexMeConstants.PexMeDynamicFieldStore);
                    Stream          streamWrite        = File.Create(filename);
                    BinaryFormatter binaryWrite        = new BinaryFormatter();
                    var             persistentFieldDic = this.GetPersistentFieldDictionary(pmd.FieldDictionary);
                    binaryWrite.Serialize(streamWrite, persistentFieldDic);
                    streamWrite.Close();
                }
                catch (Exception ex)
                {
                    pmd.Log.LogErrorFromException(ex, WikiTopics.MissingWikiTopic, "dumpwriter",
                                                  "Failed to dump dynamic field store");
                }
            }

            if (PexMeConstants.ENABLE_DYNAMICDB_STORAGE)
            {
                //Dump the dynamic method store that includes information of which method calls other methods and field they modify
                try
                {
                    var             filename            = Path.Combine(PexMeConstants.PexMeStorageDirectory, PexMeConstants.PexMeDynamicMethodStore);
                    Stream          streamWrite         = File.Create(filename);
                    BinaryFormatter binaryWrite         = new BinaryFormatter();
                    var             persistentMethodDic = this.GetPersistentMethodDictionary(pmd.MethodDictionary);
                    binaryWrite.Serialize(streamWrite, persistentMethodDic);
                    streamWrite.Close();
                }
                catch (Exception ex)
                {
                    pmd.Log.LogErrorFromException(ex, WikiTopics.MissingWikiTopic, "dumpwriter",
                                                  "Failed to dynamic dump method store");
                }
            }

            //Dump the all explored methods
            try
            {
                var             filename    = Path.Combine(PexMeConstants.PexMeStorageDirectory, PexMeConstants.PexMeDynamicExploredMethods);
                Stream          streamWrite = File.Create(filename);
                BinaryFormatter binaryWrite = new BinaryFormatter();
                binaryWrite.Serialize(streamWrite, pmd.AllExploredMethods);
                streamWrite.Close();
            }
            catch (Exception ex)
            {
                pmd.Log.LogErrorFromException(ex, WikiTopics.MissingWikiTopic, "dumpwriter",
                                              "Failed to dump all explored methods");
            }

            //Dump the all explored methods
            try
            {
                var             filename    = Path.Combine(PexMeConstants.PexMeStorageDirectory, PexMeConstants.PexMePendingExplorationMethods);
                Stream          streamWrite = File.Create(filename);
                BinaryFormatter binaryWrite = new BinaryFormatter();
                binaryWrite.Serialize(streamWrite, pmd.PendingExplorationMethods);
                streamWrite.Close();
            }
            catch (Exception ex)
            {
                pmd.Log.LogErrorFromException(ex, WikiTopics.MissingWikiTopic, "dumpwriter",
                                              "Failed to dump pending explored methods");
            }

            /******************** BEGIN OF DEBUGGING INFO ***********************/
            //Writing monitored methods
            if (PexMeConstants.ENABLE_DYNAMICDB_STORAGE)
            {
                var monitoredMethods         = pmd.MonitoredMethods;
                var monitoredMethodsFileName = Path.Combine(PexMeConstants.PexMeStorageDirectory, pmd.AssemblyName + ".dynamic.monitoredmethods.txt");
                using (StreamWriter sw = new StreamWriter(monitoredMethodsFileName))
                {
                    //Printing all monitored methods
                    sw.WriteLine("All monitored methods");
                    foreach (var methodName in pmd.MonitoredMethods)
                    {
                        sw.WriteLine(methodName);
                    }

                    //Printing all controllable types
                    sw.WriteLine();
                    sw.WriteLine("Controllable types");
                    foreach (var typeName in pmd.ControllableTypes)
                    {
                        sw.WriteLine(typeName);
                    }

                    //Printing all types for which factory methods are requested
                    sw.WriteLine();
                    sw.WriteLine("Factory requested types");
                    foreach (var typeName in pmd.PexGeneratedFactories.Values)
                    {
                        sw.WriteLine(typeName);
                    }
                }
            }

            //Writing method information
            if (PexMeConstants.ENABLE_DYNAMICDB_STORAGE)
            {
                var methodDic            = pmd.MethodDictionary;
                var methodAccessFileName = Path.Combine(PexMeConstants.PexMeStorageDirectory, pmd.AssemblyName + ".dynamic.methodAccess.txt");
                using (StreamWriter sw = new StreamWriter(methodAccessFileName))
                {
                    foreach (var methodEntry in methodDic.Values)
                    {
                        //Printing write fields
                        sw.WriteLine("Methodname: " + methodEntry.methodName);

                        if (methodEntry.WriteFields.Count > 0)
                        {
                            sw.WriteLine("Write fields: ");
                            foreach (var writeField in methodEntry.WriteFields)
                            {
                                sw.WriteLine("\tField: " + writeField);
                            }
                        }

                        if (methodEntry.CalledMethods.Count > 0)
                        {
                            sw.WriteLine("Called Methods: ");
                            foreach (var calledMethod in methodEntry.CalledMethods)
                            {
                                sw.WriteLine("\t" + calledMethod);
                            }
                        }

                        if (methodEntry.CallingMethods.Count > 0)
                        {
                            sw.WriteLine("Calling Methods: ");
                            foreach (var callingMethod in methodEntry.CallingMethods)
                            {
                                sw.WriteLine("\t" + callingMethod);
                            }
                        }

                        //TODO: Print read fields
                    }
                }
            }

            //Writing field information
            if (PexMeConstants.ENABLE_DYNAMICDB_STORAGE)
            {
                var fieldDic            = pmd.FieldDictionary;
                var fieldAccessFileName = Path.Combine(PexMeConstants.PexMeStorageDirectory, pmd.AssemblyName + ".dynamic.fieldAccess.txt");
                using (StreamWriter sw = new StreamWriter(fieldAccessFileName))
                {
                    foreach (var fieldEntry in fieldDic.Values)
                    {
                        //Printing write methods
                        sw.WriteLine("Fieldname: " + fieldEntry.FieldName);
                        sw.WriteLine("Write methods: ");
                        foreach (var writeMethodSet in fieldEntry.WriteMethods.Values)
                        {
                            foreach (var writeMethod in writeMethodSet)
                            {
                                sw.WriteLine("\tMethod: " + writeMethod + ", ModificationType: " + FieldStore.GetModificationType(fieldEntry, writeMethod)
                                             + " PreciseModificationType: " + FieldStore.GetPreciseModificationType(fieldEntry, writeMethod));
                            }
                        }

                        sw.WriteLine("Field values: ");
                        foreach (var fieldValue in fieldEntry.FieldValues)
                        {
                            sw.WriteLine("\tValue: " + fieldValue);
                        }

                        //TODO: Print read methods
                    }
                }
            }

            //Writing uncovered code locations information
            var uncoveredCLDic      = pmd.UncoveredLocationDictionary;
            var uncoveredCLFileName = Path.Combine(PexMeConstants.PexMeStorageDirectory, pmd.AssemblyName + ".uncoveredloc.txt");

            using (StreamWriter sw = new StreamWriter(uncoveredCLFileName))
            {
                foreach (var ucstorelist in uncoveredCLDic.Values)
                {
                    var ucstore = ucstorelist.StoreList[0];
                    sw.WriteLine("CodeLocation: " + ucstore.Location);
                    sw.WriteLine("Relevant Fields: ");
                    //Writing associated fields
                    foreach (var field in ucstore.AllFields)
                    {
                        sw.WriteLine("\t" + field);
                    }

                    sw.WriteLine("Code Locations and Associated conditions: ");
                    sw.WriteLine("==========================================");
                    //Writing associated terms
                    foreach (var term in ucstore.TextualTerms)
                    {
                        sw.WriteLine(term);
                    }
                    sw.WriteLine("==========================================");

                    sw.WriteLine("Suggested target method for covering the branch location: ");
                    sw.WriteLine("==========================================================");
                    sw.WriteLine(ucstore.SuggestedMethodsforFactory);
                    sw.WriteLine("==========================================================");
                }

                sw.WriteLine("Generted factory methods for this type: ");
                sw.WriteLine("========================================");
                foreach (var facMethodList in pmd.PexGeneratedFactories.Values)
                {
                    foreach (string factoryMethod in facMethodList)
                    {
                        sw.WriteLine(factoryMethod);
                    }
                }
            }

            //Dumping the contents of factory suggestion store
            var fssdebugstore = Path.Combine(PexMeConstants.PexMeStorageDirectory, pmd.AssemblyName + ".fssdebug.txt");

            using (StreamWriter sw = new StreamWriter(fssdebugstore))
            {
                foreach (var fss in pmd.FactorySuggestionsDictionary.Values)
                {
                    sw.WriteLine("==================================================");
                    sw.WriteLine("Records of explorable type: \"" + fss.DeclaringType + "\"");
                    foreach (var codelockey in fss.locationStoreSpecificSequences.Keys)
                    {
                        sw.WriteLine("Key: \"" + codelockey + "\"");
                        var pucls = fss.locationStoreSpecificSequences[codelockey];
                        sw.WriteLine("Dormant status: " + pucls.IsDormat());
                        if (pucls.IsDormat())
                        {
                            sw.WriteLine("Associated PUT: " + pucls.AssociatedPUTName);
                        }
                        sw.WriteLine("Suggested Sequences........");
                        foreach (var seq in pucls.SuggestedMethodSequences)
                        {
                            sw.WriteLine(seq);
                            sw.WriteLine();
                        }
                    }

                    sw.WriteLine("==================================================");
                    sw.WriteLine("Final suggested sequences");
                    foreach (var mkey in fss.FinalSuggestedMethodSequences.Keys)
                    {
                        sw.WriteLine("Suggested sequences for the method " + mkey + ":");
                        var value = fss.FinalSuggestedMethodSequences[mkey];
                        sw.WriteLine(value.ToString());
                        sw.WriteLine();
                    }

                    sw.WriteLine("==================================================");
                    sw.WriteLine("PUT specific sequences");
                    foreach (var mkey in fss.FinalPUTSequences.Keys)
                    {
                        sw.WriteLine("Suggested sequences for the PUT " + mkey + ":");
                        var value = fss.FinalPUTSequences[mkey];
                        sw.WriteLine(value.ToString());
                        sw.WriteLine();
                    }

                    sw.WriteLine("==================================================");
                    sw.WriteLine("Defect detecting sequences");
                    foreach (var seq in fss.DefectDetectingSequences)
                    {
                        sw.WriteLine(seq);
                    }

                    sw.WriteLine("==================================================");
                    sw.WriteLine("All given up locations (Permanent)");
                    foreach (var loc in fss.PermanentFailedUncoveredLocations)
                    {
                        sw.Write(loc.ToString());
                        if (fss.UncoveredSystemLibLocations.Contains(loc))
                        {
                            sw.Write(" ( SystemLib )");
                        }
                        sw.WriteLine();
                    }

                    sw.WriteLine("All given up locations (Temporary)");
                    foreach (var loc in fss.TemporaryFailedUncoveredLocations.Keys)
                    {
                        sw.WriteLine(loc.ToString() + ", Attempt: " + fss.TemporaryFailedUncoveredLocations[loc]);
                    }

                    sw.WriteLine("==================================================");
                    sw.WriteLine("All successful locations");
                    foreach (var loc in fss.SuccessfulCoveredLocations)
                    {
                        sw.WriteLine(loc.ToString());
                    }
                }
            }
            /******************** END OF DEBUGGING INFO ***********************/
        }
Beispiel #25
0
        /// <summary>
        /// Dumps static database
        /// </summary>
        public void DumpStaticDatabase(PexMeStaticDatabase psd)
        {
            SafeDebug.AssumeNotNull(psd, "psd");

            if (!Directory.Exists(PexMeConstants.PexMeStorageDirectory))
            {
                Directory.CreateDirectory(PexMeConstants.PexMeStorageDirectory);
            }

            //Dump the dynamic field store that includes information of which method modify which fields
            try
            {
                var             filename           = Path.Combine(PexMeConstants.PexMeStorageDirectory, PexMeConstants.PexMeStaticFieldStore);
                Stream          streamWrite        = File.Create(filename);
                BinaryFormatter binaryWrite        = new BinaryFormatter();
                var             persistentFieldDic = this.GetPersistentFieldDictionary(psd.FieldDictionary);
                binaryWrite.Serialize(streamWrite, persistentFieldDic);
                streamWrite.Close();
            }
            catch (Exception ex)
            {
                psd.Log.LogErrorFromException(ex, WikiTopics.MissingWikiTopic, "dumpwriter",
                                              "Failed to dump field store of static database");
            }

            //Dump the dynamic method store that includes information of which method calls other methods and field they modify
            try
            {
                var             filename            = Path.Combine(PexMeConstants.PexMeStorageDirectory, PexMeConstants.PexMeStaticMethodStore);
                Stream          streamWrite         = File.Create(filename);
                BinaryFormatter binaryWrite         = new BinaryFormatter();
                var             persistentMethodDic = this.GetPersistentMethodDictionary(psd.MethodDictionary);
                binaryWrite.Serialize(streamWrite, persistentMethodDic);
                streamWrite.Close();
            }
            catch (Exception ex)
            {
                psd.Log.LogErrorFromException(ex, WikiTopics.MissingWikiTopic, "dumpwriter",
                                              "Failed to dump method store of static database");
            }

            /******************** DEBUGGING INFO *************************/
            //Writing method information
            var methodDic = psd.MethodDictionary;

            var methodAccessFileName = Path.Combine(PexMeConstants.PexMeStorageDirectory, psd.AssemblyName + ".static.methodAccess.txt");

            using (StreamWriter sw = new StreamWriter(methodAccessFileName))
            {
                foreach (var methodEntry in methodDic.Values)
                {
                    //Printing write fields
                    sw.WriteLine("Methodname: " + methodEntry.methodName);

                    if (methodEntry.WriteFields.Count > 0)
                    {
                        sw.WriteLine("Write fields: ");
                        foreach (var writeField in methodEntry.WriteFields)
                        {
                            sw.WriteLine("\tField: " + writeField);
                        }
                    }

                    if (methodEntry.CalledMethods.Count > 0)
                    {
                        sw.WriteLine("Called Methods: ");
                        foreach (var calledMethod in methodEntry.CalledMethods)
                        {
                            sw.WriteLine("\t" + calledMethod);
                        }
                    }

                    if (methodEntry.CallingMethods.Count > 0)
                    {
                        sw.WriteLine("Calling Methods: ");
                        foreach (var callingMethod in methodEntry.CallingMethods)
                        {
                            sw.WriteLine("\t" + callingMethod);
                        }
                    }

                    //TODO: Print read fields
                }
            }

            //Writing field information
            var fieldDic = psd.FieldDictionary;

            var fieldAccessFileName = Path.Combine(PexMeConstants.PexMeStorageDirectory, psd.AssemblyName + ".static.fieldAccess.txt");

            using (StreamWriter sw = new StreamWriter(fieldAccessFileName))
            {
                foreach (var fieldEntry in fieldDic.Values)
                {
                    //Printing write methods
                    sw.WriteLine("Fieldname: " + fieldEntry.FieldName);
                    sw.WriteLine("Write methods: ");
                    foreach (var writeMethodSet in fieldEntry.WriteMethods.Values)
                    {
                        foreach (var writeMethod in writeMethodSet)
                        {
                            sw.WriteLine("\tMethod: " + writeMethod + ", ModificationType: " + FieldStore.GetModificationType(fieldEntry, writeMethod));
                        }
                    }

                    sw.WriteLine("Field values: ");
                    foreach (var fieldValue in fieldEntry.FieldValues)
                    {
                        sw.WriteLine("\tValue: " + fieldValue);
                    }

                    //TODO: Print read methods
                }
            }
            /******************** DEBUGGING INFO *************************/
        }
Beispiel #26
0
 public void AddDocument(KeyValuePair<string, string> fieldKeyValue, FieldIndexOption indexOption, FieldStore store)
 {
     doc.Add(new Field(fieldKeyValue.Key, fieldKeyValue.Value, GetLucentFieldStore(store), this.GetLucentFieldIndex(indexOption)));
 }