Skip to content
Browse files

Merge branch 'master' of github.com:icsharpcode/SharpDevelop

  • Loading branch information...
2 parents b589ab7 + e03cd2b commit 380f1ae28df3c8d866b0da82d01eff483d216338 @PeterForstmeier PeterForstmeier committed Sep 30, 2011
Showing with 1,465 additions and 172 deletions.
  1. +2 −0 .gitignore
  2. +1 −2 src/AddIns/Analysis/CodeQuality/TreeMaps/TreeMaps.csproj
  3. +16 −11 src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/BooProject.cs
  4. +1 −1 src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Templates/WPFApplication.xpt
  5. +12 −6 src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs
  6. +68 −6 src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs
  7. BIN ...kages/AvalonEdit.Sample/{AvalonEdit.Sample.4.0.0.7070.nupkg → AvalonEdit.Sample.4.1.0.8000.nupkg}
  8. +11 −3 src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.nuspec
  9. 0 ...ges/AvalonEdit.Sample/Content/{AvalonEdit.Sample → Samples/AvalonEdit}/BraceFoldingStrategy.cs.pp
  10. 0 ...kages/AvalonEdit.Sample/Content/{AvalonEdit.Sample → Samples/AvalonEdit}/ColorizeAvalonEdit.cs.pp
  11. 0 ...ckages/AvalonEdit.Sample/Content/{AvalonEdit.Sample → Samples/AvalonEdit}/CustomHighlighting.xshd
  12. 0 ...es/AvalonEdit.Sample/Content/{AvalonEdit.Sample → Samples/AvalonEdit}/ImageElementGenerator.cs.pp
  13. 0 ...ackages/AvalonEdit.Sample/Content/{AvalonEdit.Sample → Samples/AvalonEdit}/MyCompletionData.cs.pp
  14. 0 ...nt/Packages/AvalonEdit.Sample/Content/{AvalonEdit.Sample → Samples/AvalonEdit}/Window1.xaml.cs.pp
  15. +2 −1 ...ement/Packages/AvalonEdit.Sample/Content/{AvalonEdit.Sample → Samples/AvalonEdit}/Window1.xaml.pp
  16. 0 ...nagement/Packages/AvalonEdit.Sample/Content/{AvalonEdit.Sample → Samples/AvalonEdit}/article.html
  17. 0 ...agement/Packages/AvalonEdit.Sample/Content/{AvalonEdit.Sample → Samples/AvalonEdit}/document.html
  18. 0 ...gement/Packages/AvalonEdit.Sample/Content/{AvalonEdit.Sample → Samples/AvalonEdit}/rendering.html
  19. BIN src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.0.0.7070.nupkg
  20. BIN src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.1.0.8000.nupkg
  21. BIN src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.1.0.8000.symbols.nupkg
  22. +21 −14 src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.nuspec
  23. BIN src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/lib/Net35/ICSharpCode.AvalonEdit.dll
  24. BIN src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/lib/Net40/ICSharpCode.AvalonEdit.dll
  25. BIN src/AddIns/Misc/PackageManagement/Packages/NuGet.exe
  26. +21 −4 src/AddIns/Misc/PackageManagement/Packages/buildpackages.cmd
  27. +1 −1 src/AddIns/Misc/TextTemplating/Project/Resources/TextTemplating.xshd
  28. +12 −0 src/AddIns/Misc/TextTemplating/Project/Src/ITextTemplatingEnvironment.cs
  29. +12 −0 src/AddIns/Misc/TextTemplating/Project/Src/ITextTemplatingPathResolver.cs
  30. +12 −0 src/AddIns/Misc/TextTemplating/Project/Src/ITextTemplatingStringParser.cs
  31. +13 −0 src/AddIns/Misc/TextTemplating/Project/Src/ITextTemplatingVariables.cs
  32. +19 −2 src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingAssemblyResolver.cs
  33. +4 −2 src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingCustomTool.cs
  34. +27 −0 src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingDirectoryVariable.cs
  35. +15 −0 src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingEnvironment.cs
  36. +22 −11 src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingHost.cs
  37. +57 −0 src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingHostContext.cs
  38. +32 −0 src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingPathResolver.cs
  39. +15 −0 src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingServiceProvider.cs
  40. +16 −0 src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingStringParser.cs
  41. +75 −0 src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingVariableLocation.cs
  42. +92 −0 src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingVariables.cs
  43. +73 −0 src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingVariablesStringBuilder.cs
  44. +13 −0 src/AddIns/Misc/TextTemplating/Project/TextTemplating.csproj
  45. +2 −0 src/AddIns/Misc/TextTemplating/Test/Helpers/FakeAssemblyParserService.cs
  46. +25 −0 src/AddIns/Misc/TextTemplating/Test/Helpers/FakeServiceProvider.cs
  47. +29 −0 src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingEnvironment.cs
  48. +28 −0 src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingPathResolver.cs
  49. +26 −0 src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingStringParser.cs
  50. +35 −0 src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingVariables.cs
  51. +22 −1 src/AddIns/Misc/TextTemplating/Test/Helpers/TestableTextTemplatingHost.cs
  52. +29 −1 src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingAssemblyResolverTests.cs
  53. +47 −15 src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingHostTests.cs
  54. +57 −0 src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingPathResolverTests.cs
  55. +30 −0 src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingServiceProviderTests.cs
  56. +78 −0 src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingVariableLocationTests.cs
  57. +241 −0 src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingVariablesTests.cs
  58. +9 −0 src/AddIns/Misc/TextTemplating/Test/TextTemplating.Tests.csproj
  59. +1 −0 src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs
  60. +21 −0 src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
  61. +4 −7 ...ject/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml.cs
  62. +2 −4 src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/GacReferencePanel.cs
  63. +22 −1 src/Main/Base/Project/Src/Project/AbstractProject.cs
  64. +6 −12 src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
  65. +48 −35 src/Main/Base/Project/Src/Project/MSBuildInternals.cs
  66. +15 −18 src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs
  67. +23 −14 src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs
View
2 .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
View
3 src/AddIns/Analysis/CodeQuality/TreeMaps/TreeMaps.csproj
@@ -28,18 +28,17 @@
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ <OutputPath>..\..\..\..\..\AddIns\Analysis\CodeQualityAnalysis\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<Optimize>false</Optimize>
- <OutputPath>..\..\..\..\AddIns\Analysis\CodeQualityAnalysis\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<Optimize>true</Optimize>
- <OutputPath>.\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
View
27 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,32 +83,34 @@ public override ItemType GetDefaultItemType(string fileName)
}
internal static IProjectContent BooCompilerPC;
- internal static IProjectContent BooUsefulPC;
protected override ParseProjectContent CreateProjectContent()
{
if (BooCompilerPC == null) {
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");
pc.DefaultImports.Usings.Add("Boo.Lang.Extensions");
return pc;
}
+ public override IEnumerable<ReferenceProjectItem> 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();
View
2 src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Templates/WPFApplication.xpt
@@ -28,7 +28,7 @@
<PropertyGroup configuration="Release" escapeValue="false">
<OutputType>WinExe</OutputType>
<MainFile>Application.rb</MainFile>
- <StartArguments>--disable-gems Application.py</StartArguments>
+ <StartArguments>--disable-gems Application.rb</StartArguments>
<StartWorkingDirectory>.\</StartWorkingDirectory>
<StartAction>Program</StartAction>
<StartProgram>${addinpath:ICSharpCode.RubyBinding}\ir.exe</StartProgram>
View
18 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 @@ public VBNetProject(ProjectCreateInformation info)
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<ReferenceProjectItem> ResolveAssemblyReferences(CancellationToken cancellationToken)
+ {
+ ReferenceProjectItem[] additionalItems = {
+ new ReferenceProjectItem(this, "mscorlib"),
+ new ReferenceProjectItem(this, "Microsoft.VisualBasic"),
+ };
+ return MSBuildInternals.ResolveAssemblyReferences(this, additionalItems);
+ }
+
void InitVB()
{
reparseReferencesSensitiveProperties.Add("TargetFrameworkVersion");
View
74 src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs
@@ -8,27 +8,27 @@
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 @@ void TextEditorMouseHover(object sender, MouseEventArgs e)
{
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 @@ void TextEditorMouseHover(object sender, MouseEventArgs e)
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 @@ void PopupClosed(object sender, EventArgs e)
{
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
View
BIN ...Sample/AvalonEdit.Sample.4.0.0.7070.nupkg → ...Sample/AvalonEdit.Sample.4.1.0.8000.nupkg
Binary file not shown.
View
14 src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.nuspec
@@ -2,18 +2,26 @@
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>AvalonEdit.Sample</id>
- <version>4.0.0.7070</version>
+ <version>4.1.0.8000</version>
<authors>Daniel Grunwald</authors>
<owners>SharpDevelop</owners>
<licenseUrl>http://www.opensource.org/licenses/mit-license.php</licenseUrl>
<projectUrl>http://www.avalonedit.net</projectUrl>
<iconUrl>http://community.sharpdevelop.net/blogs/mattward/SharpDevelop.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
- <description>Sample code for AvalonEdit the WPF-based text editor used in SharpDevelop 4.0.</description>
+ <description>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"</description>
<summary>Sample code for AvalonEdit the WPF-based text editor used in SharpDevelop 4.0.</summary>
<language>en-US</language>
<dependencies>
- <dependency id="AvalonEdit" version="4.0.0.7070" />
+ <dependency id="AvalonEdit" version="4.1.0.8000" />
</dependencies>
+ <frameworkAssemblies>
+ <frameworkAssembly assemblyName="System.Windows.Forms" />
+ <frameworkAssembly assemblyName="WindowsFormsIntegration" />
+ </frameworkAssemblies>
+ <tags>WPF Text Editor SharpDevelop AvalonEdit</tags>
</metadata>
</package>
View
0 ...lonEdit.Sample/BraceFoldingStrategy.cs.pp → ...les/AvalonEdit/BraceFoldingStrategy.cs.pp
File renamed without changes.
View
0 ...valonEdit.Sample/ColorizeAvalonEdit.cs.pp → ...mples/AvalonEdit/ColorizeAvalonEdit.cs.pp
File renamed without changes.
View
0 ...AvalonEdit.Sample/CustomHighlighting.xshd → ...amples/AvalonEdit/CustomHighlighting.xshd
File renamed without changes.
View
0 ...onEdit.Sample/ImageElementGenerator.cs.pp → ...es/AvalonEdit/ImageElementGenerator.cs.pp
File renamed without changes.
View
0 .../AvalonEdit.Sample/MyCompletionData.cs.pp → ...Samples/AvalonEdit/MyCompletionData.cs.pp
File renamed without changes.
View
0 ...tent/AvalonEdit.Sample/Window1.xaml.cs.pp → ...ent/Samples/AvalonEdit/Window1.xaml.cs.pp
File renamed without changes.
View
3 ...Content/AvalonEdit.Sample/Window1.xaml.pp → ...ontent/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"
>
<DockPanel>
View
0 ...le/Content/AvalonEdit.Sample/article.html → ...e/Content/Samples/AvalonEdit/article.html
File renamed without changes.
View
0 ...e/Content/AvalonEdit.Sample/document.html → .../Content/Samples/AvalonEdit/document.html
File renamed without changes.
View
0 .../Content/AvalonEdit.Sample/rendering.html → ...Content/Samples/AvalonEdit/rendering.html
File renamed without changes.
View
BIN src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.0.0.7070.nupkg
Binary file not shown.
View
BIN src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.1.0.8000.nupkg
Binary file not shown.
View
BIN src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.1.0.8000.symbols.nupkg
Binary file not shown.
View
35 src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.nuspec
@@ -1,18 +1,25 @@
<?xml version="1.0"?>
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
- <id>AvalonEdit</id>
- <version>4.0.0.7070</version>
- <authors>Daniel Grunwald</authors>
- <owners>SharpDevelop</owners>
- <licenseUrl>http://www.opensource.org/licenses/lgpl-2.1.php</licenseUrl>
- <projectUrl>http://www.avalonedit.net</projectUrl>
- <iconUrl>http://community.sharpdevelop.net/blogs/mattward/SharpDevelop.png</iconUrl>
- <requireLicenseAcceptance>true</requireLicenseAcceptance>
- <description>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.</description>
- <summary>AvalonEdit is the WPF-based text editor used in SharpDevelop 4.0.</summary>
- <language>en-US</language>
+ <metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
+ <id>AvalonEdit</id>
+ <version>4.1.0.8000</version>
+ <authors>Daniel Grunwald</authors>
+ <owners>SharpDevelop</owners>
+ <licenseUrl>http://www.opensource.org/licenses/lgpl-2.1.php</licenseUrl>
+ <projectUrl>http://www.avalonedit.net</projectUrl>
+ <iconUrl>http://community.sharpdevelop.net/blogs/mattward/SharpDevelop.png</iconUrl>
+ <requireLicenseAcceptance>true</requireLicenseAcceptance>
+ <description>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.</description>
+ <summary>AvalonEdit is the WPF-based text editor used in SharpDevelop</summary>
+ <releaseNotes>Improved WPF text rendering performance.
+Region tooltips added.
+C# syntax highlighting: Do not colorize punctuation.</releaseNotes>
+ <language>en-US</language>
+ <tags>WPF Text Editor SharpDevelop AvalonEdit</tags>
</metadata>
+ <files>
+ <file src="lib\Net35\*.*" target="lib\Net35" />
+ <file src="lib\Net40\*.*" target="lib\Net40" />
+ <file src="..\..\..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\**\*.cs" target="src" />
+ </files>
</package>
View
BIN src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/lib/Net35/ICSharpCode.AvalonEdit.dll
Binary file not shown.
View
BIN src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/lib/Net40/ICSharpCode.AvalonEdit.dll
Binary file not shown.
View
BIN src/AddIns/Misc/PackageManagement/Packages/NuGet.exe
Binary file not shown.
View
25 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
+@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
View
2 src/AddIns/Misc/TextTemplating/Project/Resources/TextTemplating.xshd
@@ -51,7 +51,7 @@
</RuleSet>
- <RuleSet name="DirectiveBlock">
+ <RuleSet name="DirectiveBlock" ignoreCase="true">
<Keywords color="DirectiveKeywords">
<Word>template</Word>
<Word>parameter</Word>
View
12 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);
+ }
+}
View
12 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);
+ }
+}
View
12 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);
+ }
+}
View
13 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);
+ }
+}
View
21 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 @@ public class TextTemplatingAssemblyResolver : ITextTemplatingAssemblyResolver
{
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 @@ public string Resolve(string assemblyReference)
return assemblyReference;
}
+ string ResolvePath(string assemblyReference)
+ {
+ return pathResolver.ResolvePath(assemblyReference);
+ }
+
string ResolveAssemblyFromProject(string assemblyReference)
{
foreach (ReferenceProjectItem refProjectItem in project.GetItemsOfType(ItemType.Reference)) {
View
6 src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingCustomTool.cs
@@ -16,8 +16,10 @@ protected TextTemplatingHost CreateTextTemplatingHost(IProject project)
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()
View
27 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;
+ }
+ }
+}
View
15 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);
+ }
+ }
+}
View
33 src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingHost.cs
@@ -6,20 +6,15 @@
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 @@ public override AppDomain ProvideTemplatingAppDomain(string content)
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);
}
}
}
View
57 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);
+ }
+ }
+}
View
32 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);
+ }
+ }
+}
View
15 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);
+ }
+ }
+}
View
16 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);
+ }
+ }
+}
View
75 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;
+ }
+ }
+}
View
92 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<TextTemplatingVariableLocation> 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;
+ }
+ }
+}
View
73 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);
+ }
+ }
+}
View
13 src/AddIns/Misc/TextTemplating/Project/TextTemplating.csproj
@@ -57,9 +57,13 @@
<Compile Include="Src\ITextTemplatingAppDomainFactory.cs" />
<Compile Include="Src\ITextTemplatingAssemblyResolver.cs" />
<Compile Include="Src\ITextTemplatingCustomToolContext.cs" />
+ <Compile Include="Src\ITextTemplatingEnvironment.cs" />
<Compile Include="Src\ITextTemplatingFilePreprocessor.cs" />
<Compile Include="Src\ITextTemplatingHost.cs" />
<Compile Include="Src\ITextTemplatingFileGenerator.cs" />
+ <Compile Include="Src\ITextTemplatingPathResolver.cs" />
+ <Compile Include="Src\ITextTemplatingStringParser.cs" />
+ <Compile Include="Src\ITextTemplatingVariables.cs" />
<Compile Include="Src\NamespaceHint.cs" />
<Compile Include="Src\TemplatingHostProcessTemplateError.cs" />
<Compile Include="Src\TextTemplatingAppDomain.cs" />
@@ -68,14 +72,23 @@
<Compile Include="Src\TextTemplatingAssemblyResolver.cs" />
<Compile Include="Src\TextTemplatingCustomTool.cs" />
<Compile Include="Src\TextTemplatingCustomToolContext.cs" />
+ <Compile Include="Src\TextTemplatingDirectoryVariable.cs" />
+ <Compile Include="Src\TextTemplatingEnvironment.cs" />
<Compile Include="Src\TextTemplatingFileGenerator.cs" />
<Compile Include="Src\TextTemplatingFileGeneratorCustomTool.cs" />
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\TextTemplatingFilePreprocessor.cs" />
<Compile Include="Src\TextTemplatingFilePreprocessorCustomTool.cs" />
<Compile Include="Src\TextTemplatingFileProcessor.cs" />
<Compile Include="Src\TextTemplatingHost.cs" />
+ <Compile Include="Src\TextTemplatingHostContext.cs" />
+ <Compile Include="Src\TextTemplatingPathResolver.cs" />
<Compile Include="Src\TextTemplatingReflectionProjectContent.cs" />
+ <Compile Include="Src\TextTemplatingServiceProvider.cs" />
+ <Compile Include="Src\TextTemplatingStringParser.cs" />
+ <Compile Include="Src\TextTemplatingVariableLocation.cs" />
+ <Compile Include="Src\TextTemplatingVariables.cs" />
+ <Compile Include="Src\TextTemplatingVariablesStringBuilder.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\TextTemplating.xshd" />
View
2 src/AddIns/Misc/TextTemplating/Test/Helpers/FakeAssemblyParserService.cs
@@ -11,9 +11,11 @@ public class FakeAssemblyParserService : IAssemblyParserService
{
public FakeReflectionProjectContent FakeReflectionProjectContent = new FakeReflectionProjectContent();
public ReferenceProjectItem ItemPassedToGetReflectionProjectContentForReference;
+ public bool IsGetReflectionProjectContentForReferenceCalled;
public IReflectionProjectContent GetReflectionProjectContentForReference(ReferenceProjectItem item)
{
+ IsGetReflectionProjectContentForReferenceCalled = true;
ItemPassedToGetReflectionProjectContentForReference = item;
return FakeReflectionProjectContent;
}
View
25 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<Type, object> Services = new Dictionary<Type, object>();
+
+ 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;
+ }
+ }
+}
View
29 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<string, string> Variables = new Dictionary<string, string>();
+
+ 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);
+ }
+ }
+}
View
28 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<string, string> Paths = new Dictionary<string, string>();
+
+ 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);
+ }
+ }
+}
View
26 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<string, string> Properties = new Dictionary<string, string>();
+
+ 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);
+ }
+ }
+}
View
35 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<string, string> Variables = new Dictionary<string, string>();
+
+ public void AddVariable(string name, string value)
+ {
+ name = "$(" + name + ")";
+ Variables.Add(name, value);
+ }
+
+ public string ExpandVariables(string name)
+ {
+ foreach (KeyValuePair<string, string> 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;
+ }
+ }
+}
View
23 src/AddIns/Misc/TextTemplating/Test/Helpers/TestableTextTemplatingHost.cs
@@ -10,28 +10,49 @@ public class TestableTextTemplatingHost : TextTemplatingHost
{
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)
{
}
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);
+ }
}
}
View
30 src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingAssemblyResolverTests.cs
@@ -16,12 +16,14 @@ public class TextTemplatingAssemblyResolverTests
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 @@ public void Resolve_ProjectHasNoReferencesAndAssemblyReferenceNotFoundInGac_Retu
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);
+ }
}
}
View
62 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,17 +27,24 @@ void CreateHost()
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]
public void ProvideTemplatingAppDomain_PassedContentName_ReturnsDomainFromTextTemplatingAppDomainFactory()
{
CreateHost();
AppDomain expectedAppDomain = AppDomain.CreateDomain("TextTemplatingHostTests");
- textTemplatingAppDomain.AppDomain = expectedAppDomain;
+ fakeTextTemplatingAppDomain.AppDomain = expectedAppDomain;
AppDomain actualAppDomain = host.ProvideTemplatingAppDomain("test");
@@ -49,7 +58,7 @@ public void Dispose_DisposingHostAfterProvideTemplatingAppDomainCalled_DisposesT
host.ProvideTemplatingAppDomain("test");
host.Dispose();
- Assert.IsTrue(textTemplatingAppDomain.IsDisposeCalled);
+ Assert.IsTrue(fakeTextTemplatingAppDomain.IsDisposeCalled);
}
[Test]
@@ -66,7 +75,7 @@ public void ProvideTemplatingAppDomain_MethodCalledTwice_AppDomainCreatedOnce()
host.ProvideTemplatingAppDomain("test");
host.ProvideTemplatingAppDomain("test");
- Assert.AreEqual(1, textTemplatingAppDomainFactory.CreateTextTemplatingAppDomainCallCount);
+ Assert.AreEqual(1, fakeTextTemplatingAppDomainFactory.CreateTextTemplatingAppDomainCallCount);
}
[Test]
@@ -76,10 +85,10 @@ public void Dispose_DisposeCalledTwiceHostAfterProvideTemplatingAppDomainCalled_
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 @@ public void ProvideTemplatingAppDomain_PassedContentName_HostApplicationBaseIsUs
CreateHost(applicationBase);
host.ProvideTemplatingAppDomain("test");
- string actualApplicationBase = textTemplatingAppDomainFactory.ApplicationBasePassedToCreateTextTemplatingAppDomain;
+ string actualApplicationBase = fakeTextTemplatingAppDomainFactory.ApplicationBasePassedToCreateTextTemplatingAppDomain;
Assert.AreEqual(applicationBase, actualApplicationBase);
}
@@ -99,17 +108,40 @@ public void ResolveAssemblyReference_PassedMyAssemblyReference_CallsTextTemplati
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);
+ }
}
}
View
57 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);
+ }
+ }
+}
View
30 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);
+ }
+ }
+}
View
78 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);
+ }
+ }
+}
View
241 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<TextTemplatingVariableLocation> locations =
+ variables.GetVariables(null).ToList();
+
+ Assert.AreEqual(0, locations.Count);
+ }
+
+ [Test]
+ public void GetVariableLocations_EmptyStringPassed_ReturnsNoVariables()
+ {
+ CreateTextTemplatingVariables();
+ List<TextTemplatingVariableLocation> locations =
+ variables.GetVariables(String.Empty).ToList();
+
+ Assert.AreEqual(0, locations.Count);
+ }
+
+ [Test]
+ public void GetVariableLocations_TextHasNoVariables_ReturnsNoVariables()
+ {
+ CreateTextTemplatingVariables();
+ List<TextTemplatingVariableLocation> locations =
+ variables.GetVariables("No Variables").ToList();
+
+ Assert.AreEqual(0, locations.Count);
+ }
+
+ [Test]
+ public void GetVariableLocations_TextHasVariableStartButNoEnd_ReturnsNoVariables()
+ {
+ CreateTextTemplatingVariables();
+ List<TextTemplatingVariableLocation> locations =
+ variables.GetVariables("$(No Variables").ToList();
+
+ Assert.AreEqual(0, locations.Count);
+ }
+
+ [Test]
+ public void GetVariableLocations_TwoProperties_ReturnsTwoVariables()
+ {
+ CreateTextTemplatingVariables();
+
+ List<TextTemplatingVariableLocation> 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);
+ }
+ }
+}
View
9 src/AddIns/Misc/TextTemplating/Test/TextTemplating.Tests.csproj
@@ -57,13 +57,18 @@
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Helpers\FakeAssemblyParserService.cs" />
<Compile Include="Helpers\FakeReflectionProjectContent.cs" />
+ <Compile Include="Helpers\FakeServiceProvider.cs" />
<Compile Include="Helpers\FakeTextTemplatingAppDomain.cs" />
<Compile Include="Helpers\FakeTextTemplatingAppDomainFactory.cs" />
<Compile Include="Helpers\FakeTextTemplatingAssemblyResolver.cs" />
<Compile Include="Helpers\FakeTextTemplatingCustomToolContext.cs" />
+ <Compile Include="Helpers\FakeTextTemplatingEnvironment.cs" />
<Compile Include="Helpers\FakeTextTemplatingFilePreprocessor.cs" />
<Compile Include="Helpers\FakeTextTemplatingHost.cs" />
<Compile Include="Helpers\FakeTextTemplatingFileGenerator.cs" />
+ <Compile Include="Helpers\FakeTextTemplatingPathResolver.cs" />
+ <Compile Include="Helpers\FakeTextTemplatingStringParser.cs" />
+ <Compile Include="Helpers\FakeTextTemplatingVariables.cs" />
<Compile Include="Helpers\ProjectHelper.cs" />
<Compile Include="Helpers\TestableFileProjectItem.cs" />
<Compile Include="Helpers\TestableProject.cs" />
@@ -77,8 +82,12 @@
<Compile Include="Src\TextTemplatingFileGeneratorTests.cs" />
<Compile Include="Src\TextTemplatingFilePreprocessorCustomToolTests.cs" />
<Compile Include="Src\TextTemplatingHostTests.cs" />
+ <Compile Include="Src\TextTemplatingPathResolverTests.cs" />
<Compile Include="Src\TextTemplatingPreprocessorTests.cs" />
<Compile Include="Src\TextTemplatingReflectionProjectContentTests.cs" />
+ <Compile Include="Src\TextTemplatingServiceProviderTests.cs" />
+ <Compile Include="Src\TextTemplatingVariableLocationTests.cs" />
+ <Compile Include="Src\TextTemplatingVariablesTests.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Configuration" />
View
1 src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs
@@ -84,6 +84,7 @@ internal CollapsedLineSection CollapseSection(TextView textView)
/// <summary>
/// Gets the content of the collapsed lines as tooltip text.
/// </summary>
+ [Obsolete]
public string TooltipText {
get {
// This fixes SD-1394:
View
21 src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
@@ -1612,6 +1612,7 @@ public Point GetVisualPosition(TextViewPosition position, VisualYPosition yPosit
/// <summary>
/// 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.
/// </summary>
/// <param name="visualPosition">The position in WPF device-independent pixels relative
/// to the top left corner of the document.</param>
@@ -1628,6 +1629,26 @@ public Point GetVisualPosition(TextViewPosition position, VisualYPosition yPosit
int documentOffset = line.GetRelativeOffset(visualColumn) + line.FirstDocumentLine.Offset;
return new TextViewPosition(document.GetLocation(documentOffset), visualColumn);
}
+
+ /// <summary>
+ /// 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.
+ /// </summary>
+ /// <param name="visualPosition">The position in WPF device-independent pixels relative
+ /// to the top left corner of the document.</param>
+ /// <returns>The logical position, or null if the position is outside the document.</returns>
+ 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
View
11 .../Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml.cs
@@ -45,10 +45,8 @@ void OnLoaded(object sender, RoutedEventArgs e)
}
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 @@ void SelectLocalIIS()
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");
View
6 src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/GacReferencePanel.cs
@@ -378,8 +378,7 @@ void ResolveVersionsWorker()
}
});
- 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 @@ void CreateReferenceToFrameworkTable()
}
});
- 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)) {
View
23 src/Main/Base/Project/Src/Project/AbstractProject.cs
@@ -7,7 +7,7 @@
using System.ComponentModel;