diff options
Diffstat (limited to 'main/src/core/MonoDevelop.Core')
15 files changed, 54 insertions, 52 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessHostController.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessHostController.cs index 536d9c3dd4..5b6df84f51 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessHostController.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessHostController.cs @@ -131,7 +131,7 @@ namespace MonoDevelop.Core.Execution cmd.DebugMode = isDebugMode; OperationConsole cons = console ?? new ProcessHostConsole (); var p = process = executionHandlerFactory.Execute (cmd, cons); - Counters.ExternalHostProcesses++; + Counters.ExternalHostProcesses.Inc (1); process.Task.ContinueWith ((t) => ProcessExited (p)); @@ -159,8 +159,8 @@ namespace MonoDevelop.Core.Execution { lock (this) { - Counters.ExternalHostProcesses--; - + Counters.ExternalHostProcesses.Dec (1); + // Remove all callbacks from existing objects foreach (object ob in remoteObjects) RemotingService.UnregisterMethodCallback (ob, "Dispose"); @@ -204,7 +204,7 @@ namespace MonoDevelop.Core.Execution RemotingService.RegisterMethodCallback (obj, "Dispose", RemoteProcessObjectDisposing, null); RemotingService.RegisterMethodCallback (obj, "Shutdown", RemoteProcessObjectShuttingDown, null); remoteObjects.Add (obj); - Counters.ExternalObjects++; + Counters.ExternalObjects.Inc (1); return obj; } catch { ReleaseInstance (null); @@ -234,7 +234,7 @@ namespace MonoDevelop.Core.Execution RemotingService.RegisterMethodCallback (obj, "Dispose", RemoteProcessObjectDisposing, null); RemotingService.RegisterMethodCallback (obj, "Shutdown", RemoteProcessObjectShuttingDown, null); remoteObjects.Add (obj); - Counters.ExternalObjects++; + Counters.ExternalObjects.Inc (1); return obj; } catch { ReleaseInstance (null); @@ -272,7 +272,7 @@ namespace MonoDevelop.Core.Execution public void ReleaseInstance (object proc, int shutdownTimeout) { - Counters.ExternalObjects--; + Counters.ExternalObjects.Dec (1); if (processHost == null) return; diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessService.cs index ca6db5972a..6e39a2368d 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessService.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessService.cs @@ -156,7 +156,7 @@ namespace MonoDevelop.Core.Execution // p.Exited += exited; // p.EnableRaisingEvents = true; - Counters.ProcessesStarted++; + Counters.ProcessesStarted.Inc (1); p.Start (); if (exited != null) @@ -212,7 +212,7 @@ namespace MonoDevelop.Core.Execution if (p != null) { if (exited != null) p.Task.ContinueWith (t => exited (p, EventArgs.Empty), Runtime.MainTaskScheduler); - Counters.ProcessesStarted++; + Counters.ProcessesStarted.Inc (1); return p; } else { LoggingService.LogError ("Could not create external console for command: " + command + " " + arguments); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessWrapper.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessWrapper.cs index f6d15c43bf..635c056507 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessWrapper.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessWrapper.cs @@ -44,11 +44,11 @@ namespace MonoDevelop.Core.Execution // We need these wrappers, as the alternatives are not good enough. // OutputDataReceived does not persist newlines. if (OutputStreamChanged != null) { - Task.Run (CaptureOutput, cs.Token); + Task.Run (CaptureOutput, cs.Token).Ignore (); } if (ErrorStreamChanged != null) { - Task.Run (CaptureError, cs.Token); + Task.Run (CaptureError, cs.Token).Ignore (); } operation = new ProcessAsyncOperation (Task, cs) { diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FileService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FileService.cs index 4158d36ccf..4aca642c0a 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FileService.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FileService.cs @@ -805,9 +805,9 @@ namespace MonoDevelop.Core { foreach (FileEventInfo fi in args) { if (fi.IsDirectory) - Counters.DirectoriesCreated++; + Counters.DirectoriesCreated.Inc (1); else - Counters.FilesCreated++; + Counters.FilesCreated.Inc (1); } eventQueue.RaiseEvent (EventDataKind.Created, args); @@ -830,9 +830,9 @@ namespace MonoDevelop.Core { foreach (FileEventInfo fi in args) { if (fi.IsDirectory) - Counters.DirectoriesRenamed++; + Counters.DirectoriesRenamed.Inc (1); else - Counters.FilesRenamed++; + Counters.FilesRenamed.Inc (1); } eventQueue.RaiseEvent (EventDataKind.Renamed, args); @@ -843,9 +843,9 @@ namespace MonoDevelop.Core { foreach (FileEventInfo fi in args) { if (fi.IsDirectory) - Counters.DirectoriesRemoved++; + Counters.DirectoriesRemoved.Inc (1); else - Counters.FilesRemoved++; + Counters.FilesRemoved.Inc (1); } eventQueue.RaiseEvent (EventDataKind.Removed, args); @@ -854,7 +854,7 @@ namespace MonoDevelop.Core public static event EventHandler<FileEventArgs> FileChanged; static void OnFileChanged (FileEventArgs args) { - Counters.FileChangeNotifications++; + Counters.FileChangeNotifications.Inc (1); eventQueue.RaiseEvent (EventDataKind.Changed, args); } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/IProgressMonitor.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/IProgressMonitor.cs index 8f728d8422..b1a4aa1853 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/IProgressMonitor.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/IProgressMonitor.cs @@ -44,11 +44,11 @@ namespace MonoDevelop.Core public class AsyncOperation { - public static AsyncOperation CompleteOperation = new AsyncOperation (Task.FromResult(0), null); + public static AsyncOperation CompleteOperation = new AsyncOperation (Task.CompletedTask, null); protected AsyncOperation () { - Task = Task.FromResult (0); + Task = Task.CompletedTask; CancellationTokenSource = new CancellationTokenSource (); } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/CompiledAssemblyProject.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/CompiledAssemblyProject.cs index 4bb348eddc..e506fd1cd4 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/CompiledAssemblyProject.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/CompiledAssemblyProject.cs @@ -201,7 +201,7 @@ namespace MonoDevelop.Projects internal protected override Task OnSave (ProgressMonitor monitor) { // Compiled assemblies can't be saved - return Task.FromResult (0); + return Task.CompletedTask; } } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ConditionedPropertyCollection.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ConditionedPropertyCollection.cs index ec1c010046..bd43f395e7 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ConditionedPropertyCollection.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ConditionedPropertyCollection.cs @@ -33,8 +33,8 @@ namespace MonoDevelop.Projects { public class ConditionedPropertyCollection { - Dictionary<string, ImmutableList<string>> props = new Dictionary<string, ImmutableList<string>> (); - Dictionary<KeySet, ImmutableList<ValueSet>> combinedProps = new Dictionary<KeySet, ImmutableList<ValueSet>> (StructEqualityComparer<KeySet>.Instance); + Dictionary<string, ImmutableArray<string>> props = new Dictionary<string, ImmutableArray<string>> (); + Dictionary<KeySet, ImmutableArray<ValueSet>> combinedProps = new Dictionary<KeySet, ImmutableArray<ValueSet>> (StructEqualityComparer<KeySet>.Instance); /// <summary> /// A set of strings, which can be compared to other sets ignoring the order. @@ -178,14 +178,14 @@ namespace MonoDevelop.Projects foreach (var e in other.props) { var otherList = e.Value; var key = e.Key; - ImmutableList<string> list; + ImmutableArray<string> list; if (props.TryGetValue (key, out list)) { var lb = list.ToBuilder (); foreach (var c in otherList) { if (!lb.Contains (c)) lb.Add (c); } - props [key] = lb.ToImmutableList (); + props [key] = lb.ToImmutable (); } else props [key] = otherList; } @@ -193,7 +193,7 @@ namespace MonoDevelop.Projects foreach (var e in other.combinedProps) { var otherList = e.Value; var key = e.Key; - ImmutableList<ValueSet> thisList; + ImmutableArray<ValueSet> thisList; if (combinedProps.TryGetValue (key, out thisList)) { var list = thisList.ToBuilder (); foreach (var c in otherList) { @@ -210,13 +210,13 @@ namespace MonoDevelop.Projects internal void AddPropertyValues (IList<string> names, IList<string> values) { var key = new KeySet (names); - ImmutableList<ValueSet> list; + ImmutableArray<ValueSet> list; ValueSet valueSet; // First register the combination of values if (!combinedProps.TryGetValue (key, out list)) { - list = ImmutableList<ValueSet>.Empty; + list = ImmutableArray<ValueSet>.Empty; valueSet = new ValueSet (names, names, values); } else { // If there is already a list, there must be at least one item. @@ -229,12 +229,12 @@ namespace MonoDevelop.Projects // Now register each value individually - ImmutableList<string> valList; + ImmutableArray<string> valList; for (int n = 0; n < names.Count; n++) { var name = names [n]; var val = values [n]; if (!props.TryGetValue (name, out valList)) - valList = ImmutableList<string>.Empty; + valList = ImmutableArray<string>.Empty; if (!valList.Contains (val)) props[name] = valList.Add (val); } @@ -252,12 +252,12 @@ namespace MonoDevelop.Projects /// <summary> /// Gets the values used in conditions for the given property /// </summary> - public ImmutableList<string> GetAllPropertyValues (string property) + public ImmutableArray<string> GetAllPropertyValues (string property) { - ImmutableList<string> list; + ImmutableArray<string> list; if (props.TryGetValue (property, out list)) return list; - return ImmutableList<string>.Empty; + return ImmutableArray<string>.Empty; } /// <summary> @@ -266,12 +266,12 @@ namespace MonoDevelop.Projects /// Platform, it will return values for those properties specified in conditions that reference both /// Configuration and Platform. /// </summary> - public ImmutableList<ValueSet> GetCombinedPropertyValues (params string[] properties) + public ImmutableArray<ValueSet> GetCombinedPropertyValues (params string[] properties) { - ImmutableList<ValueSet> list; + ImmutableArray<ValueSet> list; if (combinedProps.TryGetValue (new KeySet (properties), out list)) return list; - return ImmutableList<ValueSet>.Empty; + return ImmutableArray<ValueSet>.Empty; } } } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/FileWatcherService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/FileWatcherService.cs index c2bf45fd01..b438d3e13d 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/FileWatcherService.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/FileWatcherService.cs @@ -585,7 +585,8 @@ namespace MonoDevelop.Projects // the original file still exists.
if (File.Exists (e.OldFullPath))
FileService.NotifyFileChanged (e.OldFullPath);
- else
+ // Handle odd file watcher events which look like a folder being renamed to a file.
+ else if (!Directory.Exists (e.OldFullPath))
FileService.NotifyFileRemoved (e.OldFullPath);
}
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs index fcd55fd427..deb72f980d 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs @@ -2433,9 +2433,9 @@ namespace MonoDevelop.Projects ProjectConfiguration config = GetConfiguration (configuration) as ProjectConfiguration; if (config == null) monitor.ReportError (GettextCatalog.GetString ("Configuration '{0}' not found in project '{1}'", configuration, Name), null); - return Task.FromResult (0); + return Task.CompletedTask; } - + /// <summary> /// Gets the absolute path to the output file generated by this project. /// </summary> @@ -2971,7 +2971,7 @@ namespace MonoDevelop.Projects // Now add configurations for which a platform has not been specified, but only if no other configuration // exists with the same name. Combine them with individually specified platforms, if available foreach (var c in confValues.Select (v => v.GetValue ("Configuration"))) { - if (platValues.Count > 0) { + if (platValues.Length > 0) { foreach (var plat in platValues.Select (v => v.GetValue ("Platform"))) { var ep = plat == "AnyCPU" ? "" : plat; if (!configData.Any (cd => cd.Config == c && cd.Platform == ep)) diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SdkProjectReader.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SdkProjectReader.cs index 2d42a1576f..3a5273948a 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SdkProjectReader.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SdkProjectReader.cs @@ -65,7 +65,8 @@ namespace MonoDevelop.Projects // 2) An Sdk node as a child of the Project node // 3) An Sdk attribute on any Import node var document = new XmlDocument (); - document.Load (new StreamReader (file)); + using (var sr = new StreamReader (file)) + document.Load (sr); XmlNode projectNode = document.SelectSingleNode ("/Project"); if (projectNode != null) { XmlAttribute sdkAttr = projectNode.Attributes ["Sdk"]; diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Solution.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Solution.cs index 4e87f0af31..5986e425e5 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Solution.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Solution.cs @@ -80,7 +80,7 @@ namespace MonoDevelop.Projects internal Solution (bool loading) { loadingFromConstructor = loading; - Counters.SolutionsLoaded++; + Counters.SolutionsLoaded.Inc (1); configurations = new SolutionConfigurationCollection (this); runConfigurations = new MultiItemSolutionRunConfigurationCollection (this); format = MSBuildFileFormat.DefaultFormat; @@ -592,7 +592,7 @@ namespace MonoDevelop.Projects // Dispose the root folder after we dispose the base item, as we need the root folder // to contain the items when unregistering from the file watcher service. RootFolder.Dispose (); - Counters.SolutionsLoaded--; + Counters.SolutionsLoaded.Dec (1); } internal bool IsSolutionItemEnabled (string solutionItemPath) @@ -925,7 +925,7 @@ namespace MonoDevelop.Projects /*protected virtual*/ Task OnPrepareExecution (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, SolutionRunConfiguration runConfiguration) { - return Task.FromResult (0); + return Task.CompletedTask; } /*protected virtual*/ void OnStartupItemChanged(EventArgs e) diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionFolder.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionFolder.cs index 725a7b2cf3..0047fd2b8d 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionFolder.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionFolder.cs @@ -399,7 +399,7 @@ namespace MonoDevelop.Projects public Task Execute (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration) { - return Task.FromResult (false); + return Task.CompletedTask; } public bool CanExecute (ExecutionContext context, ConfigurationSelector configuration) @@ -409,7 +409,7 @@ namespace MonoDevelop.Projects public Task PrepareExecution (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration) { - return Task.FromResult (false); + return Task.CompletedTask; } // note: although executing folders isn't supported, this may still get called when diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionItem.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionItem.cs index d3296fdee1..1cb0bdf6bc 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionItem.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionItem.cs @@ -85,7 +85,7 @@ namespace MonoDevelop.Projects configurations = new SolutionItemConfigurationCollection (this); configurations.ConfigurationAdded += OnConfigurationAddedToCollection; configurations.ConfigurationRemoved += OnConfigurationRemovedFromCollection; - Counters.ItemsLoaded++; + Counters.ItemsLoaded.Inc (1); fileStatusTracker = new FileStatusTracker<SolutionItemEventArgs> (this, OnReloadRequired, new SolutionItemEventArgs (this)); } @@ -123,7 +123,7 @@ namespace MonoDevelop.Projects fileStatusTracker.Dispose (); base.OnDispose (); - Counters.ItemsLoaded--; + Counters.ItemsLoaded.Dec (1); // items = null; // wildcardItems = null; @@ -1080,7 +1080,7 @@ namespace MonoDevelop.Projects [Obsolete ("Use overload that takes a RunConfiguration")] protected virtual Task OnExecute (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration) { - return Task.FromResult (0); + return Task.CompletedTask; } /// <summary> @@ -1105,7 +1105,7 @@ namespace MonoDevelop.Projects [Obsolete ("Use overload that takes a RunConfiguration")] protected virtual Task OnPrepareExecution (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration) { - return Task.FromResult (true); + return Task.CompletedTask; } bool DoGetCanExecute (ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration) diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/UnknownSolutionItem.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/UnknownSolutionItem.cs index e718d5e03c..e89aa6476e 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/UnknownSolutionItem.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/UnknownSolutionItem.cs @@ -101,7 +101,7 @@ namespace MonoDevelop.Projects protected internal override Task OnSave (ProgressMonitor monitor) { - return Task.FromResult (0); + return Task.CompletedTask; } } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItem.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItem.cs index dafbe867f6..2927163932 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItem.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItem.cs @@ -280,7 +280,7 @@ namespace MonoDevelop.Projects protected internal virtual Task OnSave (ProgressMonitor monitor) { - return Task.FromResult (0); + return Task.CompletedTask; } public virtual bool NeedsReload { @@ -330,7 +330,7 @@ namespace MonoDevelop.Projects { Loading = false; fileStatusTracker.ResetLoadTimes (); - return Task.FromResult (true); + return Task.CompletedTask; } /// <summary> |