diff --git a/.gitignore b/.gitignore
index fd23a9aaa4..5d9d573cc3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,3 +18,5 @@ bin/
/src/Main/StartUp/Project/SharpDevelop.exe.config
/src/Main/GlobalAssemblyInfo.cs
/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.AppProperties.cs
+
+/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/lib
\ No newline at end of file
diff --git a/src/AddIns/Analysis/CodeQuality/TreeMaps/TreeMaps.csproj b/src/AddIns/Analysis/CodeQuality/TreeMaps/TreeMaps.csproj
index 4e9196f588..891b7ec7ae 100644
--- a/src/AddIns/Analysis/CodeQuality/TreeMaps/TreeMaps.csproj
+++ b/src/AddIns/Analysis/CodeQuality/TreeMaps/TreeMaps.csproj
@@ -28,18 +28,17 @@
False
False
false
+ ..\..\..\..\..\AddIns\Analysis\CodeQualityAnalysis\
true
Full
false
- ..\..\..\..\AddIns\Analysis\CodeQualityAnalysis\
DEBUG;TRACE
false
true
- .\bin\Release\
TRACE
diff --git a/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/BooProject.cs b/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/BooProject.cs
index 077586e916..63b08f3f2c 100644
--- a/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/BooProject.cs
+++ b/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/BooProject.cs
@@ -2,8 +2,11 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
+using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
+using System.Linq;
+using System.Threading;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
@@ -80,7 +83,6 @@ namespace Grunwald.BooBinding
}
internal static IProjectContent BooCompilerPC;
- internal static IProjectContent BooUsefulPC;
protected override ParseProjectContent CreateProjectContent()
{
@@ -88,17 +90,8 @@ namespace Grunwald.BooBinding
ReferenceProjectItem booCompilerItem = new ReferenceProjectItem(this, typeof(Boo.Lang.Compiler.AbstractAstAttribute).Assembly.Location);
BooCompilerPC = AssemblyParserService.GetProjectContentForReference(booCompilerItem);
}
- if (BooUsefulPC == null) {
- ReferenceProjectItem booUsefulItem = new ReferenceProjectItem(this, typeof(Boo.Lang.Useful.Attributes.SingletonAttribute).Assembly.Location);
- BooUsefulPC = AssemblyParserService.GetRegistryForReference(booUsefulItem).GetProjectContentForReference("Boo.Lang.Useful", booUsefulItem.Include);
- }
+
ParseProjectContent pc = base.CreateProjectContent();
- ReferenceProjectItem systemItem = new ReferenceProjectItem(this, "System");
- pc.AddReferencedContent(AssemblyParserService.GetProjectContentForReference(systemItem));
- ReferenceProjectItem booLangItem = new ReferenceProjectItem(this, typeof(Boo.Lang.Builtins).Assembly.Location);
- pc.AddReferencedContent(AssemblyParserService.GetProjectContentForReference(booLangItem));
- ReferenceProjectItem booExtensionsItem = new ReferenceProjectItem(this, typeof(Boo.Lang.Extensions.PropertyAttribute).Assembly.Location);
- pc.AddReferencedContent(AssemblyParserService.GetProjectContentForReference(booExtensionsItem));
pc.DefaultImports = new DefaultUsing(pc);
pc.DefaultImports.Usings.Add("Boo.Lang");
pc.DefaultImports.Usings.Add("Boo.Lang.Builtins");
@@ -106,6 +99,18 @@ namespace Grunwald.BooBinding
return pc;
}
+ public override IEnumerable ResolveAssemblyReferences(CancellationToken cancellationToken)
+ {
+ ReferenceProjectItem[] additionalReferences = {
+ new ReferenceProjectItem(this, "System")
+ };
+ ReferenceProjectItem[] booReferences = {
+ new ReferenceProjectItem(this, "Boo.Lang") { FileName = typeof(Boo.Lang.Builtins).Assembly.Location },
+ new ReferenceProjectItem(this, "Boo.Extensions") { FileName = typeof(Boo.Lang.Extensions.PropertyAttribute).Assembly.Location }
+ };
+ return MSBuildInternals.ResolveAssemblyReferences(this, additionalReferences).Concat(booReferences);
+ }
+
public override IAmbience GetAmbience()
{
return new BooAmbience();
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Templates/WPFApplication.xpt b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Templates/WPFApplication.xpt
index a165b84dce..dde2f040bb 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Templates/WPFApplication.xpt
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Templates/WPFApplication.xpt
@@ -28,7 +28,7 @@
WinExe
Application.rb
- --disable-gems Application.py
+ --disable-gems Application.rb
.\
Program
${addinpath:ICSharpCode.RubyBinding}\ir.exe
diff --git a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs
index c5e2b8d726..05a19b3a06 100644
--- a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs
+++ b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs
@@ -2,9 +2,10 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
-using System.ComponentModel;
-using System.Linq;
+using System.Collections.Generic;
using System.IO;
+using System.Linq;
+using System.Threading;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
@@ -67,14 +68,19 @@ namespace ICSharpCode.VBNetBinding
protected override ParseProjectContent CreateProjectContent()
{
ParseProjectContent pc = base.CreateProjectContent();
- ReferenceProjectItem vbRef = new ReferenceProjectItem(this, "Microsoft.VisualBasic");
- if (vbRef != null) {
- pc.AddReferencedContent(AssemblyParserService.GetProjectContentForReference(vbRef));
- }
MyNamespaceBuilder.BuildNamespace(this, pc);
return pc;
}
+ public override IEnumerable ResolveAssemblyReferences(CancellationToken cancellationToken)
+ {
+ ReferenceProjectItem[] additionalItems = {
+ new ReferenceProjectItem(this, "mscorlib"),
+ new ReferenceProjectItem(this, "Microsoft.VisualBasic"),
+ };
+ return MSBuildInternals.ResolveAssemblyReferences(this, additionalItems);
+ }
+
void InitVB()
{
reparseReferencesSensitiveProperties.Add("TargetFrameworkVersion");
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs
index e9921205be..6a634e9c50 100755
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs
@@ -8,27 +8,27 @@ using System.ComponentModel.Design;
using System.Diagnostics;
using System.IO;
using System.Linq;
+using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Threading;
+
using ICSharpCode.AvalonEdit.AddIn.Options;
using ICSharpCode.AvalonEdit.AddIn.Snippets;
+using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Folding;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.AvalonEdit.Rendering;
-using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.SharpDevelop.Editor.Commands;
using ICSharpCode.SharpDevelop.Gui;
-using ICSharpCode.SharpDevelop.Refactoring;
-using Ast = ICSharpCode.NRefactory.Ast;
namespace ICSharpCode.AvalonEdit.AddIn
{
@@ -233,7 +233,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
{
Debug.Assert(sender == this);
ToolTipRequestEventArgs args = new ToolTipRequestEventArgs(this.Adapter);
- var pos = GetPositionFromPoint(e.GetPosition(this));
+ var pos = this.TextArea.TextView.GetPositionFloor(e.GetPosition(this.TextArea.TextView) + this.TextArea.TextView.ScrollOffset);
args.InDocument = pos.HasValue;
if (pos.HasValue) {
args.LogicalPosition = AvalonEditDocumentAdapter.ToLocation(pos.Value);
@@ -244,11 +244,11 @@ namespace ICSharpCode.AvalonEdit.AddIn
FoldingManager foldings = this.Adapter.GetService(typeof(FoldingManager)) as FoldingManager;
if (foldings != null) {
- var foldingsAtOffset = foldings.GetFoldingsContaining(offset);
+ var foldingsAtOffset = foldings.GetFoldingsAt(offset);
FoldingSection collapsedSection = foldingsAtOffset.FirstOrDefault(section => section.IsFolded);
if (collapsedSection != null) {
- args.SetToolTip(collapsedSection.TooltipText);
+ args.SetToolTip(GetTooltipTextForCollapsedSection(collapsedSection));
}
}
@@ -396,6 +396,68 @@ namespace ICSharpCode.AvalonEdit.AddIn
{
popup = null;
}
+
+ #region GetTooltipTextForCollapsedSection
+ string GetTooltipTextForCollapsedSection(FoldingSection foldingSection)
+ {
+ // This fixes SD-1394:
+ // Each line is checked for leading indentation whitespaces. If
+ // a line has the same or more indentation than the first line,
+ // it is reduced. If a line is less indented than the first line
+ // the indentation is removed completely.
+ //
+ // See the following example:
+ // line 1
+ // line 2
+ // line 3
+ // line 4
+ //
+ // is reduced to:
+ // line 1
+ // line 2
+ // line 3
+ // line 4
+
+ const int maxLineCount = 15;
+
+ TextDocument document = this.Document;
+ int startOffset = foldingSection.StartOffset;
+ int endOffset = foldingSection.EndOffset;
+
+ DocumentLine startLine = document.GetLineByOffset(startOffset);
+ DocumentLine endLine = document.GetLineByOffset(endOffset);
+ StringBuilder builder = new StringBuilder();
+
+ DocumentLine current = startLine;
+ ISegment startIndent = TextUtilities.GetLeadingWhitespace(document, startLine);
+ int lineCount = 0;
+ while (current != endLine.NextLine && lineCount < maxLineCount) {
+ ISegment currentIndent = TextUtilities.GetLeadingWhitespace(document, current);
+
+ if (current == startLine && current == endLine)
+ builder.Append(document.GetText(startOffset, endOffset - startOffset));
+ else if (current == startLine) {
+ if (current.EndOffset - startOffset > 0)
+ builder.AppendLine(document.GetText(startOffset, current.EndOffset - startOffset).TrimStart());
+ } else if (current == endLine) {
+ if (startIndent.Length <= currentIndent.Length)
+ builder.Append(document.GetText(current.Offset + startIndent.Length, endOffset - current.Offset - startIndent.Length));
+ else
+ builder.Append(document.GetText(current.Offset + currentIndent.Length, endOffset - current.Offset - currentIndent.Length));
+ } else {
+ if (startIndent.Length <= currentIndent.Length)
+ builder.AppendLine(document.GetText(current.Offset + startIndent.Length, current.Length - startIndent.Length));
+ else
+ builder.AppendLine(document.GetText(current.Offset + currentIndent.Length, current.Length - currentIndent.Length));
+ }
+
+ current = current.NextLine;
+ lineCount++;
+ }
+
+ return builder.ToString();
+ }
+ #endregion
#endregion
#region Ctrl+Click Go To Definition
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.4.0.0.7070.nupkg b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.4.1.0.8000.nupkg
similarity index 75%
rename from src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.4.0.0.7070.nupkg
rename to src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.4.1.0.8000.nupkg
index 73e53d80a2..6e29f74289 100644
Binary files a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.4.0.0.7070.nupkg and b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.4.1.0.8000.nupkg differ
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.nuspec b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.nuspec
index 48fee777b5..e000423510 100644
--- a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.nuspec
+++ b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.nuspec
@@ -2,18 +2,26 @@
AvalonEdit.Sample
- 4.0.0.7070
+ 4.1.0.8000
Daniel Grunwald
SharpDevelop
http://www.opensource.org/licenses/mit-license.php
http://www.avalonedit.net
http://community.sharpdevelop.net/blogs/mattward/SharpDevelop.png
false
- Sample code for AvalonEdit the WPF-based text editor used in SharpDevelop 4.0.
+ Sample code for AvalonEdit the WPF-based text editor used in SharpDevelop 4.0.
+Modify your App.xaml file so the StartupUri points to the AvalonEdit Sample window:
+
+StartupUri="/Samples/AvalonEdit/Window1.xaml"
Sample code for AvalonEdit the WPF-based text editor used in SharpDevelop 4.0.
en-US
-
+
+
+
+
+
+ WPF Text Editor SharpDevelop AvalonEdit
\ No newline at end of file
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/BraceFoldingStrategy.cs.pp b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/BraceFoldingStrategy.cs.pp
similarity index 100%
rename from src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/BraceFoldingStrategy.cs.pp
rename to src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/BraceFoldingStrategy.cs.pp
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/ColorizeAvalonEdit.cs.pp b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/ColorizeAvalonEdit.cs.pp
similarity index 100%
rename from src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/ColorizeAvalonEdit.cs.pp
rename to src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/ColorizeAvalonEdit.cs.pp
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/CustomHighlighting.xshd b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/CustomHighlighting.xshd
similarity index 100%
rename from src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/CustomHighlighting.xshd
rename to src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/CustomHighlighting.xshd
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/ImageElementGenerator.cs.pp b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/ImageElementGenerator.cs.pp
similarity index 100%
rename from src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/ImageElementGenerator.cs.pp
rename to src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/ImageElementGenerator.cs.pp
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/MyCompletionData.cs.pp b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/MyCompletionData.cs.pp
similarity index 100%
rename from src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/MyCompletionData.cs.pp
rename to src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/MyCompletionData.cs.pp
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/Window1.xaml.cs.pp b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/Window1.xaml.cs.pp
similarity index 100%
rename from src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/Window1.xaml.cs.pp
rename to src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/Window1.xaml.cs.pp
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/Window1.xaml.pp b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/Window1.xaml.pp
similarity index 96%
rename from src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/Window1.xaml.pp
rename to src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/Window1.xaml.pp
index 4af0b557ec..fc59677107 100644
--- a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/Window1.xaml.pp
+++ b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/Window1.xaml.pp
@@ -21,7 +21,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
- xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
+ xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
+ TextOptions.TextFormattingMode="Display"
Title="AvalonEdit.Sample" Height="500" Width="700"
>
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/article.html b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/article.html
similarity index 100%
rename from src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/article.html
rename to src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/article.html
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/document.html b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/document.html
similarity index 100%
rename from src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/document.html
rename to src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/document.html
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/rendering.html b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/rendering.html
similarity index 100%
rename from src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/AvalonEdit.Sample/rendering.html
rename to src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/Content/Samples/AvalonEdit/rendering.html
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.0.0.7070.nupkg b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.0.0.7070.nupkg
deleted file mode 100644
index e193f23d41..0000000000
Binary files a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.0.0.7070.nupkg and /dev/null differ
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.1.0.8000.nupkg b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.1.0.8000.nupkg
new file mode 100644
index 0000000000..2c307fee6c
Binary files /dev/null and b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.1.0.8000.nupkg differ
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.1.0.8000.symbols.nupkg b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.1.0.8000.symbols.nupkg
new file mode 100644
index 0000000000..f753371459
Binary files /dev/null and b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.1.0.8000.symbols.nupkg differ
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.nuspec b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.nuspec
index 52cd3aa14b..933dab9b9d 100644
--- a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.nuspec
+++ b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.nuspec
@@ -1,18 +1,25 @@
-
- AvalonEdit
- 4.0.0.7070
- Daniel Grunwald
- SharpDevelop
- http://www.opensource.org/licenses/lgpl-2.1.php
- http://www.avalonedit.net
- http://community.sharpdevelop.net/blogs/mattward/SharpDevelop.png
- true
- AvalonEdit is the WPF-based text editor used in SharpDevelop 4.0.
- There are two builds of AvalonEdit included in this package. One that targets .NET 4.0 and
- one that targets .NET 3.5.
- AvalonEdit is the WPF-based text editor used in SharpDevelop 4.0.
- en-US
+
+ AvalonEdit
+ 4.1.0.8000
+ Daniel Grunwald
+ SharpDevelop
+ http://www.opensource.org/licenses/lgpl-2.1.php
+ http://www.avalonedit.net
+ http://community.sharpdevelop.net/blogs/mattward/SharpDevelop.png
+ true
+ AvalonEdit is the WPF-based text editor used in SharpDevelop. There are two builds of AvalonEdit included in this package. One that targets .NET 4.0 and one that targets .NET 3.5.
+ AvalonEdit is the WPF-based text editor used in SharpDevelop
+ Improved WPF text rendering performance.
+Region tooltips added.
+C# syntax highlighting: Do not colorize punctuation.
+ en-US
+ WPF Text Editor SharpDevelop AvalonEdit
+
+
+
+
+
\ No newline at end of file
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/lib/Net35/ICSharpCode.AvalonEdit.dll b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/lib/Net35/ICSharpCode.AvalonEdit.dll
deleted file mode 100644
index 7fe9b7d76e..0000000000
Binary files a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/lib/Net35/ICSharpCode.AvalonEdit.dll and /dev/null differ
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/lib/Net40/ICSharpCode.AvalonEdit.dll b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/lib/Net40/ICSharpCode.AvalonEdit.dll
deleted file mode 100644
index c5b592b48a..0000000000
Binary files a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/lib/Net40/ICSharpCode.AvalonEdit.dll and /dev/null differ
diff --git a/src/AddIns/Misc/PackageManagement/Packages/NuGet.exe b/src/AddIns/Misc/PackageManagement/Packages/NuGet.exe
index dabb7ca654..c3960af621 100644
Binary files a/src/AddIns/Misc/PackageManagement/Packages/NuGet.exe and b/src/AddIns/Misc/PackageManagement/Packages/NuGet.exe differ
diff --git a/src/AddIns/Misc/PackageManagement/Packages/buildpackages.cmd b/src/AddIns/Misc/PackageManagement/Packages/buildpackages.cmd
index fdb7d78cbf..7e40864638 100644
--- a/src/AddIns/Misc/PackageManagement/Packages/buildpackages.cmd
+++ b/src/AddIns/Misc/PackageManagement/Packages/buildpackages.cmd
@@ -1,4 +1,21 @@
-nuget.exe pack AvalonEdit\AvalonEdit.nuspec -b AvalonEdit -o AvalonEdit
-nuget.exe pack AvalonEdit.Sample\AvalonEdit.Sample.nuspec -b AvalonEdit.Sample -o AvalonEdit.Sample
-nuget.exe pack ICSharpCode.TextEditor\ICSharpCode.TextEditor.nuspec -b ICSharpCode.TextEditor -o ICSharpCode.TextEditor
-nuget.exe pack ICSharpCode.TextEditor.Sample\ICSharpCode.TextEditor.Sample.nuspec -b ICSharpCode.TextEditor.Sample -o ICSharpCode.TextEditor.Sample
\ No newline at end of file
+@ECHO OFF
+SETLOCAL
+SET msbuild=%windir%\microsoft.net\framework\v4.0.30319\msbuild
+SET project=..\..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj
+SET buildoptions=/t:Rebuild /p:Configuration=Release /p:DebugType=PdbOnly
+
+@ECHO ON
+:Clean debug build
+%msbuild% /m %project% /t:Clean /p:Configuration=Debug /p:OutputPath=%~dp0\AvalonEdit\lib\Net40
+
+:BUILD .NET 4.0 version
+%msbuild% /m %project% %buildoptions% /p:OutputPath=%~dp0\AvalonEdit\lib\Net40
+
+:BUILD .NET 3.5 version
+%msbuild% /m %project% %buildoptions% "/p:DefineConstants=TRACE" "/p:TargetFrameworkVersion=v3.5" /p:OutputPath=%~dp0\AvalonEdit\lib\Net35
+
+nuget.exe pack AvalonEdit\AvalonEdit.nuspec -Symbols -BasePath AvalonEdit -OutputDirectory AvalonEdit
+nuget.exe pack AvalonEdit.Sample\AvalonEdit.Sample.nuspec -BasePath AvalonEdit.Sample -OutputDirectory AvalonEdit.Sample
+
+@ECHO OFF
+ENDLOCAL
\ No newline at end of file
diff --git a/src/AddIns/Misc/TextTemplating/Project/Resources/TextTemplating.xshd b/src/AddIns/Misc/TextTemplating/Project/Resources/TextTemplating.xshd
index 34723597f3..ac17c1b9ab 100644
--- a/src/AddIns/Misc/TextTemplating/Project/Resources/TextTemplating.xshd
+++ b/src/AddIns/Misc/TextTemplating/Project/Resources/TextTemplating.xshd
@@ -51,7 +51,7 @@
-
+
template
parameter
diff --git a/src/AddIns/Misc/TextTemplating/Project/Src/ITextTemplatingEnvironment.cs b/src/AddIns/Misc/TextTemplating/Project/Src/ITextTemplatingEnvironment.cs
new file mode 100644
index 0000000000..2c6d014cd8
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Project/Src/ITextTemplatingEnvironment.cs
@@ -0,0 +1,12 @@
+// 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;
+
+namespace ICSharpCode.TextTemplating
+{
+ public interface ITextTemplatingEnvironment
+ {
+ string ExpandEnvironmentVariables(string name);
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Project/Src/ITextTemplatingPathResolver.cs b/src/AddIns/Misc/TextTemplating/Project/Src/ITextTemplatingPathResolver.cs
new file mode 100644
index 0000000000..62297562b0
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Project/Src/ITextTemplatingPathResolver.cs
@@ -0,0 +1,12 @@
+// 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;
+
+namespace ICSharpCode.TextTemplating
+{
+ public interface ITextTemplatingPathResolver
+ {
+ string ResolvePath(string path);
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Project/Src/ITextTemplatingStringParser.cs b/src/AddIns/Misc/TextTemplating/Project/Src/ITextTemplatingStringParser.cs
new file mode 100644
index 0000000000..db706e0ba9
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Project/Src/ITextTemplatingStringParser.cs
@@ -0,0 +1,12 @@
+// 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;
+
+namespace ICSharpCode.TextTemplating
+{
+ public interface ITextTemplatingStringParser
+ {
+ string GetValue(string propertyName);
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Project/Src/ITextTemplatingVariables.cs b/src/AddIns/Misc/TextTemplating/Project/Src/ITextTemplatingVariables.cs
new file mode 100644
index 0000000000..50ecc2058b
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Project/Src/ITextTemplatingVariables.cs
@@ -0,0 +1,13 @@
+// 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;
+
+namespace ICSharpCode.TextTemplating
+{
+ public interface ITextTemplatingVariables
+ {
+ string ExpandVariables(string name);
+ string GetValue(string name);
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingAssemblyResolver.cs b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingAssemblyResolver.cs
index 35f95ad1e8..a47bc89ded 100644
--- a/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingAssemblyResolver.cs
+++ b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingAssemblyResolver.cs
@@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
+using System.IO;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.TextTemplating
@@ -10,22 +11,33 @@ namespace ICSharpCode.TextTemplating
{
IProject project;
IAssemblyParserService assemblyParserService;
+ ITextTemplatingPathResolver pathResolver;
public TextTemplatingAssemblyResolver(
IProject project,
- IAssemblyParserService assemblyParserService)
+ IAssemblyParserService assemblyParserService,
+ ITextTemplatingPathResolver pathResolver)
{
this.project = project;
this.assemblyParserService = assemblyParserService;
+ this.pathResolver = pathResolver;
}
public TextTemplatingAssemblyResolver(IProject project)
- : this(project, new TextTemplatingAssemblyParserService())
+ : this(
+ project,
+ new TextTemplatingAssemblyParserService(),
+ new TextTemplatingPathResolver())
{
}
public string Resolve(string assemblyReference)
{
+ assemblyReference = ResolvePath(assemblyReference);
+ if (Path.IsPathRooted(assemblyReference)) {
+ return assemblyReference;
+ }
+
string resolvedAssemblyFileName = ResolveAssemblyFromProject(assemblyReference);
if (resolvedAssemblyFileName == null) {
resolvedAssemblyFileName = ResolveAssemblyFromGac(assemblyReference);
@@ -36,6 +48,11 @@ namespace ICSharpCode.TextTemplating
return assemblyReference;
}
+ string ResolvePath(string assemblyReference)
+ {
+ return pathResolver.ResolvePath(assemblyReference);
+ }
+
string ResolveAssemblyFromProject(string assemblyReference)
{
foreach (ReferenceProjectItem refProjectItem in project.GetItemsOfType(ItemType.Reference)) {
diff --git a/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingCustomTool.cs b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingCustomTool.cs
index 8e4836fd0d..7bcc663a88 100644
--- a/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingCustomTool.cs
+++ b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingCustomTool.cs
@@ -16,8 +16,10 @@ namespace ICSharpCode.TextTemplating
var appDomainFactory = new TextTemplatingAppDomainFactory();
string applicationBase = GetAssemblyBaseLocation();
var assemblyResolver = new TextTemplatingAssemblyResolver(project);
- var host = new TextTemplatingHost(appDomainFactory, assemblyResolver, applicationBase);
- return host;
+ var textTemplatingVariables = new TextTemplatingVariables();
+ var serviceProvider = new TextTemplatingServiceProvider();
+ var context = new TextTemplatingHostContext(project);
+ return new TextTemplatingHost(context, applicationBase);
}
string GetAssemblyBaseLocation()
diff --git a/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingDirectoryVariable.cs b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingDirectoryVariable.cs
new file mode 100644
index 0000000000..ac3428f495
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingDirectoryVariable.cs
@@ -0,0 +1,27 @@
+// 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.Linq;
+
+namespace ICSharpCode.TextTemplating
+{
+ public static class TextTemplatingDirectoryVariable
+ {
+ public static bool IsDirectoryVariable(string name)
+ {
+ return name.EndsWith("Dir", StringComparison.OrdinalIgnoreCase);
+ }
+
+ public static string AppendTrailingSlashIfMissing(string variableValue)
+ {
+ if (!String.IsNullOrEmpty(variableValue)) {
+ if (variableValue.Last() == '\\') {
+ return variableValue;
+ }
+ return variableValue + "\\";
+ }
+ return String.Empty;
+ }
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingEnvironment.cs b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingEnvironment.cs
new file mode 100644
index 0000000000..52be4c7aa3
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingEnvironment.cs
@@ -0,0 +1,15 @@
+// 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;
+
+namespace ICSharpCode.TextTemplating
+{
+ public class TextTemplatingEnvironment : ITextTemplatingEnvironment
+ {
+ public string ExpandEnvironmentVariables(string name)
+ {
+ return Environment.ExpandEnvironmentVariables(name);
+ }
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingHost.cs b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingHost.cs
index 2dfc6fa592..7f40edde99 100644
--- a/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingHost.cs
+++ b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingHost.cs
@@ -6,20 +6,15 @@ using Mono.TextTemplating;
namespace ICSharpCode.TextTemplating
{
- public class TextTemplatingHost : TemplateGenerator, ITextTemplatingHost
+ public class TextTemplatingHost : TemplateGenerator, ITextTemplatingHost, IServiceProvider
{
- ITextTemplatingAppDomainFactory appDomainFactory;
ITextTemplatingAppDomain templatingAppDomain;
- ITextTemplatingAssemblyResolver assemblyResolver;
+ TextTemplatingHostContext context;
string applicationBase;
- public TextTemplatingHost(
- ITextTemplatingAppDomainFactory appDomainFactory,
- ITextTemplatingAssemblyResolver assemblyResolver,
- string applicationBase)
+ public TextTemplatingHost(TextTemplatingHostContext context, string applicationBase)
{
- this.appDomainFactory = appDomainFactory;
- this.assemblyResolver = assemblyResolver;
+ this.context = context;
this.applicationBase = applicationBase;
}
@@ -41,12 +36,28 @@ namespace ICSharpCode.TextTemplating
void CreateAppDomain()
{
- templatingAppDomain = appDomainFactory.CreateTextTemplatingAppDomain(applicationBase);
+ templatingAppDomain = context.CreateTextTemplatingAppDomain(applicationBase);
}
protected override string ResolveAssemblyReference(string assemblyReference)
{
- return assemblyResolver.Resolve(assemblyReference);
+ return context.ResolveAssemblyReference(assemblyReference);
+ }
+
+ protected override string ResolvePath(string path)
+ {
+ path = ExpandPath(path);
+ return base.ResolvePath(path);
+ }
+
+ string ExpandPath(string path)
+ {
+ return context.ExpandTemplateVariables(path);
+ }
+
+ object IServiceProvider.GetService(Type serviceType)
+ {
+ return context.GetService(serviceType);
}
}
}
diff --git a/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingHostContext.cs b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingHostContext.cs
new file mode 100644
index 0000000000..eb1b5fd849
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingHostContext.cs
@@ -0,0 +1,57 @@
+// 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 ICSharpCode.SharpDevelop.Project;
+
+namespace ICSharpCode.TextTemplating
+{
+ public class TextTemplatingHostContext
+ {
+ ITextTemplatingAppDomainFactory appDomainFactory;
+ ITextTemplatingAssemblyResolver assemblyResolver;
+ ITextTemplatingVariables templatingVariables;
+ IServiceProvider serviceProvider;
+
+ public TextTemplatingHostContext(IProject project)
+ : this(
+ new TextTemplatingAppDomainFactory(),
+ new TextTemplatingAssemblyResolver(project),
+ new TextTemplatingVariables(),
+ new TextTemplatingServiceProvider())
+ {
+ }
+
+ public TextTemplatingHostContext(
+ ITextTemplatingAppDomainFactory appDomainFactory,
+ ITextTemplatingAssemblyResolver assemblyResolver,
+ ITextTemplatingVariables templatingVariables,
+ IServiceProvider serviceProvider)
+ {
+ this.appDomainFactory = appDomainFactory;
+ this.assemblyResolver = assemblyResolver;
+ this.templatingVariables = templatingVariables;
+ this.serviceProvider = serviceProvider;
+ }
+
+ public object GetService(Type serviceType)
+ {
+ return serviceProvider.GetService(serviceType);
+ }
+
+ public string ExpandTemplateVariables(string name)
+ {
+ return templatingVariables.ExpandVariables(name);
+ }
+
+ public ITextTemplatingAppDomain CreateTextTemplatingAppDomain(string applicationBase)
+ {
+ return appDomainFactory.CreateTextTemplatingAppDomain(applicationBase);
+ }
+
+ public string ResolveAssemblyReference(string assemblyReference)
+ {
+ return assemblyResolver.Resolve(assemblyReference);
+ }
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingPathResolver.cs b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingPathResolver.cs
new file mode 100644
index 0000000000..10d8477fc3
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingPathResolver.cs
@@ -0,0 +1,32 @@
+// 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;
+
+namespace ICSharpCode.TextTemplating
+{
+ public class TextTemplatingPathResolver : ITextTemplatingPathResolver
+ {
+ ITextTemplatingVariables templatingVariables;
+ ITextTemplatingEnvironment environment;
+
+ public TextTemplatingPathResolver()
+ : this(new TextTemplatingVariables(), new TextTemplatingEnvironment())
+ {
+ }
+
+ public TextTemplatingPathResolver(
+ ITextTemplatingVariables templatingVariables,
+ ITextTemplatingEnvironment environment)
+ {
+ this.templatingVariables = templatingVariables;
+ this.environment = environment;
+ }
+
+ public string ResolvePath(string path)
+ {
+ path = environment.ExpandEnvironmentVariables(path);
+ return templatingVariables.ExpandVariables(path);
+ }
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingServiceProvider.cs b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingServiceProvider.cs
new file mode 100644
index 0000000000..11f4d0095c
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingServiceProvider.cs
@@ -0,0 +1,15 @@
+// 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;
+
+namespace ICSharpCode.TextTemplating
+{
+ public class TextTemplatingServiceProvider : IServiceProvider
+ {
+ public object GetService(Type serviceType)
+ {
+ return serviceType.Assembly.CreateInstance(serviceType.FullName);
+ }
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingStringParser.cs b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingStringParser.cs
new file mode 100644
index 0000000000..efecf4847b
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingStringParser.cs
@@ -0,0 +1,16 @@
+// 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 ICSharpCode.Core;
+
+namespace ICSharpCode.TextTemplating
+{
+ public class TextTemplatingStringParser : ITextTemplatingStringParser
+ {
+ public string GetValue(string propertyName)
+ {
+ return StringParser.GetValue(propertyName);
+ }
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingVariableLocation.cs b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingVariableLocation.cs
new file mode 100644
index 0000000000..3c57284d50
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingVariableLocation.cs
@@ -0,0 +1,75 @@
+// 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;
+
+namespace ICSharpCode.TextTemplating
+{
+ public class TextTemplatingVariableLocation
+ {
+ public TextTemplatingVariableLocation()
+ : this(String.Empty, 0, 0)
+ {
+ }
+
+ public TextTemplatingVariableLocation(
+ string variableName,
+ int index,
+ int length)
+ {
+ this.VariableName = variableName;
+ this.Index = index;
+ this.Length = length;
+ }
+
+ public static TextTemplatingVariableLocation CreateFromString(
+ string text,
+ int unexpandedVariableStartIndex,
+ int unexpandedVariableEndIndex)
+ {
+ int variableNameStart = unexpandedVariableStartIndex + 2;
+ int unexpandedLength = unexpandedVariableEndIndex - unexpandedVariableStartIndex + 1;
+ string variableName = text.Substring(variableNameStart, unexpandedVariableEndIndex - variableNameStart);
+ return new TextTemplatingVariableLocation(variableName, unexpandedVariableStartIndex, unexpandedLength);
+ }
+
+ public string VariableName { get; set; }
+ public int Index { get; set; }
+ public int Length { get; set; }
+
+ public override bool Equals(object obj)
+ {
+ var rhs = obj as TextTemplatingVariableLocation;
+ if (rhs != null) {
+ return (VariableName == rhs.VariableName) &&
+ (Index == rhs.Index) &&
+ (Length == rhs.Length);
+ }
+ return false;
+ }
+
+ public override int GetHashCode()
+ {
+ return base.GetHashCode();
+ }
+
+ public override string ToString()
+ {
+ return String.Format(
+ "VariableName: {0}, Index: {1}, Length: {2}",
+ VariableName, Index, Length);
+ }
+
+ public static TextTemplatingVariableLocation FindVariable(string text, int startSearchIndex)
+ {
+ int start = text.IndexOf("$(", startSearchIndex);
+ if (start >= 0) {
+ int end = text.IndexOf(")", start);
+ if (end >= 0) {
+ return CreateFromString(text, start, end);
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingVariables.cs b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingVariables.cs
new file mode 100644
index 0000000000..713f4735b4
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingVariables.cs
@@ -0,0 +1,92 @@
+// 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;
+using System.Linq;
+using System.Text;
+
+namespace ICSharpCode.TextTemplating
+{
+ public class TextTemplatingVariables : ITextTemplatingVariables
+ {
+ ITextTemplatingStringParser stringParser;
+
+ public TextTemplatingVariables()
+ : this(new TextTemplatingStringParser())
+ {
+ }
+
+ public TextTemplatingVariables(
+ ITextTemplatingStringParser stringParser)
+ {
+ this.stringParser = stringParser;
+ }
+
+ public string ExpandVariables(string name)
+ {
+ var variablesBuilder = new TextTemplatingVariablesStringBuilder(name, this);
+ foreach (TextTemplatingVariableLocation variableLocation in GetVariables(name)) {
+ variablesBuilder.AppendTextBeforeVariable(variableLocation);
+ variablesBuilder.AppendVariable(variableLocation);
+ }
+ variablesBuilder.AppendRemaining();
+ return variablesBuilder.ToString();
+ }
+
+ public IEnumerable GetVariables(string text)
+ {
+ if (String.IsNullOrEmpty(text)) {
+ yield break;
+ }
+
+ int currentIndex = 0;
+ while (true) {
+ TextTemplatingVariableLocation variableLocation =
+ FindVariable(text, currentIndex);
+ if (variableLocation != null) {
+ currentIndex = variableLocation.Index + variableLocation.Length;
+ yield return variableLocation;
+ } else {
+ yield break;
+ }
+ }
+ }
+
+ TextTemplatingVariableLocation FindVariable(string text, int startIndex)
+ {
+ return TextTemplatingVariableLocation.FindVariable(text, startIndex);
+ }
+
+ public string GetValue(string name)
+ {
+ if (name == null) {
+ return String.Empty;
+ }
+
+ string variableValue = stringParser.GetValue(name);
+ if (IsDirectoryVariable(name)) {
+ return AppendTrailingSlashIfMissing(variableValue);
+ }
+ return GetEmptyStringIfNull(variableValue);
+ }
+
+ bool IsDirectoryVariable(string name)
+ {
+ return TextTemplatingDirectoryVariable.IsDirectoryVariable(name);
+ }
+
+ string AppendTrailingSlashIfMissing(string variableValue)
+ {
+ return TextTemplatingDirectoryVariable.AppendTrailingSlashIfMissing(variableValue);
+ }
+
+ string GetEmptyStringIfNull(string variableValue)
+ {
+ if (variableValue != null) {
+ return variableValue;
+ }
+ return String.Empty;
+ }
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingVariablesStringBuilder.cs b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingVariablesStringBuilder.cs
new file mode 100644
index 0000000000..b69380a909
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingVariablesStringBuilder.cs
@@ -0,0 +1,73 @@
+// 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.Text;
+
+namespace ICSharpCode.TextTemplating
+{
+ public class TextTemplatingVariablesStringBuilder
+ {
+ StringBuilder variablesBuilder = new StringBuilder();
+ string unexpandedVariablesString;
+ ITextTemplatingVariables templatingVariables;
+ int currentIndex;
+
+ public TextTemplatingVariablesStringBuilder(
+ string unexpandedVariablesString,
+ ITextTemplatingVariables templatingVariables)
+ {
+ this.unexpandedVariablesString = unexpandedVariablesString;
+ this.templatingVariables = templatingVariables;
+ }
+
+ public void Append(string text)
+ {
+ variablesBuilder.Append(text);
+ }
+
+ public override string ToString()
+ {
+ return variablesBuilder.ToString();
+ }
+
+ public void AppendVariable(TextTemplatingVariableLocation variableLocation)
+ {
+ AppendVariableText(variableLocation);
+ UpdateCurrentIndex(variableLocation);
+ }
+
+ public void AppendTextBeforeVariable(TextTemplatingVariableLocation variableLocation)
+ {
+ string textBeforeVariable = unexpandedVariablesString.Substring(currentIndex, variableLocation.Index);
+ variablesBuilder.Append(textBeforeVariable);
+ }
+
+ void AppendVariableText(TextTemplatingVariableLocation variableLocation)
+ {
+ string variableValue = GetVariableValue(variableLocation);
+ variablesBuilder.Append(variableValue);
+ }
+
+ void UpdateCurrentIndex(TextTemplatingVariableLocation variableLocation)
+ {
+ currentIndex = variableLocation.Index + variableLocation.Length;
+ }
+
+ string GetVariableValue(TextTemplatingVariableLocation variableLocation)
+ {
+ return templatingVariables.GetValue(variableLocation.VariableName);
+ }
+
+ public void AppendRemaining()
+ {
+ string textNotAppended = GetTextNotAppended();
+ variablesBuilder.Append(textNotAppended);
+ }
+
+ string GetTextNotAppended()
+ {
+ return unexpandedVariablesString.Substring(currentIndex);
+ }
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Project/TextTemplating.csproj b/src/AddIns/Misc/TextTemplating/Project/TextTemplating.csproj
index 0e1e3613dc..4bca22cf27 100644
--- a/src/AddIns/Misc/TextTemplating/Project/TextTemplating.csproj
+++ b/src/AddIns/Misc/TextTemplating/Project/TextTemplating.csproj
@@ -57,9 +57,13 @@
+
+
+
+
@@ -68,6 +72,8 @@
+
+
@@ -75,7 +81,14 @@
+
+
+
+
+
+
+
diff --git a/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeAssemblyParserService.cs b/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeAssemblyParserService.cs
index f90d5743e4..6ab9b11213 100644
--- a/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeAssemblyParserService.cs
+++ b/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeAssemblyParserService.cs
@@ -11,9 +11,11 @@ namespace TextTemplating.Tests.Helpers
{
public FakeReflectionProjectContent FakeReflectionProjectContent = new FakeReflectionProjectContent();
public ReferenceProjectItem ItemPassedToGetReflectionProjectContentForReference;
+ public bool IsGetReflectionProjectContentForReferenceCalled;
public IReflectionProjectContent GetReflectionProjectContentForReference(ReferenceProjectItem item)
{
+ IsGetReflectionProjectContentForReferenceCalled = true;
ItemPassedToGetReflectionProjectContentForReference = item;
return FakeReflectionProjectContent;
}
diff --git a/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeServiceProvider.cs b/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeServiceProvider.cs
new file mode 100644
index 0000000000..86de1d9946
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeServiceProvider.cs
@@ -0,0 +1,25 @@
+// 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 TextTemplating.Tests.Helpers
+{
+ public class FakeServiceProvider : IServiceProvider
+ {
+ public Dictionary Services = new Dictionary();
+
+ public void AddService(Type serviceType, object service)
+ {
+ Services.Add(serviceType, service);
+ }
+
+ public object GetService(Type serviceType)
+ {
+ object service = null;
+ Services.TryGetValue(serviceType, out service);
+ return service;
+ }
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingEnvironment.cs b/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingEnvironment.cs
new file mode 100644
index 0000000000..3bc9938fa7
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingEnvironment.cs
@@ -0,0 +1,29 @@
+// 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;
+using ICSharpCode.TextTemplating;
+
+namespace TextTemplating.Tests.Helpers
+{
+ public class FakeTextTemplatingEnvironment : ITextTemplatingEnvironment
+ {
+ public Dictionary Variables = new Dictionary();
+
+ public string ExpandEnvironmentVariables(string name)
+ {
+ string value = null;
+ if (Variables.TryGetValue(name, out value)) {
+ return value;
+ }
+ return name;
+ }
+
+ public void AddVariable(string name, string value)
+ {
+ name = "%" + name + "%";
+ Variables.Add(name, value);
+ }
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingPathResolver.cs b/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingPathResolver.cs
new file mode 100644
index 0000000000..ba6d118acc
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingPathResolver.cs
@@ -0,0 +1,28 @@
+// 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;
+using ICSharpCode.TextTemplating;
+
+namespace TextTemplating.Tests.Helpers
+{
+ public class FakeTextTemplatingPathResolver : ITextTemplatingPathResolver
+ {
+ public Dictionary Paths = new Dictionary();
+
+ public string ResolvePath(string path)
+ {
+ string resolvedPath = null;
+ if (Paths.TryGetValue(path, out resolvedPath)) {
+ return resolvedPath;
+ }
+ return path;
+ }
+
+ public void AddPath(string path, string resolvedPath)
+ {
+ Paths.Add(path, resolvedPath);
+ }
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingStringParser.cs b/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingStringParser.cs
new file mode 100644
index 0000000000..eab83d1da4
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingStringParser.cs
@@ -0,0 +1,26 @@
+// 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;
+using ICSharpCode.TextTemplating;
+
+namespace TextTemplating.Tests.Helpers
+{
+ public class FakeTextTemplatingStringParser : ITextTemplatingStringParser
+ {
+ public Dictionary Properties = new Dictionary();
+
+ public string GetValue(string propertyName)
+ {
+ string propertyValue = null;
+ Properties.TryGetValue(propertyName, out propertyValue);
+ return propertyValue;
+ }
+
+ public void AddProperty(string name, string value)
+ {
+ Properties.Add(name, value);
+ }
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingVariables.cs b/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingVariables.cs
new file mode 100644
index 0000000000..ed8c6f2f71
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingVariables.cs
@@ -0,0 +1,35 @@
+// 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;
+using ICSharpCode.TextTemplating;
+
+namespace TextTemplating.Tests.Helpers
+{
+ public class FakeTextTemplatingVariables : ITextTemplatingVariables
+ {
+ public Dictionary Variables = new Dictionary();
+
+ public void AddVariable(string name, string value)
+ {
+ name = "$(" + name + ")";
+ Variables.Add(name, value);
+ }
+
+ public string ExpandVariables(string name)
+ {
+ foreach (KeyValuePair variable in Variables) {
+ name = name.Replace(variable.Key, variable.Value);
+ }
+ return name;
+ }
+
+ public string GetValue(string name)
+ {
+ string variableValue = null;
+ Variables.TryGetValue(name, out variableValue);
+ return variableValue;
+ }
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Test/Helpers/TestableTextTemplatingHost.cs b/src/AddIns/Misc/TextTemplating/Test/Helpers/TestableTextTemplatingHost.cs
index 6d0514d532..bf4cd0ada0 100644
--- a/src/AddIns/Misc/TextTemplating/Test/Helpers/TestableTextTemplatingHost.cs
+++ b/src/AddIns/Misc/TextTemplating/Test/Helpers/TestableTextTemplatingHost.cs
@@ -10,11 +10,16 @@ namespace TextTemplating.Tests.Helpers
{
public FakeTextTemplatingAppDomainFactory FakeTextTemplatingAppDomainFactory;
public FakeTextTemplatingAssemblyResolver FakeTextTemplatingAssemblyResolver;
+ public FakeTextTemplatingVariables FakeTextTemplatingVariables;
+ public FakeServiceProvider FakeServiceProvider;
+ public TextTemplatingHostContext HostContext;
public TestableTextTemplatingHost(string applicationBase)
: this(
new FakeTextTemplatingAppDomainFactory(),
new FakeTextTemplatingAssemblyResolver(),
+ new FakeTextTemplatingVariables(),
+ new FakeServiceProvider(),
applicationBase)
{
}
@@ -22,16 +27,32 @@ namespace TextTemplating.Tests.Helpers
public TestableTextTemplatingHost(
FakeTextTemplatingAppDomainFactory appDomainFactory,
FakeTextTemplatingAssemblyResolver assemblyResolver,
+ FakeTextTemplatingVariables textTemplatingVariables,
+ FakeServiceProvider fakeServiceProvider,
string applicationBase)
- : base(appDomainFactory, assemblyResolver, applicationBase)
+ : this(
+ new TextTemplatingHostContext(appDomainFactory, assemblyResolver, textTemplatingVariables, fakeServiceProvider),
+ applicationBase)
{
FakeTextTemplatingAppDomainFactory = appDomainFactory;
FakeTextTemplatingAssemblyResolver = assemblyResolver;
+ FakeTextTemplatingVariables = textTemplatingVariables;
+ FakeServiceProvider = fakeServiceProvider;
+ }
+
+ public TestableTextTemplatingHost(TextTemplatingHostContext context, string applicationBase)
+ : base(context, applicationBase)
+ {
}
public string CallResolveAssemblyReference(string assemblyReference)
{
return base.ResolveAssemblyReference(assemblyReference);
}
+
+ public string CallResolvePath(string path)
+ {
+ return base.ResolvePath(path);
+ }
}
}
diff --git a/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingAssemblyResolverTests.cs b/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingAssemblyResolverTests.cs
index 00b3c1238a..06d82167e3 100644
--- a/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingAssemblyResolverTests.cs
+++ b/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingAssemblyResolverTests.cs
@@ -16,12 +16,14 @@ namespace TextTemplating.Tests
TextTemplatingAssemblyResolver resolver;
IProject project;
FakeAssemblyParserService fakeAssemblyParserService;
+ FakeTextTemplatingPathResolver fakePathResolver;
void CreateResolver()
{
project = ProjectHelper.CreateProject();
fakeAssemblyParserService = new FakeAssemblyParserService();
- resolver = new TextTemplatingAssemblyResolver(project, fakeAssemblyParserService);
+ fakePathResolver = new FakeTextTemplatingPathResolver();
+ resolver = new TextTemplatingAssemblyResolver(project, fakeAssemblyParserService, fakePathResolver);
}
ReferenceProjectItem AddReferenceToProject(string referenceName)
@@ -146,5 +148,31 @@ namespace TextTemplating.Tests
Assert.AreEqual("System.Data", result);
}
+
+ [Test]
+ public void Resolve_AssemblyReferenceHasTemplateVariable_ReturnsExpandedAssemblyReferenceFileName()
+ {
+ CreateResolver();
+ string path = @"$(SolutionDir)lib\Test.dll";
+ string expectedPath = @"d:\projects\MyProject\lib\Test.dll";
+ fakePathResolver.AddPath(path, expectedPath);
+
+ string resolvedPath = resolver.Resolve(path);
+
+ Assert.AreEqual(expectedPath, resolvedPath);
+ }
+
+ [Test]
+ public void Resolve_AssemblyReferenceHasTemplateVariable_AssemblyParserServiceIsNotUsed()
+ {
+ CreateResolver();
+ string path = @"$(SolutionDir)lib\Test.dll";
+ string expectedPath = @"d:\projects\MyProject\lib\Test.dll";
+ fakePathResolver.AddPath(path, expectedPath);
+
+ string result = resolver.Resolve(path);
+
+ Assert.IsFalse(fakeAssemblyParserService.IsGetReflectionProjectContentForReferenceCalled);
+ }
}
}
diff --git a/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingHostTests.cs b/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingHostTests.cs
index 01865570fe..681ba9b1ed 100644
--- a/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingHostTests.cs
+++ b/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingHostTests.cs
@@ -13,9 +13,11 @@ namespace TextTemplating.Tests
public class TextTemplatingHostTests
{
TestableTextTemplatingHost host;
- FakeTextTemplatingAppDomainFactory textTemplatingAppDomainFactory;
- FakeTextTemplatingAppDomain textTemplatingAppDomain;
- FakeTextTemplatingAssemblyResolver assemblyResolver;
+ FakeTextTemplatingAppDomainFactory fakeTextTemplatingAppDomainFactory;
+ FakeTextTemplatingAppDomain fakeTextTemplatingAppDomain;
+ FakeTextTemplatingAssemblyResolver fakeAssemblyResolver;
+ FakeTextTemplatingVariables fakeTextTemplatingVariables;
+ FakeServiceProvider fakeServiceProvider;
void CreateHost()
{
@@ -25,9 +27,16 @@ namespace TextTemplating.Tests
void CreateHost(string applicationBase)
{
host = new TestableTextTemplatingHost(applicationBase);
- textTemplatingAppDomainFactory = host.FakeTextTemplatingAppDomainFactory;
- textTemplatingAppDomain = textTemplatingAppDomainFactory.FakeTextTemplatingAppDomain;
- assemblyResolver = host.FakeTextTemplatingAssemblyResolver;
+ fakeTextTemplatingAppDomainFactory = host.FakeTextTemplatingAppDomainFactory;
+ fakeTextTemplatingAppDomain = fakeTextTemplatingAppDomainFactory.FakeTextTemplatingAppDomain;
+ fakeAssemblyResolver = host.FakeTextTemplatingAssemblyResolver;
+ fakeTextTemplatingVariables = host.FakeTextTemplatingVariables;
+ fakeServiceProvider = host.FakeServiceProvider;
+ }
+
+ void AddTemplateVariableValue(string variableName, string variableValue)
+ {
+ fakeTextTemplatingVariables.AddVariable(variableName, variableValue);
}
[Test]
@@ -35,7 +44,7 @@ namespace TextTemplating.Tests
{
CreateHost();
AppDomain expectedAppDomain = AppDomain.CreateDomain("TextTemplatingHostTests");
- textTemplatingAppDomain.AppDomain = expectedAppDomain;
+ fakeTextTemplatingAppDomain.AppDomain = expectedAppDomain;
AppDomain actualAppDomain = host.ProvideTemplatingAppDomain("test");
@@ -49,7 +58,7 @@ namespace TextTemplating.Tests
host.ProvideTemplatingAppDomain("test");
host.Dispose();
- Assert.IsTrue(textTemplatingAppDomain.IsDisposeCalled);
+ Assert.IsTrue(fakeTextTemplatingAppDomain.IsDisposeCalled);
}
[Test]
@@ -66,7 +75,7 @@ namespace TextTemplating.Tests
host.ProvideTemplatingAppDomain("test");
host.ProvideTemplatingAppDomain("test");
- Assert.AreEqual(1, textTemplatingAppDomainFactory.CreateTextTemplatingAppDomainCallCount);
+ Assert.AreEqual(1, fakeTextTemplatingAppDomainFactory.CreateTextTemplatingAppDomainCallCount);
}
[Test]
@@ -76,10 +85,10 @@ namespace TextTemplating.Tests
host.ProvideTemplatingAppDomain("test");
host.Dispose();
- textTemplatingAppDomain.IsDisposeCalled = false;
+ fakeTextTemplatingAppDomain.IsDisposeCalled = false;
host.Dispose();
- Assert.IsFalse(textTemplatingAppDomain.IsDisposeCalled);
+ Assert.IsFalse(fakeTextTemplatingAppDomain.IsDisposeCalled);
}
[Test]
@@ -89,7 +98,7 @@ namespace TextTemplating.Tests
CreateHost(applicationBase);
host.ProvideTemplatingAppDomain("test");
- string actualApplicationBase = textTemplatingAppDomainFactory.ApplicationBasePassedToCreateTextTemplatingAppDomain;
+ string actualApplicationBase = fakeTextTemplatingAppDomainFactory.ApplicationBasePassedToCreateTextTemplatingAppDomain;
Assert.AreEqual(applicationBase, actualApplicationBase);
}
@@ -99,17 +108,40 @@ namespace TextTemplating.Tests
CreateHost();
host.CallResolveAssemblyReference("MyReference");
- Assert.AreEqual("MyReference", assemblyResolver.AssembyReferencePassedToResolve);
+ Assert.AreEqual("MyReference", fakeAssemblyResolver.AssembyReferencePassedToResolve);
}
[Test]
- public void ResolveAssemblyReference_PassedMyAssemblyReference_ReturnFileNameReturnedFromAssemblyResolverResolveMethod()
+ public void ResolveAssemblyReference_PassedMyAssemblyReference_ReturnsFileNameReturnedFromAssemblyResolverResolveMethod()
{
CreateHost();
- assemblyResolver.ResolveReturnValue = @"d:\projects\references\MyReference.dll";
+ fakeAssemblyResolver.ResolveReturnValue = @"d:\projects\references\MyReference.dll";
string result = host.CallResolveAssemblyReference("MyReference");
Assert.AreEqual(@"d:\projects\references\MyReference.dll", result);
}
+
+ [Test]
+ public void ResolvePath_PathContainsSolutionDirProperty_SolutionDirExpanded()
+ {
+ CreateHost();
+ AddTemplateVariableValue("SolutionDir", @"d:\projects\MySolution\");
+ string path = host.CallResolvePath("$(SolutionDir)");
+
+ Assert.AreEqual(@"d:\projects\MySolution\", path);
+ }
+
+ [Test]
+ public void GetService_HostPassedFakeServiceProvider_ReturnsServiceFromFakeServiceProvider()
+ {
+ CreateHost();
+ var expectedService = new StringWriter();
+ fakeServiceProvider.AddService(typeof(StringWriter), expectedService);
+
+ var hostServiceProvider = host as IServiceProvider;
+ StringWriter service = hostServiceProvider.GetService(typeof(StringWriter)) as StringWriter;
+
+ Assert.AreEqual(expectedService, service);
+ }
}
}
diff --git a/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingPathResolverTests.cs b/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingPathResolverTests.cs
new file mode 100644
index 0000000000..b3cc906939
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingPathResolverTests.cs
@@ -0,0 +1,57 @@
+// 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 ICSharpCode.TextTemplating;
+using NUnit.Framework;
+using TextTemplating.Tests.Helpers;
+
+namespace TextTemplating.Tests
+{
+ [TestFixture]
+ public class TextTemplatingPathResolverTests
+ {
+ TextTemplatingPathResolver pathResolver;
+ FakeTextTemplatingVariables fakeTemplatingVariables;
+ FakeTextTemplatingEnvironment fakeEnvironment;
+
+ void CreatePathResolver()
+ {
+ fakeTemplatingVariables = new FakeTextTemplatingVariables();
+ fakeEnvironment = new FakeTextTemplatingEnvironment();
+ pathResolver = new TextTemplatingPathResolver(fakeTemplatingVariables, fakeEnvironment);
+ }
+
+ void AddEnvironmentVariable(string name, string value)
+ {
+ fakeEnvironment.AddVariable(name, value);
+ }
+
+ void AddTemplateVariable(string name, string value)
+ {
+ fakeTemplatingVariables.AddVariable(name, value);
+ }
+
+ [Test]
+ public void ResolvePath_EnvironmentVariableInPath_ReturnsPathWithEnvironmentVariableExpanded()
+ {
+ CreatePathResolver();
+ AddEnvironmentVariable("windir", @"c:\windows");
+
+ string path = pathResolver.ResolvePath("%windir%");
+
+ Assert.AreEqual(@"c:\windows", path);
+ }
+
+ [Test]
+ public void ResolvePath_TemplateVariableInPath_ReturnsPathWithTemplateVariableExpanded()
+ {
+ CreatePathResolver();
+ AddTemplateVariable("SolutionDir", @"d:\projects\MyApp\");
+
+ string path = pathResolver.ResolvePath("$(SolutionDir)");
+
+ Assert.AreEqual(@"d:\projects\MyApp\", path);
+ }
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingServiceProviderTests.cs b/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingServiceProviderTests.cs
new file mode 100644
index 0000000000..d8393b457a
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingServiceProviderTests.cs
@@ -0,0 +1,30 @@
+// 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 ICSharpCode.TextTemplating;
+using NUnit.Framework;
+using TextTemplating.Tests.Helpers;
+
+namespace TextTemplating.Tests
+{
+ [TestFixture]
+ public class TextTemplatingServiceProviderTests
+ {
+ TextTemplatingServiceProvider serviceProvider;
+
+ void CreateServiceProvider()
+ {
+ serviceProvider = new TextTemplatingServiceProvider();
+ }
+
+ [Test]
+ public void GetService_TypeOfFakeServiceProvider_ReturnsNewFakeServiceProvider()
+ {
+ CreateServiceProvider();
+ FakeServiceProvider service = serviceProvider.GetService(typeof(FakeServiceProvider)) as FakeServiceProvider;
+
+ Assert.IsNotNull(service);
+ }
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingVariableLocationTests.cs b/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingVariableLocationTests.cs
new file mode 100644
index 0000000000..924eb0adf0
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingVariableLocationTests.cs
@@ -0,0 +1,78 @@
+// 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 ICSharpCode.TextTemplating;
+using NUnit.Framework;
+
+namespace TextTemplating.Tests
+{
+ [TestFixture]
+ public class TextTemplatingVariableLocationTests
+ {
+ TextTemplatingVariableLocation lhs;
+ TextTemplatingVariableLocation rhs;
+
+ void CreateVariableLocationsToCompare()
+ {
+ lhs = new TextTemplatingVariableLocation();
+ rhs = new TextTemplatingVariableLocation();
+ }
+
+ [Test]
+ public void Equals_AllPropertiesSame_ReturnsTrue()
+ {
+ CreateVariableLocationsToCompare();
+
+ bool result = lhs.Equals(rhs);
+
+ Assert.IsTrue(result);
+ }
+
+ [Test]
+ public void Equals_VariableNamesAreDifferent_ReturnsFalse()
+ {
+ CreateVariableLocationsToCompare();
+ lhs.VariableName = "A";
+ rhs.VariableName = "B";
+
+ bool result = lhs.Equals(rhs);
+
+ Assert.IsFalse(result);
+ }
+
+ [Test]
+ public void Equals_NullPassed_ReturnsFalse()
+ {
+ CreateVariableLocationsToCompare();
+
+ bool result = lhs.Equals(null);
+
+ Assert.IsFalse(result);
+ }
+
+ [Test]
+ public void Equals_IndexesAreDifferent_ReturnsFalse()
+ {
+ CreateVariableLocationsToCompare();
+ lhs.Index = 1;
+ rhs.Index = 3;
+
+ bool result = lhs.Equals(rhs);
+
+ Assert.IsFalse(result);
+ }
+
+ [Test]
+ public void Equals_LengthsAreDifferent_ReturnsFalse()
+ {
+ CreateVariableLocationsToCompare();
+ lhs.Length = 1;
+ rhs.Length = 3;
+
+ bool result = lhs.Equals(rhs);
+
+ Assert.IsFalse(result);
+ }
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingVariablesTests.cs b/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingVariablesTests.cs
new file mode 100644
index 0000000000..4449014999
--- /dev/null
+++ b/src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingVariablesTests.cs
@@ -0,0 +1,241 @@
+// 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;
+using System.Linq;
+using ICSharpCode.TextTemplating;
+using NUnit.Framework;
+using TextTemplating.Tests.Helpers;
+
+namespace TextTemplating.Tests
+{
+ [TestFixture]
+ public class TextTemplatingVariablesTests
+ {
+ TextTemplatingVariables variables;
+ FakeTextTemplatingStringParser fakeStringParser;
+
+ void CreateTextTemplatingVariables()
+ {
+ fakeStringParser = new FakeTextTemplatingStringParser();
+ variables = new TextTemplatingVariables(fakeStringParser);
+ }
+
+ void AddProperty(string name, string value)
+ {
+ fakeStringParser.AddProperty(name, value);
+ }
+
+ [Test]
+ public void ExpandVariables_SolutionDirProperty_SolutionDirPropertyIsExpanded()
+ {
+ CreateTextTemplatingVariables();
+ AddProperty("SolutionDir", @"d:\projects\MyProject\");
+
+ string result = variables.ExpandVariables(@"$(SolutionDir)bin\Debug\Test.dll");
+
+ string expectedResult = @"d:\projects\MyProject\bin\Debug\Test.dll";
+ Assert.AreEqual(expectedResult, result);
+ }
+
+ [Test]
+ public void ExpandVariables_ProjectDirProperty_ProjectDirPropertyIsExpanded()
+ {
+ CreateTextTemplatingVariables();
+ AddProperty("ProjectDir", @"d:\projects\MyProject\");
+
+ string result = variables.ExpandVariables(@"$(ProjectDir)bin\Debug\Test.dll");
+
+ string expectedResult = @"d:\projects\MyProject\bin\Debug\Test.dll";
+ Assert.AreEqual(expectedResult, result);
+ }
+
+ [Test]
+ public void GetVariableLocations_SolutionDirProperty_ReturnsSolutionDirVariable()
+ {
+ CreateTextTemplatingVariables();
+
+ TextTemplatingVariableLocation location = variables.GetVariables("$(SolutionDir)").First();
+
+ var expectedLocation = new TextTemplatingVariableLocation() {
+ VariableName = "SolutionDir",
+ Index = 0,
+ Length = 14
+ };
+
+ Assert.AreEqual(expectedLocation, location);
+ }
+
+ [Test]
+ public void GetVariableLocations_NullPassed_ReturnsNoVariables()
+ {
+ CreateTextTemplatingVariables();
+ List locations =
+ variables.GetVariables(null).ToList();
+
+ Assert.AreEqual(0, locations.Count);
+ }
+
+ [Test]
+ public void GetVariableLocations_EmptyStringPassed_ReturnsNoVariables()
+ {
+ CreateTextTemplatingVariables();
+ List locations =
+ variables.GetVariables(String.Empty).ToList();
+
+ Assert.AreEqual(0, locations.Count);
+ }
+
+ [Test]
+ public void GetVariableLocations_TextHasNoVariables_ReturnsNoVariables()
+ {
+ CreateTextTemplatingVariables();
+ List locations =
+ variables.GetVariables("No Variables").ToList();
+
+ Assert.AreEqual(0, locations.Count);
+ }
+
+ [Test]
+ public void GetVariableLocations_TextHasVariableStartButNoEnd_ReturnsNoVariables()
+ {
+ CreateTextTemplatingVariables();
+ List locations =
+ variables.GetVariables("$(No Variables").ToList();
+
+ Assert.AreEqual(0, locations.Count);
+ }
+
+ [Test]
+ public void GetVariableLocations_TwoProperties_ReturnsTwoVariables()
+ {
+ CreateTextTemplatingVariables();
+
+ List locations =
+ variables.GetVariables("$(SolutionDir)$(ProjectDir)").ToList();
+
+ var expectedLocation1 = new TextTemplatingVariableLocation() {
+ VariableName = "SolutionDir",
+ Index = 0,
+ Length = 14
+ };
+
+ var expectedLocation2 = new TextTemplatingVariableLocation() {
+ VariableName = "ProjectDir",
+ Index = 14,
+ Length = 13
+ };
+
+ var expectedLocations = new TextTemplatingVariableLocation[] {
+ expectedLocation1,
+ expectedLocation2
+ };
+
+ CollectionAssert.AreEqual(expectedLocations, locations);
+ }
+
+ [Test]
+ public void GetValue_ProjectDirProperty_ReturnsProjectDir()
+ {
+ CreateTextTemplatingVariables();
+ AddProperty("ProjectDir", @"d:\projects\MyProject\");
+
+ string variableValue = variables.GetValue("ProjectDir");
+
+ string expectedVariableValue = @"d:\projects\MyProject\";
+ Assert.AreEqual(expectedVariableValue, variableValue);
+ }
+
+ [Test]
+ public void GetValue_ProjectDirPropertyHasNoTrailingSlash_ReturnsProjectDirWithTrailingSlash()
+ {
+ CreateTextTemplatingVariables();
+ AddProperty("ProjectDir", @"d:\projects\MyProject");
+
+ string variableValue = variables.GetValue("ProjectDir");
+
+ string expectedVariableValue = @"d:\projects\MyProject\";
+ Assert.AreEqual(expectedVariableValue, variableValue);
+ }
+
+ [Test]
+ public void GetValue_PropertyReturnsEmptyStringAsValue_ReturnsEmptyString()
+ {
+ CreateTextTemplatingVariables();
+ AddProperty("ProjectDir", String.Empty);
+
+ string variableValue = variables.GetValue("ProjectDir");
+
+ Assert.AreEqual(String.Empty, variableValue);
+ }
+
+ [Test]
+ public void GetValue_PropertyReturnsNullAsValue_ReturnsEmptyString()
+ {
+ CreateTextTemplatingVariables();
+ AddProperty("Test", null);
+
+ string variableValue = variables.GetValue("Test");
+
+ Assert.AreEqual(String.Empty, variableValue);
+ }
+
+ [Test]
+ public void GetValue_NonDirectoryPropertyReturnsNonEmptyStringAsValue_DoesNotAppendTrailingSlash()
+ {
+ CreateTextTemplatingVariables();
+ AddProperty("Test", "abc");
+
+ string variableValue = variables.GetValue("Test");
+
+ Assert.AreEqual("abc", variableValue);
+ }
+
+ [Test]
+ public void GetValue_SolutionDirPropertyWithoutTrailingSlash_ReturnsExpandedSolutionDirWithTrailingSlash()
+ {
+ CreateTextTemplatingVariables();
+ AddProperty("SolutionDir", @"d:\projects\MySolution");
+
+ string variableValue = variables.GetValue("SolutionDir");
+
+ string expectedVariableValue = @"d:\projects\MySolution\";
+ Assert.AreEqual(expectedVariableValue, variableValue);
+ }
+
+ [Test]
+ public void GetValue_SolutionDirPropertyInLowerCaseWithoutTrailingSlash_ReturnsExpandedSolutionDirWithTrailingSlash()
+ {
+ CreateTextTemplatingVariables();
+ AddProperty("solutiondir", @"d:\projects\MySolution");
+
+ string variableValue = variables.GetValue("solutiondir");
+
+ string expectedVariableValue = @"d:\projects\MySolution\";
+ Assert.AreEqual(expectedVariableValue, variableValue);
+ }
+
+ [Test]
+ public void GetValue_NullPassed_ReturnsEmptyString()
+ {
+ CreateTextTemplatingVariables();
+
+ string variableValue = variables.GetValue(null);
+
+ Assert.AreEqual(String.Empty, variableValue);
+ }
+
+ [Test]
+ public void ExpandVariables_ProjectDirPropertyHasNoTrailingSlash_ProjectDirPropertyIsExpandedWithTrailingSlash()
+ {
+ CreateTextTemplatingVariables();
+ AddProperty("ProjectDir", @"d:\projects\MyProject");
+
+ string result = variables.ExpandVariables(@"$(ProjectDir)bin\Debug\Test.dll");
+
+ string expectedResult = @"d:\projects\MyProject\bin\Debug\Test.dll";
+ Assert.AreEqual(expectedResult, result);
+ }
+ }
+}
diff --git a/src/AddIns/Misc/TextTemplating/Test/TextTemplating.Tests.csproj b/src/AddIns/Misc/TextTemplating/Test/TextTemplating.Tests.csproj
index 0a613b236c..bddd0bf396 100644
--- a/src/AddIns/Misc/TextTemplating/Test/TextTemplating.Tests.csproj
+++ b/src/AddIns/Misc/TextTemplating/Test/TextTemplating.Tests.csproj
@@ -57,13 +57,18 @@
+
+
+
+
+
@@ -77,8 +82,12 @@
+
+
+
+
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs
index f60e0db466..7cf4364fe0 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs
@@ -84,6 +84,7 @@ namespace ICSharpCode.AvalonEdit.Folding
///
/// Gets the content of the collapsed lines as tooltip text.
///
+ [Obsolete]
public string TooltipText {
get {
// This fixes SD-1394:
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
index db13efe534..6464903978 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
@@ -1612,6 +1612,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
///
/// Gets the text view position from the specified visual position.
+ /// If the position is within a character, it is rounded to the next character boundary.
///
/// The position in WPF device-independent pixels relative
/// to the top left corner of the document.
@@ -1628,6 +1629,26 @@ namespace ICSharpCode.AvalonEdit.Rendering
int documentOffset = line.GetRelativeOffset(visualColumn) + line.FirstDocumentLine.Offset;
return new TextViewPosition(document.GetLocation(documentOffset), visualColumn);
}
+
+ ///
+ /// Gets the text view position from the specified visual position.
+ /// If the position is inside a character, the position in front of the character is returned.
+ ///
+ /// The position in WPF device-independent pixels relative
+ /// to the top left corner of the document.
+ /// The logical position, or null if the position is outside the document.
+ public TextViewPosition? GetPositionFloor(Point visualPosition)
+ {
+ VerifyAccess();
+ if (this.Document == null)
+ throw ThrowUtil.NoDocumentAssigned();
+ VisualLine line = GetVisualLineFromVisualTop(visualPosition.Y);
+ if (line == null)
+ return null;
+ int visualColumn = line.GetVisualColumnFloor(visualPosition);
+ int documentOffset = line.GetRelativeOffset(visualColumn) + line.FirstDocumentLine.Offset;
+ return new TextViewPosition(document.GetLocation(documentOffset), visualColumn);
+ }
#endregion
#region Service Provider
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml.cs
index 094e177076..f7c41a1b43 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml.cs
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml.cs
@@ -45,10 +45,8 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
}
break;
case WebServer.IIS:
- if (WebProjectService.IISVersion == IISVersion.IIS5 ||
- WebProjectService.IISVersion == IISVersion.IIS6 ||
- WebProjectService.IISVersion == IISVersion.IIS7 ||
- WebProjectService.IISVersion == IISVersion.IIS_Future) {
+ if (WebProjectService.IISVersion != IISVersion.IISExpress &&
+ WebProjectService.IISVersion != IISVersion.None) {
UseLocalIIS.IsChecked = true;
ProjectUrl.Text = CurrentProjectDebugData.ProjectUrl ?? string.Empty;
@@ -134,9 +132,8 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
WebProjectDebugData data = new WebProjectDebugData();
data.WebServer = WebServer.IIS;
data.Port = string.Empty;
- bool isIISInstalled = WebProjectService.IISVersion == IISVersion.IIS5 ||
- WebProjectService.IISVersion == IISVersion.IIS6 ||
- WebProjectService.IISVersion == IISVersion.IIS7;
+ bool isIISInstalled = WebProjectService.IISVersion != IISVersion.IISExpress &&
+ WebProjectService.IISVersion != IISVersion.None;
if (!isIISInstalled) {
StatusLabel.Text = ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.IISNotFound");
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/GacReferencePanel.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/GacReferencePanel.cs
index 260844a251..009734e3d7 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/GacReferencePanel.cs
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/GacReferencePanel.cs
@@ -378,8 +378,7 @@ namespace ICSharpCode.SharpDevelop.Gui
}
});
- string mscorlibPath;
- MSBuildInternals.ResolveAssemblyReferences(project, referenceItems.ToArray(), out mscorlibPath);
+ MSBuildInternals.ResolveAssemblyReferences(project, referenceItems.ToArray(), resolveOnlyAdditionalReferences: true, logErrorsToOutputPad: false);
WorkbenchSingleton.SafeThreadAsyncCall(
delegate {
@@ -423,8 +422,7 @@ namespace ICSharpCode.SharpDevelop.Gui
}
});
- string mscorlibPath;
- MSBuildInternals.ResolveAssemblyReferences(project, referenceItems.ToArray(), out mscorlibPath);
+ MSBuildInternals.ResolveAssemblyReferences(project, referenceItems.ToArray(), resolveOnlyAdditionalReferences: true, logErrorsToOutputPad: false);
foreach (ReferenceProjectItem rpi in referenceItems) {
if (string.IsNullOrEmpty(rpi.Redist)) continue;
if (!redistNameToRequiredFramework.ContainsKey(rpi.Redist)) {
diff --git a/src/Main/Base/Project/Src/Project/AbstractProject.cs b/src/Main/Base/Project/Src/Project/AbstractProject.cs
index a41db29263..b32ddd3296 100644
--- a/src/Main/Base/Project/Src/Project/AbstractProject.cs
+++ b/src/Main/Base/Project/Src/Project/AbstractProject.cs
@@ -7,7 +7,7 @@ using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
-using System.Linq;
+using System.Threading;
using System.Xml.Linq;
using ICSharpCode.Core;
@@ -525,6 +525,27 @@ namespace ICSharpCode.SharpDevelop.Project
{
}
+ public virtual IEnumerable ResolveAssemblyReferences(CancellationToken cancellationToken)
+ {
+ ResolveAssemblyReferences();
+ List referenceItems = new List();
+ bool mscorlib = false;
+ foreach (ProjectItem item in this.Items) {
+ cancellationToken.ThrowIfCancellationRequested();
+ if (ItemType.ReferenceItemTypes.Contains(item.ItemType)) {
+ ReferenceProjectItem reference = item as ReferenceProjectItem;
+ if (reference != null) {
+ referenceItems.Add(reference);
+ mscorlib |= "mscorlib".Equals(reference.Include, StringComparison.OrdinalIgnoreCase);
+ }
+ }
+ }
+ if (!mscorlib) {
+ referenceItems.Add(new ReferenceProjectItem(this, "mscorlib") { FileName = typeof(object).Module.FullyQualifiedName });
+ }
+ return referenceItems;
+ }
+
public virtual void StartBuild(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink)
{
feedbackSink.ReportError(new BuildError { ErrorText = "Building project " + Name + " is not supported.", IsWarning = true });
diff --git a/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs b/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
index 07917ac7c8..ac7453f5ef 100644
--- a/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
+++ b/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
@@ -8,6 +8,7 @@ using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
+using System.Threading;
using System.Xml;
using System.Xml.Linq;
using ICSharpCode.Core;
@@ -137,21 +138,14 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
- volatile string mscorlibPath;
-
- ///
- /// Gets the path to mscorlib.
- /// This property is set only after ResolveAssemblyReferences() is called.
- ///
- public string MscorlibPath {
- get { return mscorlibPath; }
+ public override void ResolveAssemblyReferences()
+ {
+ MSBuildInternals.ResolveAssemblyReferences(this);
}
- public override void ResolveAssemblyReferences()
+ public override IEnumerable ResolveAssemblyReferences(CancellationToken cancellationToken)
{
- string mscorlib;
- MSBuildInternals.ResolveAssemblyReferences(this, null, out mscorlib);
- this.mscorlibPath = mscorlib;
+ return MSBuildInternals.ResolveAssemblyReferences(this);
}
#region CreateProjectItem
diff --git a/src/Main/Base/Project/Src/Project/MSBuildInternals.cs b/src/Main/Base/Project/Src/Project/MSBuildInternals.cs
index 5760270806..7fbbc6f5dc 100644
--- a/src/Main/Base/Project/Src/Project/MSBuildInternals.cs
+++ b/src/Main/Base/Project/Src/Project/MSBuildInternals.cs
@@ -162,7 +162,10 @@ namespace ICSharpCode.SharpDevelop.Project
/// The base project.
/// A different set of references to use instead of those in the project.
/// Used by the GacReferencePanel.
- internal static void ResolveAssemblyReferences(MSBuildBasedProject baseProject, ReferenceProjectItem[] referenceReplacements, out string mscorlibPath)
+ public static IList ResolveAssemblyReferences(
+ MSBuildBasedProject baseProject,
+ ReferenceProjectItem[] additionalReferences = null, bool resolveOnlyAdditionalReferences = false,
+ bool logErrorsToOutputPad = true)
{
ProjectInstance project = baseProject.CreateProjectInstance();
project.SetProperty("BuildingProject", "false");
@@ -173,30 +176,35 @@ namespace ICSharpCode.SharpDevelop.Project
select item
).ToList();
- ReferenceProjectItem[] referenceProjectItems;
+ List referenceProjectItems;
- if (referenceReplacements == null) {
- // Remove the "Private" meta data.
- // This is necessary to detect the default value for "Private"
+ if (resolveOnlyAdditionalReferences) {
+ // Remove existing references from project
foreach (ProjectItemInstance reference in references) {
- reference.RemoveMetadata("Private");
+ project.RemoveItem(reference);
}
-
- referenceProjectItems = baseProject.Items.OfType().ToArray();
+ references.Clear();
+ referenceProjectItems = new List();
} else {
+ // Remove the "Private" meta data.
+ // This is necessary to detect the default value for "Private"
foreach (ProjectItemInstance reference in references) {
- project.RemoveItem(reference);
+ reference.RemoveMetadata("Private");
}
- foreach (ReferenceProjectItem item in referenceReplacements) {
- project.AddItem("Reference", item.Include);
+ referenceProjectItems = baseProject.Items.OfType().ToList();
+ }
+
+ if (additionalReferences != null) {
+ referenceProjectItems.AddRange(additionalReferences);
+ foreach (ReferenceProjectItem item in additionalReferences) {
+ references.Add(project.AddItem("Reference", item.Include));
}
- referenceProjectItems = referenceReplacements;
}
string[] targets = { "ResolveAssemblyReferences" };
BuildRequestData requestData = new BuildRequestData(project, targets, new HostServices());
List loggers = new List();
- if (referenceReplacements == null)
+ if (logErrorsToOutputPad)
loggers.Add(new SimpleErrorLogger());
lock (SolutionProjectCollectionLock) {
BuildParameters parameters = new BuildParameters(baseProject.MSBuildProjectCollection);
@@ -209,32 +217,37 @@ namespace ICSharpCode.SharpDevelop.Project
LoggingService.Debug("Build for ResolveAssemblyReferences finished: " + result.OverallResult);
}
- var referenceDict = new Dictionary();
- foreach (ReferenceProjectItem item in referenceProjectItems) {
- // references could be duplicate, so we cannot use referenceDict.Add or reference.ToDictionary
- referenceDict[item.Include] = item;
- }
+ IEnumerable resolvedAssemblyProjectItems = project.GetItems("_ResolveAssemblyReferenceResolvedFiles");
- mscorlibPath = null;
- foreach (ProjectItemInstance item in project.GetItems("_ResolveAssemblyReferenceResolvedFiles")) {
- DomAssemblyName assemblyName = new DomAssemblyName(item.GetMetadataValue("FusionName"));
- string fullPath = FileUtility.GetAbsolutePath(baseProject.Directory, item.GetMetadataValue("Identity"));
-
- string originalInclude = item.GetMetadataValue("OriginalItemSpec");
- ReferenceProjectItem reference;
- if (referenceDict.TryGetValue(originalInclude, out reference)) {
- reference.AssemblyName = new Dom.DomAssemblyName(item.GetMetadataValue("FusionName"));
- reference.FileName = fullPath;
- reference.Redist = item.GetMetadataValue("Redist");
- LoggingService.Debug("Got information about " + originalInclude + "; fullpath=" + fullPath);
- reference.DefaultCopyLocalValue = bool.Parse(item.GetMetadataValue("CopyLocal"));
- } else if (string.Equals(assemblyName.ShortName, "mscorlib", StringComparison.OrdinalIgnoreCase)) {
- LoggingService.Debug("Got information for mscorlib: " + fullPath);
- mscorlibPath = fullPath;
+ var query =
+ from msbuildItem in resolvedAssemblyProjectItems
+ let originalInclude = msbuildItem.GetMetadataValue("OriginalItemSpec")
+ join item in referenceProjectItems on originalInclude equals item.Include into referenceItems
+ select new {
+ OriginalInclude = originalInclude,
+ AssemblyName = new DomAssemblyName(msbuildItem.GetMetadataValue("FusionName")),
+ FullPath = FileUtility.GetAbsolutePath(baseProject.Directory, msbuildItem.GetMetadataValue("Identity")),
+ Redist = msbuildItem.GetMetadataValue("Redist"),
+ CopyLocal = bool.Parse(msbuildItem.GetMetadataValue("CopyLocal")),
+ ReferenceItems = referenceItems
+ };
+ List resolvedAssemblies = new List();
+ foreach (var assembly in query) {
+ LoggingService.Debug("Got information about " + assembly.OriginalInclude + "; fullpath=" + assembly.FullPath);
+ foreach (var referenceItem in assembly.ReferenceItems) {
+ referenceItem.AssemblyName = assembly.AssemblyName;
+ referenceItem.FileName = assembly.FullPath;
+ referenceItem.Redist = assembly.Redist;
+ referenceItem.DefaultCopyLocalValue = assembly.CopyLocal;
+ }
+ ReferenceProjectItem firstItem = assembly.ReferenceItems.FirstOrDefault();
+ if (firstItem != null) {
+ resolvedAssemblies.Add(firstItem);
} else {
- LoggingService.Warn("Unknown item " + originalInclude);
+ resolvedAssemblies.Add(new ReferenceProjectItem(baseProject, assembly.OriginalInclude) { FileName = assembly.FullPath });
}
}
+ return resolvedAssemblies;
}
sealed class SimpleErrorLogger : ILogger
diff --git a/src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs b/src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs
index 6816d85cdb..76e5536532 100644
--- a/src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs
+++ b/src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs
@@ -57,27 +57,23 @@ namespace ICSharpCode.SharpDevelop
UpdateDefaultImports(items);
// TODO: Translate me
// progressMonitor.TaskName = "Resolving references for " + project.Name + "...";
- project.ResolveAssemblyReferences();
- MSBuildBasedProject msbuildProject = project as MSBuildBasedProject;
- if (msbuildProject != null) {
- string mscorlib = msbuildProject.MscorlibPath;
- if (string.IsNullOrEmpty(mscorlib)) {
- AddReferencedContent(AssemblyParserService.DefaultProjectContentRegistry.Mscorlib);
- } else {
- AddReferencedContent(AssemblyParserService.DefaultProjectContentRegistry.GetProjectContentForReference("mscorlib", mscorlib));
+ AbstractProject abstractProject = project as AbstractProject;
+ if (abstractProject != null) {
+ foreach (var reference in abstractProject.ResolveAssemblyReferences(progressMonitor.CancellationToken)) {
+ if (!initializing) return; // abort initialization
+ AddReference(reference, false, progressMonitor.CancellationToken);
}
} else {
+ project.ResolveAssemblyReferences();
AddReferencedContent(AssemblyParserService.DefaultProjectContentRegistry.Mscorlib);
- }
- foreach (ProjectItem item in items) {
- if (!initializing) return; // abort initialization
- progressMonitor.CancellationToken.ThrowIfCancellationRequested();
- if (ItemType.ReferenceItemTypes.Contains(item.ItemType)) {
- ReferenceProjectItem reference = item as ReferenceProjectItem;
- if (reference != null) {
- // TODO: Translate me
-// progressMonitor.TaskName = "Loading " + reference.ShortName + "...";
- AddReference(reference, false, progressMonitor.CancellationToken);
+ foreach (ProjectItem item in items) {
+ if (!initializing) return; // abort initialization
+ progressMonitor.CancellationToken.ThrowIfCancellationRequested();
+ if (ItemType.ReferenceItemTypes.Contains(item.ItemType)) {
+ ReferenceProjectItem reference = item as ReferenceProjectItem;
+ if (reference != null) {
+ AddReference(reference, false, progressMonitor.CancellationToken);
+ }
}
}
}
@@ -116,6 +112,7 @@ namespace ICSharpCode.SharpDevelop
void AddReference(ReferenceProjectItem reference, bool updateInterDependencies, CancellationToken cancellationToken)
{
try {
+ cancellationToken.ThrowIfCancellationRequested();
AddReferencedContent(AssemblyParserService.GetProjectContentForReference(reference));
if (updateInterDependencies) {
UpdateReferenceInterDependencies();
diff --git a/src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs b/src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs
index 639ef591fb..a674c126dd 100644
--- a/src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs
+++ b/src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs
@@ -7,6 +7,7 @@ using System.IO;
using System.Reflection;
using ICSharpCode.Core;
+using ICSharpCode.SharpDevelop.Dom;
using Microsoft.Win32;
namespace ICSharpCode.SharpDevelop.Project
@@ -14,11 +15,12 @@ namespace ICSharpCode.SharpDevelop.Project
public enum IISVersion
{
None = 0,
+ IISExpress,
IIS5 = 5,
IIS6,
IIS7,
- IISExpress,
- IIS_Future
+ IIS8,
+ IIS_Future = 100
}
public enum WebServer
@@ -49,7 +51,7 @@ namespace ICSharpCode.SharpDevelop.Project
///
/// Gets "iisexpress" string.
///
- public const string IIS_EXPRESS_PROCESS_NAME = "iisexpress";
+ public const string IIS_EXPRESS_PROCESS_NAME = "iisexpress";
///
/// Gets "aspnet_wp" string.
@@ -193,8 +195,9 @@ namespace ICSharpCode.SharpDevelop.Project
public static string CreateVirtualDirectory(string virtualDirectoryName, string physicalDirectoryPath)
{
try {
+ string iisNotFoundError = ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.IISNotFound");
if (!IsIISInstalled)
- return ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.IISNotFound");
+ return iisNotFoundError;
string error;
@@ -208,20 +211,26 @@ namespace ICSharpCode.SharpDevelop.Project
virtualDirectoryName,
out error);
break;
-
+ case IISVersion.None:
+ return iisNotFoundError;
default:
- // TODO: find a better way to create IIS 7 applications without Microsoft.Web.Administration.ServerManager
+ // TODO: find a better way to create IIS applications without Microsoft.Web.Administration.ServerManager
string name = "/" + virtualDirectoryName;
- // load from GAC - IIS7 is installed
- Assembly webAdministrationAssembly;
+ // load from GAC
+ Assembly webAdministrationAssembly = null;
try {
- // iis 7
- webAdministrationAssembly = Assembly.Load("Microsoft.Web.Administration, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
- }
- catch {
- // iis express
- webAdministrationAssembly = Assembly.Load("Microsoft.Web.Administration, Version=7.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
+ // iis installed
+ foreach(var assembly in GacInterop.GetAssemblyList()) {
+ if (assembly.FullName.Contains("Microsoft.Web.Administration")) {
+ webAdministrationAssembly = Assembly.Load(assembly.FullName);
+ break;
+ }
+ }
+ } catch {
+ return iisNotFoundError;
}
+ if (webAdministrationAssembly == null)
+ return iisNotFoundError;
// use dynamic because classic reflection is way TOO ugly
dynamic manager = webAdministrationAssembly.CreateInstance("Microsoft.Web.Administration.ServerManager");