Skip to content

Commit

Permalink
More internal IFileSystem deprecation and tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ladipro committed Aug 19, 2021
1 parent cb827cc commit 180f7a8
Show file tree
Hide file tree
Showing 18 changed files with 156 additions and 157 deletions.
2 changes: 1 addition & 1 deletion src/Build.UnitTests/BackEnd/TaskRegistry_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2255,7 +2255,7 @@ internal static Expander<ProjectPropertyInstance, ProjectItemInstance> GetExpand
secondaryItemsByName.ImportItems(thirdItemGroup);
secondaryItemsByName.ImportItems(trueItemGroup);

Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(pg, secondaryItemsByName, FileSystems.Default);
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(pg, secondaryItemsByName);
return expander;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Build.UnitTests/Evaluation/Evaluator_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4298,7 +4298,7 @@ public void VerifyDTDProcessingIsDisabled2()
public void VerifyConditionEvaluatorResetStateOnFailure()
{
PropertyDictionary<ProjectPropertyInstance> propertyBag = new PropertyDictionary<ProjectPropertyInstance>();
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(propertyBag, FileSystems.Default);
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(propertyBag);
string condition = " '$(TargetOSFamily)' >= '3' ";

// Give an incorrect value for the property "TargetOSFamily", and then the evaluation should throw an exception.
Expand Down
230 changes: 115 additions & 115 deletions src/Build.UnitTests/Evaluation/Expander_Tests.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Build.UnitTests/Evaluation/ItemSpec_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private ProjectInstanceExpander CreateExpander(Dictionary<string, string[]> item
{
var itemDictionary = ToItemDictionary(items);

return new ProjectInstanceExpander(new PropertyDictionary<ProjectPropertyInstance>(), itemDictionary, (IFileSystem) FileSystems.Default);
return new ProjectInstanceExpander(new PropertyDictionary<ProjectPropertyInstance>(), itemDictionary);
}

private static ItemDictionary<ProjectItemInstance> ToItemDictionary(Dictionary<string, string[]> itemTypes)
Expand Down
2 changes: 1 addition & 1 deletion src/Build.UnitTests/ExpressionTreeExpression_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public ExpressionTest(ITestOutputHelper output)
metadataDictionary["Culture"] = "french";
StringMetadataTable itemMetadata = new StringMetadataTable(metadataDictionary);

_expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(propertyBag, itemBag, itemMetadata, FileSystems.Default);
_expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(propertyBag, itemBag, itemMetadata);

foreach (string file in FilesWithExistenceChecks)
{
Expand Down
28 changes: 14 additions & 14 deletions src/Build.UnitTests/ExpressionTree_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ExpressionTreeTest
public void SimpleEvaluationTests()
{
Parser p = new Parser();
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(new PropertyDictionary<ProjectPropertyInstance>(), FileSystems.Default);
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(new PropertyDictionary<ProjectPropertyInstance>());

AssertParseEvaluate(p, "true", expander, true);
AssertParseEvaluate(p, "on", expander, true);
Expand All @@ -41,7 +41,7 @@ public void SimpleEvaluationTests()
public void EqualityTests()
{
Parser p = new Parser();
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(new PropertyDictionary<ProjectPropertyInstance>(), FileSystems.Default);
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(new PropertyDictionary<ProjectPropertyInstance>());

AssertParseEvaluate(p, "true == on", expander, true);
AssertParseEvaluate(p, "TrUe == On", expander, true);
Expand All @@ -66,7 +66,7 @@ public void EqualityTests()
public void RelationalTests()
{
Parser p = new Parser();
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(new PropertyDictionary<ProjectPropertyInstance>(), FileSystems.Default);
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(new PropertyDictionary<ProjectPropertyInstance>());

AssertParseEvaluate(p, "1234 < 1235", expander, true);
AssertParseEvaluate(p, "1234 <= 1235", expander, true);
Expand All @@ -85,7 +85,7 @@ public void RelationalTests()
public void AndandOrTests()
{
Parser p = new Parser();
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(new PropertyDictionary<ProjectPropertyInstance>(), FileSystems.Default);
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(new PropertyDictionary<ProjectPropertyInstance>());

AssertParseEvaluate(p, "true == on and 1234 < 1235", expander, true);
}
Expand All @@ -97,7 +97,7 @@ public void FunctionTests()
{
Parser p = new Parser();
GenericExpressionNode tree;
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(new PropertyDictionary<ProjectPropertyInstance>(), new ItemDictionary<ProjectItemInstance>(), FileSystems.Default);
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(new PropertyDictionary<ProjectPropertyInstance>(), new ItemDictionary<ProjectItemInstance>());
expander.Metadata = new StringMetadataTable(null);
bool value;

Expand Down Expand Up @@ -149,7 +149,7 @@ public void PropertyTests()
propertyBag.Set(ProjectPropertyInstance.Create("x86", "x86"));
propertyBag.Set(ProjectPropertyInstance.Create("no", "no"));

Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(propertyBag, new ItemDictionary<ProjectItemInstance>(), FileSystems.Default);
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(propertyBag, new ItemDictionary<ProjectItemInstance>());
AssertParseEvaluate(p, "$(foo)", expander, true);
AssertParseEvaluate(p, "!$(foo)", expander, false);
// Test properties with strings
Expand Down Expand Up @@ -187,7 +187,7 @@ public void ItemListTests()
itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "baz.cs", parentProject.FullPath));
itemBag.Add(new ProjectItemInstance(parentProject, "Boolean", "true", parentProject.FullPath));

Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(new PropertyDictionary<ProjectPropertyInstance>(), itemBag, FileSystems.Default);
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(new PropertyDictionary<ProjectPropertyInstance>(), itemBag);

AssertParseEvaluate(p, "@(Compile) == 'foo.cs;bar.cs;baz.cs'", expander, true);
AssertParseEvaluate(p, "@(Compile,' ') == 'foo.cs bar.cs baz.cs'", expander, true);
Expand Down Expand Up @@ -230,7 +230,7 @@ public void StringExpansionTests()
propertyBag.Set(ProjectPropertyInstance.Create("AnotherTestQuote", "Here's Johnny!"));
propertyBag.Set(ProjectPropertyInstance.Create("Atsign", "Test the @ replacement"));

Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(propertyBag, itemBag, FileSystems.Default);
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(propertyBag, itemBag);

AssertParseEvaluate(p, "'simplestring: true foo.cs;bar.cs;baz.cs' == '$(simple): $(foo) @(compile)'", expander, true);
AssertParseEvaluate(p, "'$(c1) $(c2)' == 'Another (complex) one. Another (complex) one.'", expander, true);
Expand Down Expand Up @@ -262,7 +262,7 @@ public void ComplexTests()
propertyBag.Set(ProjectPropertyInstance.Create("c1", "Another (complex) one."));
propertyBag.Set(ProjectPropertyInstance.Create("c2", "Another (complex) one."));

Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(propertyBag, itemBag, FileSystems.Default);
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(propertyBag, itemBag);

AssertParseEvaluate(p, "(($(foo) != 'two' and $(bar)) and 5 >= 1) or $(one) == 1", expander, true);
AssertParseEvaluate(p, "(($(foo) != 'twoo' or !$(bar)) and 5 >= 1) or $(two) == 1", expander, true);
Expand All @@ -283,7 +283,7 @@ public void InvalidItemInConditionEvaluation()

PropertyDictionary<ProjectPropertyInstance> propertyBag = new PropertyDictionary<ProjectPropertyInstance>();

Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(propertyBag, itemBag, FileSystems.Default);
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(propertyBag, itemBag);

AssertParseEvaluateThrow(p, "@(Compile) > 0", expander, null);
}
Expand Down Expand Up @@ -312,7 +312,7 @@ public void OldSyntaxTests()
propertyBag.Set(ProjectPropertyInstance.Create("c1", "Another (complex) one."));
propertyBag.Set(ProjectPropertyInstance.Create("c2", "Another (complex) one."));

Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(propertyBag, itemBag, FileSystems.Default);
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(propertyBag, itemBag);

AssertParseEvaluate(p, "(($(foo) != 'two' and $(bar)) and 5 >= 1) or $(one) == 1", expander, true);
}
Expand All @@ -329,7 +329,7 @@ public void ConditionedPropertyUpdateTests()
itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "bar.cs", parentProject.FullPath));
itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "baz.cs", parentProject.FullPath));

Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(new PropertyDictionary<ProjectPropertyInstance>(), itemBag, FileSystems.Default);
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(new PropertyDictionary<ProjectPropertyInstance>(), itemBag);
Dictionary<string, List<string>> conditionedProperties = new Dictionary<string, List<string>>();
ConditionEvaluator.IConditionEvaluationState state =
new ConditionEvaluator.ConditionEvaluationState<ProjectPropertyInstance, ProjectItemInstance>
Expand Down Expand Up @@ -418,7 +418,7 @@ public void NotTests()
propertyBag.Set(ProjectPropertyInstance.Create("foo", "4"));
propertyBag.Set(ProjectPropertyInstance.Create("bar", "32"));

Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(propertyBag, new ItemDictionary<ProjectItemInstance>(), FileSystems.Default);
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(propertyBag, new ItemDictionary<ProjectItemInstance>());

AssertParseEvaluate(p, "!true", expander, false);
AssertParseEvaluate(p, "!(true)", expander, false);
Expand Down Expand Up @@ -509,7 +509,7 @@ private void AssertParseEvaluateThrow(Parser p, string expression, Expander<Proj
public void NegativeTests()
{
Parser p = new Parser();
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(new PropertyDictionary<ProjectPropertyInstance>(), FileSystems.Default);
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(new PropertyDictionary<ProjectPropertyInstance>());

AssertParseEvaluateThrow(p, "foo", expander);
AssertParseEvaluateThrow(p, "0", expander);
Expand Down
2 changes: 1 addition & 1 deletion src/Build/BackEnd/Components/RequestBuilder/ItemBucket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ int bucketSequenceNumber
}

_metadata = metadata;
_expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(_lookup, _lookup, new StringMetadataTable(metadata), FileSystems.Default);
_expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(_lookup, _lookup, new StringMetadataTable(metadata));

_bucketSequenceNumber = bucketSequenceNumber;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Build/BackEnd/Components/RequestBuilder/TargetEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ internal TargetEntry(BuildRequestEntry requestEntry, ITargetBuilderCallback targ
_targetSpecification = targetSpecification;
_parentTarget = parentTarget;
_buildReason = buildReason;
_expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(baseLookup, baseLookup, FileSystems.Default);
_expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(baseLookup, baseLookup);
_state = TargetEntryState.Dependencies;
_baseLookup = baseLookup;
_host = host;
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Definition/ProjectItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ string IItem.GetMetadataValueEscaped(string name)

if (metadatum != null && Expander<ProjectProperty, ProjectItem>.ExpressionMayContainExpandableExpressions(metadatum.EvaluatedValueEscaped))
{
Expander<ProjectProperty, ProjectItem> expander = new Expander<ProjectProperty, ProjectItem>(null, null, new BuiltInMetadataTable(this), FileSystems.Default);
Expander<ProjectProperty, ProjectItem> expander = new Expander<ProjectProperty, ProjectItem>(null, null, new BuiltInMetadataTable(this));

value = expander.ExpandIntoStringLeaveEscaped(metadatum.EvaluatedValueEscaped, ExpanderOptions.ExpandBuiltInMetadata, metadatum.Location);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Definition/Toolset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ private void InitializeProperties(ILoggingService loggingServices, BuildEventCon

if (_expander == null)
{
_expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(_propertyBag, FileSystems.Default);
_expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(_propertyBag);
}
}
catch (Exception e) when (ExceptionHandling.IsIoRelatedException(e))
Expand Down
4 changes: 2 additions & 2 deletions src/Build/Definition/ToolsetReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ bool accumulateProperties

IEnumerable<ToolsetPropertyDefinition> rawProperties = GetPropertyDefinitions(toolsVersion.Name);

Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(initialProperties, FileSystems.Default);
Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(initialProperties);

foreach (ToolsetPropertyDefinition property in rawProperties)
{
Expand Down Expand Up @@ -668,7 +668,7 @@ private void EvaluateAndSetProperty(ToolsetPropertyDefinition property, Property

if (accumulateProperties)
{
expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(initialProperties, FileSystems.Default);
expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(initialProperties);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/Build/Evaluation/Context/EvaluationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
using Microsoft.Build.BackEnd.SdkResolution;
using Microsoft.Build.FileSystem;
Expand Down
12 changes: 6 additions & 6 deletions src/Build/Evaluation/Expander.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,11 @@ private void FlushFirstValueIfNeeded()
/// Creates an expander passing it some properties to use.
/// Properties may be null.
/// </summary>
internal Expander(IPropertyProvider<P> properties, IFileSystem fileSystem)
internal Expander(IPropertyProvider<P> properties)
{
_properties = properties;
_usedUninitializedProperties = new UsedUninitializedProperties();
_fileSystem = fileSystem;
_fileSystem = FileSystems.Default;
}

/// <summary>
Expand All @@ -334,8 +334,8 @@ internal Expander(IPropertyProvider<P> properties, EvaluationContext evaluationC
/// Creates an expander passing it some properties and items to use.
/// Either or both may be null.
/// </summary>
internal Expander(IPropertyProvider<P> properties, IItemProvider<I> items, IFileSystem fileSystem)
: this(properties, fileSystem)
internal Expander(IPropertyProvider<P> properties, IItemProvider<I> items)
: this(properties)
{
_items = items;
}
Expand All @@ -354,8 +354,8 @@ internal Expander(IPropertyProvider<P> properties, IItemProvider<I> items, Evalu
/// Creates an expander passing it some properties, items, and/or metadata to use.
/// Any or all may be null.
/// </summary>
internal Expander(IPropertyProvider<P> properties, IItemProvider<I> items, IMetadataTable metadata, IFileSystem fileSystem)
: this(properties, items, fileSystem)
internal Expander(IPropertyProvider<P> properties, IItemProvider<I> items, IMetadataTable metadata)
: this(properties, items)
{
_metadata = metadata;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Evaluation/LazyItemEvaluator.EvaluatorData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
using Microsoft.Build.BackEnd;
using Microsoft.Build.BackEnd.SdkResolution;
using Microsoft.Build.Construction;
using Microsoft.Build.Execution;
using Microsoft.Build.Evaluation.Context;
using Microsoft.Build.Execution;

namespace Microsoft.Build.Evaluation
{
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Evaluation/LazyItemEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal partial class LazyItemEvaluator<P, I, M, D>
private readonly Expander<P, I> _outerExpander;
private readonly IEvaluatorData<P, I, M, D> _evaluatorData;
private readonly Expander<P, I> _expander;
protected readonly IItemFactory<I, I> _itemFactory;
private readonly IItemFactory<I, I> _itemFactory;
private readonly LoggingContext _loggingContext;
private readonly EvaluationProfiler _evaluationProfiler;

Expand Down
Loading

0 comments on commit 180f7a8

Please sign in to comment.