Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the priority order of lazyloading #9744

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Build.UnitTests/Evaluation/ItemEvaluation_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,9 @@ public void LazyWildcardExpansionDoesNotEvaluateWildCardsIfNotReferenced()
<Project>
<Import Project=`foo/*.props`/>
<ItemGroup>
<i Include=`**/foo/**/*.cs`/>
<i2 Include=`**/bar/**/*.cs`/>
<i Include=`**/foo/**/*.cs` />
<i2 Include=`**/bar/**/*.cs` />
<i3 Include=`**/yyy/**/*.cs` Exclude=`mock-value` />
</ItemGroup>

<ItemGroup>
Expand All @@ -584,18 +585,19 @@ public void LazyWildcardExpansionDoesNotEvaluateWildCardsIfNotReferenced()
".Cleanup();
using (var env = TestEnvironment.Create())
{
var projectFiles = env.CreateTestProjectWithFiles(content, new[] { "foo/extra.props", "foo/a.cs", "foo/b.cs", "bar/c.cs", "bar/d.cs" });
var projectFiles = env.CreateTestProjectWithFiles(content, new[] { "foo/extra.props", "foo/a.cs", "foo/b.cs", "bar/c.cs", "bar/d.cs", "yyy/d.cs" });

File.WriteAllText(projectFiles.CreatedFiles[0], import);

env.SetEnvironmentVariable("MsBuildSkipEagerWildCardEvaluationRegexes", ".*foo.*");
env.SetEnvironmentVariable("MsBuildSkipEagerWildCardEvaluationRegexes", ".*foo.*;.*yyy*.");

EngineFileUtilities.CaptureLazyWildcardRegexes();

var project = new Project(projectFiles.ProjectFile);

Assert.Equal("true", project.GetPropertyValue("FromImport"));
Assert.Equal("**/foo/**/*.cs", project.GetConcatenatedItemsOfType("i"));
Assert.Equal("**/yyy/**/*.cs", project.GetConcatenatedItemsOfType("i3"));

var expectedItems = "bar\\c.cs;bar\\d.cs";

Expand Down
12 changes: 8 additions & 4 deletions src/Build/Utilities/EngineFileUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,14 @@ private static string[] GetFileList(
FileMatcher.SearchAction action = FileMatcher.SearchAction.None;
string excludeFileSpec = string.Empty;

var noWildcards = !FilespecHasWildcards(filespecEscaped) || FilespecMatchesLazyWildcard(filespecEscaped, forceEvaluateWildCards);

// It is possible to return original string if no wildcard matches and no entries in Exclude set.
if (noWildcards && excludeSpecsEscaped?.Any() != true)
var filespecHasNoWildCards = !FilespecHasWildcards(filespecEscaped);
var filespecMatchesLazyWildcard = FilespecMatchesLazyWildcard(filespecEscaped, forceEvaluateWildCards);
var excludeSpecsAreEmpty = excludeSpecsEscaped?.Any() != true;

// Return original value if:
// FileSpec matches lazyloading regex or
// file has no wildcard and excludeSpecs are empty
if ( filespecMatchesLazyWildcard || (filespecHasNoWildCards && excludeSpecsAreEmpty) )
{
// Just return the original string.
fileList = new string[] { returnEscaped ? filespecEscaped : EscapingUtilities.UnescapeAll(filespecEscaped) };
Expand Down