/// <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)); }
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; }
/// <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, " ")); }
/// <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; }
/// <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 + '`'); }
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 + '`'); }
/// <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) { }
/// <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);