diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2015-06-19 17:06:53 +0300 |
---|---|---|
committer | Lluis Sanchez <lluis@xamarin.com> | 2015-06-19 17:06:53 +0300 |
commit | e6bf0121b395f0349a3e5aa67943e80a44a579ff (patch) | |
tree | f0a14b790924860071db0c36d92ac09ecb3ad6c2 /main/src/core/MonoDevelop.Core | |
parent | 47245b71203ae5f44060a85d4c82ff1467e4adcd (diff) | |
parent | 87c3bf130bacf7abec302da2622d2a38435c9f09 (diff) |
Merge branch 'roslyn' into roslyn-noxml
Diffstat (limited to 'main/src/core/MonoDevelop.Core')
16 files changed, 146 insertions, 66 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/SystemAssemblyService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/SystemAssemblyService.cs index a03241af68..5ff18e93e6 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/SystemAssemblyService.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/SystemAssemblyService.cs @@ -36,6 +36,7 @@ using MonoDevelop.Core.AddIns; using Mono.Addins; using System.Reflection; using System.Linq; +using System.Collections.Immutable; namespace MonoDevelop.Core.Assemblies { @@ -415,22 +416,37 @@ namespace MonoDevelop.Core.Assemblies } } + static ImmutableDictionary<string, bool> referenceDict = ImmutableDictionary<string, bool>.Empty; + static object referenceLock = new object (); + public static bool ContainsReferenceToSystemRuntime (string fileName) { - using (var universe = new IKVM.Reflection.Universe ()) { - IKVM.Reflection.Assembly assembly; - try { - assembly = universe.LoadFile (fileName); - } catch { - return false; - } - foreach (var r in assembly.GetReferencedAssemblies ()) { - if (r.FullName.Equals ("System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")) - return true; + lock (referenceLock) { + bool result; + if (referenceDict.TryGetValue (fileName, out result)) + return result; + + //const int cacheLimit = 4096; + //if (referenceDict.Count > cacheLimit) + // referenceDict = ImmutableDictionary<string, bool>.Empty + + using (var universe = new IKVM.Reflection.Universe ()) { + IKVM.Reflection.Assembly assembly; + try { + assembly = universe.LoadFile (fileName); + } catch { + return false; + } + foreach (var r in assembly.GetReferencedAssemblies ()) { + if (r.FullName.Equals ("System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")) { + referenceDict = referenceDict.SetItem (fileName, true); + return true; + } + } } + referenceDict = referenceDict.SetItem (fileName, false); + return false; } - - return false; } public class ManifestResource 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 26f021697f..9ef65cd766 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessService.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessService.cs @@ -211,7 +211,7 @@ namespace MonoDevelop.Core.Execution if (p != null) { if (exited != null) - p.Task.ContinueWith (t => exited (p, EventArgs.Empty), TaskScheduler.FromCurrentSynchronizationContext ()); + p.Task.ContinueWith (t => exited (p, EventArgs.Empty), Runtime.MainTaskScheduler); Counters.ProcessesStarted++; return p; } else { diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Instrumentation/Counter.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Instrumentation/Counter.cs index 6d5ecc8370..26f173eb98 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Instrumentation/Counter.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Instrumentation/Counter.cs @@ -82,7 +82,12 @@ namespace MonoDevelop.Core.Instrumentation this.name = name; this.category = category; } - + + public override string ToString () + { + return string.Format ("[Counter: Name={0}, Enabled={1}, Id={2}, Category={3}, Count={4}, TotalCount={5}, LastValue={6}]", Name, Enabled, Id, Category, Count, TotalCount, LastValue); + } + public string Name { get { return name; } } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Instrumentation/TimerCounter.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Instrumentation/TimerCounter.cs index 8b785bbe21..308e2b91fd 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Instrumentation/TimerCounter.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Instrumentation/TimerCounter.cs @@ -43,7 +43,12 @@ namespace MonoDevelop.Core.Instrumentation public TimerCounter (string name, CounterCategory category): base (name, category) { } - + + public override string ToString () + { + return string.Format ("[TimerCounter: Name={0} Id={1} Category={2} MinSeconds={3}, TotalTime={4}, AverageTime={5}, MinTime={6}, MaxTime={7}, CountWithDuration={8}]",Name, Id, Category, MinSeconds, TotalTime, AverageTime, MinTime, MaxTime, CountWithDuration); + } + public double MinSeconds { get { return this.minSeconds; } set { this.minSeconds = value; } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj index 0a160d88a6..a15b61e8bc 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj @@ -98,18 +98,6 @@ </Reference> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Web" /> - <Reference Include="System.Collections.Immutable"> - <HintPath>..\..\..\packages\System.Collections.Immutable.1.1.33-beta\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath> - </Reference> - <Reference Include="System.Reflection.Metadata"> - <HintPath>..\..\..\packages\System.Reflection.Metadata.1.0.18-beta\lib\portable-net45+win8\System.Reflection.Metadata.dll</HintPath> - </Reference> - <Reference Include="Microsoft.CodeAnalysis.Desktop"> - <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.Common.1.0.0-rc2\lib\net45\Microsoft.CodeAnalysis.Desktop.dll</HintPath> - </Reference> - <Reference Include="Microsoft.CodeAnalysis"> - <HintPath>..\..\..\packages\Microsoft.CodeAnalysis.Common.1.0.0-rc2\lib\net45\Microsoft.CodeAnalysis.dll</HintPath> - </Reference> <Reference Include="System.ServiceModel" /> <Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.Build.Engine" /> @@ -117,6 +105,19 @@ <Reference Include="Microsoft.Build.Utilities.v12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <Reference Include="Newtonsoft.Json"> <HintPath>..\..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="System.Reflection.Metadata"> + <HintPath>..\..\..\external\roslyn\Binaries\Debug\System.Reflection.Metadata.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="System.Collections.Immutable"> + <HintPath>..\..\..\external\roslyn\Binaries\Debug\System.Collections.Immutable.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="Microsoft.CodeAnalysis"> + <HintPath>..\..\..\external\roslyn\Binaries\Debug\Microsoft.CodeAnalysis.dll</HintPath> + <Private>False</Private> </Reference> </ItemGroup> <ItemGroup> diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs index 3f86abb1a8..e411f5ee06 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs @@ -95,7 +95,7 @@ namespace MonoDevelop.Core try { buffer = Marshal.AllocHGlobal (PATHMAX); var result = realpath (this, buffer); - return result == IntPtr.Zero ? this : (FilePath) Marshal.PtrToStringAuto (buffer); + return result == IntPtr.Zero ? Path.GetFullPath (this) : Marshal.PtrToStringAuto (buffer); } finally { if (buffer != IntPtr.Zero) Marshal.FreeHGlobal (buffer); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/MacSystemInformation.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/MacSystemInformation.cs index 1579d1ccb8..b6a408ab91 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/MacSystemInformation.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/MacSystemInformation.cs @@ -30,6 +30,7 @@ namespace MonoDevelop.Core { public class MacSystemInformation : UnixSystemInformation { + public static readonly Version ElCapitan = new Version (10, 11); public static readonly Version Yosemite = new Version (10, 10); public static readonly Version Mavericks = new Version (10, 9); public static readonly Version MountainLion = new Version (10, 8); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/SystemInformation.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/SystemInformation.cs index 3dcf1648d3..69e83d4d0b 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/SystemInformation.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/SystemInformation.cs @@ -148,6 +148,13 @@ namespace MonoDevelop.Core } return sb.ToString (); } + + public static string GetOperatingSystemDescription () + { + var sb = new StringBuilder (); + Instance.AppendOperatingSystem (sb); + return sb.ToString ().Trim (); + } } class SystemInformationSection: ISystemInformationProvider diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/SlnFileFormat.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/SlnFileFormat.cs index 78bb9753e5..1d577e27c3 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/SlnFileFormat.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/SlnFileFormat.cs @@ -203,7 +203,7 @@ namespace MonoDevelop.Projects.Formats.MSBuild void WriteProjects (SolutionFolder folder, SlnFile sln, ProgressMonitor monitor, HashSet<string> unknownProjects) { monitor.BeginTask (folder.Items.Count); - foreach (SolutionFolderItem ce in folder.Items) + foreach (SolutionFolderItem ce in folder.Items.ToArray ()) { monitor.BeginStep (); if (ce is SolutionItem) { diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/CustomCommand.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/CustomCommand.cs index ffc8cde872..882b8c9205 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/CustomCommand.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/CustomCommand.cs @@ -99,6 +99,24 @@ namespace MonoDevelop.Projects get { return pauseExternalConsole; } set { pauseExternalConsole = value; } } + + public string TypeLabel { + get { + switch (type) { + case CustomCommandType.BeforeBuild: return GettextCatalog.GetString ("Before Build"); + case CustomCommandType.Build: return GettextCatalog.GetString ("Build"); + case CustomCommandType.AfterBuild: return GettextCatalog.GetString ("After Build"); + case CustomCommandType.BeforeExecute: return GettextCatalog.GetString ("Before Execute"); + case CustomCommandType.Execute: return GettextCatalog.GetString ("Execute"); + case CustomCommandType.AfterExecute: return GettextCatalog.GetString ("After Execute"); + case CustomCommandType.BeforeClean: return GettextCatalog.GetString ("Before Clean"); + case CustomCommandType.Clean: return GettextCatalog.GetString ("Clean"); + case CustomCommandType.AfterClean: return GettextCatalog.GetString ("After Clean"); + case CustomCommandType.Custom: return GettextCatalog.GetString ("Custom Command"); + default: return type.ToString (); + } + } + } public string GetCommandFile (WorkspaceObject entry, ConfigurationSelector configuration) { @@ -176,6 +194,8 @@ namespace MonoDevelop.Projects public ProcessExecutionCommand CreateExecutionCommand (WorkspaceObject entry, ConfigurationSelector configuration) { + if (string.IsNullOrEmpty (command)) + throw new UserException (GettextCatalog.GetString ("Invalid custom command for '{0}' step: the path to the command to execute has not been provided.", TypeLabel)); string exe, args; StringTagModel tagSource = GetTagModel (entry, configuration); ParseCommand (tagSource, out exe, out args); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs index be5f9611a2..a7478512fd 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs @@ -532,7 +532,7 @@ namespace MonoDevelop.Projects get { return LanguageBinding.SupportsPartialTypes; } } - void CheckReferenceChange (FilePath updatedFile) + async void CheckReferenceChange (FilePath updatedFile) { for (int n=0; n<References.Count; n++) { ProjectReference pr = References [n]; @@ -545,6 +545,13 @@ namespace MonoDevelop.Projects References [n] = nr; } } + + // If a referenced assembly changes, dirtify the project. + foreach (var asm in await GetReferencedAssemblies (DefaultConfiguration.Selector)) + if (asm == updatedFile) { + SetFastBuildCheckDirty (); + break; + } } internal override void OnFileChanged (object source, MonoDevelop.Core.FileEventArgs e) @@ -1043,6 +1050,17 @@ namespace MonoDevelop.Projects return (compileTarget == CompileTarget.Exe || compileTarget == CompileTarget.WinExe) && context.ExecutionHandler.CanExecute (cmd); } + protected override ProjectFeatures OnGetSupportedFeatures () + { + var sf = base.OnGetSupportedFeatures (); + + // Libraries are not executable by default, unless the project has a custom execution command + if (compileTarget == CompileTarget.Library && !Configurations.OfType<ProjectConfiguration> ().Any (c => c.CustomCommands.HasCommands (CustomCommandType.Execute))) + sf &= ~ProjectFeatures.Execute; + + return sf; + } + protected override IEnumerable<FilePath> OnGetItemFiles (bool includeReferencedFiles) { var baseFiles = base.OnGetItemFiles (includeReferencedFiles); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ItemCollection.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ItemCollection.cs index 8a23f51772..cc38755f4b 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ItemCollection.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ItemCollection.cs @@ -37,7 +37,6 @@ namespace MonoDevelop.Projects { ImmutableList<T> list = ImmutableList<T>.Empty; bool controlWrites; - T[] singleItem = new T[1]; protected ImmutableList<T> List { get { @@ -62,8 +61,7 @@ namespace MonoDevelop.Projects public void Add (T item) { list = list.Add (item); - singleItem [0] = item; - OnItemsAdded (singleItem); + OnItemsAdded (new [] { item }); } public void AddRange (IEnumerable<T> items) @@ -76,8 +74,7 @@ namespace MonoDevelop.Projects public void Insert (int index, T item) { list = list.Insert (index, item); - singleItem [0] = item; - OnItemsAdded (singleItem); + OnItemsAdded (new [] { item }); } public void RemoveRange (IEnumerable<T> items) @@ -104,8 +101,7 @@ namespace MonoDevelop.Projects AssertCanWrite (); T it = list [index]; list = list.RemoveAt (index); - singleItem [0] = it; - OnItemsRemoved (singleItem); + OnItemsRemoved (new [] { it }); } public int IndexOf (T item) @@ -126,10 +122,8 @@ namespace MonoDevelop.Projects AssertCanWrite (); T it = list [index]; list = list.SetItem (index, value); - singleItem [0] = it; - OnItemsRemoved (singleItem); - singleItem [0] = value; - OnItemsAdded (singleItem); + OnItemsRemoved (new [] { it }); + OnItemsAdded (new [] { value }); } } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs index 29dee1a69f..7ab749ad87 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs @@ -740,9 +740,23 @@ namespace MonoDevelop.Projects return new TargetEvaluationResult (BuildResult.CreateSuccess ().SetSource (this)); } } - var tr = await OnRunTarget (monitor, target, configuration, context); - tr.BuildResult.SourceTarget = this; - return tr; + + // Collect last write times for the files generated by this project + var fileTimes = new Dictionary<FilePath, DateTime> (); + foreach (var f in GetOutputFiles (configuration)) + fileTimes [f] = File.GetLastWriteTime (f); + + try { + var tr = await OnRunTarget (monitor, target, configuration, context); + tr.BuildResult.SourceTarget = this; + return tr; + } finally { + // If any of the project generated files changes, notify it + foreach (var e in fileTimes) { + if (File.GetLastWriteTime (e.Key) != e.Value) + FileService.NotifyFileChanged (e.Key); + } + } } async Task<TargetEvaluationResult> RunMSBuildTarget (ProgressMonitor monitor, string target, ConfigurationSelector configuration, TargetEvaluationContext context) diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectService.cs index 9697044eb1..48e87d4b86 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectService.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectService.cs @@ -407,7 +407,7 @@ namespace MonoDevelop.Projects if (DataContextChanged != null) DataContextChanged (this, EventArgs.Empty); } - + string GetTargetFile (string file) { if (!Platform.IsWindows) { diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItem.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItem.cs index 78de451769..006066309e 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItem.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItem.cs @@ -343,21 +343,23 @@ namespace MonoDevelop.Projects await Task.Run (() => { if (!File.Exists (preferencesFileName)) return; - - XmlTextReader reader = new XmlTextReader (preferencesFileName); - try { - reader.MoveToContent (); - if (reader.LocalName != "Properties") - return; - XmlDataSerializer ser = new XmlDataSerializer (new DataContext ()); - ser.SerializationContext.BaseFile = preferencesFileName; - userProperties = (PropertyBag)ser.Deserialize (reader, typeof(PropertyBag)); - } catch (Exception e) { - LoggingService.LogError ("Exception while loading user solution preferences.", e); - return; - } finally { - reader.Close (); + using (var streamReader = new StreamReader (preferencesFileName)) { + XmlTextReader reader = new XmlTextReader (streamReader); + try { + reader.MoveToContent (); + if (reader.LocalName != "Properties") + return; + + XmlDataSerializer ser = new XmlDataSerializer (new DataContext ()); + ser.SerializationContext.BaseFile = preferencesFileName; + userProperties = (PropertyBag)ser.Deserialize (reader, typeof(PropertyBag)); + } catch (Exception e) { + LoggingService.LogError ("Exception while loading user solution preferences.", e); + return; + } finally { + reader.Close (); + } } }); } diff --git a/main/src/core/MonoDevelop.Core/packages.config b/main/src/core/MonoDevelop.Core/packages.config index 5ef4dda39d..f96fb6d64f 100644 --- a/main/src/core/MonoDevelop.Core/packages.config +++ b/main/src/core/MonoDevelop.Core/packages.config @@ -1,8 +1,5 @@ -<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="Microsoft.CodeAnalysis.Common" version="1.0.0-rc2" targetFramework="net45" />
- <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
- <package id="System.Collections.Immutable" version="1.1.33-beta" targetFramework="net45" />
- <package id="System.Reflection.Metadata" version="1.0.18-beta" targetFramework="net45" />
- <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
+<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" /> + <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" /> </packages>
\ No newline at end of file |