/// <summary> /// Rename an entry in the cache. /// Entry must already be in the cache. /// </summary> internal override void RenameEntry(string oldFullPath, ProjectRootElement projectRootElement) { lock (_locker) { ErrorUtilities.VerifyThrowArgumentLength(oldFullPath, "oldFullPath"); RenameEntryInternal(oldFullPath, projectRootElement); } }
/// <summary> /// Creates a new property /// </summary> /// <param name="name">The property name</param> /// <param name="value">The property value</param> /// <param name="source">The property source</param> public ToolsetPropertyDefinition(string name, string value, IElementLocation source) { ErrorUtilities.VerifyThrowArgumentLength(name, "name"); ErrorUtilities.VerifyThrowArgumentNull(source, "source"); // value can be the empty string but not null ErrorUtilities.VerifyThrowArgumentNull(value, "value"); _name = name; _value = value; _source = source; }
public static string Replace(this string aString, string oldValue, string newValue, StringComparison stringComparison) { ErrorUtilities.VerifyThrowArgumentNull(aString, nameof(aString)); ErrorUtilities.VerifyThrowArgumentNull(oldValue, nameof(oldValue)); ErrorUtilities.VerifyThrowArgumentLength(oldValue, nameof(oldValue)); if (newValue == null) { newValue = string.Empty; } var currentOccurrence = aString.IndexOf(oldValue, stringComparison); if (currentOccurrence == -1) { return(aString); } var endOfPreviousOccurrence = 0; // Assumes one match. Optimizes for replacing fallback property values (e.g. MSBuildExtensionsPath), where an import usually references the fallback property once. // Reduces memory usage by half. var builder = new StringBuilder(aString.Length - oldValue.Length + newValue.Length); while (currentOccurrence != -1) { var nonMatchLength = currentOccurrence - endOfPreviousOccurrence; builder.Append(aString, endOfPreviousOccurrence, nonMatchLength); builder.Append(newValue); endOfPreviousOccurrence = currentOccurrence + oldValue.Length; currentOccurrence = aString.IndexOf(oldValue, endOfPreviousOccurrence, stringComparison); } builder.Append(aString, endOfPreviousOccurrence, aString.Length - endOfPreviousOccurrence); return(builder.ToString()); }
/// <summary> /// Gets an identifier for a property based on its name, its containing object's name and/or type. This is intended to /// help the user zero in on the offending line/element in a xaml file, when we don't have access to a parser to /// report line numbers. /// </summary> /// <param name="propertyName"> The name of the property. </param> /// <param name="containingObjectName"> The name of the containing object. </param> /// <param name="containingObject"> The object which contains this property. </param> /// <returns> Returns "(containingObject's type name)containingObjectName.PropertyName". </returns> internal static string GetPropertyId(string propertyName, string containingObjectName, object containingObject) { ErrorUtilities.VerifyThrowArgumentLength(propertyName, "propertyName"); ErrorUtilities.VerifyThrowArgumentLength(containingObjectName, "containingObjectName"); ErrorUtilities.VerifyThrowArgumentNull(containingObject, "containingObject"); StringBuilder propertyId = new StringBuilder(); propertyId.Append("("); propertyId.Append(containingObject.GetType().Name); propertyId.Append(")"); if (!string.IsNullOrEmpty(containingObjectName)) { propertyId.Append(containingObjectName); } propertyId.Append("."); propertyId.Append(propertyName); return(propertyId.ToString()); }
/// <summary> /// Changes the unique name of the project. /// </summary> internal void UpdateUniqueProjectName(string newUniqueName) { ErrorUtilities.VerifyThrowArgumentLength(newUniqueName, nameof(newUniqueName)); _uniqueProjectName = newUniqueName; }
/// <summary> /// Validates the properties of this object. This method should be called /// after initialization is complete. /// </summary> internal void Validate(this DynamicEnumProperty type) { (type as BaseProperty).Validate(); ErrorUtilities.VerifyThrowArgumentLength(type.EnumProvider, "EnumProvider"); }