Beispiel #1
0
        private static bool SameMemberAsTopPartialStackTrace(Exception e, string file, string member)
        {
            const string key = "PartialStackTrace";

            if (!TryGetValue(e, key, out string partialStackTrace))
            {
                return(false);
            }

            int    firstLineEndsAt = partialStackTrace.IndexOf('\r');
            string firstLine       = firstLineEndsAt == -1 ? partialStackTrace : partialStackTrace.Substring(0, firstLineEndsAt);

            string pstFile, pstMember;

            try
            {
                FileLine.ParseCompact(firstLine, out pstFile, out pstMember, out _);
            }
            catch
            {
                return(false);
            }

            return(string.Equals(pstFile, file, StringComparison.Ordinal) &&
                   string.Equals(pstMember, member, StringComparison.Ordinal));
        }
 /// <summary>
 /// Handles the specified event.
 /// </summary>
 /// <param name="evnt">The event to handle.</param>
 void IEventHandler <ShuttingDownEvent> .Handle(ShuttingDownEvent evnt)
 {
     // make sure critical shutdown state is reached before the event queue finishes shutting down
     if (this.LastStateFinishedHandling != AppState.Shutdown)
     {
         FileLine.ParseCompact(evnt.EventEnqueuePos, out var file, out var member, out var line);
         this.MoveToState(AppState.Shutdown, file, member, line);
     }
 }
Beispiel #3
0
        public static void ParseCompact()
        {
            FileLine.ParseCompact("Member, File.cs:5", out var file, out var member, out var line);
            Test.OrdinalEquals("File.cs", file);
            Test.OrdinalEquals("Member", member);
            Assert.AreEqual(5, line);

            FileLine.ParseCompact("Member,,Fi,:le::5", out file, out member, out line);
            Test.OrdinalEquals(",Fi,:le:", file);
            Test.OrdinalEquals("Member", member);
            Assert.AreEqual(5, line);
        }