<NME> ProjectFileInfo.cs
<BEF> ﻿using System;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Runtime.Versioning;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Globbing;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.Extensions.Logging;
using NuGet.Packaging.Core;
using OmniSharp.Options;
using OmniSharp.Utilities;

{
    internal partial class ProjectFileInfo
    {
        private readonly ProjectData _data;

        public string FilePath { get; }
        public string Directory { get; }

        public ProjectId Id { get => ProjectIdInfo.Id; }

        public Guid Guid => _data.Guid;
        public string Name => _data.Name;

        public string AssemblyName => _data.AssemblyName;
        public string TargetPath => _data.TargetPath;
        public string OutputPath => _data.OutputPath;
        public string IntermediateOutputPath => _data.IntermediateOutputPath;
        public string ProjectAssetsFile => _data.ProjectAssetsFile;

        public string Configuration => _data.Configuration;
        public string Platform => _data.Platform;
        public string PlatformTarget => _data.PlatformTarget;
        public FrameworkName TargetFramework => _data.TargetFramework;
        public ImmutableArray<string> TargetFrameworks => _data.TargetFrameworks;

        public OutputKind OutputKind => _data.OutputKind;
        public LanguageVersion LanguageVersion => _data.LanguageVersion;
        public NullableContextOptions NullableContextOptions => _data.NullableContextOptions;
        public bool AllowUnsafeCode => _data.AllowUnsafeCode;
        public bool CheckForOverflowUnderflow => _data.CheckForOverflowUnderflow;
        public string DocumentationFile => _data.DocumentationFile;
        public ImmutableArray<string> PreprocessorSymbolNames => _data.PreprocessorSymbolNames;
        public ImmutableArray<string> SuppressedDiagnosticIds => _data.SuppressedDiagnosticIds;
        public ImmutableArray<string> WarningsAsErrors => _data.WarningsAsErrors;
        public ImmutableArray<string> WarningsNotAsErrors => _data.WarningsNotAsErrors;

        public bool SignAssembly => _data.SignAssembly;
        public string AssemblyOriginatorKeyFile => _data.AssemblyOriginatorKeyFile;
        public RuleSet RuleSet => _data.RuleSet;

        public ImmutableArray<string> SourceFiles => _data.SourceFiles;
        public ImmutableArray<string> References => _data.References;
        public ImmutableArray<string> ProjectReferences => _data.ProjectReferences;
        public ImmutableArray<PackageReference> PackageReferences => _data.PackageReferences;
        public ImmutableArray<string> Analyzers => _data.Analyzers;
        public ImmutableArray<string> AdditionalFiles => _data.AdditionalFiles;
        public ImmutableArray<string> AnalyzerConfigFiles => _data.AnalyzerConfigFiles;
        public ImmutableDictionary<string, string> ReferenceAliases => _data.ReferenceAliases;
        public ImmutableDictionary<string, string> ProjectReferenceAliases => _data.ProjectReferenceAliases;
        public bool TreatWarningsAsErrors => _data.TreatWarningsAsErrors;
        public bool RunAnalyzers => _data.RunAnalyzers;
        public bool RunAnalyzersDuringLiveAnalysis => _data.RunAnalyzersDuringLiveAnalysis;
        public string DefaultNamespace => _data.DefaultNamespace;
        public ImmutableArray<IMSBuildGlob> FileInclusionGlobPatterns => _data.FileInclusionGlobs;

        public ProjectIdInfo ProjectIdInfo { get; }
        public DotNetInfo DotNetInfo { get; }
        public Guid SessionId { get; }

        private ProjectFileInfo(
            ProjectIdInfo projectIdInfo,
            string filePath,
            ProjectData data,
            Guid sessionId,
            DotNetInfo dotNetInfo)
        {
            this.ProjectIdInfo = projectIdInfo;
            this.FilePath = filePath;
            this.Directory = Path.GetDirectoryName(filePath);
            this.SessionId = sessionId;
            this.DotNetInfo = dotNetInfo;

            _data = data;
        }

        internal static ProjectFileInfo CreateEmpty(string filePath)
        {
            var id = ProjectId.CreateNewId(debugName: filePath);

            return new ProjectFileInfo(new ProjectIdInfo(id, isDefinedInSolution: false), filePath, data: null, sessionId: Guid.NewGuid(), DotNetInfo.Empty);
        }

        internal static ProjectFileInfo CreateNoBuild(string filePath, ProjectLoader loader, DotNetInfo dotNetInfo)
        {
            var id = ProjectId.CreateNewId(debugName: filePath);
            var project = loader.EvaluateProjectFile(filePath);

            var data = ProjectData.Create(project);
            //we are not reading the solution here
            var projectIdInfo = new ProjectIdInfo(id, isDefinedInSolution: false);

            return new ProjectFileInfo(projectIdInfo, filePath, data, sessionId: Guid.NewGuid(), dotNetInfo);
        }

        public static (ProjectFileInfo, ImmutableArray<MSBuildDiagnostic>, ProjectLoadedEventArgs) Load(string filePath, ProjectIdInfo projectIdInfo, ProjectLoader loader, Guid sessionId, DotNetInfo dotNetInfo)
        {
            if (!File.Exists(filePath))
            {
            string solutionDirectory,
            ILogger logger,
            MSBuildOptions options = null,
            ICollection<Models.MSBuildDiagnosticsMessage> diagnostics = null)
        {
            if (!File.Exists(projectFilePath))
            {
            }

            var data = ProjectData.Create(filePath, projectInstance, project);
            var projectFileInfo = new ProjectFileInfo(projectIdInfo, filePath, data, sessionId, dotNetInfo);
            var eventArgs = new ProjectLoadedEventArgs(projectIdInfo.Id,
                                                       project,
                                                       sessionId,
                                                       projectInstance,
                                                       diagnostics,
                                                       isReload: false,
                                                       projectIdInfo.IsDefinedInSolution,
                                                       projectFileInfo.SourceFiles,
                                                       dotNetInfo.Version,
                                                       data.References);

            return (projectFileInfo, diagnostics, eventArgs);
        }

        public (ProjectFileInfo, ImmutableArray<MSBuildDiagnostic>, ProjectLoadedEventArgs) Reload(ProjectLoader loader)
        {
            var (projectInstance, project, diagnostics) = loader.BuildProject(FilePath, ProjectIdInfo?.SolutionConfiguration);
            if (projectInstance == null)
            {
                return (null, diagnostics, null);
            }

            var data = ProjectData.Create(FilePath, projectInstance, project);
            var projectFileInfo = new ProjectFileInfo(ProjectIdInfo, FilePath, data, SessionId, DotNetInfo);
            var eventArgs = new ProjectLoadedEventArgs(Id,
                                                       project,
                                                       SessionId,
                                                       projectInstance,
                                                       diagnostics,
                                                       isReload: true,
                                                       ProjectIdInfo.IsDefinedInSolution,
                                                       data.SourceFiles,
                                                       DotNetInfo.Version,
                                                       data.References);

            return (projectFileInfo, diagnostics, eventArgs);
        }

        public bool IsUnityProject()
            => References.Any(filePath =>
                {
                    var fileName = Path.GetFileName(filePath);

                    return string.Equals(fileName, "UnityEngine.dll", StringComparison.OrdinalIgnoreCase)
                        || string.Equals(fileName, "UnityEditor.dll", StringComparison.OrdinalIgnoreCase);
                });


        public bool IsFileIncluded(string filePath)
        {
            if (SourceFiles.Contains(filePath, StringComparer.OrdinalIgnoreCase))
                return true;

            var relativePath = FileSystemHelper.GetRelativePath(filePath, FilePath);
            return FileInclusionGlobPatterns.Any(glob => glob.IsMatch(relativePath));
        }
    }
}

<MSG> Clean up MSBuild models and events

<DFF> @@ -9,6 +9,7 @@
 using Microsoft.CodeAnalysis.CSharp;
 using Microsoft.Extensions.Logging;
 using NuGet.Packaging.Core;
+using OmniSharp.MSBuild.Models.Events;
 using OmniSharp.Options;
 using OmniSharp.Utilities;
 
@@ -113,7 +114,7 @@ public void SetProjectId(ProjectId projectId)
             string solutionDirectory,
             ILogger logger,
             MSBuildOptions options = null,
-            ICollection<Models.MSBuildDiagnosticsMessage> diagnostics = null)
+            ICollection<MSBuildDiagnosticsMessage> diagnostics = null)
         {
             if (!File.Exists(projectFilePath))
             {

{'commit': 'diff --git a/src/OmniSharp.Abstractions/Eventing/IEventEmitterExtensions.cs b/src/OmniSharp.Abstractions/Eventing/IEventEmitterExtensions.cs\nindex 6caa7219..eb936afd 100644\n--- a/src/OmniSharp.Abstractions/Eventing/IEventEmitterExtensions.cs\n+++ b/src/OmniSharp.Abstractions/Eventing/IEventEmitterExtensions.cs\n@@ -1,9 +1,17 @@\n-\ufeffusing OmniSharp.Models.Events;\n+\ufeffusing System;\n+using OmniSharp.Models.Events;\n \n namespace OmniSharp.Eventing\n {\n     public static class IEventEmitterExtensions\n     {\n+        public static void Error(this IEventEmitter emitter, Exception ex, string fileName = null)\n+        {\n+            emitter.Emit(\n+                EventTypes.Error,\n+                new ErrorMessage { FileName = fileName, Text = ex.ToString() });\n+        }\n+\n         public static void RestoreStarted(this IEventEmitter emitter, string projectPath)\n         {\n             emitter.Emit(\ndiff --git a/src/OmniSharp.Abstractions/Models/Events/EventTypes.cs b/src/OmniSharp.Abstractions/Models/Events/EventTypes.cs\nindex d189e888..16d92b29 100644\n--- a/src/OmniSharp.Abstractions/Models/Events/EventTypes.cs\n+++ b/src/OmniSharp.Abstractions/Models/Events/EventTypes.cs\n@@ -7,7 +7,6 @@ public static class EventTypes\n         public static readonly string ProjectRemoved = nameof(ProjectRemoved);\n         public static readonly string Error = nameof(Error);\n         public static readonly string Diagnostic = nameof(Diagnostic);\n-        public static readonly string MsBuildProjectDiagnostics = nameof(MsBuildProjectDiagnostics);\n         public static readonly string PackageRestoreStarted = nameof(PackageRestoreStarted);\n         public static readonly string PackageRestoreFinished = nameof(PackageRestoreFinished);\n         public static readonly string UnresolvedDependencies = nameof(UnresolvedDependencies);\ndiff --git a/src/OmniSharp.MSBuild/MSBuildLogForwarder.cs b/src/OmniSharp.MSBuild/MSBuildLogForwarder.cs\nindex a43d2047..39d06afe 100644\n--- a/src/OmniSharp.MSBuild/MSBuildLogForwarder.cs\n+++ b/src/OmniSharp.MSBuild/MSBuildLogForwarder.cs\n@@ -1,7 +1,7 @@\n using System;\n using System.Collections.Generic;\n using Microsoft.Extensions.Logging;\n-using OmniSharp.Models;\n+using OmniSharp.MSBuild.Models.Events;\n \n namespace OmniSharp.MSBuild\n {\ndiff --git a/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs b/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs\nindex ecd194cb..3e549a4a 100644\n--- a/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs\n+++ b/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs\n@@ -12,9 +12,10 @@\n using NuGet.ProjectModel;\n using OmniSharp.Eventing;\n using OmniSharp.FileWatching;\n-using OmniSharp.Models;\n using OmniSharp.Models.Events;\n using OmniSharp.Models.WorkspaceInformation;\n+using OmniSharp.MSBuild.Models;\n+using OmniSharp.MSBuild.Models.Events;\n using OmniSharp.MSBuild.ProjectFile;\n using OmniSharp.Options;\n using OmniSharp.Services;\n@@ -292,19 +293,10 @@ private ProjectFileInfo CreateProjectFileInfo(string projectFilePath)\n             catch (Exception ex)\n             {\n                 _logger.LogWarning($"Failed to process project file \'{projectFilePath}\'.", ex);\n-                _eventEmitter.Emit(EventTypes.Error, new ErrorMessage()\n-                {\n-                    FileName = projectFilePath,\n-                    Text = ex.ToString()\n-                });\n+                _eventEmitter.Error(ex, fileName: projectFilePath);\n             }\n \n-            _eventEmitter.Emit(EventTypes.MsBuildProjectDiagnostics, new MSBuildProjectDiagnostics()\n-            {\n-                FileName = projectFilePath,\n-                Warnings = diagnostics.Where(d => d.LogLevel == "Warning"),\n-                Errors = diagnostics.Where(d => d.LogLevel == "Error"),\n-            });\n+            _eventEmitter.MSBuildProjectDiagnostics(projectFilePath, diagnostics);\n \n             return projectFileInfo;\n         }\n@@ -596,9 +588,11 @@ private ProjectFileInfo GetProjectFileInfo(string path)\n \n         Task<object> IProjectSystem.GetWorkspaceModelAsync(WorkspaceInformationRequest request)\n         {\n-            return Task.FromResult<object>(\n-                new MsBuildWorkspaceInformation(_solutionFileOrRootPath, _projects,\n-                    excludeSourceFiles: request?.ExcludeSourceFiles ?? false));\n+            var info = new MSBuildWorkspaceInfo(\n+                _solutionFileOrRootPath, _projects,\n+                excludeSourceFiles: request?.ExcludeSourceFiles ?? false);\n+\n+            return Task.FromResult<object>(info);\n         }\n \n         Task<object> IProjectSystem.GetProjectModelAsync(string filePath)\n@@ -616,8 +610,9 @@ Task<object> IProjectSystem.GetProjectModelAsync(string filePath)\n                 return Task.FromResult<object>(null);\n             }\n \n-            return Task.FromResult<object>(\n-                new MSBuildProjectInformation(projectFileInfo));\n+            var info = new MSBuildProjectInfo(projectFileInfo);\n+\n+            return Task.FromResult<object>(info);\n         }\n     }\n }\ndiff --git a/src/OmniSharp.MSBuild/Models/Events/IEventEmitterExtensions.cs b/src/OmniSharp.MSBuild/Models/Events/IEventEmitterExtensions.cs\nnew file mode 100644\nindex 00000000..3adbb459\n--- /dev/null\n+++ b/src/OmniSharp.MSBuild/Models/Events/IEventEmitterExtensions.cs\n@@ -0,0 +1,19 @@\n+\ufeffusing System.Collections.Generic;\n+using System.Linq;\n+using OmniSharp.Eventing;\n+\n+namespace OmniSharp.MSBuild.Models.Events\n+{\n+    internal static class IEventEmitterExtensions\n+    {\n+        public static void MSBuildProjectDiagnostics(this IEventEmitter eventEmitter, string projectFilePath, IEnumerable<MSBuildDiagnosticsMessage> diagnostics)\n+        {\n+            eventEmitter.Emit(MSBuildProjectDiagnosticsEvent.Id, new MSBuildProjectDiagnosticsEvent()\n+            {\n+                FileName = projectFilePath,\n+                Warnings = diagnostics.Where(d => d.LogLevel == "Warning"),\n+                Errors = diagnostics.Where(d => d.LogLevel == "Error"),\n+            });\n+        }\n+    }\n+}\ndiff --git a/src/OmniSharp.MSBuild/Models/MSBuildDiagnosticsMessage.cs b/src/OmniSharp.MSBuild/Models/Events/MSBuildDiagnosticsMessage.cs\nsimilarity index 89%\nrename from src/OmniSharp.MSBuild/Models/MSBuildDiagnosticsMessage.cs\nrename to src/OmniSharp.MSBuild/Models/Events/MSBuildDiagnosticsMessage.cs\nindex 68a2d33d..20c9d19b 100644\n--- a/src/OmniSharp.MSBuild/Models/MSBuildDiagnosticsMessage.cs\n+++ b/src/OmniSharp.MSBuild/Models/Events/MSBuildDiagnosticsMessage.cs\n@@ -1,4 +1,4 @@\n-namespace OmniSharp.Models\n+namespace OmniSharp.MSBuild.Models.Events\n {\n     public class MSBuildDiagnosticsMessage\n     {\ndiff --git a/src/OmniSharp.MSBuild/Models/MSBuildProjectDiagnostics.cs b/src/OmniSharp.MSBuild/Models/Events/MSBuildProjectDiagnosticsEvent.cs\nsimilarity index 61%\nrename from src/OmniSharp.MSBuild/Models/MSBuildProjectDiagnostics.cs\nrename to src/OmniSharp.MSBuild/Models/Events/MSBuildProjectDiagnosticsEvent.cs\nindex d3980928..c68ac512 100644\n--- a/src/OmniSharp.MSBuild/Models/MSBuildProjectDiagnostics.cs\n+++ b/src/OmniSharp.MSBuild/Models/Events/MSBuildProjectDiagnosticsEvent.cs\n@@ -1,9 +1,11 @@\n using System.Collections.Generic;\n \n-namespace OmniSharp.Models\n+namespace OmniSharp.MSBuild.Models.Events\n {\n-    public class MSBuildProjectDiagnostics\n+    public class MSBuildProjectDiagnosticsEvent\n     {\n+        public const string Id = "MsBuildProjectDiagnostics";\n+\n         public string FileName { get; set; }\n         public IEnumerable<MSBuildDiagnosticsMessage> Warnings { get; set; }\n         public IEnumerable<MSBuildDiagnosticsMessage> Errors { get; set; }\ndiff --git a/src/OmniSharp.MSBuild/Models/MSBuildProjectInformation.cs b/src/OmniSharp.MSBuild/Models/MSBuildProjectInfo.cs\nsimilarity index 92%\nrename from src/OmniSharp.MSBuild/Models/MSBuildProjectInformation.cs\nrename to src/OmniSharp.MSBuild/Models/MSBuildProjectInfo.cs\nindex f18ecc02..a9ffa256 100644\n--- a/src/OmniSharp.MSBuild/Models/MSBuildProjectInformation.cs\n+++ b/src/OmniSharp.MSBuild/Models/MSBuildProjectInfo.cs\n@@ -4,9 +4,9 @@\n using NuGet.Frameworks;\n using OmniSharp.MSBuild.ProjectFile;\n \n-namespace OmniSharp.Models\n+namespace OmniSharp.MSBuild.Models\n {\n-    public class MSBuildProjectInformation\n+    public class MSBuildProjectInfo\n     {\n         public Guid ProjectGuid { get; set; }\n         public string Path { get; set; }\n@@ -19,7 +19,7 @@ public class MSBuildProjectInformation\n         public bool IsExe { get; set; }\n         public bool IsUnityProject { get; set; }\n \n-        public MSBuildProjectInformation(ProjectFileInfo projectFileInfo)\n+        public MSBuildProjectInfo(ProjectFileInfo projectFileInfo)\n         {\n             AssemblyName = projectFileInfo.AssemblyName;\n             Path = projectFileInfo.ProjectFilePath;\ndiff --git a/src/OmniSharp.MSBuild/Models/MsBuildWorkspaceInformation.cs b/src/OmniSharp.MSBuild/Models/MSBuildWorkspaceInfo.cs\nsimilarity index 60%\nrename from src/OmniSharp.MSBuild/Models/MsBuildWorkspaceInformation.cs\nrename to src/OmniSharp.MSBuild/Models/MSBuildWorkspaceInfo.cs\nindex 80f90c17..f5c29aa0 100644\n--- a/src/OmniSharp.MSBuild/Models/MsBuildWorkspaceInformation.cs\n+++ b/src/OmniSharp.MSBuild/Models/MSBuildWorkspaceInfo.cs\n@@ -2,18 +2,18 @@\n using System.Linq;\n using OmniSharp.MSBuild.ProjectFile;\n \n-namespace OmniSharp.Models\n+namespace OmniSharp.MSBuild.Models\n {\n-    public class MsBuildWorkspaceInformation\n+    public class MSBuildWorkspaceInfo\n     {\n-        public MsBuildWorkspaceInformation(string solutionFilePath, IEnumerable<ProjectFileInfo> projects, bool excludeSourceFiles)\n+        public MSBuildWorkspaceInfo(string solutionFilePath, IEnumerable<ProjectFileInfo> projects, bool excludeSourceFiles)\n         {\n             SolutionPath = solutionFilePath;\n \n             Projects = projects\n                 .OrderBy(x => x.AssemblyName)\n                 .Select(p => {\n-                    var project = new MSBuildProjectInformation(p);\n+                    var project = new MSBuildProjectInfo(p);\n                     if (excludeSourceFiles)\n                     {\n                         project.SourceFiles = null;\n@@ -24,6 +24,6 @@ public MsBuildWorkspaceInformation(string solutionFilePath, IEnumerable<ProjectF\n         }\n \n         public string SolutionPath { get; }\n-        public IEnumerable<MSBuildProjectInformation> Projects { get; }\n+        public IEnumerable<MSBuildProjectInfo> Projects { get; }\n     }\n }\n\\ No newline at end of file\ndiff --git a/src/OmniSharp.MSBuild/Models/TargetFramework.cs b/src/OmniSharp.MSBuild/Models/TargetFramework.cs\nindex 12142e95..24472169 100644\n--- a/src/OmniSharp.MSBuild/Models/TargetFramework.cs\n+++ b/src/OmniSharp.MSBuild/Models/TargetFramework.cs\n@@ -1,6 +1,6 @@\n \ufeffusing NuGet.Frameworks;\n \n-namespace OmniSharp.Models\n+namespace OmniSharp.MSBuild.Models\n {\n     public class TargetFramework\n     {\ndiff --git a/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs b/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs\nindex 6749ca9e..efb1a186 100644\n--- a/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs\n+++ b/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs\n@@ -9,6 +9,7 @@\n using Microsoft.CodeAnalysis.CSharp;\n using Microsoft.Extensions.Logging;\n using NuGet.Packaging.Core;\n+using OmniSharp.MSBuild.Models.Events;\n using OmniSharp.Options;\n using OmniSharp.Utilities;\n \n@@ -113,7 +114,7 @@ public void SetProjectId(ProjectId projectId)\n             string solutionDirectory,\n             ILogger logger,\n             MSBuildOptions options = null,\n-            ICollection<Models.MSBuildDiagnosticsMessage> diagnostics = null)\n+            ICollection<MSBuildDiagnosticsMessage> diagnostics = null)\n         {\n             if (!File.Exists(projectFilePath))\n             {\n', 'commit_subject': 'Clean up MSBuild models and events', 'repo_name': 'OmniSharp/omnisharp-roslyn', 'committer': {'name': 'Dustin Campbell', 'email': '1c08efb9b3965701be9d700d9a6f481f1ffec3ea@teamcampbell.org', 'time_sec': '1493156225', 'tz_offset': '-420', 'date': {'seconds': '1493156225'}}, 'commit_tree': '0c0ec12e858f900a3f197bff56b45d3a74c94c21', 'commit_message': 'Clean up MSBuild models and events\n', 'language_name': 'C#', 'license': 'mit', 'hunks': '@@ -9,6 +9,7 @@\n using Microsoft.CodeAnalysis.CSharp;\n using Microsoft.Extensions.Logging;\n using NuGet.Packaging.Core;\n+using OmniSharp.MSBuild.Models.Events;\n using OmniSharp.Options;\n using OmniSharp.Utilities;\n \n@@ -113,7 +114,7 @@ public void SetProjectId(ProjectId projectId)\n             string solutionDirectory,\n             ILogger logger,\n             MSBuildOptions options = null,\n-            ICollection<Models.MSBuildDiagnosticsMessage> diagnostics = null)\n+            ICollection<MSBuildDiagnosticsMessage> diagnostics = null)\n         {\n             if (!File.Exists(projectFilePath))\n             {\n', 'addition_count': 2, 'deletion_count': 1, 'src_file': 'a/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs', 'tgt_file': 'b/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs', 'file_extension': '.cs', 'before_file': '\ufeffusing System;\nusing System.Collections.Immutable;\nusing System.IO;\nusing System.Linq;\nusing System.Runtime.Versioning;\nusing Microsoft.Build.Evaluation;\nusing Microsoft.Build.Globbing;\nusing Microsoft.CodeAnalysis;\nusing Microsoft.CodeAnalysis.CSharp;\nusing Microsoft.Extensions.Logging;\nusing NuGet.Packaging.Core;\nusing OmniSharp.Options;\nusing OmniSharp.Utilities;\n\n{\n    internal partial class ProjectFileInfo\n    {\n        private readonly ProjectData _data;\n\n        public string FilePath { get; }\n        public string Directory { get; }\n\n        public ProjectId Id { get => ProjectIdInfo.Id; }\n\n        public Guid Guid => _data.Guid;\n        public string Name => _data.Name;\n\n        public string AssemblyName => _data.AssemblyName;\n        public string TargetPath => _data.TargetPath;\n        public string OutputPath => _data.OutputPath;\n        public string IntermediateOutputPath => _data.IntermediateOutputPath;\n        public string ProjectAssetsFile => _data.ProjectAssetsFile;\n\n        public string Configuration => _data.Configuration;\n        public string Platform => _data.Platform;\n        public string PlatformTarget => _data.PlatformTarget;\n        public FrameworkName TargetFramework => _data.TargetFramework;\n        public ImmutableArray<string> TargetFrameworks => _data.TargetFrameworks;\n\n        public OutputKind OutputKind => _data.OutputKind;\n        public LanguageVersion LanguageVersion => _data.LanguageVersion;\n        public NullableContextOptions NullableContextOptions => _data.NullableContextOptions;\n        public bool AllowUnsafeCode => _data.AllowUnsafeCode;\n        public bool CheckForOverflowUnderflow => _data.CheckForOverflowUnderflow;\n        public string DocumentationFile => _data.DocumentationFile;\n        public ImmutableArray<string> PreprocessorSymbolNames => _data.PreprocessorSymbolNames;\n        public ImmutableArray<string> SuppressedDiagnosticIds => _data.SuppressedDiagnosticIds;\n        public ImmutableArray<string> WarningsAsErrors => _data.WarningsAsErrors;\n        public ImmutableArray<string> WarningsNotAsErrors => _data.WarningsNotAsErrors;\n\n        public bool SignAssembly => _data.SignAssembly;\n        public string AssemblyOriginatorKeyFile => _data.AssemblyOriginatorKeyFile;\n        public RuleSet RuleSet => _data.RuleSet;\n\n        public ImmutableArray<string> SourceFiles => _data.SourceFiles;\n        public ImmutableArray<string> References => _data.References;\n        public ImmutableArray<string> ProjectReferences => _data.ProjectReferences;\n        public ImmutableArray<PackageReference> PackageReferences => _data.PackageReferences;\n        public ImmutableArray<string> Analyzers => _data.Analyzers;\n        public ImmutableArray<string> AdditionalFiles => _data.AdditionalFiles;\n        public ImmutableArray<string> AnalyzerConfigFiles => _data.AnalyzerConfigFiles;\n        public ImmutableDictionary<string, string> ReferenceAliases => _data.ReferenceAliases;\n        public ImmutableDictionary<string, string> ProjectReferenceAliases => _data.ProjectReferenceAliases;\n        public bool TreatWarningsAsErrors => _data.TreatWarningsAsErrors;\n        public bool RunAnalyzers => _data.RunAnalyzers;\n        public bool RunAnalyzersDuringLiveAnalysis => _data.RunAnalyzersDuringLiveAnalysis;\n        public string DefaultNamespace => _data.DefaultNamespace;\n        public ImmutableArray<IMSBuildGlob> FileInclusionGlobPatterns => _data.FileInclusionGlobs;\n\n        public ProjectIdInfo ProjectIdInfo { get; }\n        public DotNetInfo DotNetInfo { get; }\n        public Guid SessionId { get; }\n\n        private ProjectFileInfo(\n            ProjectIdInfo projectIdInfo,\n            string filePath,\n            ProjectData data,\n            Guid sessionId,\n            DotNetInfo dotNetInfo)\n        {\n            this.ProjectIdInfo = projectIdInfo;\n            this.FilePath = filePath;\n            this.Directory = Path.GetDirectoryName(filePath);\n            this.SessionId = sessionId;\n            this.DotNetInfo = dotNetInfo;\n\n            _data = data;\n        }\n\n        internal static ProjectFileInfo CreateEmpty(string filePath)\n        {\n            var id = ProjectId.CreateNewId(debugName: filePath);\n\n            return new ProjectFileInfo(new ProjectIdInfo(id, isDefinedInSolution: false), filePath, data: null, sessionId: Guid.NewGuid(), DotNetInfo.Empty);\n        }\n\n        internal static ProjectFileInfo CreateNoBuild(string filePath, ProjectLoader loader, DotNetInfo dotNetInfo)\n        {\n            var id = ProjectId.CreateNewId(debugName: filePath);\n            var project = loader.EvaluateProjectFile(filePath);\n\n            var data = ProjectData.Create(project);\n            //we are not reading the solution here\n            var projectIdInfo = new ProjectIdInfo(id, isDefinedInSolution: false);\n\n            return new ProjectFileInfo(projectIdInfo, filePath, data, sessionId: Guid.NewGuid(), dotNetInfo);\n        }\n\n        public static (ProjectFileInfo, ImmutableArray<MSBuildDiagnostic>, ProjectLoadedEventArgs) Load(string filePath, ProjectIdInfo projectIdInfo, ProjectLoader loader, Guid sessionId, DotNetInfo dotNetInfo)\n        {\n            if (!File.Exists(filePath))\n            {\n            string solutionDirectory,\n            ILogger logger,\n            MSBuildOptions options = null,\n            ICollection<Models.MSBuildDiagnosticsMessage> diagnostics = null)\n        {\n            if (!File.Exists(projectFilePath))\n            {\n            }\n\n            var data = ProjectData.Create(filePath, projectInstance, project);\n            var projectFileInfo = new ProjectFileInfo(projectIdInfo, filePath, data, sessionId, dotNetInfo);\n            var eventArgs = new ProjectLoadedEventArgs(projectIdInfo.Id,\n                                                       project,\n                                                       sessionId,\n                                                       projectInstance,\n                                                       diagnostics,\n                                                       isReload: false,\n                                                       projectIdInfo.IsDefinedInSolution,\n                                                       projectFileInfo.SourceFiles,\n                                                       dotNetInfo.Version,\n                                                       data.References);\n\n            return (projectFileInfo, diagnostics, eventArgs);\n        }\n\n        public (ProjectFileInfo, ImmutableArray<MSBuildDiagnostic>, ProjectLoadedEventArgs) Reload(ProjectLoader loader)\n        {\n            var (projectInstance, project, diagnostics) = loader.BuildProject(FilePath, ProjectIdInfo?.SolutionConfiguration);\n            if (projectInstance == null)\n            {\n                return (null, diagnostics, null);\n            }\n\n            var data = ProjectData.Create(FilePath, projectInstance, project);\n            var projectFileInfo = new ProjectFileInfo(ProjectIdInfo, FilePath, data, SessionId, DotNetInfo);\n            var eventArgs = new ProjectLoadedEventArgs(Id,\n                                                       project,\n                                                       SessionId,\n                                                       projectInstance,\n                                                       diagnostics,\n                                                       isReload: true,\n                                                       ProjectIdInfo.IsDefinedInSolution,\n                                                       data.SourceFiles,\n                                                       DotNetInfo.Version,\n                                                       data.References);\n\n            return (projectFileInfo, diagnostics, eventArgs);\n        }\n\n        public bool IsUnityProject()\n            => References.Any(filePath =>\n                {\n                    var fileName = Path.GetFileName(filePath);\n\n                    return string.Equals(fileName, "UnityEngine.dll", StringComparison.OrdinalIgnoreCase)\n                        || string.Equals(fileName, "UnityEditor.dll", StringComparison.OrdinalIgnoreCase);\n                });\n\n\n        public bool IsFileIncluded(string filePath)\n        {\n            if (SourceFiles.Contains(filePath, StringComparer.OrdinalIgnoreCase))\n                return true;\n\n            var relativePath = FileSystemHelper.GetRelativePath(filePath, FilePath);\n            return FileInclusionGlobPatterns.Any(glob => glob.IsMatch(relativePath));\n        }\n    }\n}\n', 'message': 'Clean up MSBuild models and events\n', 'author_name': 'Dustin Campbell', 'lang': 'MSBuild/ProjectFile/ProjectFileInfo'}