/// <nodoc/>
        protected static string GetElementOrConditionText(string description, EvaluationLocationKind kind)
        {
            if (description == null)
            {
                return(null);
            }

            if (kind == EvaluationLocationKind.Condition)
            {
                return($"Condition=\"{description}\")");
            }

            if (kind == EvaluationLocationKind.Glob)
            {
                return($"Glob=\"{description}\")");
            }

            var outerXml = description;

            outerXml = outerXml.Replace(@"xmlns=""http://schemas.microsoft.com/developer/msbuild/2003""", "");

            var newLineIndex = outerXml.IndexOfAny(new[] { '\r', '\n' });

            return(newLineIndex == -1 ? outerXml : outerXml.Remove(newLineIndex));
        }
示例#2
0
        private EvaluationLocation ReadEvaluationLocation()
        {
            string elementName           = ReadOptionalString();
            string description           = ReadOptionalString();
            string evaluationDescription = ReadOptionalString();
            string file = ReadOptionalString();
            EvaluationLocationKind kind           = (EvaluationLocationKind)ReadInt32();
            EvaluationPass         evaluationPass = (EvaluationPass)ReadInt32();

            int? line    = null;
            bool hasLine = ReadBoolean();

            if (hasLine)
            {
                line = ReadInt32();
            }

            // Id and parent Id were introduced in version 6
            if (fileFormatVersion > 5)
            {
                long id        = ReadInt64();
                long?parentId  = null;
                bool hasParent = ReadBoolean();
                if (hasParent)
                {
                    parentId = ReadInt64();
                }
                return(new EvaluationLocation(id, parentId, evaluationPass, evaluationDescription, file, line, elementName, description, kind));
            }

            return(new EvaluationLocation(0, null, evaluationPass, evaluationDescription, file, line, elementName, description, kind));
        }
 public EvaluatedLocationInfo(string elementName, string elementDescription, EvaluationLocationKind kind, string file, int?line, IEnumerable <EvaluatedLocationInfo> children, TimeInfo time)
 {
     ElementName        = elementName;
     ElementDescription = elementDescription;
     Kind     = kind;
     File     = file;
     Line     = line;
     Children = children?.ToImmutableArray() ?? ImmutableArray <EvaluatedLocationInfo> .Empty;
     Time     = time;
 }
示例#4
0
 /// <summary>
 /// Constructs the generic case.
 /// </summary>
 /// <remarks>
 /// Used by serialization/deserialization purposes
 /// </remarks>
 public EvaluationLocation(EvaluationPass evaluationPass, string evaluationDescription, string file, int?line, string elementName, string description, EvaluationLocationKind kind)
 {
     EvaluationPass        = evaluationPass;
     EvaluationDescription = evaluationDescription;
     File        = file;
     Line        = line;
     ElementName = elementName;
     Description = description;
     Kind        = kind;
 }
        protected override string NormalizeExpression(string description, EvaluationLocationKind kind)
        {
            var text = GetElementOrConditionText(description, kind);

            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }

            // Swap tabs for spaces, so we don't mess up the TSV format
            return(text.Replace(Separator, " "));
        }
示例#6
0
 /// <summary>
 /// Constructs a generic evaluation location
 /// </summary>
 /// <remarks>
 /// Used by serialization/deserialization purposes
 /// </remarks>
 public EvaluationLocation(long id, long?parentId, EvaluationPass evaluationPass, string evaluationPassDescription, string file,
                           int?line, string elementName, string elementDescription, EvaluationLocationKind kind)
 {
     Id                        = id;
     ParentId                  = parentId == EmptyLocation.Id? null : parentId; // The empty location doesn't count as a parent id, since it's just a dummy starting point
     EvaluationPass            = evaluationPass;
     EvaluationPassDescription = evaluationPassDescription;
     File                      = file;
     Line                      = line;
     ElementName               = elementName;
     ElementDescription        = elementDescription;
     Kind                      = kind;
 }
示例#7
0
        /// <inheritdoc/>
        protected override string NormalizeExpression(string description, EvaluationLocationKind kind)
        {
            var text = GetElementOrConditionText(description, kind);

            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }

            text = text.Replace(Separator, "\\" + Separator);

            if (text.Length > 100)
            {
                text = text.Remove(100) + "...";
            }

            return('`' + text + '`');
        }
示例#8
0
        private static string GetExpression(string description, EvaluationLocationKind kind)
        {
            var text = GetElementOrConditionText(description, kind);

            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }

            text = text.Replace("|", "\\|");

            if (text.Length > 100)
            {
                text = text.Remove(100) + "...";
            }

            return('`' + text + '`');
        }
示例#9
0
 /// <summary>
 /// Constructs a generic evaluation location with no parent.
 /// </summary>
 /// <remarks>
 /// A unique Id gets assigned automatically
 /// Used by serialization/deserialization purposes
 /// </remarks>
 public EvaluationLocation(EvaluationPass evaluationPass, string evaluationPassDescription, string file, int?line, string elementName, string elementDescription, EvaluationLocationKind kind)
     : this(null, evaluationPass, evaluationPassDescription, file, line, elementName, elementDescription, kind)
 {
 }
示例#10
0
 /// <summary>
 /// Constructs a generic evaluation location based on a (possibly null) parent Id.
 /// </summary>
 /// <remarks>
 /// A unique Id gets assigned automatically
 /// Used by serialization/deserialization purposes
 /// </remarks>
 public EvaluationLocation(long?parentId, EvaluationPass evaluationPass, string evaluationPassDescription, string file, int?line, string elementName, string elementDescription, EvaluationLocationKind kind)
     : this(EvaluationIdProvider.GetNextId(), parentId, evaluationPass, evaluationPassDescription, file, line, elementName, elementDescription, kind)
 {
 }
 /// <summary>
 /// Normalizes the expression returned by <see cref="GetElementOrConditionText"/>
 /// </summary>
 protected abstract string NormalizeExpression(string description, EvaluationLocationKind kind);