Example #1
0
        public void Create_A_Short_Description_Correctly()
        {
            // arrange
            var dumpObject = new DumpObject(0x1337, "Dogs.Corgi.Duke", 0x42, 1);

            // act
            // assert
            dumpObject.Address.Should().Be(0x1337);
            dumpObject.ToShortDescription().Should().Be($"Dogs.Corgi.Duke : {0x42} : 0x0000000000001337");
        }
Example #2
0
        /// <summary>
        ///     Extracts data from the provided object
        /// </summary>
        /// <param name="clrObject">The object.</param>
        /// <param name="clrRuntime">The runtime.</param>
        /// <returns>Extracted dump object</returns>
        public DumpObject Extract(IClrObject clrObject, IClrRuntime clrRuntime)
        {
            var address    = clrObject.Address;
            var gen        = clrRuntime.Heap.GetGeneration(address);
            var size       = clrObject.Size;
            var name       = clrObject.Type.Name;
            var dumpObject = new DumpObject(address, name, size, gen);

            return(dumpObject);
        }
Example #3
0
        public void Add_A_Thread_Only_Once()
        {
            // arrange
            var sut    = new DumpObject();
            var thread = new DumpThread();

            // act
            sut.AddThread(thread);
            sut.AddThread(thread);

            // assert
            sut.Threads.Should().HaveCount(1);
        }
Example #4
0
        public void Correctly_Add_A_Reference_Object()
        {
            // arrange
            var first  = new DumpObject(0x1337, "Dogs.Corgi.Duke", 0x42, 1);
            var second = new DumpObject(0x1338, "Dogs.Corgi.Brady", 0x42, 2);

            first.AddReference(second);
            second.AddReferencer(first);

            // act
            // assert
            first.References.Should().HaveCount(1);
            second.Referencers.Should().HaveCount(1);
        }
Example #5
0
        public void Exhibit_Entity_Equality()
        {
            // arrange
            var a = new DumpObject
            {
                Address      = 0,
                FullTypeName = "Something"
            };
            var b = new DumpObject
            {
                Address      = 0,
                FullTypeName = "Something Else"
            };
            var c = new DumpObject
            {
                Address      = 1,
                FullTypeName = "Something"
            };

            // act
            // assert
            a.GetHashCode().Should().Be(b.GetHashCode());
            a.GetHashCode().Should().NotBe(c.GetHashCode());

            a.Equals(a).Should().BeTrue();
            a.Equals(b).Should().BeTrue();
            a.Equals(c).Should().BeFalse();
            a.Equals(null).Should().BeFalse();
            a.Equals("").Should().BeFalse();
            a.CompareTo(a).Should().Be(0);
            a.CompareTo(b).Should().Be(0);
            a.CompareTo(c).Should().Be(-1);
            a.CompareTo(null).Should().Be(1);
            a.Equals((object)a).Should().BeTrue();
            a.Equals((object)b).Should().BeTrue();
            a.Equals((object)c).Should().BeFalse();
            a.Equals((object)null).Should().BeFalse();
            a.CompareTo((object)a).Should().Be(0);
            a.CompareTo((object)b).Should().Be(0);
            a.CompareTo((object)c).Should().Be(-1);
            a.CompareTo((object)null).Should().Be(1);
            (a < b).Should().BeFalse();
            (a <= b).Should().BeTrue();
            (c > a).Should().BeTrue();
            (c >= a).Should().BeTrue();
            Action throws = () => a.CompareTo("");

            throws.Should().Throw <ArgumentException>();
        }
Example #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.Tag          = this;
            CatchMe.AllowDump = true;
            string yyy = null;

            using (StreamWriter sw = new StreamWriter(@"c:\ProjetTemp\Variable.txt"))
            {
                Button[] hh = new Button [] { new Button(), new Button() };

                int[,] hh2 = new int[2, 2]  {
                    { 0, 0 }, { 5, 8 }
                };

                List <int> hh3 = new List <int>();
                hh3.Add(5);
                hh3.Add(5);
                hh3.Add(5);
                hh3.Add(5);
                hh3.Add(5);

                //sw.Write(yyy = DumpObject.Dump(this, 0));
                sw.Write(yyy = new DumpObject().Dump(hh3, 0));
            }
            textBox1.Text = yyy;

            //  object ret2 = null;
            // ret2.ToString();

            /*
             * try
             * {
             *  object ret = null;
             *  ret.ToString();
             * }
             * catch(Exception ex)
             * {
             * // string str = DumpObject.Dump(this, 0);
             *
             *  LogTrace.CatchException.CatchMe.WriteMessage("Test").Level(1).Screen().Variable("EventArgs", e).Variable("Sender", sender).Where().Write();
             *
             *  LogTrace.CatchException.CatchMe.WriteException(ex).Where().Write();
             * }*/
        }
Example #7
0
        internal void OnUpdateRequestCache(object sender, EventArgs e)
        {
            var         application = (HttpApplication)sender;
            HttpContext context     = application.Context;

#if DEBUG
            bool isAspx = context.Request.Path.EndsWith(".aspx", StringComparison.OrdinalIgnoreCase);

            if (isAspx)
            {
                lock (LockThis)
                {
                    Trace.WriteLine("------------------------------------------------START CONTEXT-------------------------------------------------------------------");

                    var objectDump = new StringBuilder();
                    DumpObject.Dump(context, objectDump, BindingFlags.Public | BindingFlags.NonPublic);

                    Trace.WriteLine(objectDump.ToString());

                    Trace.WriteLine("------------------------------------------------END CONTEXT--------------------------------------------------------------------");

                    Trace.WriteLine("------------------------------------------------START REQUEST-------------------------------------------------------------------");

                    objectDump.Clear();
                    DumpObject.Dump(context.Request, objectDump, BindingFlags.Public | BindingFlags.NonPublic);

                    Trace.WriteLine(objectDump.ToString());

                    Trace.WriteLine("------------------------------------------------END REQUEST--------------------------------------------------------------------");

                    Trace.WriteLine("------------------------------------------------START RESPONSE-------------------------------------------------------------------");

                    objectDump.Clear();
                    DumpObject.Dump(context.Response, objectDump, BindingFlags.Public | BindingFlags.NonPublic);

                    Trace.WriteLine(objectDump.ToString());

                    Trace.WriteLine("------------------------------------------------END RESPONSE--------------------------------------------------------------------");
                }
            }
#endif

            string url = Utilities.GetUrlWithNoQueries(context);

            if (IsValidRequestToCache(context, url))
            {
                bool flag = IsCacheable(context);

                if (flag)
                {
                    string key = CreateOutputCachedItemKey(url, context);

                    RawResponse rawResponse = GetSnapshot(context.Response);

                    CacheDependency dependencies = GetDependencies(context, url);

                    context.Cache.Insert(key, rawResponse, dependencies, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(60), CacheItemPriority.Low, null);

                    if (!_serverListLoaded)
                    {
                        SPSecurity.RunWithElevatedPrivileges(delegate
                        {
                            _servers = LoadBalancingServerList(application);
                        });
                    }

                    if (_servers.Count > 0)
                    {
                        string currentSiteUrl = SPContext.Current.Site.Url;

                        if (!currentSiteUrl.EndsWith("/"))
                        {
                            currentSiteUrl = currentSiteUrl + "/";
                        }

                        try
                        {
                            SPSecurity.RunWithElevatedPrivileges(
                                () => UpdateServersCache(key, rawResponse, url, currentSiteUrl));
                        }
                        catch (Exception ex)
                        {
                            Common.SharePoint.Library.Exception.LogException(EventSourceName,
                                                                             "Error in Alphamosaik.Translator.Caching.CachingHttpModule.GetUserGroupsCollection: " + ex.Message,
                                                                             EventLogEntryType.Warning);
                        }
                    }

                    Trace.WriteLine("EffectivePercentagePhysicalMemoryLimit: " +
                                    context.Cache.EffectivePercentagePhysicalMemoryLimit);
                    Trace.WriteLine("EffectivePrivateBytesLimit: " + context.Cache.EffectivePrivateBytesLimit);
                }
            }
        }