Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: icsharpcode/SharpDevelop
...
head fork: icsharpcode/SharpDevelop
  • 2 commits
  • 24 files changed
  • 0 commit comments
  • 1 contributor
Commits on May 18, 2012
@dgrunwald dgrunwald Add "Portable Library" project template. e454861
Commits on May 24, 2012
@dgrunwald dgrunwald Use "ResolveReferences" instead of "ResolveAssemblyReferences" for Po…
…rtable Library projects.

This makes the default references (System.Linq.dll etc.) available in code completion (previously we were only showing types from mscorlib)
305c991
Showing with 441 additions and 98 deletions.
  1. +27 −0 data/templates/project/CSharp/PortableAssemblyInfo.cs
  2. +54 −0 data/templates/project/CSharp/PortableLibrary.xpt
  3. +3 −1 src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
  4. +5 −0 src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  5. +18 −16 src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs
  6. +10 −0 src/Main/Base/Project/Src/Project/AbstractProject.cs
  7. +38 −0 src/Main/Base/Project/Src/Project/Behaviors/DotNetStartBehavior.cs
  8. +23 −0 src/Main/Base/Project/Src/Project/Behaviors/ProjectBehavior.cs
  9. +12 −27 src/Main/Base/Project/Src/Project/Behaviors/ProjectBehaviorSupportedConditionEvaluator.cs
  10. +7 −27 src/Main/Base/Project/Src/Project/CompilableProject.cs
  11. +6 −0 src/Main/Base/Project/Src/Project/Converter/IUpgradableProject.cs
  12. +20 −24 src/Main/Base/Project/Src/Project/Converter/UpgradeView.xaml.cs
  13. +3 −0  src/Main/Base/Project/Src/Project/IProject.cs
  14. +14 −1 src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
  15. +14 −2 src/Main/Base/Project/Src/Project/MSBuildInternals.cs
  16. +5 −0 src/Main/Base/Project/Src/Project/MissingProject.cs
  17. +38 −0 src/Main/Base/Project/Src/Project/PortableLibrary/PortableLibraryProjectBehavior.cs
  18. +45 −0 src/Main/Base/Project/Src/Project/PortableLibrary/Profile.cs
  19. +36 −0 src/Main/Base/Project/Src/Project/PortableLibrary/SupportedFramework.cs
  20. +1 −0  src/Main/Base/Project/Src/Project/Solution/Project_TypeGuids.cs
  21. +6 −0 src/Main/Base/Project/Src/Project/TargetFramework.cs
  22. +5 −0 src/Main/Base/Project/Src/Project/UnknownProject.cs
  23. +6 −0 src/Main/Base/Project/Src/Util/ExtensionMethods.cs
  24. +45 −0 src/Main/Base/Project/Src/Util/KeyComparer.cs
View
27 data/templates/project/CSharp/PortableAssemblyInfo.cs
@@ -0,0 +1,27 @@
+#region Using directives
+
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+#endregion
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("${ProjectName}")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("${ProjectName}")]
+[assembly: AssemblyCopyright("Copyright ${DATE:yyyy}")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all the values or you can use the default the Revision and
+// Build Numbers by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.*")]
View
54 data/templates/project/CSharp/PortableLibrary.xpt
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<Template originator = "Daniel Grunwald" created = "05/17/2012">
+
+ <!-- Template Header -->
+ <TemplateConfiguration>
+ <Name>Portable Library</Name>
+ <Category>C#</Category>
+ <Icon>C#.Project.Library</Icon>
+ <Description>Library that can be used on Windows, Silverlight, Windows Phone, and Xbox.</Description>
+ </TemplateConfiguration>
+
+ <!-- Actions -->
+ <Actions>
+ <Open filename = "MyClass.cs"/>
+ </Actions>
+
+ <!-- Template Content -->
+ <Project language="C#">
+ <PropertyGroup>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>Profile1</TargetFrameworkProfile>
+ </PropertyGroup>
+
+ <PropertyGroup escapeValue="False">
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ </PropertyGroup>
+
+ <ProjectItems />
+
+ <Imports clear="True">
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
+ </Imports>
+
+ <Files>
+ <File name="MyClass.cs"><![CDATA[${StandardHeader.C#}
+using System;
+using System.Collections.Generic;
+
+namespace ${StandardNamespace}
+{
+ /// <summary>
+ /// Description of MyClass.
+ /// </summary>
+ public class MyClass
+ {
+
+ }
+}]]></File>
+ <File name="Properties\AssemblyInfo.cs" src="PortableAssemblyInfo.cs"/>
+ </Files>
+ </Project>
+</Template>
View
4 src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
@@ -2362,6 +2362,8 @@
</Path>
<Path name = "/SharpDevelop/Workbench/ProjectBehaviors">
-
+ <Condition name="ProjectBehaviorSupported" guid="{786C830F-07A1-408B-BD7F-6EE04809D6DB}">
+ <Class id="PortableLibraryBehavior" class="ICSharpCode.SharpDevelop.Project.PortableLibrary.PortableLibraryProjectBehavior" />
+ </Condition>
</Path>
</AddIn>
View
5 src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
@@ -379,6 +379,9 @@
<Compile Include="Src\Project\MSBuildEngine\WorkerProcess.cs" />
<Compile Include="Src\Project\MSBuildFileProject.cs" />
<Compile Include="Src\Project\MSBuildItemWrapper.cs" />
+ <Compile Include="Src\Project\PortableLibrary\PortableLibraryProjectBehavior.cs" />
+ <Compile Include="Src\Project\PortableLibrary\Profile.cs" />
+ <Compile Include="Src\Project\PortableLibrary\SupportedFramework.cs" />
<Compile Include="Src\Project\ProjectChangeWatcher.cs" />
<Compile Include="Src\Project\ProjectLoadInformation.cs" />
<Compile Include="Src\Project\ProjectStartException.cs" />
@@ -808,6 +811,7 @@
<Compile Include="Src\Services\ProjectService\ProjectLoader.cs" />
<Compile Include="Src\Util\DotnetDetection.cs" />
<Compile Include="Src\Util\FakeXmlViewContent.cs" />
+ <Compile Include="Src\Util\KeyComparer.cs" />
<Compile Include="Src\Util\ReactiveExtensions.cs" />
<Compile Include="Src\Util\TreeNode.cs" />
<Compile Include="Src\Util\NativeMethods.cs" />
@@ -928,6 +932,7 @@
</ProjectReference>
<Folder Include="Src\Gui\Dialogs\ReferenceDialog\ServiceReference" />
<Folder Include="Src\Project\Behaviors" />
+ <Folder Include="Src\Project\PortableLibrary" />
<Folder Include="themes" />
<Folder Include="Src\Bookmarks\Pad\Controls" />
<Folder Include="Src\Editor\AvalonEdit" />
View
34 src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs
@@ -422,6 +422,24 @@ public IProject CreateProject(ProjectCreateInformation projectCreateInformation,
}
}
+ // Add properties from <PropertyGroup>
+ // This must be done before adding <Imports>, because the import path can refer to properties.
+ if (projectProperties.Count > 0) {
+ if (!(project is MSBuildBasedProject))
+ throw new Exception("<PropertyGroup> may be only used in project templates for MSBuildBasedProjects");
+
+ foreach (ProjectProperty p in projectProperties) {
+ ((MSBuildBasedProject)project).SetProperty(
+ StringParser.Parse(p.Configuration),
+ StringParser.Parse(p.Platform),
+ StringParser.Parse(p.Name),
+ StringParser.Parse(p.Value),
+ p.Location,
+ p.ValueIsLiteral
+ );
+ }
+ }
+
// Add Imports
if (clearExistingImports || projectImports.Count > 0) {
MSBuildBasedProject msbuildProject = project as MSBuildBasedProject;
@@ -450,22 +468,6 @@ public IProject CreateProject(ProjectCreateInformation projectCreateInformation,
}
}
- if (projectProperties.Count > 0) {
- if (!(project is MSBuildBasedProject))
- throw new Exception("<PropertyGroup> may be only used in project templates for MSBuildBasedProjects");
-
- foreach (ProjectProperty p in projectProperties) {
- ((MSBuildBasedProject)project).SetProperty(
- StringParser.Parse(p.Configuration),
- StringParser.Parse(p.Platform),
- StringParser.Parse(p.Name),
- StringParser.Parse(p.Value),
- p.Location,
- p.ValueIsLiteral
- );
- }
- }
-
// Add Files
if (project is IProjectItemListProvider) {
View
10 src/Main/Base/Project/Src/Project/AbstractProject.cs
@@ -597,5 +597,15 @@ protected virtual ProjectBehavior GetOrCreateBehavior()
return projectBehavior;
}
}
+
+ public virtual bool HasProjectType(Guid projectTypeGuid)
+ {
+ Guid myGuid;
+ if (Guid.TryParse(this.TypeGuid, out myGuid)) {
+ return myGuid == projectTypeGuid;
+ } else {
+ return false;
+ }
+ }
}
}
View
38 src/Main/Base/Project/Src/Project/Behaviors/DotNetStartBehavior.cs
@@ -126,6 +126,22 @@ public override ItemType GetDefaultItemType(string fileName)
return base.GetDefaultItemType(fileName);
}
+ public override CompilerVersion CurrentCompilerVersion {
+ get {
+ switch (Project.MinimumSolutionVersion) {
+ case Solution.SolutionVersionVS2005:
+ return CompilerVersion.MSBuild20;
+ case Solution.SolutionVersionVS2008:
+ return CompilerVersion.MSBuild35;
+ case Solution.SolutionVersionVS2010:
+ case Solution.SolutionVersionVS11:
+ return CompilerVersion.MSBuild40;
+ default:
+ throw new NotSupportedException();
+ }
+ }
+ }
+
public override IEnumerable<CompilerVersion> GetAvailableCompilerVersions()
{
List<CompilerVersion> versions = new List<CompilerVersion>();
@@ -137,6 +153,28 @@ public override IEnumerable<CompilerVersion> GetAvailableCompilerVersions()
return versions;
}
+ public override TargetFramework CurrentTargetFramework {
+ get {
+ string fxVersion = Project.TargetFrameworkVersion;
+ string fxProfile = Project.TargetFrameworkProfile;
+ if (string.Equals(fxProfile, "Client", StringComparison.OrdinalIgnoreCase)) {
+ foreach (ClientProfileTargetFramework fx in TargetFramework.TargetFrameworks.OfType<ClientProfileTargetFramework>())
+ if (fx.FullFramework.Name == fxVersion)
+ return fx;
+ } else {
+ foreach (TargetFramework fx in TargetFramework.TargetFrameworks)
+ if (fx.Name == fxVersion)
+ return fx;
+ }
+ return null;
+ }
+ }
+
+ public override IEnumerable<TargetFramework> GetAvailableTargetFrameworks()
+ {
+ return TargetFramework.TargetFrameworks.Where(fx => fx.IsAvailable());
+ }
+
public override void UpgradeProject(CompilerVersion newVersion, TargetFramework newFramework)
{
if (!Project.ReadOnly) {
View
23 src/Main/Base/Project/Src/Project/Behaviors/ProjectBehavior.cs
@@ -94,6 +94,29 @@ public virtual IEnumerable<CompilerVersion> GetAvailableCompilerVersions()
return Enumerable.Empty<CompilerVersion>();
}
+ public virtual IEnumerable<TargetFramework> GetAvailableTargetFrameworks()
+ {
+ if (this.next != null)
+ return next.GetAvailableTargetFrameworks();
+ return Enumerable.Empty<TargetFramework>();
+ }
+
+ public virtual CompilerVersion CurrentCompilerVersion {
+ get {
+ if (this.next != null)
+ return next.CurrentCompilerVersion;
+ throw new InvalidOperationException();
+ }
+ }
+
+ public virtual TargetFramework CurrentTargetFramework {
+ get {
+ if (this.next != null)
+ return next.CurrentTargetFramework;
+ throw new InvalidOperationException();
+ }
+ }
+
public virtual void UpgradeProject(CompilerVersion newVersion, TargetFramework newFramework)
{
if (this.next != null)
View
39 src/Main/Base/Project/Src/Project/Behaviors/ProjectBehaviorSupportedConditionEvaluator.cs
@@ -16,35 +16,20 @@ public bool IsValid(object owner, Condition condition)
if (!Guid.TryParse(condition.Properties["guid"], out conditionGuid))
return true;
- string guidString;
- if (owner is IProject)
- guidString = FindGuidInProject((IProject)owner);
- else if (ProjectService.CurrentProject != null)
- guidString = FindGuidInProject(ProjectService.CurrentProject);
- else
+ IProject project = owner as IProject ?? ProjectService.CurrentProject;
+ if (project == null)
return false;
-
- Guid result;
- foreach (string guid in guidString.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) {
- if (Guid.TryParse(guid, out result) && conditionGuid == result)
- return true;
+ // TODO: simplify this once HasProjectType() is part of IProject
+ AbstractProject p2 = project as AbstractProject;
+ if (p2 != null) {
+ return p2.HasProjectType(conditionGuid);
+ } else {
+ Guid projectGuid;
+ if (Guid.TryParse(project.TypeGuid, out projectGuid))
+ return conditionGuid == projectGuid;
+ else
+ return false;
}
-
- return false;
- }
-
- string FindGuidInProject(IProject project)
- {
- if (project is MSBuildBasedProject) {
- string guid = ((MSBuildBasedProject)project).GetEvaluatedProperty("ProjectTypeGuids");
- if (!string.IsNullOrEmpty(guid))
- return guid;
- } else if (project is UnknownProject || project is MissingProject) {
- // don't return any GUID for projects that could not be loaded
- return string.Empty;
- }
-
- return project.TypeGuid;
}
}
}
View
34 src/Main/Base/Project/Src/Project/CompilableProject.cs
@@ -277,36 +277,11 @@ protected override ProjectBehavior CreateDefaultBehavior()
}
public virtual CompilerVersion CurrentCompilerVersion {
- get {
- switch (MinimumSolutionVersion) {
- case Solution.SolutionVersionVS2005:
- return CompilerVersion.MSBuild20;
- case Solution.SolutionVersionVS2008:
- return CompilerVersion.MSBuild35;
- case Solution.SolutionVersionVS2010:
- case Solution.SolutionVersionVS11:
- return CompilerVersion.MSBuild40;
- default:
- throw new NotSupportedException();
- }
- }
+ get { return GetOrCreateBehavior().CurrentCompilerVersion; }
}
public virtual TargetFramework CurrentTargetFramework {
- get {
- string fxVersion = this.TargetFrameworkVersion;
- string fxProfile = this.TargetFrameworkProfile;
- if (string.Equals(fxProfile, "Client", StringComparison.OrdinalIgnoreCase)) {
- foreach (ClientProfileTargetFramework fx in TargetFramework.TargetFrameworks.OfType<ClientProfileTargetFramework>())
- if (fx.FullFramework.Name == fxVersion)
- return fx;
- } else {
- foreach (TargetFramework fx in TargetFramework.TargetFrameworks)
- if (fx.Name == fxVersion)
- return fx;
- }
- return null;
- }
+ get { return GetOrCreateBehavior().CurrentTargetFramework; }
}
public virtual IEnumerable<CompilerVersion> GetAvailableCompilerVersions()
@@ -314,6 +289,11 @@ public virtual IEnumerable<CompilerVersion> GetAvailableCompilerVersions()
return GetOrCreateBehavior().GetAvailableCompilerVersions();
}
+ public virtual IEnumerable<TargetFramework> GetAvailableTargetFrameworks()
+ {
+ return GetOrCreateBehavior().GetAvailableTargetFrameworks();
+ }
+
public virtual void UpgradeProject(CompilerVersion newVersion, TargetFramework newFramework)
{
GetOrCreateBehavior().UpgradeProject(newVersion, newFramework);
View
6 src/Main/Base/Project/Src/Project/Converter/IUpgradableProject.cs
@@ -29,6 +29,11 @@ public interface IUpgradableProject
IEnumerable<CompilerVersion> GetAvailableCompilerVersions();
/// <summary>
+ /// Gets the supported target frameworks.
+ /// </summary>
+ IEnumerable<TargetFramework> GetAvailableTargetFrameworks();
+
+ /// <summary>
/// Gets the current compiler version.
/// </summary>
CompilerVersion CurrentCompilerVersion { get; }
@@ -56,6 +61,7 @@ public class CompilerVersion
public static readonly CompilerVersion MSBuild35 = new CompilerVersion(new Version(3, 5), "MSBuild 3.5");
public static readonly CompilerVersion MSBuild40 = new CompilerVersion(new Version(4, 0), "MSBuild 4.0");
+ [Obsolete("Use IUpgradableProject.GetAvailableTargetFrameworks() instead")]
public virtual IEnumerable<TargetFramework> GetSupportedTargetFrameworks()
{
return from fx in TargetFramework.TargetFrameworks
View
44 src/Main/Base/Project/Src/Project/Converter/UpgradeView.xaml.cs
@@ -121,34 +121,30 @@ void newVersionComboBox_SelectionChanged(object sender, SelectionChangedEventArg
void UpdateTargetFrameworkComboBox()
{
// Determine the available target frameworks
- List<TargetFramework> availableFrameworks;
bool doNotChangeAllowed;
CompilerVersion selectedCompiler = newVersionComboBox.SelectedValue as CompilerVersion;
- if (selectedCompiler == null || selectedCompiler is UnchangedCompilerVersion) {
- // no entries or "Do not change" selected
- // -> available target frameworks is the intersection of all compiler's target framework,
- // and "Do not change" is always available
-
- availableFrameworks = (
- from Entry entry in listView.SelectedItems
- where entry.CompilerVersion != null
- from fx in entry.CompilerVersion.GetSupportedTargetFrameworks()
- select fx
- ).Distinct().ToList();
-
- doNotChangeAllowed = true;
- } else {
- // Specific compiler version is selected
- // Show that compiler's target frameworks
- availableFrameworks = selectedCompiler.GetSupportedTargetFrameworks().ToList();
- // Allow do not change on target framework if all current frameworks are supported
- // by the new compiler.
- doNotChangeAllowed = true;
- foreach (Entry entry in listView.SelectedItems) {
- doNotChangeAllowed &= availableFrameworks.Contains(entry.TargetFramework);
- }
+ if (selectedCompiler is UnchangedCompilerVersion)
+ selectedCompiler = null;
+
+ // Calculate the intersection of available frameworks for all selected projects:
+ HashSet<TargetFramework> availableFrameworkSet = null;
+ foreach (Entry entry in listView.SelectedItems) {
+ var entryFrameworks = entry.Project.GetAvailableTargetFrameworks()
+ .Where(fx => fx.IsCompatibleWith(selectedCompiler ?? entry.CompilerVersion));
+ if (availableFrameworkSet == null)
+ availableFrameworkSet = new HashSet<TargetFramework>(entryFrameworks);
+ else
+ availableFrameworkSet.IntersectWith(entryFrameworks);
+ }
+
+ // Allow do not change on target framework if all current frameworks are supported
+ // by the new compiler.
+ doNotChangeAllowed = true;
+ foreach (Entry entry in listView.SelectedItems) {
+ doNotChangeAllowed &= availableFrameworkSet.Contains(entry.TargetFramework);
}
+ List<TargetFramework> availableFrameworks = availableFrameworkSet.ToList();
availableFrameworks.Sort((a, b) => a.DisplayName.CompareTo(b.DisplayName));
if (doNotChangeAllowed) {
availableFrameworks.Insert(0, new UnchangedTargetFramework());
View
3  src/Main/Base/Project/Src/Project/IProject.cs
@@ -273,6 +273,9 @@ public interface IProject
/// Saves the project extension content with the specified name.
/// </summary>
void SaveProjectExtensions(string name, XElement element);
+
+ // TODO:
+ // bool HasProjectType(Guid projectTypeGuid);
}
/// <summary>
View
15 src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
@@ -1625,6 +1625,19 @@ string FormatProjectExtension(XElement element)
}
return formattedText.ToString();
}
- #endregion
+ #endregion
+
+ public override bool HasProjectType(Guid projectTypeGuid)
+ {
+ string guidList = GetEvaluatedProperty("ProjectTypeGuids");
+ if (string.IsNullOrEmpty(guidList))
+ return base.HasProjectType(projectTypeGuid);
+ foreach (string guid in guidList.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) {
+ Guid result;
+ if (Guid.TryParse(guid, out result) && projectTypeGuid == result)
+ return true;
+ }
+ return false;
+ }
}
}
View
16 src/Main/Base/Project/Src/Project/MSBuildInternals.cs
@@ -7,9 +7,11 @@
using System.Text.RegularExpressions;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.SharpDevelop.Util;
using Microsoft.Build.Construction;
using Microsoft.Build.Execution;
using Microsoft.Build.Framework;
+using Microsoft.Build.Logging;
using MSBuild = Microsoft.Build;
using ProjectCollection = Microsoft.Build.Evaluation.ProjectCollection;
@@ -169,6 +171,7 @@ internal static PropertyStorageLocations GetLocationFromCondition(string conditi
{
ProjectInstance project = baseProject.CreateProjectInstance();
project.SetProperty("BuildingProject", "false");
+ project.SetProperty("DesignTimeBuild", "true");
List<ProjectItemInstance> references = (
from item in project.Items
@@ -201,9 +204,16 @@ select item
}
}
- string[] targets = { "ResolveAssemblyReferences" };
- BuildRequestData requestData = new BuildRequestData(project, targets, new HostServices());
+ List<string> targets = new List<string>();
+ if (baseProject.HasProjectType(ProjectTypeGuids.PortableLibrary)) {
+ targets.Add("ResolveReferences");
+ targets.Add("DesignTimeResolveAssemblyReferences");
+ } else {
+ targets.Add("ResolveAssemblyReferences");
+ }
+ BuildRequestData requestData = new BuildRequestData(project, targets.ToArray(), new HostServices());
List<ILogger> loggers = new List<ILogger>();
+ //loggers.Add(new ConsoleLogger(LoggerVerbosity.Diagnostic));
if (logErrorsToOutputPad)
loggers.Add(new SimpleErrorLogger());
lock (SolutionProjectCollectionLock) {
@@ -231,6 +241,8 @@ select item
CopyLocal = bool.Parse(msbuildItem.GetMetadataValue("CopyLocal")),
ReferenceItems = referenceItems
};
+ // HACK: mscorlib is reported twice for portable library projects (even if we don't specify it as additionalReference)
+ query = query.DistinctBy(asm => asm.FullPath);
List<ReferenceProjectItem> resolvedAssemblies = new List<ReferenceProjectItem>();
List<ReferenceProjectItem> handledReferenceItems = new List<ReferenceProjectItem>();
foreach (var assembly in query) {
View
5 src/Main/Base/Project/Src/Project/MissingProject.cs
@@ -30,5 +30,10 @@ protected override ProjectBehavior GetOrCreateBehavior()
return projectBehavior;
}
}
+
+ public override bool HasProjectType(Guid projectTypeGuid)
+ {
+ return false;
+ }
}
}
View
38 src/Main/Base/Project/Src/Project/PortableLibrary/PortableLibraryProjectBehavior.cs
@@ -0,0 +1,38 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using ICSharpCode.SharpDevelop.Project.Converter;
+
+namespace ICSharpCode.SharpDevelop.Project.PortableLibrary
+{
+ public class PortableLibraryProjectBehavior : ProjectBehavior
+ {
+ public readonly static TargetFramework PortableTargetFramework = new TargetFramework("v4.0Portable", "Portable Library") {
+ MinimumMSBuildVersion = new Version(4, 0)
+ };
+
+ public override IEnumerable<CompilerVersion> GetAvailableCompilerVersions()
+ {
+ return base.GetAvailableCompilerVersions().Where(c => c.MSBuildVersion == new Version(4, 0));
+ }
+
+ public override IEnumerable<TargetFramework> GetAvailableTargetFrameworks()
+ {
+ return new[] { PortableTargetFramework };
+ }
+
+ public override TargetFramework CurrentTargetFramework {
+ get { return PortableTargetFramework; }
+ }
+
+ public override void UpgradeProject(CompilerVersion newVersion, TargetFramework newFramework)
+ {
+ // can't upgrade portable libraries
+ }
+ }
+}
View
45 src/Main/Base/Project/Src/Project/PortableLibrary/Profile.cs
@@ -0,0 +1,45 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+
+namespace ICSharpCode.SharpDevelop.Project.PortableLibrary
+{
+ /// <summary>
+ /// Description of Profile.
+ /// </summary>
+ public class Profile
+ {
+ #region Load List of Profiles
+ static string GetPortableLibraryPath()
+ {
+ string programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
+ return Path.Combine(programFiles, @"Reference Assemblies\Microsoft\Framework\.NETPortable");
+ }
+
+ public static IList<Profile> LoadProfiles()
+ {
+ throw new NotImplementedException();
+ }
+
+ public static bool IsPortableLibraryInstalled()
+ {
+ return Directory.Exists(GetPortableLibraryPath());
+ }
+ #endregion
+
+ public readonly string TargetFrameworkVersion;
+ public readonly string TargetFrameworkProfile;
+ public readonly IList<SupportedFramework> SupportedFrameworks;
+
+ public Profile(string targetFrameworkVersion, string targetFrameworkProfile, IList<SupportedFramework> supportedFrameworks)
+ {
+ this.TargetFrameworkVersion = targetFrameworkVersion;
+ this.TargetFrameworkProfile = targetFrameworkProfile;
+ this.SupportedFrameworks = supportedFrameworks;
+ }
+ }
+}
View
36 src/Main/Base/Project/Src/Project/PortableLibrary/SupportedFramework.cs
@@ -0,0 +1,36 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Xml.Linq;
+
+namespace ICSharpCode.SharpDevelop.Project.PortableLibrary
+{
+ /// <summary>
+ /// A supported framework.
+ /// </summary>
+ public class SupportedFramework
+ {
+ public readonly string Identifier;
+ public readonly string Profile;
+ public readonly Version MinimumVersion;
+ public readonly string DisplayName;
+
+ public SupportedFramework(XElement framework)
+ {
+ this.Identifier = (string)framework.Attribute("Identifier");
+ this.Profile = (string)framework.Attribute("Profile");
+ Version.TryParse((string)framework.Attribute("MinimumVersion"), out MinimumVersion);
+ string displayName = (string)framework.Attribute("DisplayName");
+ string minimumVersionDisplayName = (string)framework.Attribute("MinimumVersionDisplayName");
+ if (!string.IsNullOrEmpty(minimumVersionDisplayName))
+ displayName += " " + minimumVersionDisplayName;
+ this.DisplayName = displayName;
+ }
+
+ public override string ToString()
+ {
+ return this.DisplayName;
+ }
+ }
+}
View
1  src/Main/Base/Project/Src/Project/Solution/Project_TypeGuids.cs
@@ -22,5 +22,6 @@ public static class ProjectTypeGuids
public const string WebApplication = "{349C5851-65DF-11DA-9384-00065B846F21}";
public const string WebSite = "{E24C65DC-7377-472B-9ABA-BC803B73C61A}";
public const string Silverlight = "{A1591282-1198-4647-A2B1-27E5FF5F6F3B}";
+ public static readonly Guid PortableLibrary = Guid.Parse("{786C830F-07A1-408B-BD7F-6EE04809D6DB}");
}
}
View
6 src/Main/Base/Project/Src/Project/TargetFramework.cs
@@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
+using ICSharpCode.SharpDevelop.Project.Converter;
namespace ICSharpCode.SharpDevelop.Project
{
@@ -116,6 +117,11 @@ public TargetFramework(string name, string displayName)
/// </summary>
public TargetFramework BasedOn { get; set; }
+ public virtual bool IsCompatibleWith(CompilerVersion compilerVersion)
+ {
+ return MinimumMSBuildVersion <= compilerVersion.MSBuildVersion;
+ }
+
public bool IsBasedOn(TargetFramework potentialBase)
{
TargetFramework tmp = this;
View
5 src/Main/Base/Project/Src/Project/UnknownProject.cs
@@ -52,5 +52,10 @@ protected override ProjectBehavior GetOrCreateBehavior()
return projectBehavior;
}
}
+
+ public override bool HasProjectType(Guid projectTypeGuid)
+ {
+ return false;
+ }
}
}
View
6 src/Main/Base/Project/Src/Util/ExtensionMethods.cs
@@ -22,6 +22,7 @@
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.SharpDevelop.Util;
using WinForms = System.Windows.Forms;
namespace ICSharpCode.SharpDevelop
@@ -160,6 +161,11 @@ public static T[] Splice<T>(this T[] array, int startIndex, int length)
return result;
}
+ public static IEnumerable<T> DistinctBy<T, K>(this IEnumerable<T> input, Func<T, K> keySelector)
+ {
+ return input.Distinct(KeyComparer.Create(keySelector));
+ }
+
/// <summary>
/// Sets the Content property of the specified ControlControl to the specified content.
/// If the content is a Windows-Forms control, it is wrapped in a WindowsFormsHost.
View
45 src/Main/Base/Project/Src/Util/KeyComparer.cs
@@ -0,0 +1,45 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+
+namespace ICSharpCode.SharpDevelop.Util
+{
+ public static class KeyComparer
+ {
+ public static KeyComparer<TElement, TKey> Create<TElement, TKey>(Func<TElement, TKey> keySelector)
+ {
+ return new KeyComparer<TElement, TKey>(keySelector, Comparer<TKey>.Default, EqualityComparer<TKey>.Default);
+ }
+ }
+
+ public class KeyComparer<TElement, TKey> : IComparer<TElement>, IEqualityComparer<TElement>
+ {
+ readonly Func<TElement, TKey> keySelector;
+ readonly IComparer<TKey> keyComparer;
+ readonly IEqualityComparer<TKey> keyEqualityComparer;
+
+ public KeyComparer(Func<TElement, TKey> keySelector, IComparer<TKey> keyComparer, IEqualityComparer<TKey> keyEqualityComparer)
+ {
+ this.keySelector = keySelector;
+ this.keyComparer = keyComparer;
+ this.keyEqualityComparer = keyEqualityComparer;
+ }
+
+ public int Compare(TElement x, TElement y)
+ {
+ return keyComparer.Compare(keySelector(x), keySelector(y));
+ }
+
+ public bool Equals(TElement x, TElement y)
+ {
+ return keyEqualityComparer.Equals(keySelector(x), keySelector(y));
+ }
+
+ public int GetHashCode(TElement obj)
+ {
+ return keyEqualityComparer.GetHashCode(keySelector(obj));
+ }
+ }
+}

No commit comments for this range

Something went wrong with that request. Please try again.