示例#1
0
        public static MITextPosition TryParse(TupleValue miTuple)
        {
            string filename = miTuple.TryFindString("fullname");

            if (string.IsNullOrEmpty(filename))
            {
                filename = miTuple.TryFindString("file");
            }
            if (!string.IsNullOrEmpty(filename))
            {
                filename = DebuggedProcess.UnixPathToWindowsPath(filename);
            }

            if (string.IsNullOrWhiteSpace(filename))
            {
                return(null);
            }

            uint?line = miTuple.TryFindUint("line");

            if (!line.HasValue || line.Value == 0)
            {
                return(null);
            }

            uint lineValue = line.Value;

            Microsoft.VisualStudio.Debugger.Interop.TEXT_POSITION startPosition = new Microsoft.VisualStudio.Debugger.Interop.TEXT_POSITION();
            startPosition.dwLine   = lineValue - 1;
            startPosition.dwColumn = 0;

            uint?startColumn = miTuple.TryFindUint("col");

            if (startColumn > 0)
            {
                startPosition.dwColumn = startColumn.Value - 1;
            }

            Microsoft.VisualStudio.Debugger.Interop.TEXT_POSITION endPosition = startPosition;
            uint?endLine = miTuple.TryFindUint("end-line");

            if (endLine > 0)
            {
                endPosition.dwLine = endLine.Value - 1;

                uint?endCol = miTuple.TryFindUint("end-col");
                if (endCol > 0)
                {
                    endPosition.dwColumn = endCol.Value - 1;
                }
            }

            return(new MITextPosition(filename, startPosition, endPosition));
        }