/Microsoft.Build/Microsoft.Build/Microsoft/Build/Evaluation/ProjectCollection.cs
C# | 1506 lines | 1394 code | 112 blank | 0 comment | 157 complexity | 8091f0fe87c8f30a1cf292b2d4f97a32 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-3.0
Large files files are truncated, but you can click here to view the full file
- namespace Microsoft.Build.Evaluation
- {
- using Microsoft.Build.BackEnd;
- using Microsoft.Build.BackEnd.Logging;
- using Microsoft.Build.Collections;
- using Microsoft.Build.Construction;
- using Microsoft.Build.Exceptions;
- using Microsoft.Build.Execution;
- using Microsoft.Build.Framework;
- using Microsoft.Build.Internal;
- using Microsoft.Build.Logging;
- using Microsoft.Build.Shared;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Reflection;
- using System.Runtime;
- using System.Runtime.CompilerServices;
- using System.Threading;
- using System.Xml;
-
- public class ProjectCollection : IToolsetProvider, IBuildComponent, IDisposable
- {
- private string defaultToolsVersion;
- private static System.Version engineVersion;
- private PropertyDictionary<ProjectPropertyInstance> environmentProperties;
- private static object globalLock = new object();
- private static ProjectCollection globalProjectCollection;
- private PropertyDictionary<ProjectPropertyInstance> globalProperties;
- private IBuildComponentHost host;
- private Microsoft.Build.Execution.HostServices hostServices;
- private bool isBuildEnabled;
- private LoadedProjectCollection loadedProjects;
- private ILoggingService loggingService;
- private bool onlyLogCriticalEvents;
- private ToolsetDefinitionLocations toolsetDefinitionLocations;
- private Dictionary<string, Toolset> toolsets;
- private int toolsetsVersion;
-
- static ProjectCollection()
- {
- AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandling.UnhandledExceptionHandler);
- }
-
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- public ProjectCollection() : this((IDictionary<string, string>) null)
- {
- }
-
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- public ProjectCollection(IDictionary<string, string> globalProperties) : this(globalProperties, null, ToolsetDefinitionLocations.Registry | ToolsetDefinitionLocations.ConfigurationFile)
- {
- }
-
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- public ProjectCollection(ToolsetDefinitionLocations toolsetLocations) : this(null, null, toolsetLocations)
- {
- }
-
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- public ProjectCollection(IDictionary<string, string> globalProperties, IEnumerable<ILogger> loggers, ToolsetDefinitionLocations toolsetDefinitionLocations) : this(globalProperties, loggers, null, toolsetDefinitionLocations, 1, false)
- {
- }
-
- public ProjectCollection(IDictionary<string, string> globalProperties, IEnumerable<ILogger> loggers, IEnumerable<ForwardingLoggerRecord> remoteLoggers, ToolsetDefinitionLocations toolsetDefinitionLocations, int maxNodeCount, bool onlyLogCriticalEvents)
- {
- this.isBuildEnabled = true;
- this.loadedProjects = new LoadedProjectCollection();
- this.toolsetDefinitionLocations = toolsetDefinitionLocations;
- this.MaxNodeCount = maxNodeCount;
- this.ProjectRootElementCache = new Microsoft.Build.Evaluation.ProjectRootElementCache(false);
- this.OnlyLogCriticalEvents = onlyLogCriticalEvents;
- try
- {
- this.CreateLoggingService(maxNodeCount, onlyLogCriticalEvents);
- this.RegisterLoggers(loggers);
- this.RegisterForwardingLoggers(remoteLoggers);
- if (globalProperties != null)
- {
- this.globalProperties = new PropertyDictionary<ProjectPropertyInstance>(globalProperties.Count);
- foreach (KeyValuePair<string, string> pair in globalProperties)
- {
- try
- {
- this.globalProperties.Set(new ProjectPropertyInstance(pair.Key, pair.Value));
- continue;
- }
- catch (ArgumentException exception)
- {
- try
- {
- ProjectErrorUtilities.ThrowInvalidProject(new ElementLocation("MSBUILD"), "InvalidProperty", exception.Message);
- }
- catch (InvalidProjectFileException exception2)
- {
- BuildEventContext buildEventContext = new BuildEventContext(0, -1, -2, -1);
- this.LoggingService.LogInvalidProjectFileError(buildEventContext, exception2);
- throw;
- }
- continue;
- }
- }
- }
- else
- {
- this.globalProperties = new PropertyDictionary<ProjectPropertyInstance>();
- }
- this.InitializeToolsetCollection();
- }
- catch (Exception)
- {
- this.ShutDownLoggingService();
- throw;
- }
- }
-
- public void AddToolset(Toolset toolset)
- {
- ErrorUtilities.VerifyThrowArgumentNull(toolset, "toolset");
- this.toolsets[toolset.ToolsVersion] = toolset;
- this.toolsetsVersion++;
- }
-
- internal void AfterUpdateLoadedProjectGlobalProperties(Project project)
- {
- ErrorUtilities.VerifyThrowInvalidOperation(object.ReferenceEquals(project.ProjectCollection, this), "OM_IncorrectObjectAssociation", "Project", "ProjectCollection");
- if ((project.FullPath != null) && this.loadedProjects.RemoveProject(project))
- {
- this.loadedProjects.AddProject(project);
- }
- }
-
- public bool ContainsToolset(string toolsVersion)
- {
- return (this.GetToolset(toolsVersion) != null);
- }
-
- private void CreateLoggingService(int maxCPUCount, bool onlyLogCriticalEvents)
- {
- this.loggingService = Microsoft.Build.BackEnd.Logging.LoggingService.CreateLoggingService(LoggerMode.Synchronous, 0);
- this.loggingService.MaxCPUCount = maxCPUCount;
- this.loggingService.OnlyLogCriticalEvents = onlyLogCriticalEvents;
- }
-
- public void Dispose()
- {
- this.Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (disposing)
- {
- this.ShutDownLoggingService();
- }
- }
-
- public static string Escape(string unescapedString)
- {
- return EscapingUtilities.Escape(unescapedString);
- }
-
- public ProjectPropertyInstance GetGlobalProperty(string name)
- {
- return this.globalProperties[name];
- }
-
- public ICollection<Project> GetLoadedProjects(string fullPath)
- {
- return new ReadOnlyCollection<Project>(this.loadedProjects.GetMatchingProjectsIfAny(fullPath));
- }
-
- public Toolset GetToolset(string toolsVersion)
- {
- Toolset toolset;
- ErrorUtilities.VerifyThrowArgumentLength(toolsVersion, "toolsVersion");
- this.toolsets.TryGetValue(toolsVersion, out toolset);
- return toolset;
- }
-
- private void InitializeToolsetCollection()
- {
- this.toolsets = new Dictionary<string, Toolset>(StringComparer.OrdinalIgnoreCase);
- this.defaultToolsVersion = ToolsetReader.ReadAllToolsets(this.toolsets, this.EnvironmentProperties, this.globalProperties, this.toolsetDefinitionLocations);
- this.toolsetsVersion++;
- }
-
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- public Project LoadProject(string fileName)
- {
- return this.LoadProject(fileName, null);
- }
-
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- public Project LoadProject(XmlReader xmlReader)
- {
- return this.LoadProject(xmlReader, null);
- }
-
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- public Project LoadProject(string fileName, string toolsVersion)
- {
- return this.LoadProject(fileName, null, toolsVersion);
- }
-
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- public Project LoadProject(XmlReader xmlReader, string toolsVersion)
- {
- return this.LoadProject(xmlReader, null, toolsVersion);
- }
-
- public Project LoadProject(string fileName, IDictionary<string, string> globalProperties, string toolsVersion)
- {
- ErrorUtilities.VerifyThrowArgumentLength(fileName, "fileName");
- BuildEventContext buildEventContext = new BuildEventContext(0, -1, -2, -1);
- if (globalProperties == null)
- {
- globalProperties = this.GlobalProperties;
- }
- else
- {
- foreach (KeyValuePair<string, string> pair in this.GlobalProperties)
- {
- if (!globalProperties.ContainsKey(pair.Key))
- {
- globalProperties.Add(pair);
- }
- }
- }
- fileName = FileUtilities.NormalizePath(fileName);
- if (toolsVersion == null)
- {
- try
- {
- ProjectRootElement element = ProjectRootElement.OpenProjectOrSolution(fileName, globalProperties, toolsVersion, this.LoggingService, this.ProjectRootElementCache, buildEventContext);
- toolsVersion = (element.ToolsVersion.Length > 0) ? element.ToolsVersion : this.DefaultToolsVersion;
- }
- catch (InvalidProjectFileException exception)
- {
- this.LoggingService.LogInvalidProjectFileError(buildEventContext, exception);
- throw;
- }
- }
- Project project = this.loadedProjects.GetMatchingProjectIfAny(fileName, globalProperties, toolsVersion);
- if (project == null)
- {
- project = new Project(fileName, globalProperties, toolsVersion, this);
- }
- return project;
- }
-
- public Project LoadProject(XmlReader xmlReader, IDictionary<string, string> globalProperties, string toolsVersion)
- {
- return new Project(xmlReader, globalProperties, toolsVersion, this);
- }
-
- void IBuildComponent.InitializeComponent(IBuildComponentHost host)
- {
- this.host = host;
- }
-
- void IBuildComponent.ShutdownComponent()
- {
- this.host = null;
- }
-
- internal void OnAfterRenameLoadedProject(string oldFullPathIfAny, Project project)
- {
- if (project.FullPath != null)
- {
- if (oldFullPathIfAny != null)
- {
- ErrorUtilities.VerifyThrowInvalidOperation(this.loadedProjects.RemoveProject(oldFullPathIfAny, project), "OM_ProjectWasNotLoaded");
- }
- this.loadedProjects.AddProject(project);
- if (this.hostServices != null)
- {
- this.HostServices.OnRenameProject(oldFullPathIfAny, project.FullPath);
- }
- }
- }
-
- public void RegisterForwardingLoggers(IEnumerable<ForwardingLoggerRecord> remoteLoggers)
- {
- if (remoteLoggers != null)
- {
- foreach (ForwardingLoggerRecord record in remoteLoggers)
- {
- this.loggingService.RegisterDistributedLogger(new ReusableLogger(record.CentralLogger), record.ForwardingLoggerDescription);
- }
- }
- }
-
- public void RegisterLogger(ILogger logger)
- {
- ErrorUtilities.VerifyThrowArgumentNull(logger, "logger");
- this.loggingService.RegisterLogger(new ReusableLogger(logger));
- }
-
- public void RegisterLoggers(IEnumerable<ILogger> loggers)
- {
- if (loggers != null)
- {
- foreach (ILogger logger in loggers)
- {
- this.RegisterLogger(logger);
- }
- }
- }
-
- public void RemoveAllToolsets()
- {
- List<Toolset> list = new List<Toolset>(this.Toolsets);
- foreach (Toolset toolset in list)
- {
- this.RemoveToolset(toolset.ToolsVersion);
- }
- }
-
- public bool RemoveGlobalProperty(string name)
- {
- bool flag = this.globalProperties.Remove(name);
- List<Project> list = new List<Project>(this.loadedProjects);
- foreach (Project project in list)
- {
- project.RemoveGlobalProperty(name);
- }
- return flag;
- }
-
- public bool RemoveToolset(string toolsVersion)
- {
- ErrorUtilities.VerifyThrowArgumentLength(toolsVersion, "toolsVersion");
- if (!this.toolsets.ContainsKey(toolsVersion))
- {
- return false;
- }
- this.toolsets.Remove(toolsVersion);
- this.toolsetsVersion++;
- return true;
- }
-
- public void SetGlobalProperty(string name, string value)
- {
- this.globalProperties.Set(new ProjectPropertyInstance(name, value));
- List<Project> list = new List<Project>(this.loadedProjects);
- foreach (Project project in list)
- {
- project.SetGlobalProperty(name, value);
- }
- }
-
- private void ShutDownLoggingService()
- {
- if (this.loggingService != null)
- {
- try
- {
- ((IBuildComponent) this.LoggingService).ShutdownComponent();
- }
- catch (LoggerException)
- {
- throw;
- }
- catch (InternalLoggerException)
- {
- throw;
- }
- catch (Exception exception)
- {
- ErrorUtilities.ThrowInternalError("Throwing from logger shutdown", exception, new object[0]);
- throw;
- }
- this.loggingService = null;
- }
- }
-
- public bool TryUnloadProject(ProjectRootElement projectRootElement)
- {
- ErrorUtilities.VerifyThrowArgumentNull(projectRootElement, "projectRootElement");
- this.ProjectRootElementCache.DiscardStrongReferences();
- if (this.LoadedProjects.FirstOrDefault<Project>(project => project.UsesProjectRootElement(projectRootElement)) == null)
- {
- this.ProjectRootElementCache.DiscardAnyWeakReference(projectRootElement);
- return true;
- }
- return false;
- }
-
- public static string Unescape(string escapedString)
- {
- return EscapingUtilities.UnescapeAll(escapedString);
- }
-
- public void UnloadAllProjects()
- {
- foreach (Project project in this.loadedProjects)
- {
- project.Zombify();
- if (this.hostServices != null)
- {
- this.hostServices.UnregisterProject(project.FullPath);
- }
- }
- this.loadedProjects.RemoveAllProjects();
- this.ProjectRootElementCache.Clear();
- }
-
- public void UnloadProject(ProjectRootElement projectRootElement)
- {
- ErrorUtilities.VerifyThrowArgumentNull(projectRootElement, "projectRootElement");
- Project project = this.LoadedProjects.FirstOrDefault<Project>(project => project.UsesProjectRootElement(projectRootElement));
- if (project != null)
- {
- ErrorUtilities.ThrowInvalidOperation("OM_ProjectXmlCannotBeUnloadedDueToLoadedProjects", new object[] { projectRootElement.FullPath, project.FullPath });
- }
- this.ProjectRootElementCache.DiscardAnyWeakReference(projectRootElement);
- }
-
- public void UnloadProject(Project project)
- {
- ErrorUtilities.VerifyThrowInvalidOperation(this.loadedProjects.RemoveProject(project), "OM_ProjectWasNotLoaded");
- project.Zombify();
- if ((this.hostServices != null) && (this.loadedProjects.GetMatchingProjectsIfAny(project.FullPath).Count == 0))
- {
- this.hostServices.UnregisterProject(project.FullPath);
- }
- this.ProjectRootElementCache.DiscardStrongReferences();
- }
-
- public void UnregisterAllLoggers()
- {
- this.loggingService.UnregisterAllLoggers();
- this.CreateLoggingService(this.MaxNodeCount, this.OnlyLogCriticalEvents);
- }
-
- public int Count
- {
- get
- {
- return this.loadedProjects.Count;
- }
- }
-
- public string DefaultToolsVersion
- {
- get
- {
- ErrorUtilities.VerifyThrow(this.defaultToolsVersion != null, "Should have a default");
- return this.defaultToolsVersion;
- }
- set
- {
- ErrorUtilities.VerifyThrowArgumentLength(value, "DefaultToolsVersion");
- if (!this.toolsets.ContainsKey(value))
- {
- string str = Utilities.CreateToolsVersionListString(this.Toolsets);
- ErrorUtilities.ThrowInvalidOperation("UnrecognizedToolsVersion", new object[] { value, str });
- }
- this.defaultToolsVersion = value;
- }
- }
-
- public bool DisableMarkDirty
- {
- [CompilerGenerated, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- get
- {
- return this.<DisableMarkDirty>k__BackingField;
- }
- [CompilerGenerated, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- set
- {
- this.<DisableMarkDirty>k__BackingField = value;
- }
- }
-
- internal PropertyDictionary<ProjectPropertyInstance> EnvironmentProperties
- {
- get
- {
- if (this.environmentProperties == null)
- {
- this.environmentProperties = Utilities.GetEnvironmentProperties();
- }
- return this.environmentProperties;
- }
- }
-
- public static ProjectCollection GlobalProjectCollection
- {
- get
- {
- lock (globalLock)
- {
- if (globalProjectCollection == null)
- {
- globalProjectCollection = new ProjectCollection();
- }
- return globalProjectCollection;
- }
- }
- }
-
- public IDictionary<string, string> GlobalProperties
- {
- get
- {
- if (this.globalProperties.Count == 0)
- {
- return ReadOnlyEmptyDictionary<string, string>.Instance;
- }
- Dictionary<string, string> backing = new Dictionary<string, string>(this.globalProperties.Count, MSBuildNameIgnoreCaseComparer.Default);
- foreach (ProjectPropertyInstance instance in this.globalProperties)
- {
- backing[instance.Name] = ((IProperty) instance).EvaluatedValueEscaped;
- }
- return ReadOnlyDictionary<string, string>.CreateWrapper(backing);
- }
- }
-
- internal PropertyDictionary<ProjectPropertyInstance> GlobalPropertiesCollection
- {
- [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- get
- {
- return this.globalProperties;
- }
- }
-
- public Microsoft.Build.Execution.HostServices HostServices
- {
- get
- {
- if (this.hostServices == null)
- {
- this.HostServices = new Microsoft.Build.Execution.HostServices();
- }
- return this.hostServices;
- }
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- set
- {
- this.hostServices = value;
- }
- }
-
- public bool IsBuildEnabled
- {
- [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- get
- {
- return this.isBuildEnabled;
- }
- [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- set
- {
- this.isBuildEnabled = value;
- }
- }
-
- public ICollection<Project> LoadedProjects
- {
- get
- {
- return new ReadOnlyCollection<Project>(this.loadedProjects);
- }
- }
-
- public ICollection<ILogger> Loggers
- {
- [DebuggerStepThrough]
- get
- {
- if (this.loggingService.Loggers != null)
- {
- return new ReadOnlyCollection<ILogger>(this.loggingService.Loggers);
- }
- return ReadOnlyEmptyCollection<ILogger>.Instance;
- }
- }
-
- internal ILoggingService LoggingService
- {
- [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- get
- {
- return this.loggingService;
- }
- }
-
- internal int MaxNodeCount
- {
- [CompilerGenerated, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- get
- {
- return this.<MaxNodeCount>k__BackingField;
- }
- [CompilerGenerated, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- set
- {
- this.<MaxNodeCount>k__BackingField = value;
- }
- }
-
- public bool OnlyLogCriticalEvents
- {
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- get
- {
- return this.onlyLogCriticalEvents;
- }
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- set
- {
- this.onlyLogCriticalEvents = value;
- }
- }
-
- internal Microsoft.Build.Evaluation.ProjectRootElementCache ProjectRootElementCache
- {
- [CompilerGenerated, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- get
- {
- return this.<ProjectRootElementCache>k__BackingField;
- }
- [CompilerGenerated]
- private set
- {
- this.<ProjectRootElementCache>k__BackingField = value;
- }
- }
-
- public bool SkipEvaluation
- {
- [CompilerGenerated, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- get
- {
- return this.<SkipEvaluation>k__BackingField;
- }
- [CompilerGenerated, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- set
- {
- this.<SkipEvaluation>k__BackingField = value;
- }
- }
-
- public ToolsetDefinitionLocations ToolsetLocations
- {
- [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- get
- {
- return this.toolsetDefinitionLocations;
- }
- }
-
- public ICollection<Toolset> Toolsets
- {
- get
- {
- return this.toolsets.Values;
- }
- }
-
- internal int ToolsetsVersion
- {
- [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- get
- {
- return this.toolsetsVersion;
- }
- }
-
- public static System.Version Version
- {
- get
- {
- if (engineVersion == null)
- {
- engineVersion = new System.Version(FileVersionInfo.GetVersionInfo(new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath).ProductVersion);
- }
- return engineVersion;
- }
- }
-
- private class LoadedProjectCollection : IEnumerable<Project>, IEnumerable
- {
- private int count;
- private Dictionary<string, List<Project>> loadedProjects = new Dictionary<string, List<Project>>(StringComparer.OrdinalIgnoreCase);
-
- internal LoadedProjectCollection()
- {
- }
-
- internal void AddProject(Project project)
- {
- List<Project> list;
- if (!this.loadedProjects.TryGetValue(project.FullPath, out list))
- {
- list = new List<Project>();
- this.loadedProjects.Add(project.FullPath, list);
- }
- foreach (Project project2 in list)
- {
- if (this.HasEquivalentGlobalPropertiesAndToolsVersion(project2, project.GlobalProperties, project.ToolsVersion))
- {
- ErrorUtilities.ThrowInvalidOperation("OM_MatchingProjectAlreadyInCollection", new object[] { project2.FullPath });
- }
- }
- list.Add(project);
- this.count++;
- }
-
- public IEnumerator<Project> GetEnumerator()
- {
- foreach (List<Project> iteratorVariable0 in this.loadedProjects.Values)
- {
- foreach (Project iteratorVariable1 in iteratorVariable0)
- {
- yield return iteratorVariable1;
- }
- }
- }
-
- internal Project GetMatchingProjectIfAny(string fullPath, IDictionary<string, string> globalProperties, string toolsVersion)
- {
- List<Project> list;
- if (this.loadedProjects.TryGetValue(fullPath, out list))
- {
- foreach (Project project in list)
- {
- if (this.HasEquivalentGlobalPropertiesAndToolsVersion(project, globalProperties, toolsVersion))
- {
- return project;
- }
- }
- }
- return null;
- }
-
- internal IList<Project> GetMatchingProjectsIfAny(string fullPath)
- {
- List<Project> list;
- this.loadedProjects.TryGetValue(fullPath, out list);
- if (list != null)
- {
- return list;
- }
- return ReadOnlyEmptyList<Project>.Instance;
- }
-
- private bool HasEquivalentGlobalPropertiesAndToolsVersion(Project project, IDictionary<string, string> globalProperties, string toolsVersion)
- {
- if (!string.Equals(project.ToolsVersion, toolsVersion, StringComparison.OrdinalIgnoreCase))
- {
- return false;
- }
- if (project.GlobalProperties.Count != globalProperties.Count)
- {
- return false;
- }
- foreach (KeyValuePair<string, string> pair in project.GlobalProperties)
- {
- string str;
- if (!globalProperties.TryGetValue(pair.Key, out str))
- {
- return false;
- }
- if (!string.Equals(pair.Value, str, StringComparison.OrdinalIgnoreCase))
- {
- return false;
- }
- }
- return true;
- }
-
- internal void RemoveAllProjects()
- {
- this.loadedProjects = new Dictionary<string, List<Project>>(StringComparer.OrdinalIgnoreCase);
- this.count = 0;
- }
-
- internal bool RemoveProject(Project project)
- {
- return this.RemoveProject(project.FullPath, project);
- }
-
- internal bool RemoveProject(string projectFullPath, Project project)
- {
- List<Project> list;
- if (!this.loadedProjects.TryGetValue(projectFullPath, out list))
- {
- return false;
- }
- bool flag = list.Remove(project);
- if (flag)
- {
- this.count--;
- if (list.Count == 0)
- {
- this.loadedProjects.Remove(projectFullPath);
- }
- }
- return flag;
- }
-
- [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
- IEnumerator IEnumerable.GetEnumerator()
- {
- return this.GetEnumerator();
- }
-
- internal int Count
- {
- get
- {
- return this.count;
- }
- }
-
- }
-
- internal class ReusableLogger : INodeLogger, ILogger, IEventSource
- {
- private AnyEventHandler anyEventHandler;
- private AnyEventHandler AnyEventRaised;
- private BuildErrorEventHandler buildErrorEventHandler;
- private BuildFinishedEventHandler BuildFinished;
- private BuildFinishedEventHandler buildFinishedEventHandler;
- private BuildMessageEventHandler buildMessageEventHandler;
- private BuildStartedEventHandler BuildStarted;
- private BuildStartedEventHandler buildStartedEventHandler;
- private BuildStatusEventHandler buildStatusEventHandler;
- private IEventSource buildTimeEventSource;
- private BuildWarningEventHandler buildWarningEventHandler;
- private CustomBuildEventHandler customBuildEventHandler;
- private CustomBuildEventHandler CustomEventRaised;
- private IEventSource designTimeEventSource;
- private BuildErrorEventHandler ErrorRaised;
- private BuildMessageEventHandler MessageRaised;
- private ILogger originalLogger;
- private ProjectFinishedEventHandler ProjectFinished;
- private ProjectFinishedEventHandler projectFinishedEventHandler;
- private ProjectStartedEventHandler ProjectStarted;
- private ProjectStartedEventHandler projectStartedEventHandler;
- private BuildStatusEventHandler StatusEventRaised;
- private TargetFinishedEventHandler TargetFinished;
- private TargetFinishedEventHandler targetFinishedEventHandler;
- private TargetStartedEventHandler TargetStarted;
- private TargetStartedEventHandler targetStartedEventHandler;
- private TaskFinishedEventHandler TaskFinished;
- private TaskFinishedEventHandler taskFinishedEventHandler;
- private TaskStartedEventHandler TaskStarted;
- private TaskStartedEventHandler taskStartedEventHandler;
- private BuildWarningEventHandler WarningRaised;
-
- public event AnyEventHandler AnyEventRaised
- {
- add
- {
- AnyEventHandler handler2;
- AnyEventHandler anyEventRaised = this.AnyEventRaised;
- do
- {
- handler2 = anyEventRaised;
- AnyEventHandler handler3 = (AnyEventHandler) Delegate.Combine(handler2, value);
- anyEventRaised = Interlocked.CompareExchange<AnyEventHandler>(ref this.AnyEventRaised, handler3, handler2);
- }
- while (anyEventRaised != handler2);
- }
- remove
- {
- AnyEventHandler handler2;
- AnyEventHandler anyEventRaised = this.AnyEventRaised;
- do
- {
- handler2 = anyEventRaised;
- AnyEventHandler handler3 = (AnyEventHandler) Delegate.Remove(handler2, value);
- anyEventRaised = Interlocked.CompareExchange<AnyEventHandler>(ref this.AnyEventRaised, handler3, handler2);
- }
- while (anyEventRaised != handler2);
- }
- }
-
- public event BuildFinishedEventHandler BuildFinished
- {
- add
- {
- BuildFinishedEventHandler handler2;
- BuildFinishedEventHandler buildFinished = this.BuildFinished;
- do
- {
- handler2 = buildFinished;
- BuildFinishedEventHandler handler3 = (BuildFinishedEventHandler) Delegate.Combine(handler2, value);
- buildFinished = Interlocked.CompareExchange<BuildFinishedEventHandler>(ref this.BuildFinished, handler3, handler2);
- }
- while (buildFinished != handler2);
- }
- remove
- {
- BuildFinishedEventHandler handler2;
- BuildFinishedEventHandler buildFinished = this.BuildFinished;
- do
- {
- handler2 = buildFinished;
- BuildFinishedEventHandler handler3 = (BuildFinishedEventHandler) Delegate.Remove(handler2, value);
- buildFinished = Interlocked.CompareExchange<BuildFinishedEventHandler>(ref this.BuildFinished, handler3, handler2);
- }
- while (buildFinished != handler2);
- }
- }
-
- public event BuildStartedEventHandler BuildStarted
- {
- add
- {
- BuildStartedEventHandler handler2;
- BuildStartedEventHandler buildStarted = this.BuildStarted;
- do
- {
- handler2 = buildStarted;
- BuildStartedEventHandler handler3 = (BuildStartedEventHandler) Delegate.Combine(handler2, value);
- buildStarted = Interlocked.CompareExchange<BuildStartedEventHandler>(ref this.BuildStarted, handler3, handler2);
- }
- while (buildStarted != handler2);
- }
- remove
- {
- BuildStartedEventHandler handler2;
- BuildStartedEventHandler buildStarted = this.BuildStarted;
- do
- {
- handler2 = buildStarted;
- BuildStartedEventHandler handler3 = (BuildStartedEventHandler) Delegate.Remove(handler2, value);
- buildStarted = Interlocked.CompareExchange<BuildStartedEventHandler>(ref this.BuildStarted, handler3, handler2);
- }
- while (buildStarted != handler2);
- }
- }
-
- public event CustomBuildEventHandler CustomEventRaised
- {
- add
- {
- CustomBuildEventHandler handler2;
- CustomBuildEventHandler customEventRaised = this.CustomEventRaised;
- do
- {
- handler2 = customEventRaised;
- CustomBuildEventHandler handler3 = (CustomBuildEventHandler) Delegate.Combine(handler2, value);
- customEventRaised = Interlocked.CompareExchange<CustomBuildEventHandler>(ref this.CustomEventRaised, handler3, handler2);
- }
- while (customEventRaised != handler2);
- }
- remove
- {
- CustomBuildEventHandler handler2;
- CustomBuildEventHandler customEventRaised = this.CustomEventRaised;
- do
- {
- handler2 = customEventRaised;
- CustomBuildEventHandler handler3 = (CustomBuildEventHandler) Delegate.Remove(handler2, value);
- customEventRaised = Interlocked.CompareExchange<CustomBuildEventHandler>(ref this.CustomEventRaised, handler3, handler2);
- }
- while (customEventRaised != handler2);
- }
- }
-
- public event BuildErrorEventHandler ErrorRaised
- {
- add
- {
- BuildErrorEventHandler handler2;
- BuildErrorEventHandler errorRaised = this.ErrorRaised;
- do
- {
- handler2 = errorRaised;
- BuildErrorEventHandler handler3 = (BuildErrorEventHandler) Delegate.Combine(handler2, value);
- errorRaised = Interlocked.CompareExchange<BuildErrorEventHandler>(ref this.ErrorRaised, handler3, handler2);
- }
- while (errorRaised != handler2);
- }
- remove
- {
- BuildErrorEventHandler handler2;
- BuildErrorEventHandler errorRaised = this.ErrorRaised;
- do
- {
- handler2 = errorRaised;
- BuildErrorEventHandler handler3 = (BuildErrorEventHandler) Delegate.Remove(handler2, value);
- errorRaised = Interlocked.CompareExchange<BuildErrorEventHandler>(ref this.ErrorRaised, handler3, handler2);
- }
- while (errorRaised != handler2);
- }
- }
-
- public event BuildMessageEventHandler MessageRaised
- {
- add
- {
- BuildMessageEventHandler handler2;
- BuildMessageEventHandler messageRaised = this.MessageRaised;
- do
- {
- handler2 = messageRaised;
- BuildMessageEventHandler handler3 = (BuildMessageEventHandler) Delegate.Combine(handler2, value);
- messageRaised = Interlocked.CompareExchange<BuildMessageEventHandler>(ref this.MessageRaised, handler3, handler2);
- }
- while (messageRaised != handler2);
- }
- remove
- {
- BuildMessageEventHandler handler2;
- BuildMessageEventHandler messageRaised = this.MessageRaised;
- do
- {
- handler2 = messageRaised;
- BuildMessageEventHandler handler3 = (BuildMessageEventHandler) Delegate.Remove(handler2, value);
- messageRaised = Interlocked.CompareExchange<BuildMessageEventHandler>(ref this.MessageRaised, handler3, handler2);
- }
- while (messageRaised != handler2);
- }
- }
-
- public event ProjectFinishedEventHandler ProjectFinished
- {
- add
- {
- ProjectFinishedEventHandler handler2;
- ProjectFinishedEventHandler projectFinished = this.ProjectFinished;
- do
- {
- handler2 = projectFinished;
- ProjectFinishedEventHandler handler3 = (ProjectFinishedEventHandler) Delegate.Combine(handler2, value);
- projectFinished = Interlocked.CompareExchange<ProjectFinishedEventHandler>(ref this.ProjectFinished, handler3, handler2);
- }
- while (projectFinished != handler2);
- }
- remove
- {
- ProjectFinishedEventHandler handler2;
- ProjectFinishedEventHandler projectFinished = this.ProjectFinished;
- do
- {
- handler2 = projectFinished;
- ProjectFinishedEventHandler handler3 = (ProjectFinishedEventHandler) Delegate.Remove(handler2, value);
- projectFinished = Interlocked.CompareExchange<ProjectFinishedEventHandler>(ref this.ProjectFinished, handler3, handler2);
- }
- while (projectFinished != handler2);
- }
- }
-
- public event ProjectStartedEventHandler ProjectStarted
- {
- add
- {
- ProjectStartedEventHandler handler2;
- ProjectStartedEventHandler projectStarted = this.ProjectStarted;
- do
- {
- handler2 = projectStarted;
- ProjectStartedEventHandler handler3 = (ProjectStartedEventHandler) Delegate.Combine(handler2, value);
- projectStarted = Interlocked.CompareExchange<ProjectStartedEventHandler>(ref this.ProjectStarted, handler3, handler2);
- }
- while (projectStarted != handler2);
- }
- remove
- {
- ProjectStartedEventHandler handler2;
- ProjectStartedEventHandler projectStarted = this.ProjectStarted;
- do
- {
- handler2 = projectStarted;
- ProjectStartedEventHandler handler3 = (ProjectStartedEventHandler) Delegate.Remove(handler2, value);
- projectStarted = Interlocked.CompareExchange<ProjectStartedEventHandler>(ref this.ProjectStarted, handler3, handler2);
- }
- while (projectStarted != handler2);
- }
- }
-
- public event BuildStatusEventHandler StatusEventRaised
- {
- add
- {
- BuildStatusEventHandler handler2;
- BuildStatusEventHandler statusEventRaised = this.StatusEventRaised;
- do
- {
- handler2 = statusEventRaised;
- BuildStatusEventHandler handler3 = (BuildStatusEventHandler) Delegate.Combine(handler2, value);
- statusEventRaised = Interlocked.CompareExchange<BuildStatusEventHandler>(ref this.StatusEventRaised, handler3, handler2);
- }
- while (statusEventRaised != handler2);
- }
- remove
- {
- BuildStatusEventHandler handler2;
- BuildStatusEventHandler statusEventRaised = this.StatusEventRaised;
- do
- {
- handler2 = statusEventRaised;
- BuildStatusEventHandler handler3 = (BuildStatusEventHandler) Delegate.Remove(handler2, value);
- statusEventRaised = Interlocked.CompareExchange<BuildStatusEventHandler>(ref this.StatusEventRaised, handler3, handler2);
- }
- while (statusEventRaised != handler2);
- }
- }
-
- public event TargetFinishedEventHandler TargetFinished
- {
- add
- {
- TargetFinishedEventHandler handler2;
- TargetFinishedEventHandler targetFinished = this.TargetFinished;
- do
- {
- handler2 = targetFinished;
- TargetFinishedEventHandler handler3 = (TargetFinishedEventHandler) Delegate.Combine(handler2, value);
- targetFinished = Interlocked.CompareExchange<TargetFinishedEventHandler>(ref this.TargetFinished, handler3, handler2);
- }
- while (targetFinished != handler2);
- }
- remove
- {
- TargetFinishedEventHandler handler2;
- TargetFinishedEventHandler targetFinished = this.TargetFinished;
- do
- {
- handler2 = targetFinished;
- TargetFinishedEventHandler handler3 = (TargetFinishedEventHandler) Delegate.Remove(handler2, value);
- targetFinished = Interlocked.CompareExchange<TargetFinishedEventHandler>(ref this.TargetFinished, handler3, handler2);
- }
- while (targetFinished != handler2);
- }
- }
-
- public event TargetStartedEventHandler TargetStarted
- {
- add
- {
- TargetStartedEventHandler handler2;
- TargetStartedEventHandler targetStarted = this.TargetStarted;
- do
- {
- handler2 = targetStarted;
- TargetStartedEventHandler handler3 = (TargetStartedEventHandler) Delegate.Combine(handler2, value);
- targetStarted = Interlocked.CompareExchange<TargetStartedEventHandler>(ref this.TargetStarted, handler3, handler2);
- }
- while (targetStarted != handler2);
- }
- remove
- {
- TargetStartedEventHandler handler2;
- TargetStartedEventHandler targetStarted = this.TargetStarted;
- do
- {
- handler2 = targetStarted;
- TargetStartedEventHandler handler3 = (TargetStartedEventHandler) Delegate.Remove(handler2, value);
- targetStarted = Interlocked.CompareExchange<TargetStartedEventHandler>(ref this.TargetStarted, handler3, handler2);
- }
- while (targetStarted != handler2);
- }
- }
-
- public event TaskFinishedEventHandler TaskFinished
- {
- add
- {
- TaskFinishedEventHandler handler2;
- TaskFinishedEventHandler taskFinished = this.TaskFinished;
- do
- {
- handler2 = taskFinished;
- TaskFinishedEventHandler handler3 = (TaskFinishedEventHandler) Delegate.Combine(handler2, value);
- taskFinished = Interlocked.CompareExchange<TaskFinishedEventHandler>(ref this.TaskFinished, handler3, handl…
Large files files are truncated, but you can click here to view the full file