Skip to content

Commit

Permalink
Remove extra lock in ProjectRootElementCache.Get for unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
AR-May committed Jul 20, 2021
1 parent cb1f138 commit a6db102
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/Build/Evaluation/ProjectRootElementCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,26 +157,23 @@ private bool IsInvalidEntry(string projectFile, ProjectRootElement projectRootEl
}
else if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("MSBUILDCACHECHECKFILECONTENT")))
{
lock (_locker)
// QA tests run too fast for the timestamp check to work. This environment variable is for their
// use: it checks the file content as well as the timestamp. That's better than completely disabling
// the cache as we get test coverage of the rest of the cache code.
XmlDocument document = new XmlDocument();
document.PreserveWhitespace = projectRootElement.XmlDocument.PreserveWhitespace;

using (var xtr = XmlReaderExtension.Create(projectRootElement.FullPath, projectRootElement.ProjectRootElementCache.LoadProjectsReadOnly))
{
document.Load(xtr.Reader);
}

string diskContent = document.OuterXml;
string cacheContent = projectRootElement.XmlDocument.OuterXml;

if (diskContent != cacheContent)
{
// QA tests run too fast for the timestamp check to work. This environment variable is for their
// use: it checks the file content as well as the timestamp. That's better than completely disabling
// the cache as we get test coverage of the rest of the cache code.
XmlDocument document = new XmlDocument();
document.PreserveWhitespace = projectRootElement.XmlDocument.PreserveWhitespace;

using (var xtr = XmlReaderExtension.Create(projectRootElement.FullPath, projectRootElement.ProjectRootElementCache.LoadProjectsReadOnly))
{
document.Load(xtr.Reader);
}

string diskContent = document.OuterXml;
string cacheContent = projectRootElement.XmlDocument.OuterXml;

if (diskContent != cacheContent)
{
return true;
}
return true;
}
}
}
Expand Down

0 comments on commit a6db102

Please sign in to comment.