Skip to content

Commit

Permalink
Regex update CallerArgument pattern
Browse files Browse the repository at this point in the history
From

```
ErrorUtilities\.VerifyThrowArgumentLength\(([a-zA-Z0-9]+), nameof\(\1\)\);
```

to

```
ErrorUtilities.VerifyThrowArgumentLength($1);
```

And revert `src/Deprecated`.
  • Loading branch information
rainersigwald committed Oct 14, 2024
1 parent e644968 commit 0e3e4f5
Show file tree
Hide file tree
Showing 56 changed files with 134 additions and 134 deletions.
2 changes: 1 addition & 1 deletion src/Build/BackEnd/BuildManager/BuildRequestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public BuildRequestData(string projectFullPath, IDictionary<string, string?> glo
public BuildRequestData(string projectFullPath, IDictionary<string, string?> globalProperties, string? toolsVersion, string[] targetsToBuild, HostServices? hostServices, BuildRequestDataFlags flags)
: this(targetsToBuild, hostServices, flags, FileUtilities.NormalizePath(projectFullPath)!)
{
ErrorUtilities.VerifyThrowArgumentLength(projectFullPath, nameof(projectFullPath));
ErrorUtilities.VerifyThrowArgumentLength(projectFullPath);
ErrorUtilities.VerifyThrowArgumentNull(globalProperties);

GlobalPropertiesDictionary = new PropertyDictionary<ProjectPropertyInstance>(globalProperties.Count);
Expand Down
2 changes: 1 addition & 1 deletion src/Build/BackEnd/Components/ProjectCache/CacheResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static CacheResult IndicateCacheHit(ProxyTargets proxyTargets)

public static CacheResult IndicateCacheHit(IReadOnlyCollection<PluginTargetResult> targetResults)
{
ErrorUtilities.VerifyThrowArgumentLength(targetResults, nameof(targetResults));
ErrorUtilities.VerifyThrowArgumentLength(targetResults);

return new CacheResult(CacheResultType.CacheHit, ConstructBuildResult(targetResults));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Build/BackEnd/Components/ProjectCache/ProxyTargets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private ProxyTargets()

public ProxyTargets(IReadOnlyDictionary<string, string> proxyTargetToRealTargetMap)
{
ErrorUtilities.VerifyThrowArgumentLength(proxyTargetToRealTargetMap, nameof(proxyTargetToRealTargetMap));
ErrorUtilities.VerifyThrowArgumentLength(proxyTargetToRealTargetMap);

_proxyTargetToRealTargetMap = proxyTargetToRealTargetMap.ToDictionary(kvp => kvp.Key, kvp => kvp.Value, StringComparer.OrdinalIgnoreCase);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal class TargetSpecification : ITranslatable
/// <param name="targetBuiltReason">Reason the target is being built</param>
internal TargetSpecification(string targetName, ElementLocation referenceLocation, TargetBuiltReason targetBuiltReason = TargetBuiltReason.None)
{
ErrorUtilities.VerifyThrowArgumentLength(targetName, nameof(targetName));
ErrorUtilities.VerifyThrowArgumentLength(targetName);
ErrorUtilities.VerifyThrowArgumentNull(referenceLocation);

this._targetName = targetName;
Expand Down
2 changes: 1 addition & 1 deletion src/Build/BackEnd/Shared/ConfigurationMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public ConfigurationMetadata(Project project)
/// </summary>
public ConfigurationMetadata(string projectFullPath, PropertyDictionary<ProjectPropertyInstance> globalProperties)
{
ErrorUtilities.VerifyThrowArgumentLength(projectFullPath, nameof(projectFullPath));
ErrorUtilities.VerifyThrowArgumentLength(projectFullPath);
ErrorUtilities.VerifyThrowArgumentNull(globalProperties);

_projectFullPath = projectFullPath;
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Collections/CopyOnWritePropertyDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ IEnumerator<KeyValuePair<string, T>> IEnumerable<KeyValuePair<string, T>>.GetEnu
/// </summary>
public bool Remove(string name)
{
ErrorUtilities.VerifyThrowArgumentLength(name, nameof(name));
ErrorUtilities.VerifyThrowArgumentLength(name);

return ImmutableInterlocked.TryRemove(ref _backing, name, out _);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Collections/PropertyDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ IEnumerator<KeyValuePair<string, T>> IEnumerable<KeyValuePair<string, T>>.GetEnu
/// </summary>
internal bool Remove(string name)
{
ErrorUtilities.VerifyThrowArgumentLength(name, nameof(name));
ErrorUtilities.VerifyThrowArgumentLength(name);

lock (_properties)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Build/Construction/ProjectExtensionsElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public string this[string name]
{
get
{
ErrorUtilities.VerifyThrowArgumentLength(name, nameof(name));
ErrorUtilities.VerifyThrowArgumentLength(name);

if (Link != null)
{
Expand All @@ -116,7 +116,7 @@ public string this[string name]

set
{
ErrorUtilities.VerifyThrowArgumentLength(name, nameof(name));
ErrorUtilities.VerifyThrowArgumentLength(name);
ErrorUtilities.VerifyThrowArgumentNull(value, "value");

if (Link != null)
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Construction/ProjectImportGroupElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private ProjectImportGroupElement(XmlElementWithLocation xmlElement, ProjectRoot
/// </summary>
public ProjectImportElement AddImport(string project)
{
ErrorUtilities.VerifyThrowArgumentLength(project, nameof(project));
ErrorUtilities.VerifyThrowArgumentLength(project);

ProjectImportElement newImport = ContainingProject.CreateImportElement(project);
AppendChild(newImport);
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Construction/ProjectItemDefinitionElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public ProjectMetadataElement AddMetadata(string name, string unevaluatedValue)
/// </param>
public ProjectMetadataElement AddMetadata(string name, string unevaluatedValue, bool expressAsAttribute)
{
ErrorUtilities.VerifyThrowArgumentLength(name, nameof(name));
ErrorUtilities.VerifyThrowArgumentLength(name);
ErrorUtilities.VerifyThrowArgumentNull(unevaluatedValue);

if (expressAsAttribute)
Expand Down
4 changes: 2 additions & 2 deletions src/Build/Construction/ProjectItemElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public ProjectMetadataElement AddMetadata(string name, string unevaluatedValue)
/// </param>
public ProjectMetadataElement AddMetadata(string name, string unevaluatedValue, bool expressAsAttribute)
{
ErrorUtilities.VerifyThrowArgumentLength(name, nameof(name));
ErrorUtilities.VerifyThrowArgumentLength(name);
ErrorUtilities.VerifyThrowArgumentNull(unevaluatedValue);

if (expressAsAttribute)
Expand Down Expand Up @@ -439,7 +439,7 @@ internal static ProjectItemElement CreateDisconnected(string itemType, ProjectRo
/// </remarks>
internal void ChangeItemType(string newItemType)
{
ErrorUtilities.VerifyThrowArgumentLength(newItemType, nameof(newItemType));
ErrorUtilities.VerifyThrowArgumentLength(newItemType);
XmlUtilities.VerifyThrowArgumentValidElementName(newItemType);
ErrorUtilities.VerifyThrowArgument(!XMakeElements.ReservedItemNames.Contains(newItemType), "CannotModifyReservedItem", newItemType);
if (Link != null)
Expand Down
4 changes: 2 additions & 2 deletions src/Build/Construction/ProjectItemGroupElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public ProjectItemElement AddItem(string itemType, string include)
/// </summary>
public ProjectItemElement AddItem(string itemType, string include, IEnumerable<KeyValuePair<string, string>> metadata)
{
ErrorUtilities.VerifyThrowArgumentLength(itemType, nameof(itemType));
ErrorUtilities.VerifyThrowArgumentLength(include, nameof(include));
ErrorUtilities.VerifyThrowArgumentLength(itemType);
ErrorUtilities.VerifyThrowArgumentLength(include);

// If there are no items, or it turns out that there are only items with
// item types that sort earlier, then we should go after the last child
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Construction/ProjectMetadataElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ internal static ProjectMetadataElement CreateDisconnected(string name, ProjectRo
/// </remarks>
internal void ChangeName(string newName)
{
ErrorUtilities.VerifyThrowArgumentLength(newName, nameof(newName));
ErrorUtilities.VerifyThrowArgumentLength(newName);
XmlUtilities.VerifyThrowArgumentValidElementName(newName);
ErrorUtilities.VerifyThrowArgument(!XMakeElements.ReservedItemNames.Contains(newName), "CannotModifyReservedItemMetadata", newName);

Expand Down
2 changes: 1 addition & 1 deletion src/Build/Construction/ProjectOutputElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public string TaskParameter
[DebuggerStepThrough]
set
{
ErrorUtilities.VerifyThrowArgumentLength(value, nameof(value));
ErrorUtilities.VerifyThrowArgumentLength(value);
SetOrRemoveAttribute(XMakeAttributes.taskParameter, value, "Set Output TaskParameter {0}", value);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Construction/ProjectPropertyElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ internal static ProjectPropertyElement CreateDisconnected(string name, ProjectRo
/// </remarks>
internal void ChangeName(string newName)
{
ErrorUtilities.VerifyThrowArgumentLength(newName, nameof(newName));
ErrorUtilities.VerifyThrowArgumentLength(newName);
XmlUtilities.VerifyThrowArgumentValidElementName(newName);
ErrorUtilities.VerifyThrowArgument(!XMakeElements.ReservedItemNames.Contains(newName), "CannotModifyReservedProperty", newName);
if (Link != null)
Expand Down
4 changes: 2 additions & 2 deletions src/Build/Construction/ProjectPropertyGroupElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private ProjectPropertyGroupElement(XmlElementWithLocation xmlElement, ProjectRo
/// </summary>
public ProjectPropertyElement AddProperty(string name, string unevaluatedValue)
{
ErrorUtilities.VerifyThrowArgumentLength(name, nameof(name));
ErrorUtilities.VerifyThrowArgumentLength(name);
ErrorUtilities.VerifyThrowArgumentNull(unevaluatedValue);

ProjectPropertyElement newProperty = ContainingProject.CreatePropertyElement(name);
Expand All @@ -75,7 +75,7 @@ public ProjectPropertyElement AddProperty(string name, string unevaluatedValue)
/// </summary>
public ProjectPropertyElement SetProperty(string name, string unevaluatedValue)
{
ErrorUtilities.VerifyThrowArgumentLength(name, nameof(name));
ErrorUtilities.VerifyThrowArgumentLength(name);
ErrorUtilities.VerifyThrowArgumentNull(unevaluatedValue);

foreach (ProjectPropertyElement property in Properties)
Expand Down
20 changes: 10 additions & 10 deletions src/Build/Construction/ProjectRootElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private ProjectRootElement(
ProjectRootElementCacheBase projectRootElementCache,
bool preserveFormatting)
{
ErrorUtilities.VerifyThrowArgumentLength(path, nameof(path));
ErrorUtilities.VerifyThrowArgumentLength(path);
ErrorUtilities.VerifyThrowInternalRooted(path);
ErrorUtilities.VerifyThrowArgumentNull(projectRootElementCache);
ProjectRootElementCache = projectRootElementCache;
Expand Down Expand Up @@ -397,7 +397,7 @@ public string FullPath

set
{
ErrorUtilities.VerifyThrowArgumentLength(value, nameof(value));
ErrorUtilities.VerifyThrowArgumentLength(value);
if (Link != null)
{
RootLink.FullPath = value;
Expand Down Expand Up @@ -782,7 +782,7 @@ public static ProjectRootElement Create(string path, ProjectCollection projectCo
/// </summary>
public static ProjectRootElement Create(string path, ProjectCollection projectCollection, NewProjectFileOptions newProjectFileOptions)
{
ErrorUtilities.VerifyThrowArgumentLength(path, nameof(path));
ErrorUtilities.VerifyThrowArgumentLength(path);
ErrorUtilities.VerifyThrowArgumentNull(projectCollection);

var projectRootElement = new ProjectRootElement(
Expand Down Expand Up @@ -853,7 +853,7 @@ public static ProjectRootElement Open(string path, ProjectCollection projectColl
/// </summary>
public static ProjectRootElement Open(string path, ProjectCollection projectCollection, bool? preserveFormatting)
{
ErrorUtilities.VerifyThrowArgumentLength(path, nameof(path));
ErrorUtilities.VerifyThrowArgumentLength(path);
ErrorUtilities.VerifyThrowArgumentNull(projectCollection);

path = FileUtilities.NormalizePath(path);
Expand All @@ -873,7 +873,7 @@ public static ProjectRootElement Open(string path, ProjectCollection projectColl
/// </remarks>
public static ProjectRootElement TryOpen(string path)
{
ErrorUtilities.VerifyThrowArgumentLength(path, nameof(path));
ErrorUtilities.VerifyThrowArgumentLength(path);

return TryOpen(path, ProjectCollection.GlobalProjectCollection);
}
Expand Down Expand Up @@ -910,7 +910,7 @@ public static ProjectRootElement TryOpen(string path, ProjectCollection projectC
/// </remarks>
public static ProjectRootElement TryOpen(string path, ProjectCollection projectCollection, bool? preserveFormatting)
{
ErrorUtilities.VerifyThrowArgumentLength(path, nameof(path));
ErrorUtilities.VerifyThrowArgumentLength(path);
ErrorUtilities.VerifyThrowArgumentNull(projectCollection);

path = FileUtilities.NormalizePath(path);
Expand All @@ -927,7 +927,7 @@ public static ProjectRootElement TryOpen(string path, ProjectCollection projectC
/// </summary>
public ProjectImportElement AddImport(string project)
{
ErrorUtilities.VerifyThrowArgumentLength(project, nameof(project));
ErrorUtilities.VerifyThrowArgumentLength(project);

ProjectImportGroupElement importGroupToAddTo =
ImportGroupsReversed.FirstOrDefault(importGroup => importGroup.Condition.Length <= 0);
Expand Down Expand Up @@ -984,8 +984,8 @@ public ProjectItemElement AddItem(string itemType, string include)
/// </remarks>
public ProjectItemElement AddItem(string itemType, string include, IEnumerable<KeyValuePair<string, string>> metadata)
{
ErrorUtilities.VerifyThrowArgumentLength(itemType, nameof(itemType));
ErrorUtilities.VerifyThrowArgumentLength(include, nameof(include));
ErrorUtilities.VerifyThrowArgumentLength(itemType);
ErrorUtilities.VerifyThrowArgumentLength(include);

ProjectItemGroupElement itemGroupToAddTo = null;

Expand Down Expand Up @@ -1061,7 +1061,7 @@ public ProjectItemGroupElement AddItemGroup()
/// </summary>
public ProjectItemDefinitionElement AddItemDefinition(string itemType)
{
ErrorUtilities.VerifyThrowArgumentLength(itemType, nameof(itemType));
ErrorUtilities.VerifyThrowArgumentLength(itemType);

ProjectItemDefinitionGroupElement itemDefinitionGroupToAddTo = null;

Expand Down
4 changes: 2 additions & 2 deletions src/Build/Construction/ProjectTargetElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public string Name

set
{
ErrorUtilities.VerifyThrowArgumentLength(value, nameof(value));
ErrorUtilities.VerifyThrowArgumentLength(value);
if (Link != null)
{
TargetLink.Name = value;
Expand Down Expand Up @@ -378,7 +378,7 @@ public ProjectPropertyGroupElement AddPropertyGroup()
/// </summary>
public ProjectTaskElement AddTask(string taskName)
{
ErrorUtilities.VerifyThrowArgumentLength(taskName, nameof(taskName));
ErrorUtilities.VerifyThrowArgumentLength(taskName);

ProjectTaskElement task = ContainingProject.CreateTaskElement(taskName);

Expand Down
14 changes: 7 additions & 7 deletions src/Build/Construction/ProjectTaskElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ public IEnumerable<KeyValuePair<string, ElementLocation>> ParameterLocations
/// </summary>
public ProjectOutputElement AddOutputItem(string taskParameter, string itemType)
{
ErrorUtilities.VerifyThrowArgumentLength(taskParameter, nameof(taskParameter));
ErrorUtilities.VerifyThrowArgumentLength(itemType, nameof(itemType));
ErrorUtilities.VerifyThrowArgumentLength(taskParameter);
ErrorUtilities.VerifyThrowArgumentLength(itemType);

return AddOutputItem(taskParameter, itemType, null);
}
Expand Down Expand Up @@ -259,8 +259,8 @@ public ProjectOutputElement AddOutputItem(string taskParameter, string itemType,
/// </summary>
public ProjectOutputElement AddOutputProperty(string taskParameter, string propertyName)
{
ErrorUtilities.VerifyThrowArgumentLength(taskParameter, nameof(taskParameter));
ErrorUtilities.VerifyThrowArgumentLength(propertyName, nameof(propertyName));
ErrorUtilities.VerifyThrowArgumentLength(taskParameter);
ErrorUtilities.VerifyThrowArgumentLength(propertyName);

return AddOutputProperty(taskParameter, propertyName, null);
}
Expand Down Expand Up @@ -296,7 +296,7 @@ public string GetParameter(string name)

lock (_locker)
{
ErrorUtilities.VerifyThrowArgumentLength(name, nameof(name));
ErrorUtilities.VerifyThrowArgumentLength(name);

EnsureParametersInitialized();

Expand All @@ -322,7 +322,7 @@ public void SetParameter(string name, string unevaluatedValue)

lock (_locker)
{
ErrorUtilities.VerifyThrowArgumentLength(name, nameof(name));
ErrorUtilities.VerifyThrowArgumentLength(name);
ErrorUtilities.VerifyThrowArgumentNull(unevaluatedValue);
ErrorUtilities.VerifyThrowArgument(!XMakeAttributes.IsSpecialTaskAttribute(name), "CannotAccessKnownAttributes", name);

Expand Down Expand Up @@ -411,7 +411,7 @@ public override void CopyFrom(ProjectElement element)
/// </remarks>
internal static ProjectTaskElement CreateDisconnected(string name, ProjectRootElement containingProject)
{
ErrorUtilities.VerifyThrowArgumentLength(name, nameof(name));
ErrorUtilities.VerifyThrowArgumentLength(name);

XmlElementWithLocation element = containingProject.CreateElement(name);

Expand Down
2 changes: 1 addition & 1 deletion src/Build/Construction/Solution/ProjectInSolution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ internal string GetProjectGuidWithoutCurlyBrackets()
/// </summary>
internal void UpdateUniqueProjectName(string newUniqueName)
{
ErrorUtilities.VerifyThrowArgumentLength(newUniqueName, nameof(newUniqueName));
ErrorUtilities.VerifyThrowArgumentLength(newUniqueName);

_uniqueProjectName = newUniqueName;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Construction/UsingTaskParameterGroupElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public override ElementLocation ConditionLocation
/// </summary>
public ProjectUsingTaskParameterElement AddParameter(string name, string output, string required, string parameterType)
{
ErrorUtilities.VerifyThrowArgumentLength(name, nameof(name));
ErrorUtilities.VerifyThrowArgumentLength(name);

ProjectUsingTaskParameterElement newParameter = ContainingProject.CreateUsingTaskParameterElement(name, output, required, parameterType);
AppendChild(newParameter);
Expand Down
10 changes: 5 additions & 5 deletions src/Build/Definition/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2924,7 +2924,7 @@ public override string GetPropertyValue(string name)
/// </summary>
public override ProjectProperty SetProperty(string name, string unevaluatedValue)
{
ErrorUtilities.VerifyThrowArgumentLength(name, nameof(name));
ErrorUtilities.VerifyThrowArgumentLength(name);
ErrorUtilities.VerifyThrowArgumentNull(unevaluatedValue);

ProjectProperty property = _data.Properties[name];
Expand Down Expand Up @@ -3052,8 +3052,8 @@ public override IList<ProjectItem> AddItem(string itemType, string unevaluatedIn
/// </summary>
public override IList<ProjectItem> AddItemFast(string itemType, string unevaluatedInclude, IEnumerable<KeyValuePair<string, string>> metadata)
{
ErrorUtilities.VerifyThrowArgumentLength(itemType, nameof(itemType));
ErrorUtilities.VerifyThrowArgumentLength(unevaluatedInclude, nameof(unevaluatedInclude));
ErrorUtilities.VerifyThrowArgumentLength(itemType);
ErrorUtilities.VerifyThrowArgumentLength(unevaluatedInclude);

ProjectItemGroupElement groupToAppendTo = null;

Expand Down Expand Up @@ -3179,7 +3179,7 @@ public override bool RemoveProperty(ProjectProperty property)
/// </summary>
public override bool RemoveGlobalProperty(string name)
{
ErrorUtilities.VerifyThrowArgumentLength(name, nameof(name));
ErrorUtilities.VerifyThrowArgumentLength(name);

bool result = _data.GlobalPropertiesDictionary.Remove(name);

Expand Down Expand Up @@ -4623,7 +4623,7 @@ internal ICollection<ProjectItem> GetItemsByEvaluatedInclude(string evaluatedInc
/// </remarks>
internal string GetPropertyValue(string name)
{
ErrorUtilities.VerifyThrowArgumentLength(name, nameof(name));
ErrorUtilities.VerifyThrowArgumentLength(name);

ProjectProperty property = Properties[name];
string value = property?.EvaluatedValue ?? String.Empty;
Expand Down
Loading

0 comments on commit 0e3e4f5

Please sign in to comment.