<NME> TestHelpers.cs
<BEF> using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Scripting.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using OmniSharp;
using OmniSharp.FileWatching;
using OmniSharp.MSBuild.Discovery;
using OmniSharp.Roslyn.EditorConfig;
using OmniSharp.Script;
using OmniSharp.Services;

namespace TestUtility
{
    public static class TestHelpers
    {
        public static OmniSharpWorkspace CreateCsxWorkspace(TestFile testFile)
        {
            var workspace = new OmniSharpWorkspace(new HostServicesAggregator(Enumerable.Empty<IHostServicesProvider>(), new LoggerFactory()), new LoggerFactory(), new ManualFileSystemWatcher());
            AddCsxProjectToWorkspace(workspace, testFile);
            return workspace;
        }

        public static void AddCsxProjectToWorkspace(OmniSharpWorkspace workspace, TestFile testFile)
        {
            var references = GetReferences();
            var scriptHelper = new ScriptProjectProvider(new ScriptOptions(), new OmniSharpEnvironment(), new LoggerFactory(), isDesktopClr: true, editorConfigEnabled: true);
            var project = scriptHelper.CreateProject(testFile.FileName, references.Union(new[] { MetadataReference.CreateFromFile(typeof(CommandLineScriptGlobals).GetTypeInfo().Assembly.Location) }), testFile.FileName, typeof(CommandLineScriptGlobals), Enumerable.Empty<string>());
            workspace.AddProject(project);

            var documentInfo = DocumentInfo.Create(
                id: DocumentId.CreateNewId(project.Id),
                name: testFile.FileName,
                sourceCodeKind: SourceCodeKind.Script,
                loader: TextLoader.From(TextAndVersion.Create(testFile.Content.Text, VersionStamp.Create())),
                filePath: testFile.FileName);
            workspace.AddDocument(documentInfo);
        }

        public static IEnumerable<ProjectId> AddProjectToWorkspace(OmniSharpWorkspace workspace, string filePath, string[] frameworks, TestFile[] testFiles, ImmutableArray<AnalyzerReference> analyzerRefs = default)
        {
            var versionStamp = VersionStamp.Create();
            var references = GetReferences();
            frameworks = frameworks ?? new[] { string.Empty };
            var projectsIds = new List<ProjectId>();
            var editorConfigPaths = EditorConfigFinder.GetEditorConfigPaths(filePath);

            foreach (var framework in frameworks)
            {
                var projectId = ProjectId.CreateNewId();
                var analyzerConfigDocuments = editorConfigPaths.Select(path =>
                        DocumentInfo.Create(
                            DocumentId.CreateNewId(projectId),
                            name: ".editorconfig",
                            loader: new FileTextLoader(path, Encoding.UTF8),
                            filePath: path))
                    .ToImmutableArray();

                var projectInfo = ProjectInfo.Create(
                    id: projectId,
                    version: versionStamp,
                    name: "OmniSharp+" + framework,
                    assemblyName: "AssemblyName",
                    language: LanguageNames.CSharp,
                    filePath: filePath,
                    metadataReferences: references,
                    analyzerReferences: analyzerRefs)
                    .WithDefaultNamespace("OmniSharpTest")
                    .WithAnalyzerConfigDocuments(analyzerConfigDocuments);

                workspace.AddProject(projectInfo);

                foreach (var testFile in testFiles)
                {
                    workspace.AddDocument(projectInfo.Id, testFile.FileName, TextLoader.From(TextAndVersion.Create(testFile.Content.Text, versionStamp)), SourceCodeKind.Regular);
                }

                projectsIds.Add(projectInfo.Id);
            }

            return projectsIds;
        }

        private static ImmutableArray<PortableExecutableReference> _references;

        private static IEnumerable<PortableExecutableReference> GetReferences()
        {
            if (!_references.IsDefaultOrEmpty)
            {
                return _references;
            }

            // This is a bit messy. Essentially, we need to add all assemblies that type forwarders might point to.
            var assemblies = new[]
            {
                AssemblyHelpers.FromType(typeof(object)),
                AssemblyHelpers.FromType(typeof(Enumerable)),
                AssemblyHelpers.FromType(typeof(Stack<>)),
                AssemblyHelpers.FromType(typeof(Lazy<,>)),
                AssemblyHelpers.FromName("System.Runtime"),
#if NETCOREAPP
                AssemblyHelpers.FromType(typeof(Console)),
#else
                AssemblyHelpers.FromName("mscorlib")
#endif
            };

            _references = assemblies
                .Where(a => a != null)
                .Select(a => a.Location)
                .Distinct()
                .Select(l => MetadataReference.CreateFromFile(l))
                .ToImmutableArray();

            return _references;
        }

        public static MSBuildInstance AddDotNetCoreToFakeInstance(this MSBuildInstance instance)
        {
            const string dotnetSdkResolver = "Microsoft.DotNet.MSBuildSdkResolver";

            var directory = Path.Combine(
                instance.MSBuildPath,
                "SdkResolvers",
                dotnetSdkResolver
            );

            Directory.CreateDirectory(directory);

            TestIO.TouchFakeFile(Path.Combine(directory, dotnetSdkResolver + ".dll"));

            return instance;
        }

        public static IConfiguration GetConfigurationDataWithAnalyzerConfig(
            bool roslynAnalyzersEnabled = false,
            bool analyzeOpenDocumentsOnly = false,
            bool editorConfigEnabled = false,
            Dictionary<string, string> existingConfiguration = null)
        {
            if (existingConfiguration == null)
            {
                return new Dictionary<string, string>()
                {
                    { "RoslynExtensionsOptions:EnableAnalyzersSupport", roslynAnalyzersEnabled.ToString() },
                    { "RoslynExtensionsOptions:AnalyzeOpenDocumentsOnly", analyzeOpenDocumentsOnly.ToString() },
                    { "FormattingOptions:EnableEditorConfigSupport", editorConfigEnabled.ToString() }
                }.ToConfiguration();
            }

            var copyOfExistingConfigs = existingConfiguration.ToDictionary(x => x.Key, x => x.Value);
            copyOfExistingConfigs.Add("RoslynExtensionsOptions:EnableAnalyzersSupport", roslynAnalyzersEnabled.ToString());
            copyOfExistingConfigs.Add("RoslynExtensionsOptions:AnalyzeOpenDocumentsOnly", analyzeOpenDocumentsOnly.ToString());
            copyOfExistingConfigs.Add("FormattingOptions:EnableEditorConfigSupport", editorConfigEnabled.ToString());

            return copyOfExistingConfigs.ToConfiguration();
        }

        public static async Task WaitUntil(Func<Task<bool>> condition, int frequency = 25, int timeout = -1)
        {
            var waitTask = Task.Run(async () =>
            {
                while (!await condition()) await Task.Delay(frequency);
            });

            if (waitTask != await Task.WhenAny(waitTask,
                    Task.Delay(timeout)))
                throw new TimeoutException();
        }

        public static void SetDefaultCulture()
        {
            CultureInfo ci = new CultureInfo("en-US");
            CultureInfo.DefaultThreadCurrentCulture = ci;
            CultureInfo.DefaultThreadCurrentUICulture = ci;
        }
    }
}

<MSG> Update MappedLocation to better simulate Razor scenario

<DFF> @@ -46,8 +46,10 @@ public static void AddCsxProjectToWorkspace(OmniSharpWorkspace workspace, TestFi
             workspace.AddDocument(documentInfo);
         }
 
-        public static IEnumerable<ProjectId> AddProjectToWorkspace(OmniSharpWorkspace workspace, string filePath, string[] frameworks, TestFile[] testFiles, ImmutableArray<AnalyzerReference> analyzerRefs = default)
+        public static IEnumerable<ProjectId> AddProjectToWorkspace(OmniSharpWorkspace workspace, string filePath, string[] frameworks, TestFile[] testFiles, TestFile[] otherFiles = null, ImmutableArray<AnalyzerReference> analyzerRefs = default)
         {
+            otherFiles ??= Array.Empty<TestFile>();
+
             var versionStamp = VersionStamp.Create();
             var references = GetReferences();
             frameworks = frameworks ?? new[] { string.Empty };
@@ -84,6 +86,11 @@ public static IEnumerable<ProjectId> AddProjectToWorkspace(OmniSharpWorkspace wo
                     workspace.AddDocument(projectInfo.Id, testFile.FileName, TextLoader.From(TextAndVersion.Create(testFile.Content.Text, versionStamp)), SourceCodeKind.Regular);
                 }
 
+                foreach (var otherFile in otherFiles)
+                {
+                    workspace.AddAdditionalDocument(projectInfo.Id, otherFile.FileName, TextLoader.From(TextAndVersion.Create(otherFile.Content.Text, versionStamp)));
+                }
+
                 projectsIds.Add(projectInfo.Id);
             }
 

{'commit': 'diff --git a/src/OmniSharp.Roslyn/OmniSharpWorkspace.cs b/src/OmniSharp.Roslyn/OmniSharpWorkspace.cs\nindex 3be8382d..eb6f9417 100644\n--- a/src/OmniSharp.Roslyn/OmniSharpWorkspace.cs\n+++ b/src/OmniSharp.Roslyn/OmniSharpWorkspace.cs\n@@ -543,8 +543,13 @@ public void SetAnalyzerReferences(ProjectId id, ImmutableArray<AnalyzerFileRefer\n \n         public void AddAdditionalDocument(ProjectId projectId, string filePath)\n         {\n-            var documentId = DocumentId.CreateNewId(projectId);\n             var loader = new OmniSharpTextLoader(filePath);\n+            AddAdditionalDocument(projectId, filePath, loader);\n+        }\n+\n+        public void AddAdditionalDocument(ProjectId projectId, string filePath, TextLoader loader)\n+        {\n+            var documentId = DocumentId.CreateNewId(projectId);\n             var documentInfo = DocumentInfo.Create(documentId, Path.GetFileName(filePath), filePath: filePath, loader: loader);\n             OnAdditionalDocumentAdded(documentInfo);\n         }\ndiff --git a/tests/OmniSharp.Roslyn.CSharp.Tests/FindReferencesFacts.cs b/tests/OmniSharp.Roslyn.CSharp.Tests/FindReferencesFacts.cs\nindex 22087b4d..26fd6d97 100644\n--- a/tests/OmniSharp.Roslyn.CSharp.Tests/FindReferencesFacts.cs\n+++ b/tests/OmniSharp.Roslyn.CSharp.Tests/FindReferencesFacts.cs\n@@ -421,29 +421,46 @@ public class F$$oo {\n         [Fact]\n         public async Task MappedLocationFileNameProperlyRooted()\n         {\n-            var relativeFile = ".\\\\pages\\\\test.xaml";\n+            var folderPath = Directory.GetCurrentDirectory();\n+            var relativeFile = ".\\\\Index.cshtml";\n+            var mappedFilePath = Path.GetFullPath(Path.Combine(folderPath, relativeFile));\n \n             var testFiles = new[]\n             {\n-                new TestFile("a.cs",\n-                 @"public class Bar : F$$oo {}"),\n-                new TestFile("b.cs", $@"\n-                    #line 23 ""{relativeFile}""\n-                    public class Foo {{ }}\n+                new TestFile("Constants.cs", @"\n+                    public static class Constants\n+                    {\n+                        public const string My$$Text = ""Hello World"";\n+                    }"),\n+                new TestFile("Index.cshtml.cs", @"\n+                    using Microsoft.AspNetCore.Mvc.RazorPages;\n+\n+                    public class IndexModel : PageModel\n+                    {\n+                        public IndexModel()\n+                        {\n+                        }\n+\n+                        public void OnGet()\n+                        {\n+\n+                        }\n+                    }"),\n+                new TestFile("Index.cshtml_virtual.cs", $@"\n+                    #line 1 ""{relativeFile}""\n+                    Constants.MyText\n                     #line default\n-                    #line hidden")\n+                    #line hidden"),\n+                new TestFile(mappedFilePath, "<p>@Constants.MyText</p>")\n             };\n \n-            var usages = await FindUsagesAsync(testFiles, onlyThisFile: false);\n+            var usages = await FindUsagesAsync(testFiles, onlyThisFile: false, folderPath: folderPath);\n \n-            Assert.DoesNotContain(usages.QuickFixes, location => location.FileName.EndsWith("b.cs"));\n+            Assert.DoesNotContain(usages.QuickFixes, location => location.FileName.EndsWith("Index.cshtml_virtual.cs"));\n             Assert.DoesNotContain(usages.QuickFixes, location => location.FileName.Equals(relativeFile));\n \n-            var project = SharedOmniSharpTestHost.Workspace.CurrentSolution.Projects.Single();\n-            var projectFolder = Path.GetDirectoryName(project.FilePath);\n-            var mappedFilePath = Path.GetFullPath(Path.Combine(projectFolder, relativeFile));\n-\n-            Assert.Single(usages.QuickFixes, location => location.FileName.Equals(mappedFilePath));\n+            var quickFix = Assert.Single(usages.QuickFixes, location => location.FileName.Equals(mappedFilePath));\n+            Assert.Empty(quickFix.Projects);\n         }\n \n         [Fact]\n@@ -493,9 +510,9 @@ private Task<QuickFixResponse> FindUsagesAsync(string code, bool excludeDefiniti\n             return FindUsagesAsync(new[] { new TestFile("dummy.cs", code) }, false, excludeDefinition);\n         }\n \n-        private async Task<QuickFixResponse> FindUsagesAsync(TestFile[] testFiles, bool onlyThisFile, bool excludeDefinition = false)\n+        private async Task<QuickFixResponse> FindUsagesAsync(TestFile[] testFiles, bool onlyThisFile, bool excludeDefinition = false, string folderPath = null)\n         {\n-            SharedOmniSharpTestHost.AddFilesToWorkspace(testFiles);\n+            SharedOmniSharpTestHost.AddFilesToWorkspace(folderPath, testFiles);\n             var file = testFiles.Single(tf => tf.Content.HasPosition);\n             var point = file.Content.GetPointFromPosition();\n \ndiff --git a/tests/OmniSharp.Roslyn.CSharp.Tests/SourceGeneratorFacts.cs b/tests/OmniSharp.Roslyn.CSharp.Tests/SourceGeneratorFacts.cs\nindex 8ef4fd42..e4cb5b1e 100644\n--- a/tests/OmniSharp.Roslyn.CSharp.Tests/SourceGeneratorFacts.cs\n+++ b/tests/OmniSharp.Roslyn.CSharp.Tests/SourceGeneratorFacts.cs\n@@ -47,6 +47,7 @@ class GeneratedCode\n                 "project.csproj",\n                 new[] { "netcoreapp3.1" },\n                 new[] { testFile },\n+                otherFiles: null,\n                 ImmutableArray.Create<AnalyzerReference>(reference));\n \n             var point = testFile.Content.GetPointFromPosition();\ndiff --git a/tests/TestUtility/OmniSharpTestHost.cs b/tests/TestUtility/OmniSharpTestHost.cs\nindex 2a739749..7733452f 100644\n--- a/tests/TestUtility/OmniSharpTestHost.cs\n+++ b/tests/TestUtility/OmniSharpTestHost.cs\n@@ -144,7 +144,8 @@ public IEnumerable<ProjectId> AddFilesToWorkspace(string folderPath, params Test\n                 Workspace,\n                 Path.Combine(folderPath, "project.csproj"),\n                 new[] { "net472" },\n-                testFiles.Where(f => f.FileName.EndsWith(".cs", StringComparison.OrdinalIgnoreCase)).ToArray());\n+                testFiles.Where(f => f.FileName.EndsWith(".cs", StringComparison.OrdinalIgnoreCase)).ToArray(),\n+                testFiles.Where(f => !f.FileName.EndsWith(".cs", StringComparison.OrdinalIgnoreCase) && !f.FileName.EndsWith(".csx", StringComparison.OrdinalIgnoreCase)).ToArray());\n \n             foreach (var csxFile in testFiles.Where(f => f.FileName.EndsWith(".csx", StringComparison.OrdinalIgnoreCase)))\n             {\ndiff --git a/tests/TestUtility/TestHelpers.cs b/tests/TestUtility/TestHelpers.cs\nindex 93d0f7a2..fd47b141 100644\n--- a/tests/TestUtility/TestHelpers.cs\n+++ b/tests/TestUtility/TestHelpers.cs\n@@ -46,8 +46,10 @@ public static void AddCsxProjectToWorkspace(OmniSharpWorkspace workspace, TestFi\n             workspace.AddDocument(documentInfo);\n         }\n \n-        public static IEnumerable<ProjectId> AddProjectToWorkspace(OmniSharpWorkspace workspace, string filePath, string[] frameworks, TestFile[] testFiles, ImmutableArray<AnalyzerReference> analyzerRefs = default)\n+        public static IEnumerable<ProjectId> AddProjectToWorkspace(OmniSharpWorkspace workspace, string filePath, string[] frameworks, TestFile[] testFiles, TestFile[] otherFiles = null, ImmutableArray<AnalyzerReference> analyzerRefs = default)\n         {\n+            otherFiles ??= Array.Empty<TestFile>();\n+\n             var versionStamp = VersionStamp.Create();\n             var references = GetReferences();\n             frameworks = frameworks ?? new[] { string.Empty };\n@@ -84,6 +86,11 @@ public static IEnumerable<ProjectId> AddProjectToWorkspace(OmniSharpWorkspace wo\n                     workspace.AddDocument(projectInfo.Id, testFile.FileName, TextLoader.From(TextAndVersion.Create(testFile.Content.Text, versionStamp)), SourceCodeKind.Regular);\n                 }\n \n+                foreach (var otherFile in otherFiles)\n+                {\n+                    workspace.AddAdditionalDocument(projectInfo.Id, otherFile.FileName, TextLoader.From(TextAndVersion.Create(otherFile.Content.Text, versionStamp)));\n+                }\n+\n                 projectsIds.Add(projectInfo.Id);\n             }\n \n', 'commit_subject': 'Update MappedLocation to better simulate Razor scenario', 'repo_name': 'OmniSharp/omnisharp-roslyn', 'committer': {'name': 'Joey Robichaud', 'email': '681506cb781ec8e7123da10968e977916bbcfe04@microsoft.com', 'time_sec': '1631225920', 'tz_offset': '-420', 'date': {'seconds': '1631225920'}}, 'commit_tree': '3ffb040da32ac6846403fd6d927ae7b0b6523984', 'commit_message': 'Update MappedLocation to better simulate Razor scenario\n', 'language_name': 'C#', 'license': 'mit', 'hunks': '@@ -46,8 +46,10 @@ public static void AddCsxProjectToWorkspace(OmniSharpWorkspace workspace, TestFi\n             workspace.AddDocument(documentInfo);\n         }\n \n-        public static IEnumerable<ProjectId> AddProjectToWorkspace(OmniSharpWorkspace workspace, string filePath, string[] frameworks, TestFile[] testFiles, ImmutableArray<AnalyzerReference> analyzerRefs = default)\n+        public static IEnumerable<ProjectId> AddProjectToWorkspace(OmniSharpWorkspace workspace, string filePath, string[] frameworks, TestFile[] testFiles, TestFile[] otherFiles = null, ImmutableArray<AnalyzerReference> analyzerRefs = default)\n         {\n+            otherFiles ??= Array.Empty<TestFile>();\n+\n             var versionStamp = VersionStamp.Create();\n             var references = GetReferences();\n             frameworks = frameworks ?? new[] { string.Empty };\n@@ -84,6 +86,11 @@ public static IEnumerable<ProjectId> AddProjectToWorkspace(OmniSharpWorkspace wo\n                     workspace.AddDocument(projectInfo.Id, testFile.FileName, TextLoader.From(TextAndVersion.Create(testFile.Content.Text, versionStamp)), SourceCodeKind.Regular);\n                 }\n \n+                foreach (var otherFile in otherFiles)\n+                {\n+                    workspace.AddAdditionalDocument(projectInfo.Id, otherFile.FileName, TextLoader.From(TextAndVersion.Create(otherFile.Content.Text, versionStamp)));\n+                }\n+\n                 projectsIds.Add(projectInfo.Id);\n             }\n \n', 'addition_count': 8, 'deletion_count': 1, 'src_file': 'a/tests/TestUtility/TestHelpers.cs', 'tgt_file': 'b/tests/TestUtility/TestHelpers.cs', 'file_extension': '.cs', 'before_file': 'using System;\nusing System.Collections.Generic;\nusing System.Collections.Immutable;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Reflection;\nusing System.Text;\nusing System.Threading.Tasks;\nusing Microsoft.CodeAnalysis;\nusing Microsoft.CodeAnalysis.Diagnostics;\nusing Microsoft.CodeAnalysis.Scripting.Hosting;\nusing Microsoft.Extensions.Configuration;\nusing Microsoft.Extensions.Logging;\nusing OmniSharp;\nusing OmniSharp.FileWatching;\nusing OmniSharp.MSBuild.Discovery;\nusing OmniSharp.Roslyn.EditorConfig;\nusing OmniSharp.Script;\nusing OmniSharp.Services;\n\nnamespace TestUtility\n{\n    public static class TestHelpers\n    {\n        public static OmniSharpWorkspace CreateCsxWorkspace(TestFile testFile)\n        {\n            var workspace = new OmniSharpWorkspace(new HostServicesAggregator(Enumerable.Empty<IHostServicesProvider>(), new LoggerFactory()), new LoggerFactory(), new ManualFileSystemWatcher());\n            AddCsxProjectToWorkspace(workspace, testFile);\n            return workspace;\n        }\n\n        public static void AddCsxProjectToWorkspace(OmniSharpWorkspace workspace, TestFile testFile)\n        {\n            var references = GetReferences();\n            var scriptHelper = new ScriptProjectProvider(new ScriptOptions(), new OmniSharpEnvironment(), new LoggerFactory(), isDesktopClr: true, editorConfigEnabled: true);\n            var project = scriptHelper.CreateProject(testFile.FileName, references.Union(new[] { MetadataReference.CreateFromFile(typeof(CommandLineScriptGlobals).GetTypeInfo().Assembly.Location) }), testFile.FileName, typeof(CommandLineScriptGlobals), Enumerable.Empty<string>());\n            workspace.AddProject(project);\n\n            var documentInfo = DocumentInfo.Create(\n                id: DocumentId.CreateNewId(project.Id),\n                name: testFile.FileName,\n                sourceCodeKind: SourceCodeKind.Script,\n                loader: TextLoader.From(TextAndVersion.Create(testFile.Content.Text, VersionStamp.Create())),\n                filePath: testFile.FileName);\n            workspace.AddDocument(documentInfo);\n        }\n\n        public static IEnumerable<ProjectId> AddProjectToWorkspace(OmniSharpWorkspace workspace, string filePath, string[] frameworks, TestFile[] testFiles, ImmutableArray<AnalyzerReference> analyzerRefs = default)\n        {\n            var versionStamp = VersionStamp.Create();\n            var references = GetReferences();\n            frameworks = frameworks ?? new[] { string.Empty };\n            var projectsIds = new List<ProjectId>();\n            var editorConfigPaths = EditorConfigFinder.GetEditorConfigPaths(filePath);\n\n            foreach (var framework in frameworks)\n            {\n                var projectId = ProjectId.CreateNewId();\n                var analyzerConfigDocuments = editorConfigPaths.Select(path =>\n                        DocumentInfo.Create(\n                            DocumentId.CreateNewId(projectId),\n                            name: ".editorconfig",\n                            loader: new FileTextLoader(path, Encoding.UTF8),\n                            filePath: path))\n                    .ToImmutableArray();\n\n                var projectInfo = ProjectInfo.Create(\n                    id: projectId,\n                    version: versionStamp,\n                    name: "OmniSharp+" + framework,\n                    assemblyName: "AssemblyName",\n                    language: LanguageNames.CSharp,\n                    filePath: filePath,\n                    metadataReferences: references,\n                    analyzerReferences: analyzerRefs)\n                    .WithDefaultNamespace("OmniSharpTest")\n                    .WithAnalyzerConfigDocuments(analyzerConfigDocuments);\n\n                workspace.AddProject(projectInfo);\n\n                foreach (var testFile in testFiles)\n                {\n                    workspace.AddDocument(projectInfo.Id, testFile.FileName, TextLoader.From(TextAndVersion.Create(testFile.Content.Text, versionStamp)), SourceCodeKind.Regular);\n                }\n\n                projectsIds.Add(projectInfo.Id);\n            }\n\n            return projectsIds;\n        }\n\n        private static ImmutableArray<PortableExecutableReference> _references;\n\n        private static IEnumerable<PortableExecutableReference> GetReferences()\n        {\n            if (!_references.IsDefaultOrEmpty)\n            {\n                return _references;\n            }\n\n            // This is a bit messy. Essentially, we need to add all assemblies that type forwarders might point to.\n            var assemblies = new[]\n            {\n                AssemblyHelpers.FromType(typeof(object)),\n                AssemblyHelpers.FromType(typeof(Enumerable)),\n                AssemblyHelpers.FromType(typeof(Stack<>)),\n                AssemblyHelpers.FromType(typeof(Lazy<,>)),\n                AssemblyHelpers.FromName("System.Runtime"),\n#if NETCOREAPP\n                AssemblyHelpers.FromType(typeof(Console)),\n#else\n                AssemblyHelpers.FromName("mscorlib")\n#endif\n            };\n\n            _references = assemblies\n                .Where(a => a != null)\n                .Select(a => a.Location)\n                .Distinct()\n                .Select(l => MetadataReference.CreateFromFile(l))\n                .ToImmutableArray();\n\n            return _references;\n        }\n\n        public static MSBuildInstance AddDotNetCoreToFakeInstance(this MSBuildInstance instance)\n        {\n            const string dotnetSdkResolver = "Microsoft.DotNet.MSBuildSdkResolver";\n\n            var directory = Path.Combine(\n                instance.MSBuildPath,\n                "SdkResolvers",\n                dotnetSdkResolver\n            );\n\n            Directory.CreateDirectory(directory);\n\n            TestIO.TouchFakeFile(Path.Combine(directory, dotnetSdkResolver + ".dll"));\n\n            return instance;\n        }\n\n        public static IConfiguration GetConfigurationDataWithAnalyzerConfig(\n            bool roslynAnalyzersEnabled = false,\n            bool analyzeOpenDocumentsOnly = false,\n            bool editorConfigEnabled = false,\n            Dictionary<string, string> existingConfiguration = null)\n        {\n            if (existingConfiguration == null)\n            {\n                return new Dictionary<string, string>()\n                {\n                    { "RoslynExtensionsOptions:EnableAnalyzersSupport", roslynAnalyzersEnabled.ToString() },\n                    { "RoslynExtensionsOptions:AnalyzeOpenDocumentsOnly", analyzeOpenDocumentsOnly.ToString() },\n                    { "FormattingOptions:EnableEditorConfigSupport", editorConfigEnabled.ToString() }\n                }.ToConfiguration();\n            }\n\n            var copyOfExistingConfigs = existingConfiguration.ToDictionary(x => x.Key, x => x.Value);\n            copyOfExistingConfigs.Add("RoslynExtensionsOptions:EnableAnalyzersSupport", roslynAnalyzersEnabled.ToString());\n            copyOfExistingConfigs.Add("RoslynExtensionsOptions:AnalyzeOpenDocumentsOnly", analyzeOpenDocumentsOnly.ToString());\n            copyOfExistingConfigs.Add("FormattingOptions:EnableEditorConfigSupport", editorConfigEnabled.ToString());\n\n            return copyOfExistingConfigs.ToConfiguration();\n        }\n\n        public static async Task WaitUntil(Func<Task<bool>> condition, int frequency = 25, int timeout = -1)\n        {\n            var waitTask = Task.Run(async () =>\n            {\n                while (!await condition()) await Task.Delay(frequency);\n            });\n\n            if (waitTask != await Task.WhenAny(waitTask,\n                    Task.Delay(timeout)))\n                throw new TimeoutException();\n        }\n\n        public static void SetDefaultCulture()\n        {\n            CultureInfo ci = new CultureInfo("en-US");\n            CultureInfo.DefaultThreadCurrentCulture = ci;\n            CultureInfo.DefaultThreadCurrentUICulture = ci;\n        }\n    }\n}\n', 'message': 'Update MappedLocation to better simulate Razor scenario\n', 'author_name': 'Joey Robichaud', 'lang': 'cs'}