diff --git a/SparkleLib/AssemblyInfo.cs.in b/SparkleLib/AssemblyInfo.cs.in
deleted file mode 100755
index 11ce20de..00000000
--- a/SparkleLib/AssemblyInfo.cs.in
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * AssemblyInfo.cs
- *
- * This is free software. See COPYING for details.
- */
-
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
-[assembly: AssemblyVersion("@ASM_VERSION@")]
-[assembly: AssemblyTitle ("SparkleShare")]
diff --git a/SparkleLib/Defines.cs.in b/SparkleLib/Defines.cs.in
index bee485ad..99059352 100755
--- a/SparkleLib/Defines.cs.in
+++ b/SparkleLib/Defines.cs.in
@@ -15,16 +15,13 @@
// along with this program. If not, see .
using System;
+using System.Reflection;
+[assembly: AssemblyTitle("SparkleLib")]
+[assembly: AssemblyVersion("0.9.0.0")]
namespace SparkleLib {
- public class Defines {
-
- public const string VERSION = "@VERSION@";
- public const string LOCALE_DIR = "@prefix@/share/locale";
- public const string DATAROOTDIR = "@expanded_datadir@";
- public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@";
- public const string PREFIX = "@prefix@";
- }
+ public class Defines {
+ public const string INSTALL_DIR = "@expanded_datadir@/sparkleshare";
+ }
}
-
diff --git a/SparkleLib/Git/Makefile.am b/SparkleLib/Git/Makefile.am
index 5d516405..359516a4 100755
--- a/SparkleLib/Git/Makefile.am
+++ b/SparkleLib/Git/Makefile.am
@@ -1,6 +1,8 @@
ASSEMBLY = SparkleLib.Git
TARGET = library
+ASSEMBLY_INFO_SOURCE = ../Defines.cs
+
LINK = -r:$(DIR_BIN)/SparkleLib.dll
SOURCES = \
diff --git a/SparkleLib/windows/SparkleLib.Git.csproj b/SparkleLib/Git/SparkleLib.Git.csproj
similarity index 73%
rename from SparkleLib/windows/SparkleLib.Git.csproj
rename to SparkleLib/Git/SparkleLib.Git.csproj
index d338f639..ab22caa7 100644
--- a/SparkleLib/windows/SparkleLib.Git.csproj
+++ b/SparkleLib/Git/SparkleLib.Git.csproj
@@ -11,6 +11,7 @@
SparkleLib.Git
SparkleLib.Git
512
+
true
@@ -29,43 +30,23 @@
prompt
4
-
-
- TextTemplatingFileGenerator
- Defines.cs
-
-
- TextTemplatingFileGenerator
- GlobalAssemblyInfoGit.cs
-
-
-
+
SparkleFetcherGit.cs
-
- SparkleGit.cs
+
Component
+ SparkleGit.cs
-
+
SparkleRepoGit.cs
-
- True
- True
- Defines.tt
-
-
- True
- True
- GlobalAssemblyInfoGit.tt
-
-
+
{2C914413-B31C-4362-93C7-1AE34F09112A}
SparkleLib
diff --git a/SparkleLib/Makefile.am b/SparkleLib/Makefile.am
index 1a6d1b8b..aa340d2e 100755
--- a/SparkleLib/Makefile.am
+++ b/SparkleLib/Makefile.am
@@ -1,6 +1,8 @@
ASSEMBLY = SparkleLib
TARGET = library
+ASSEMBLY_INFO_SOURCE = Defines.cs
+
SOURCES = \
Defines.cs \
SparkleAnnouncement.cs \
diff --git a/SparkleLib/SparkleBackend.cs b/SparkleLib/SparkleBackend.cs
index 8efe332c..8c896f4e 100755
--- a/SparkleLib/SparkleBackend.cs
+++ b/SparkleLib/SparkleBackend.cs
@@ -16,7 +16,7 @@
using System;
-using System.IO;
+using System.Reflection;
using System.Runtime.InteropServices;
namespace SparkleLib {
@@ -25,16 +25,11 @@ namespace SparkleLib {
public static string Version {
get {
- return Defines.VERSION;
+ return Assembly.GetExecutingAssembly ().GetName ().Version.ToString ();
}
}
- // Strange magic needed by Platform ()
- [DllImport ("libc")]
- private static extern int uname (IntPtr buf);
-
-
// This fixes the PlatformID enumeration for MacOSX in Environment.OSVersion.Platform,
// which is intentionally broken in Mono for historical reasons
public static PlatformID Platform {
@@ -56,5 +51,9 @@ namespace SparkleLib {
return Environment.OSVersion.Platform;
}
}
+
+
+ [DllImport ("libc")]
+ private static extern int uname (IntPtr buf);
}
}
diff --git a/SparkleLib/SparkleLib.csproj b/SparkleLib/SparkleLib.csproj
old mode 100755
new mode 100644
index 9d77e24e..59b83d4a
--- a/SparkleLib/SparkleLib.csproj
+++ b/SparkleLib/SparkleLib.csproj
@@ -1,5 +1,5 @@
-
+
Debug
AnyCPU
@@ -9,6 +9,8 @@
Library
SparkleLib
SparkleLib
+
+ v3.5
true
@@ -35,15 +37,10 @@
-
-
-
-
-
@@ -52,11 +49,13 @@
+
+
-
+
diff --git a/SparkleLib/windows/AssemblyInfo.cs b/SparkleLib/windows/AssemblyInfo.cs
deleted file mode 100644
index 9d14d314..00000000
--- a/SparkleLib/windows/AssemblyInfo.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * AssemblyInfo.cs
- *
- * This is free software. See COPYING for details.
- */
-
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle ("SparkleLib")]
-[assembly: AssemblyDescription ("SparkleShare is a simple file sharing and collaboration tool.")]
-
-[assembly: Guid ("38092E48-5DCC-4d23-8109-9D994E710ACF")]
diff --git a/SparkleLib/windows/Defines.tt b/SparkleLib/windows/Defines.tt
deleted file mode 100644
index ffbc5538..00000000
--- a/SparkleLib/windows/Defines.tt
+++ /dev/null
@@ -1,46 +0,0 @@
-// SparkleShare, an instant update workflow to Git.
-// Copyright (C) 2010 Hylke Bons
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-
-<#@ template language="C#v3.5" HostSpecific="true" #>
-<#@ output extension="cs" #>
-
-<#@ include file="getversion.tt" #>
-
-<#
- PlatformID platform = Environment.OSVersion.Platform;
- bool IsWindows = (platform == PlatformID.Win32NT
- || platform == PlatformID.Win32S
- || platform == PlatformID.Win32Windows
- || platform == PlatformID.WinCE);
-#>
-
-using System;
-
-namespace SparkleLib {
-
- public class Defines {
-
- public const string VERSION = "<#= VERSION #>";
- public const string LOCALE_DIR = "@prefix@/share/locale";
- public const string DATAROOTDIR = "@expanded_datadir@";
- public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@";
- public const string PREFIX = "@prefix@";
- public const string OPEN_COMMAND = "xdg-open";
-
- }
-
-}
-
diff --git a/SparkleLib/windows/GlobalAssemblyInfo.tt b/SparkleLib/windows/GlobalAssemblyInfo.tt
deleted file mode 100644
index 36b1865d..00000000
--- a/SparkleLib/windows/GlobalAssemblyInfo.tt
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * GlobalAssemblyInfo.cs
- *
- * This is free software. See COPYING for details.
- */
-<#@ template language="C#v3.5" HostSpecific="true" #>
-<#@ output extension="cs" #>
-
-<#@ include file="getversion.tt" #>
-
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
-[assembly: AssemblyProduct("SparkleLib.Git")]
-
-[assembly: AssemblyVersion("<#= ASM_VERSION #>")]
-[assembly: AssemblyFileVersion("<#= ASM_FILE_VERSION #>")]
-[assembly: AssemblyInformationalVersion("<#= VERSION #>")]
-
-#if DEBUG
-[assembly: AssemblyConfiguration("Debug")]
-#else
-[assembly: AssemblyConfiguration("Release")]
-#endif
-
diff --git a/SparkleLib/windows/GlobalAssemblyInfoGit.tt b/SparkleLib/windows/GlobalAssemblyInfoGit.tt
deleted file mode 100644
index 104f2caf..00000000
--- a/SparkleLib/windows/GlobalAssemblyInfoGit.tt
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * GlobalAssemblyInfo.cs
- *
- * This is free software. See COPYING for details.
- */
-<#@ template language="C#v3.5" HostSpecific="true" #>
-<#@ output extension="cs" #>
-
-<#@ include file="getversion.tt" #>
-
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
-[assembly: AssemblyProduct("SparkleShare")]
-
-[assembly: AssemblyVersion("<#= ASM_VERSION #>")]
-[assembly: AssemblyFileVersion("<#= ASM_FILE_VERSION #>")]
-[assembly: AssemblyInformationalVersion("<#= VERSION #>")]
-
-#if DEBUG
-[assembly: AssemblyConfiguration("Debug")]
-#else
-[assembly: AssemblyConfiguration("Release")]
-#endif
-
diff --git a/SparkleLib/windows/Settings.StyleCop b/SparkleLib/windows/Settings.StyleCop
deleted file mode 100644
index 361f9955..00000000
--- a/SparkleLib/windows/Settings.StyleCop
+++ /dev/null
@@ -1,294 +0,0 @@
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/SparkleLib/windows/SparkleLib.csproj b/SparkleLib/windows/SparkleLib.csproj
deleted file mode 100644
index 4d324fbb..00000000
--- a/SparkleLib/windows/SparkleLib.csproj
+++ /dev/null
@@ -1,168 +0,0 @@
-
-
-
- Debug
- AnyCPU
- 9.0.30729
- 2.0
- {2C914413-B31C-4362-93C7-1AE34F09112A}
- Library
- SparkleLib
- SparkleLib
-
-
- 3.5
-
-
- false
- publish\
- true
- Disk
- false
- Foreground
- 7
- Days
- false
- false
- true
- 0
- 1.0.0.%2a
- false
- true
-
-
- true
- full
- false
- ..\..\bin
- DEBUG
- prompt
- 4
- false
- x86
- AllRules.ruleset
-
-
- none
- false
- ..\..\bin
- prompt
- 4
- false
- AllRules.ruleset
- x86
-
-
-
-
- 3.5
-
-
-
-
-
- SparkleAnnouncement.cs
-
-
- SparkleConfig.cs
-
-
- SparkleExtensions.cs
-
-
- SparkleListenerFactory.cs
-
-
- SparkleRepoBase.cs
-
-
- SparkleUser.cs
-
-
- SparkleWatcher.cs
- Component
-
-
-
- Defines.tt
- Code
- True
- True
-
-
-
-
-
-
-
-
- True
- True
- GlobalAssemblyInfo.tt
-
-
- SparkleExceptions.cs
-
-
-
-
-
-
-
-
- False
- .NET Framework 3.5 SP1 Client Profile
- false
-
-
- False
- .NET Framework 2.0 %28x86%29
- true
-
-
- False
- .NET Framework 3.0 %28x86%29
- false
-
-
- False
- .NET Framework 3.5
- false
-
-
- False
- .NET Framework 3.5 SP1
- false
-
-
-
-
- TextTemplatingFileGenerator
- Defines.cs
-
-
- TextTemplatingFileGenerator
- GlobalAssemblyInfo.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- "$(ProjectDir)transform_tt.cmd"
-
-
diff --git a/SparkleLib/windows/getversion.tt b/SparkleLib/windows/getversion.tt
deleted file mode 100644
index 19976aa3..00000000
--- a/SparkleLib/windows/getversion.tt
+++ /dev/null
@@ -1,15 +0,0 @@
-<#@ import namespace="System" #>
-<#@ import namespace="System.IO" #>
-<#@ import namespace="System.Diagnostics" #>
-<#@ import namespace="System.Text.RegularExpressions" #>
-
-<#
- String VERSION;
- String ASM_VERSION;
- String ASM_FILE_VERSION;
- VERSION = ASM_VERSION = ASM_FILE_VERSION = "0.9.0";
-#>
-
-// VERSION=<#= VERSION #>
-// ASM_VERSION=<#= ASM_VERSION #>
-
diff --git a/SparkleLib/windows/transform_tt.cmd b/SparkleLib/windows/transform_tt.cmd
deleted file mode 100644
index e2cb3880..00000000
--- a/SparkleLib/windows/transform_tt.cmd
+++ /dev/null
@@ -1,11 +0,0 @@
-@echo off
-cd %~dp0
-
-set TextTransform=..\..\SparkleShare\Windows\tools\TextTemplating\bin\TextTransform.exe
-if not exist %TextTransform% call ..\..\SparkleShare\Windows\tools\TextTemplating\build.cmd
-
-echo running texttransform..
-
-%TextTransform% -out Defines.cs Defines.tt
-%TextTransform% -out GlobalAssemblyInfo.cs GlobalAssemblyInfo.tt
-%TextTransform% -out GlobalAssemblyInfoGit.cs GlobalAssemblyInfoGit.tt
diff --git a/SparkleShare/Mac/SparkleController.cs b/SparkleShare/Mac/SparkleController.cs
index d204b6c5..3d69a953 100755
--- a/SparkleShare/Mac/SparkleController.cs
+++ b/SparkleShare/Mac/SparkleController.cs
@@ -22,6 +22,7 @@ using System.IO;
using MonoMac.Foundation;
using MonoMac.AppKit;
using MonoMac.ObjCRuntime;
+
using SparkleLib;
namespace SparkleShare {
diff --git a/SparkleShare/Mac/SparkleShare.csproj b/SparkleShare/Mac/SparkleShare.csproj
index aada9751..43eb28cc 100644
--- a/SparkleShare/Mac/SparkleShare.csproj
+++ b/SparkleShare/Mac/SparkleShare.csproj
@@ -1,7 +1,7 @@
- Debug
+ Release
AnyCPU
10.0.0
2.0
@@ -10,9 +10,10 @@
Exe
SparkleShare
SparkleShare
- 0.9.0
+
+
-
+
true
full
false
@@ -20,19 +21,11 @@
DEBUG
prompt
4
- false
-
-
- none
- false
- bin\Release
- prompt
- 4
false
@@ -43,12 +36,6 @@
-
- ..\..\bin\SparkleLib.dll
-
-
- ..\..\bin\SparkleLib.Git.dll
-
@@ -270,4 +257,14 @@
+
+
+ {2C914413-B31C-4362-93C7-1AE34F09112A}
+ SparkleLib
+
+
+ {009FDCD7-1D57-4202-BB6D-8477D8C6B8EE}
+ SparkleLib.Git
+
+
diff --git a/SparkleShare/Mac/SparkleShare.sln b/SparkleShare/Mac/SparkleShare.sln
index 9368bca1..25d3e8b1 100644
--- a/SparkleShare/Mac/SparkleShare.sln
+++ b/SparkleShare/Mac/SparkleShare.sln
@@ -3,19 +3,29 @@ Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkleShare", "SparkleShare.csproj", "{CF5BC8DB-A633-4FCC-8A3E-E3AC9B59FABC}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkleLib", "..\..\SparkleLib\SparkleLib.csproj", "{2C914413-B31C-4362-93C7-1AE34F09112A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkleLib.Git", "..\..\SparkleLib\Git\SparkleLib.Git.csproj", "{009FDCD7-1D57-4202-BB6D-8477D8C6B8EE}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
+ Debug|Any CPU = Debug|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {CF5BC8DB-A633-4FCC-8A3E-E3AC9B59FABC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {CF5BC8DB-A633-4FCC-8A3E-E3AC9B59FABC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {009FDCD7-1D57-4202-BB6D-8477D8C6B8EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {009FDCD7-1D57-4202-BB6D-8477D8C6B8EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {009FDCD7-1D57-4202-BB6D-8477D8C6B8EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {009FDCD7-1D57-4202-BB6D-8477D8C6B8EE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2C914413-B31C-4362-93C7-1AE34F09112A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2C914413-B31C-4362-93C7-1AE34F09112A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2C914413-B31C-4362-93C7-1AE34F09112A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2C914413-B31C-4362-93C7-1AE34F09112A}.Release|Any CPU.Build.0 = Release|Any CPU
{CF5BC8DB-A633-4FCC-8A3E-E3AC9B59FABC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF5BC8DB-A633-4FCC-8A3E-E3AC9B59FABC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = SparkleShare.csproj
- version = 0.9.0
+ version =
EndGlobalSection
EndGlobal
diff --git a/SparkleShare/Windows/AssemblyInfo.cs b/SparkleShare/Windows/AssemblyInfo.cs
deleted file mode 100644
index 72e14600..00000000
--- a/SparkleShare/Windows/AssemblyInfo.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-// SparkleShare, a collaboration and sharing tool.
-// Copyright (C) 2010 Hylke Bons (hylkebons@gmail.com)
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see (http://www.gnu.org/licenses/).
-
-
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle ("SparkleShare")]
-[assembly: AssemblyDescription ("SparkleShare is a simple file sharing and collaboration tool.")]
-
-[assembly: Guid ("A8F34995-DB20-4bf2-AA27-869B15B8C2F9")]
diff --git a/SparkleShare/Windows/SparkleShare.csproj b/SparkleShare/Windows/SparkleShare.csproj
index 30a6ecf2..f4dccb92 100644
--- a/SparkleShare/Windows/SparkleShare.csproj
+++ b/SparkleShare/Windows/SparkleShare.csproj
@@ -30,6 +30,7 @@
false
true
Pixmaps\sparkleshare-app.ico
+
true
@@ -70,12 +71,6 @@
-
- GlobalAssemblyInfo.cs
- True
- True
- GlobalAssemblyInfo.tt
-
SparkleBubblesController.cs
@@ -94,7 +89,6 @@
SparkleStatusIconController.cs
-
@@ -119,12 +113,6 @@
-
-
- {2C914413-B31C-4362-93C7-1AE34F09112A}
- SparkleLib
-
-
@@ -162,13 +150,6 @@
-
-
- GlobalAssemblyInfo.tt
- TextTemplatingFileGenerator
- GlobalAssemblyInfo.cs
-
-
"$(ProjectDir)transform_tt.cmd"
@@ -303,4 +284,10 @@
+
+
+ {2C914413-B31C-4362-93C7-1AE34F09112A}
+ SparkleLib
+
+
diff --git a/SparkleShare/Windows/SparkleShare.sln b/SparkleShare/Windows/SparkleShare.sln
index c5a171c7..1532ac72 100644
--- a/SparkleShare/Windows/SparkleShare.sln
+++ b/SparkleShare/Windows/SparkleShare.sln
@@ -7,26 +7,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkleShare", "SparkleShar
{009FDCD7-1D57-4202-BB6D-8477D8C6B8EE} = {009FDCD7-1D57-4202-BB6D-8477D8C6B8EE}
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkleLib", "..\..\SparkleLib\windows\SparkleLib.csproj", "{2C914413-B31C-4362-93C7-1AE34F09112A}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkleLib.Git", "..\..\SparkleLib\windows\SparkleLib.Git.csproj", "{009FDCD7-1D57-4202-BB6D-8477D8C6B8EE}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkleShareInviteOpener", "SparkleShareInviteOpener\SparkleShareInviteOpener.csproj", "{1DB5492D-B897-4A5E-8DD7-175EC65F52F2}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkleLib", "..\..\SparkleLib\SparkleLib.csproj", "{2C914413-B31C-4362-93C7-1AE34F09112A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkleLib.Git", "..\..\SparkleLib\Git\SparkleLib.Git.csproj", "{009FDCD7-1D57-4202-BB6D-8477D8C6B8EE}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {728483AA-E34B-4441-BF2C-C8BC2901E4E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {728483AA-E34B-4441-BF2C-C8BC2901E4E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {728483AA-E34B-4441-BF2C-C8BC2901E4E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {728483AA-E34B-4441-BF2C-C8BC2901E4E0}.Release|Any CPU.Build.0 = Release|Any CPU
- {2C914413-B31C-4362-93C7-1AE34F09112A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2C914413-B31C-4362-93C7-1AE34F09112A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2C914413-B31C-4362-93C7-1AE34F09112A}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2C914413-B31C-4362-93C7-1AE34F09112A}.Release|Any CPU.Build.0 = Release|Any CPU
{009FDCD7-1D57-4202-BB6D-8477D8C6B8EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{009FDCD7-1D57-4202-BB6D-8477D8C6B8EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{009FDCD7-1D57-4202-BB6D-8477D8C6B8EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -35,13 +27,22 @@ Global
{1DB5492D-B897-4A5E-8DD7-175EC65F52F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DB5492D-B897-4A5E-8DD7-175EC65F52F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DB5492D-B897-4A5E-8DD7-175EC65F52F2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2C914413-B31C-4362-93C7-1AE34F09112A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2C914413-B31C-4362-93C7-1AE34F09112A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2C914413-B31C-4362-93C7-1AE34F09112A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2C914413-B31C-4362-93C7-1AE34F09112A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {728483AA-E34B-4441-BF2C-C8BC2901E4E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {728483AA-E34B-4441-BF2C-C8BC2901E4E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {728483AA-E34B-4441-BF2C-C8BC2901E4E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {728483AA-E34B-4441-BF2C-C8BC2901E4E0}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = SparkleShare.csproj
+ version =
+ outputpath = bin
+ name = SparkleShare
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
- GlobalSection(MonoDevelopProperties) = preSolution
- StartupItem = SparkleShare.csproj
- outputpath = bin
- name = SparkleShare
- EndGlobalSection
EndGlobal
diff --git a/SparkleShare/Windows/SparkleShareInviteOpener/SparkleShareInviteOpener.csproj b/SparkleShare/Windows/SparkleShareInviteOpener/SparkleShareInviteOpener.csproj
index c741d98f..8e78e1d5 100644
--- a/SparkleShare/Windows/SparkleShareInviteOpener/SparkleShareInviteOpener.csproj
+++ b/SparkleShare/Windows/SparkleShareInviteOpener/SparkleShareInviteOpener.csproj
@@ -10,10 +10,9 @@
Properties
SparkleShareInviteOpener
SparkleShareInviteOpener
- v4.0
512
..\Pixmaps\sparkleshare-app.ico
-
+
true
diff --git a/SparkleShare/Windows/tools/TextTemplating/.gitattributes b/SparkleShare/Windows/tools/TextTemplating/.gitattributes
deleted file mode 100644
index 4cadb26b..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/.gitattributes
+++ /dev/null
@@ -1,2 +0,0 @@
-.gitattributes eol=lf
-.gitmodules eol=lf
diff --git a/SparkleShare/Windows/tools/TextTemplating/.gitignore b/SparkleShare/Windows/tools/TextTemplating/.gitignore
deleted file mode 100644
index 335c1472..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/.gitignore
+++ /dev/null
@@ -1,11 +0,0 @@
-*~
-*.bak
-*.suo
-*.user
-*.sln.cache
-bin/
-obj/
-_ReSharper.*/
-_UpgradeReport_Files/
-Backup/
-UpgradeLog.XML
diff --git a/SparkleShare/Windows/tools/TextTemplating/ChangeLog b/SparkleShare/Windows/tools/TextTemplating/ChangeLog
deleted file mode 100644
index b50bf135..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/ChangeLog
+++ /dev/null
@@ -1,9 +0,0 @@
-2009-08-12 Michael Hutchinson
-
- * Makefile.am:
- * TextTransform:
- * Mono.TextTemplating:
- * Mono.TextTemplating.Tests:
- * MonoDevelop.TextTemplating: Include the ASP.NET MVC and
- TextTemplating addins in the main solution and build.
-
diff --git a/SparkleShare/Windows/tools/TextTemplating/Makefile.am b/SparkleShare/Windows/tools/TextTemplating/Makefile.am
deleted file mode 100644
index f0cb7546..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Makefile.am
+++ /dev/null
@@ -1,4 +0,0 @@
-SUBDIRS = \
- Mono.TextTemplating \
- TextTransform \
- MonoDevelop.TextTemplating
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/ChangeLog b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/ChangeLog
deleted file mode 100644
index 061fc503..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/ChangeLog
+++ /dev/null
@@ -1,65 +0,0 @@
-2009-12-11 Michael Hutchinson
-
- * Mono.TextTemplating.Tests.csproj: Don't local-copy nunit.
-
-2009-11-27 Olivier Dagenais
-
- * GenerationTests.cs: Make tests independent of the runtime
- they are running under by stripping the "autogenerated"
- comment (i.e. the first 9 lines).
-
-2009-10-29 Lluis Sanchez Gual
-
- * Mono.TextTemplating.Tests.csproj: Flush.
-
-2009-08-13 Lluis Sanchez Gual
-
- * DummyHost.cs: Fix windows build.
-
-2009-08-13 Michael Hutchinson
-
- * Mono.TextTemplating.Tests.csproj: Use assembly refs for
- nunit.
-
-2009-08-12 Michael Hutchinson
-
- * Mono.TextTemplating.Tests.csproj: Include the ASP.NET MVC
- and TextTemplating addins in the main solution and build.
-
-2009-04-13 Michael Hutchinson
-
- * GenerationTests.cs: Add tests for Windows/Mac newlines.
-
-2009-04-03 Michael Hutchinson
-
- * Mono.TextTemplating.Tests.csproj: Updated.
-
- * GenerationTests.cs: Add test for C# output.
-
- * ParsingTests.cs: Track dummy host name change.
-
- * DummyHost.cs: Add more functionality to dummy host.
-
-2009-03-13 Michael Hutchinson
-
- * Mono.TextTemplating.Tests.csproj: Move output dir from
- ../bin to ../build.
-
-2009-03-13 Michael Hutchinson
-
- * Mono.TextTemplating.Tests.csproj: Fix output directory.
-
-2009-03-12 Michael Hutchinson
-
- * Mono.TextTemplating.Tests.csproj: Updated.
-
- * ParsingTests.cs: Add parser test.
-
- * DummyHost.cs: Dummy templating host.
-
-2009-03-12 Michael Hutchinson
-
- * Mono.TextTemplating.Tests.csproj: Add tests.
-
- * ParsingTests.cs: Tokeniser state/value/location test.
-
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/DummyHost.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/DummyHost.cs
deleted file mode 100644
index 027a2ddc..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/DummyHost.cs
+++ /dev/null
@@ -1,113 +0,0 @@
-//
-// IncludeFileProviderHost.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Collections.Generic;
-using System.CodeDom.Compiler;
-using Microsoft.VisualStudio.TextTemplating;
-
-namespace Mono.TextTemplating.Tests
-{
-
- public class DummyHost : ITextTemplatingEngineHost
- {
- public readonly Dictionary Locations = new Dictionary ();
- public readonly Dictionary Contents = new Dictionary ();
- public readonly Dictionary HostOptions = new Dictionary ();
- List standardAssemblyReferences = new List ();
- List standardImports = new List ();
- public readonly CompilerErrorCollection Errors = new CompilerErrorCollection ();
- public readonly Dictionary DirectiveProcessors = new Dictionary ();
-
- public virtual object GetHostOption (string optionName)
- {
- object o;
- HostOptions.TryGetValue (optionName, out o);
- return o;
- }
-
- public virtual bool LoadIncludeText (string requestFileName, out string content, out string location)
- {
- content = null;
- return Locations.TryGetValue (requestFileName, out location)
- && Contents.TryGetValue (requestFileName, out content);
- }
-
- public virtual void LogErrors (CompilerErrorCollection errors)
- {
- Errors.AddRange (errors);
- }
-
- public virtual AppDomain ProvideTemplatingAppDomain (string content)
- {
- return null;
- }
-
- public virtual string ResolveAssemblyReference (string assemblyReference)
- {
- throw new System.NotImplementedException();
- }
-
- public virtual Type ResolveDirectiveProcessor (string processorName)
- {
- Type t;
- DirectiveProcessors.TryGetValue (processorName, out t);
- return t;
- }
-
- public virtual string ResolveParameterValue (string directiveId, string processorName, string parameterName)
- {
- throw new System.NotImplementedException();
- }
-
- public virtual string ResolvePath (string path)
- {
- throw new System.NotImplementedException();
- }
-
- public virtual void SetFileExtension (string extension)
- {
- throw new System.NotImplementedException();
- }
-
- public virtual void SetOutputEncoding (System.Text.Encoding encoding, bool fromOutputDirective)
- {
- throw new System.NotImplementedException();
- }
-
- public virtual IList StandardAssemblyReferences {
- get { return standardAssemblyReferences; }
- }
-
- public virtual IList StandardImports {
- get { return standardImports; }
- }
-
- public virtual string TemplateFile {
- get; set;
- }
- }
-}
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/GenerationTests.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/GenerationTests.cs
deleted file mode 100644
index 1a4bd2b4..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/GenerationTests.cs
+++ /dev/null
@@ -1,171 +0,0 @@
-//
-// GenerationTests.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using NUnit.Framework;
-using Microsoft.VisualStudio.TextTemplating;
-
-namespace Mono.TextTemplating.Tests
-{
-
-
- [TestFixture]
- public class GenerationTests
- {
- [Test]
- public void Generate ()
- {
- string Input = ParsingTests.ParseSample1;
- string Output = OutputSample1;
- Generate (Input, Output, "\n");
- }
-
- [Test]
- public void GenerateMacNewlines ()
- {
- string MacInput = ParsingTests.ParseSample1.Replace ("\n", "\r");
- string MacOutput = OutputSample1.Replace ("\\n", "\\r").Replace ("\n", "\r");;
- Generate (MacInput, MacOutput, "\r");
- }
-
- [Test]
- public void GenerateWindowsNewlines ()
- {
- string WinInput = ParsingTests.ParseSample1.Replace ("\n", "\r\n");
- string WinOutput = OutputSample1.Replace ("\\n", "\\r\\n").Replace ("\n", "\r\n");
- Generate (WinInput, WinOutput, "\r\n");
- }
-
- //NOTE: we set the newline property on the code generator so that the whole files has matching newlines,
- // in order to match the newlines in the verbatim code blocks
- void Generate (string input, string expectedOutput, string newline)
- {
- DummyHost host = new DummyHost ();
- string className = "GeneratedTextTransformation4f504ca0";
- string code = GenerateCode (host, input, className, newline);
- Assert.AreEqual (0, host.Errors.Count);
- Assert.AreEqual (expectedOutput, TemplatingEngineHelper.StripHeader (code, newline));
- }
-
- #region Helpers
-
- string GenerateCode (ITextTemplatingEngineHost host, string content, string name, string generatorNewline)
- {
- ParsedTemplate pt = ParsedTemplate.FromText (content, host);
- if (pt.Errors.HasErrors) {
- host.LogErrors (pt.Errors);
- return null;
- }
-
- TemplateSettings settings = TemplatingEngine.GetSettings (host, pt);
- if (name != null)
- settings.Name = name;
- if (pt.Errors.HasErrors) {
- host.LogErrors (pt.Errors);
- return null;
- }
-
- var ccu = TemplatingEngine.GenerateCompileUnit (host, content, pt, settings);
- if (pt.Errors.HasErrors) {
- host.LogErrors (pt.Errors);
- return null;
- }
-
- var opts = new System.CodeDom.Compiler.CodeGeneratorOptions ();
- using (var writer = new System.IO.StringWriter ()) {
- writer.NewLine = generatorNewline;
- settings.Provider.GenerateCodeFromCompileUnit (ccu, writer, opts);
- return writer.ToString ();
- }
- }
-
- #endregion
-
- #region Expected output strings
-
- public static string OutputSample1 =
-@"
-namespace Microsoft.VisualStudio.TextTemplating {
-
-
- public partial class GeneratedTextTransformation4f504ca0 : global::Microsoft.VisualStudio.TextTemplating.TextTransformation {
-
-
- #line 9 """"
-
-baz \#>
-
- #line default
- #line hidden
-
- public override string TransformText() {
- this.GenerationEnvironment = null;
-
- #line 2 """"
- this.Write(""Line One\nLine Two\n"");
-
- #line default
- #line hidden
-
- #line 4 """"
-
-foo
-
-
- #line default
- #line hidden
-
- #line 7 """"
- this.Write(""Line Three "");
-
- #line default
- #line hidden
-
- #line 7 """"
- this.Write(global::Microsoft.VisualStudio.TextTemplating.ToStringHelper.ToStringWithCulture( bar ));
-
- #line default
- #line hidden
-
- #line 7 """"
- this.Write(""\nLine Four\n"");
-
- #line default
- #line hidden
- return this.GenerationEnvironment.ToString();
- }
-
- protected override void Initialize() {
- base.Initialize();
- }
- }
-}
-";
- #endregion
- }
-}
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/Mono.TextTemplating.Tests.csproj b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/Mono.TextTemplating.Tests.csproj
deleted file mode 100644
index 75860807..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/Mono.TextTemplating.Tests.csproj
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
- Debug
- AnyCPU
- 9.0.21022
- 2.0
- {CB590106-8331-4CBE-8131-B154E7BF79E1}
- Library
- Mono.TextTemplating.Tests
- Mono.TextTemplating.Tests
-
-
- true
- full
- false
- ..\bin
- DEBUG
- prompt
- 4
-
-
- none
- false
- ..\bin
- prompt
- 4
-
-
-
-
- ..\NUnit\lib\nunit.core.dll
- False
-
-
- ..\NUnit\lib\nunit.framework.dll
- False
-
-
-
-
-
-
-
-
-
-
-
- {A2364D6A-00EF-417C-80A6-815726C70032}
- Mono.TextTemplating
- False
-
-
-
-
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/ParsingTests.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/ParsingTests.cs
deleted file mode 100644
index 5e247509..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/ParsingTests.cs
+++ /dev/null
@@ -1,191 +0,0 @@
-//
-// Test.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Collections.Generic;
-using NUnit.Framework;
-
-namespace Mono.TextTemplating.Tests
-{
-
-
- [TestFixture]
- public class ParsingTests
- {
- public static string ParseSample1 =
-@"<#@ template language=""C#v3.5"" #>
-Line One
-Line Two
-<#
-foo
-#>
-Line Three <#= bar #>
-Line Four
-<#+
-baz \#>
-#>
-";
-
- [Test]
- public void TokenTest ()
- {
- string tf = "test.input";
- Tokeniser tk = new Tokeniser (tf, ParseSample1);
-
- //line 1
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 1, 1), tk.Location);
- Assert.AreEqual (State.Content, tk.State);
- Assert.AreEqual ("", tk.Value);
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (State.Directive, tk.State);
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 1, 5), tk.Location);
- Assert.AreEqual (State.DirectiveName, tk.State);
- Assert.AreEqual ("template", tk.Value);
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (State.Directive, tk.State);
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 1, 14), tk.Location);
- Assert.AreEqual (State.DirectiveName, tk.State);
- Assert.AreEqual ("language", tk.Value);
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (State.Directive, tk.State);
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (State.DirectiveValue, tk.State);
- Assert.AreEqual (new Location (tf, 1, 23), tk.Location);
- Assert.AreEqual ("C#v3.5", tk.Value);
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (State.Directive, tk.State);
-
- //line 2, 3
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 2, 1), tk.Location);
- Assert.AreEqual (State.Content, tk.State);
- Assert.AreEqual ("Line One\nLine Two\n", tk.Value);
-
- //line 4, 5, 6
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 4, 1), tk.TagStartLocation);
- Assert.AreEqual (new Location (tf, 4, 3), tk.Location);
- Assert.AreEqual (new Location (tf, 6, 3), tk.TagEndLocation);
- Assert.AreEqual (State.Block, tk.State);
- Assert.AreEqual ("\nfoo\n", tk.Value);
-
- //line 7
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 7, 1), tk.Location);
- Assert.AreEqual (State.Content, tk.State);
- Assert.AreEqual ("Line Three ", tk.Value);
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 7, 12), tk.TagStartLocation);
- Assert.AreEqual (new Location (tf, 7, 15), tk.Location);
- Assert.AreEqual (new Location (tf, 7, 22), tk.TagEndLocation);
- Assert.AreEqual (State.Expression, tk.State);
- Assert.AreEqual (" bar ", tk.Value);
-
- //line 8
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 7, 22), tk.Location);
- Assert.AreEqual (State.Content, tk.State);
- Assert.AreEqual ("\nLine Four\n", tk.Value);
-
- //line 9, 10, 11
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 9, 1), tk.TagStartLocation);
- Assert.AreEqual (new Location (tf, 9, 4), tk.Location);
- Assert.AreEqual (new Location (tf, 11, 3), tk.TagEndLocation);
- Assert.AreEqual (State.Helper, tk.State);
- Assert.AreEqual (" \nbaz \\#>\n", tk.Value);
-
- //line 12
- Assert.IsTrue (tk.Advance ());
- Assert.AreEqual (new Location (tf, 12, 1), tk.Location);
- Assert.AreEqual (State.Content, tk.State);
- Assert.AreEqual ("", tk.Value);
-
- //EOF
- Assert.IsFalse (tk.Advance ());
- Assert.AreEqual (new Location (tf, 12, 1), tk.Location);
- Assert.AreEqual (State.EOF, tk.State);
- }
-
- [Test]
- public void ParseTest ()
- {
- string tf = "test.input";
-
- ParsedTemplate pt = new ParsedTemplate ("test.input");
- Tokeniser tk = new Tokeniser (tf, ParseSample1);
- DummyHost host = new DummyHost ();
- pt.Parse (host, tk);
-
- Assert.AreEqual (0, pt.Errors.Count);
- var content = new List (pt.Content);
- var dirs = new List (pt.Directives);
-
- Assert.AreEqual (1, dirs.Count);
- Assert.AreEqual (6, content.Count);
-
- Assert.AreEqual ("template", dirs[0].Name);
- Assert.AreEqual (1, dirs[0].Attributes.Count);
- Assert.AreEqual ("C#v3.5", dirs[0].Attributes["language"]);
- Assert.AreEqual (new Location (tf, 1, 1), dirs[0].TagStartLocation);
- Assert.AreEqual (new Location (tf, 1, 34), dirs[0].EndLocation);
-
- Assert.AreEqual ("Line One\nLine Two\n", content[0].Text);
- Assert.AreEqual ("\nfoo\n", content[1].Text);
- Assert.AreEqual ("Line Three ", content[2].Text);
- Assert.AreEqual (" bar ", content[3].Text);
- Assert.AreEqual ("\nLine Four\n", content[4].Text);
- Assert.AreEqual (" \nbaz \\#>\n", content[5].Text);
-
- Assert.AreEqual (SegmentType.Content, content[0].Type);
- Assert.AreEqual (SegmentType.Block, content[1].Type);
- Assert.AreEqual (SegmentType.Content, content[2].Type);
- Assert.AreEqual (SegmentType.Expression, content[3].Type);
- Assert.AreEqual (SegmentType.Content, content[4].Type);
- Assert.AreEqual (SegmentType.Helper, content[5].Type);
-
- Assert.AreEqual (new Location (tf, 4, 1), content[1].TagStartLocation);
- Assert.AreEqual (new Location (tf, 7, 12), content[3].TagStartLocation);
- Assert.AreEqual (new Location (tf, 9, 1), content[5].TagStartLocation);
-
- Assert.AreEqual (new Location (tf, 2, 1), content[0].StartLocation);
- Assert.AreEqual (new Location (tf, 4, 3), content[1].StartLocation);
- Assert.AreEqual (new Location (tf, 7, 1), content[2].StartLocation);
- Assert.AreEqual (new Location (tf, 7, 15), content[3].StartLocation);
- Assert.AreEqual (new Location (tf, 7, 22), content[4].StartLocation);
- Assert.AreEqual (new Location (tf, 9, 4), content[5].StartLocation);
-
- Assert.AreEqual (new Location (tf, 6, 3), content[1].EndLocation);
- Assert.AreEqual (new Location (tf, 7, 22), content[3].EndLocation);
- Assert.AreEqual (new Location (tf, 11, 3), content[5].EndLocation);
- }
-
-
- }
-}
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/TemplateEnginePreprocessTemplateTests.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/TemplateEnginePreprocessTemplateTests.cs
deleted file mode 100644
index 02bcab11..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/TemplateEnginePreprocessTemplateTests.cs
+++ /dev/null
@@ -1,246 +0,0 @@
-//
-// TemplateEnginePreprocessTemplateTests.cs
-//
-// Author:
-// Matt Ward
-//
-// Copyright (c) 2010 Matt Ward
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using NUnit.Framework;
-using Microsoft.VisualStudio.TextTemplating;
-
-namespace Mono.TextTemplating.Tests
-{
- [TestFixture]
- public class TemplateEnginePreprocessTemplateTests
- {
- [Test]
- public void Preprocess ()
- {
- string input =
- "<#@ template language=\"C#\" #>\r\n" +
- "Test\r\n";
-
- string expectedOutput = OutputSample1;
- string output = Preprocess (input);
-
- Assert.AreEqual (expectedOutput, output);
- }
-
- #region Helpers
-
- string Preprocess (string input)
- {
- DummyHost host = new DummyHost ();
- string className = "PreprocessedTemplate";
- string classNamespace = "Templating";
- string language = null;
- string[] references = null;
-
- TemplatingEngine engine = new TemplatingEngine ();
- string output = engine.PreprocessTemplate (input, host, className, classNamespace, out language, out references);
- output = output.Replace ("\r\n", "\n");
- return TemplatingEngineHelper.StripHeader (output, "\n");
- }
-
- #endregion
-
- #region Expected output strings
-
- public static string OutputSample1 =
-@"
-namespace Templating {
-
-
- public partial class PreprocessedTemplate : PreprocessedTemplateBase {
-
- public virtual string TransformText() {
- this.GenerationEnvironment = null;
-
- #line 2 """"
- this.Write(""Test\r\n"");
-
- #line default
- #line hidden
- return this.GenerationEnvironment.ToString();
- }
-
- protected virtual void Initialize() {
- }
- }
-
- public class PreprocessedTemplateBase {
-
- private global::System.Text.StringBuilder builder;
-
- private global::System.Collections.Generic.IDictionary session;
-
- private global::System.CodeDom.Compiler.CompilerErrorCollection errors;
-
- private string currentIndent = string.Empty;
-
- private global::System.Collections.Generic.Stack indents;
-
- private ToStringInstanceHelper _toStringHelper = new ToStringInstanceHelper();
-
- public virtual global::System.Collections.Generic.IDictionary Session {
- get {
- return this.session;
- }
- set {
- this.session = value;
- }
- }
-
- public global::System.Text.StringBuilder GenerationEnvironment {
- get {
- if ((this.builder == null)) {
- this.builder = new global::System.Text.StringBuilder();
- }
- return this.builder;
- }
- set {
- this.builder = value;
- }
- }
-
- protected global::System.CodeDom.Compiler.CompilerErrorCollection Errors {
- get {
- if ((this.errors == null)) {
- this.errors = new global::System.CodeDom.Compiler.CompilerErrorCollection();
- }
- return this.errors;
- }
- }
-
- public string CurrentIndent {
- get {
- return this.currentIndent;
- }
- }
-
- private global::System.Collections.Generic.Stack Indents {
- get {
- if ((this.indents == null)) {
- this.indents = new global::System.Collections.Generic.Stack();
- }
- return this.indents;
- }
- }
-
- public ToStringInstanceHelper ToStringHelper {
- get {
- return this._toStringHelper;
- }
- }
-
- public void Error(string message) {
- this.Errors.Add(new global::System.CodeDom.Compiler.CompilerError(null, -1, -1, null, message));
- }
-
- public void Warning(string message) {
- global::System.CodeDom.Compiler.CompilerError val = new global::System.CodeDom.Compiler.CompilerError(null, -1, -1, null, message);
- val.IsWarning = true;
- this.Errors.Add(val);
- }
-
- public string PopIndent() {
- if ((this.Indents.Count == 0)) {
- return string.Empty;
- }
- int lastPos = (this.currentIndent.Length - this.Indents.Pop());
- string last = this.currentIndent.Substring(lastPos);
- this.currentIndent = this.currentIndent.Substring(0, lastPos);
- return last;
- }
-
- public void PushIndent(string indent) {
- this.Indents.Push(indent.Length);
- this.currentIndent = (this.currentIndent + indent);
- }
-
- public void ClearIndent() {
- this.currentIndent = string.Empty;
- this.Indents.Clear();
- }
-
- public void Write(string textToAppend) {
- this.GenerationEnvironment.Append(textToAppend);
- }
-
- public void Write(string format, params object[] args) {
- this.GenerationEnvironment.AppendFormat(format, args);
- }
-
- public void WriteLine(string textToAppend) {
- this.GenerationEnvironment.Append(this.currentIndent);
- this.GenerationEnvironment.AppendLine(textToAppend);
- }
-
- public void WriteLine(string format, params object[] args) {
- this.GenerationEnvironment.Append(this.currentIndent);
- this.GenerationEnvironment.AppendFormat(format, args);
- this.GenerationEnvironment.AppendLine();
- }
-
- public class ToStringInstanceHelper {
-
- private global::System.IFormatProvider formatProvider = global::System.Globalization.CultureInfo.InvariantCulture;
-
- public global::System.IFormatProvider FormatProvider {
- get {
- return this.formatProvider;
- }
- set {
- if ((this.formatProvider == null)) {
- throw new global::System.ArgumentNullException(""formatProvider"");
- }
- this.formatProvider = value;
- }
- }
-
- public string ToStringWithCulture(object objectToConvert) {
- if ((objectToConvert == null)) {
- throw new global::System.ArgumentNullException(""objectToConvert"");
- }
- global::System.Type type = objectToConvert.GetType();
- global::System.Type iConvertibleType = typeof(global::System.IConvertible);
- if (iConvertibleType.IsAssignableFrom(type)) {
- return ((global::System.IConvertible)(objectToConvert)).ToString(this.formatProvider);
- }
- global::System.Reflection.MethodInfo methInfo = type.GetMethod(""ToString"", new global::System.Type[] {
- iConvertibleType});
- if ((methInfo != null)) {
- return ((string)(methInfo.Invoke(objectToConvert, new object[] {
- this.formatProvider})));
- }
- return objectToConvert.ToString();
- }
- }
- }
-}
-";
- #endregion
- }
-}
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/TemplatingEngineHelper.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/TemplatingEngineHelper.cs
deleted file mode 100644
index 6238f7a8..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating.Tests/TemplatingEngineHelper.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-//
-// Test.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.IO;
-
-namespace Mono.TextTemplating.Tests
-{
- public static class TemplatingEngineHelper
- {
- public static string StripHeader (string input, string newLine)
- {
- using (var writer = new StringWriter ()) {
- using (var reader = new StringReader (input)) {
- for (int i = 0; i < 9; i++) {
- reader.ReadLine ();
- }
- string line;
- while ((line = reader.ReadLine ()) != null) {
- writer.Write (line);
- writer.Write (newLine);
- }
- }
- return writer.ToString ();
- }
- }
- }
-}
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/AssemblyInfo.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/AssemblyInfo.cs
deleted file mode 100644
index 13849716..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/AssemblyInfo.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// AssemblyInfo.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System;
-
-[assembly: AssemblyTitle("Mono.TextTemplating")]
-[assembly: AssemblyDescription("An implementation of Visual Studio's T4 text templating")]
-[assembly: AssemblyCompany("The Mono Project")]
-[assembly: AssemblyProduct("MonoDevelop")]
-[assembly: AssemblyCopyright("MIT/X11")]
-[assembly: CLSCompliant (true)]
-
-//[assembly: AssemblyVersion("1.0.0.0")]
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/ChangeLog b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/ChangeLog
deleted file mode 100644
index 51377760..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/ChangeLog
+++ /dev/null
@@ -1,212 +0,0 @@
-2010-03-15 Michael Hutchinson
-
- * Mono.TextTemplating/TemplateGenerator.cs: Expose OutputFile
- for custom tool to access.
-
-2010-03-01 Michael Hutchinson
-
- * Mono.TextTemplating/CrossAppDomainAssemblyResolver.cs: A
- handler for AssemblyResolve events that looks them up in the
- domain that created the resolver.
-
- * Makefile.am:
- * Mono.TextTemplating.csproj: Added file.
-
-2009-11-27 Olivier Dagenais
- * Mono.TextTemplating/ParsedTemplate.cs: Fixed a bug where the
- location of an error was being ignored.
-
-2009-11-27 Olivier Dagenais
-
- * Mono.TextTemplating/TemplatingEngine.cs: Mark the generated
- type as partial.
-
-2009-11-25 Michael Hutchinson
-
- * Mono.TextTemplating/ParsedTemplate.cs: Don't check if
- included file exists before trying to resolve it from the
- host, because host may use include paths. Patch from Aaron
- Bockover.
-
-2009-08-17 Michael Hutchinson
-
- * Mono.TextTemplating/TemplatingEngine.cs: Fix NRE when
- template fails to compile.
-
-2009-08-12 Michael Hutchinson
-
- * Makefile.am:
- * Mono.TextTemplating.csproj: Include the ASP.NET MVC and
- TextTemplating addins in the main solution and build.
-
-2009-08-11 Michael Hutchinson
-
- * Mono.TextTemplating.csproj:
- * Mono.TextTemplating/ParsedTemplate.cs:
- * Mono.TextTemplating/CompiledTemplate.cs:
- * Mono.TextTemplating/TemplatingEngine.cs:
- * Mono.TextTemplating/TemplateGenerator.cs:
- * Mono.TextTemplating/IExtendedTextTemplatingEngineHost.cs:
- Add support for caching compiled templates, and a couple of
- bugfixes. Patch from Nathan Baulch
- (nathan.baulch@gmail.com).
-
-2009-06-25 Michael Hutchinson
-
- * Mono.TextTemplating/TemplatingEngine.cs: Handle expressions
- and content in helpers, based on patch from Nathan Baulch.
- Liberally add C# 3 sugar to neaten up CodeDOM usage.
-
-2009-06-25 Michael Hutchinson
-
- * Mono.TextTemplating/TemplateGenerator.cs: Added overload for
- Process template that uses input/output strings directly,
- avoiding file read/write. Expose engine to subclasses.
-
- * Mono.TextTemplating/Tokeniser.cs: Remove outdated TODO.
-
-2009-04-13 Michael Hutchinson
-
- * Microsoft.VisualStudio.TextTemplating/ToStringHelper.cs: Use
- IConvertible.ToString (formatProvider) when possible.
-
- Thanks to Stuart Carnie for this patch.
-
-2009-04-13 Michael Hutchinson
-
- * Mono.TextTemplating/Tokeniser.cs: Add support for Mac and
- Windows newlines.
-
- * Mono.TextTemplating/TemplatingEngine.cs: Keep temp files
- when in debug mode, so that the generated code can be
- debugged.
-
- * Mono.TextTemplating/ParsedTemplate.cs: Fixes for csc
- compilation.
-
- Thanks to Stuart Carnie for this patch.
-
-2009-04-03 Michael Hutchinson
-
- * Mono.TextTemplating.csproj:
- * Mono.TextTemplating/TemplatingEngine.cs:
- * Mono.TextTemplating/TemplateSettings.cs:
- * Microsoft.VisualStudio.TextTemplating/Engine.cs: Move the
- real engine into the Mono.TextTemplating namespace and
- expose helper methods so that they can be tested.
-
-2009-03-13 Michael Hutchinson
-
- * Mono.TextTemplating.csproj: Move output dir from ../bin to
- ../build.
-
-2009-03-12 Michael Hutchinson
-
- * Mono.TextTemplating/Tokeniser.cs: Tweaked location of next
- state after directive.
-
-2009-03-12 Michael Hutchinson
-
- * Mono.TextTemplating/Tokeniser.cs: Location tweaks within
- directives.
-
- * Mono.TextTemplating/ParsedTemplate.cs: Make Location
- equatable.
-
-2009-03-10 Michael Hutchinson
-
- * Mono.TextTemplating/Tokeniser.cs:
- * Mono.TextTemplating/ParsedTemplate.cs: Fix end location
- capture after newline handling changes.
-
-2009-03-10 Michael Hutchinson
-
- * Mono.TextTemplating/Tokeniser.cs:
- * Microsoft.VisualStudio.TextTemplating/Engine.cs: Match T4's
- newline handling.
-
-2009-03-10 Michael Hutchinson
-
- * Mono.TextTemplating/ParsedTemplate.cs: Fix logic that
- prevented adding directives.
-
-2009-03-09 Michael Hutchinson
-
- * Mono.TextTemplating/Tokeniser.cs:
- * Mono.TextTemplating/ParsedTemplate.cs: More accurate
- location captures. Capture start of tags as well as start of
- content.
-
-2009-03-09 Michael Hutchinson
-
- * Mono.TextTemplating/TemplateGenerator.cs: Report exceptions
- in errors.
-
- * Mono.TextTemplating/Tokeniser.cs: Make API public.
-
- * Mono.TextTemplating/ParsedTemplate.cs: Unify segment types.
- Track end locations. Make API public. Allow parsing without
- includes.
-
- * Microsoft.VisualStudio.TextTemplating/Engine.cs: Track
- location API.
-
-2009-03-06 Michael Hutchinson
-
- * Mono.TextTemplating/TemplateGenerator.cs: Fix
- SetFileExtension.
-
- * Microsoft.VisualStudio.TextTemplating/Engine.cs: Capture
- hostspecific attribute from template directive.
-
-2009-03-05 Michael Hutchinson
-
- * Mono.TextTemplating/TemplateGenerator.cs: Fix output
- extension changing.
-
- * Mono.TextTemplating/Tokeniser.cs: Fix helper regions.
-
-2009-03-05 Michael Hutchinson
-
- * Mono.TextTemplating.csproj: Updated.
-
- * Mono.TextTemplating/TemplateGenerator.cs: Simple template
- host implementation. Doesn't handle everything yet.
-
- * Mono.TextTemplating/Tokeniser.cs: Fix a number of offset
- issues that broke most captures. Only allow EOF in content
- regions, and in this case capture the last content. Track
- current column, for error reporting.
-
- * Mono.TextTemplating/ParsedTemplate.cs: Overhaul location
- tracking for error reporting. Don't record empty segments.
-
- * Microsoft.VisualStudio.TextTemplating/Engine.cs: Use run
- method instead of runner, since the whole thing's done in
- the appdomain now. Catch errors from the runner. Use host's
- default assemblies and imports. Track ParsedTemplate error
- reporting changes. Filter out content regions with only a
- single newline.
-
- * Microsoft.VisualStudio.TextTemplating/ToStringHelper.cs:
- Don't cache delegates; this won't work for instances. Maybe
- IL generation is called for.
-
-2009-03-04 Michael Hutchinson
-
- * AssemblyInfo.cs:
- * Mono.TextTemplating:
- * Mono.TextTemplating.csproj:
- * Mono.TextTemplating/Tokeniser.cs:
- * Microsoft.VisualStudio.TextTemplating:
- * Mono.TextTemplating/ParsedTemplate.cs:
- * Microsoft.VisualStudio.TextTemplating/Engine.cs:
- * Microsoft.VisualStudio.TextTemplating/ToStringHelper.cs:
- * Microsoft.VisualStudio.TextTemplating/DirectiveProcessor.cs:
- * Microsoft.VisualStudio.TextTemplating/TextTransformation.cs:
- * Microsoft.VisualStudio.TextTemplating/ITextTemplatingEngineHost.cs:
- * Microsoft.VisualStudio.TextTemplating/DirectiveProcessorException.cs:
- * Microsoft.VisualStudio.TextTemplating/RequiresProvidesDirectiveProcessor.cs:
- Move T4 implementation to its own assembly. Tweak some
- appdomain stuff.
-
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Makefile.am b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Makefile.am
deleted file mode 100644
index 72ec1552..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Makefile.am
+++ /dev/null
@@ -1,55 +0,0 @@
-ADDIN_BUILD = $(top_builddir)/build/AddIns/MonoDevelop.TextTemplating
-ASSEMBLY = $(ADDIN_BUILD)/Mono.TextTemplating.dll
-
-DEPS =
-
-REFS = \
- -r:System \
- -r:System.Core
-
-FILES = \
- AssemblyInfo.cs \
- Microsoft.VisualStudio.TextTemplating/AssemblyCacheMonitor.cs \
- Microsoft.VisualStudio.TextTemplating/DirectiveProcessor.cs \
- Microsoft.VisualStudio.TextTemplating/DirectiveProcessorException.cs \
- Microsoft.VisualStudio.TextTemplating/EncodingHelper.cs \
- Microsoft.VisualStudio.TextTemplating/Engine.cs \
- Microsoft.VisualStudio.TextTemplating/Interfaces.cs \
- Microsoft.VisualStudio.TextTemplating/ParameterDirectiveProcessor.cs \
- Microsoft.VisualStudio.TextTemplating/RequiresProvidesDirectiveProcessor.cs \
- Microsoft.VisualStudio.TextTemplating/TextTemplatingSession.cs \
- Microsoft.VisualStudio.TextTemplating/TextTransformation.cs \
- Microsoft.VisualStudio.TextTemplating/ToStringHelper.cs \
- Mono.TextTemplating/CompiledTemplate.cs \
- Mono.TextTemplating/CrossAppDomainAssemblyResolver.cs \
- Mono.TextTemplating/ParsedTemplate.cs \
- Mono.TextTemplating/TemplateGenerator.cs \
- Mono.TextTemplating/TemplateSettings.cs \
- Mono.TextTemplating/TemplatingEngine.cs \
- Mono.TextTemplating/Tokeniser.cs
-
-RES =
-
-all: $(ASSEMBLY) $(ASSEMBLY).mdb $(DATA_FILE_BUILD)
-
-$(ASSEMBLY): $(build_sources) $(build_resources) $(DEPS)
- mkdir -p $(ADDIN_BUILD)
- $(CSC) $(CSC_FLAGS) -debug -out:$@ -target:library $(REFS) $(build_deps) \
- $(build_resources:%=/resource:%) $(build_sources)
-
-$(ASSEMBLY).mdb: $(ASSEMBLY)
-
-$(DATA_FILE_BUILD): $(srcdir)$(subst $(ADDIN_BUILD),, $@)
- mkdir -p $(ADDIN_BUILD)/Schemas
- cp $(srcdir)/$(subst $(ADDIN_BUILD),,$@) $@
-
-check: all
-
-assemblydir = $(MD_ADDIN_DIR)/MonoDevelop.TextTemplating
-assembly_DATA = $(ASSEMBLY) $(ASSEMBLY).mdb
-
-CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb
-EXTRA_DIST = $(FILES) $(RES)
-
-include $(top_srcdir)/Makefile.include
-
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/AssemblyCacheMonitor.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/AssemblyCacheMonitor.cs
deleted file mode 100644
index 68a17fb0..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/AssemblyCacheMonitor.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// AssemblyCacheMonitor.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2010 Novell, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
- public sealed class AssemblyCacheMonitor : MarshalByRefObject
- {
- public AssemblyCacheMonitor ()
- {
- }
-
- public int GetStaleAssembliesCount (TimeSpan assemblyStaleTime)
- {
- throw new NotImplementedException ();
- }
- }
-}
-
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/DirectiveProcessor.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/DirectiveProcessor.cs
deleted file mode 100644
index f86dbd2e..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/DirectiveProcessor.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-//
-// DirectiveProcessor.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Collections.Generic;
-using System.CodeDom.Compiler;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
- public abstract class DirectiveProcessor
- {
- protected DirectiveProcessor ()
- {
- }
-
- public virtual void Initialize (ITextTemplatingEngineHost host)
- {
- if (host == null)
- throw new ArgumentNullException ("host");
- }
-
- public virtual void StartProcessingRun (CodeDomProvider languageProvider, string templateContents, CompilerErrorCollection errors)
- {
- if (languageProvider == null)
- throw new ArgumentNullException ("languageProvider");
- this.Errors = errors;
- }
-
- public abstract void FinishProcessingRun ();
- public abstract string GetClassCodeForProcessingRun ();
- public abstract string[] GetImportsForProcessingRun ();
- public abstract string GetPostInitializationCodeForProcessingRun ();
- public abstract string GetPreInitializationCodeForProcessingRun ();
- public abstract string[] GetReferencesForProcessingRun ();
- public abstract bool IsDirectiveSupported (string directiveName);
- public abstract void ProcessDirective (string directiveName, IDictionary arguments);
-
- protected CompilerErrorCollection Errors { get; private set; }
- }
-}
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/DirectiveProcessorException.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/DirectiveProcessorException.cs
deleted file mode 100644
index 1d95faca..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/DirectiveProcessorException.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-//
-// DirectiveProcessorException.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Runtime.Serialization;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
-
- [Serializable]
- public class DirectiveProcessorException : Exception
- {
-
- public DirectiveProcessorException ()
- {
- }
-
- public DirectiveProcessorException (string message)
- : base (message)
- {
- }
-
- public DirectiveProcessorException (SerializationInfo info, StreamingContext context)
- : base (info, context)
- {
- }
-
- public DirectiveProcessorException (string message, Exception inner)
- : base (message, inner)
- {
- }
- }
-}
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/EncodingHelper.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/EncodingHelper.cs
deleted file mode 100644
index 9934646b..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/EncodingHelper.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// EncodingHelper.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2010 Novell, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Text;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
- public static class EncodingHelper
- {
- public static Encoding GetEncoding (string filePath)
- {
- throw new NotImplementedException ();
- }
- }
-}
-
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/Engine.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/Engine.cs
deleted file mode 100644
index fc9c9aac..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/Engine.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-// Engine.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.IO;
-using System.Text;
-using System.Collections.Generic;
-using System.CodeDom;
-using System.CodeDom.Compiler;
-using Mono.TextTemplating;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
- public class Engine : ITextTemplatingEngine
- {
- TemplatingEngine engine = new TemplatingEngine ();
-
- public Engine ()
- {
- }
-
- public string ProcessTemplate (string content, ITextTemplatingEngineHost host)
- {
- return engine.ProcessTemplate (content, host);
- }
-
- public string PreprocessTemplate (string content, ITextTemplatingEngineHost host, string className,
- string classNamespace, out string language, out string[] references)
- {
- return engine.PreprocessTemplate (content, host, className, classNamespace, out language, out references);
- }
-
- public const string CacheAssembliesOptionString = "CacheAssemblies";
- }
-}
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/Interfaces.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/Interfaces.cs
deleted file mode 100644
index 5ea7413f..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/Interfaces.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-//
-// ITextTemplatingEngineHost.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2009-2010 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Text;
-using System.CodeDom.Compiler;
-using System.Collections.Generic;
-using System.Collections;
-using System.Runtime.Serialization;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
- public interface IRecognizeHostSpecific
- {
- void SetProcessingRunIsHostSpecific (bool hostSpecific);
- bool RequiresProcessingRunIsHostSpecific { get; }
- }
-
- [CLSCompliant(true)]
- public interface ITextTemplatingEngine
- {
- string ProcessTemplate (string content, ITextTemplatingEngineHost host);
- string PreprocessTemplate (string content, ITextTemplatingEngineHost host, string className,
- string classNamespace, out string language, out string[] references);
- }
-
- [CLSCompliant(true)]
- public interface ITextTemplatingEngineHost
- {
- object GetHostOption (string optionName);
- bool LoadIncludeText (string requestFileName, out string content, out string location);
- void LogErrors (CompilerErrorCollection errors);
- AppDomain ProvideTemplatingAppDomain (string content);
- string ResolveAssemblyReference (string assemblyReference);
- Type ResolveDirectiveProcessor (string processorName);
- string ResolveParameterValue (string directiveId, string processorName, string parameterName);
- string ResolvePath (string path);
- void SetFileExtension (string extension);
- void SetOutputEncoding (Encoding encoding, bool fromOutputDirective);
- IList StandardAssemblyReferences { get; }
- IList StandardImports { get; }
- string TemplateFile { get; }
- }
-
- [CLSCompliant(true)]
- public interface ITextTemplatingSession :
- IEquatable, IEquatable, IDictionary,
- ICollection>,
- IEnumerable>,
- IEnumerable, ISerializable
- {
- Guid Id { get; }
- }
-
- [CLSCompliant(true)]
- public interface ITextTemplatingSessionHost
- {
- ITextTemplatingSession CreateSession ();
- ITextTemplatingSession Session { get; set; }
- }
-}
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/ParameterDirectiveProcessor.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/ParameterDirectiveProcessor.cs
deleted file mode 100644
index 9518a428..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/ParameterDirectiveProcessor.cs
+++ /dev/null
@@ -1,268 +0,0 @@
-//
-// ParameterDirectiveProcessor.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2010 Novell, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Collections.Generic;
-using System.CodeDom.Compiler;
-using System.CodeDom;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
- public sealed class ParameterDirectiveProcessor : DirectiveProcessor, IRecognizeHostSpecific
- {
- CodeDomProvider provider;
- bool isCSharp;
- bool useMonoHack;
-
- bool hostSpecific;
- List postStatements = new List ();
- CodeTypeMemberCollection members = new CodeTypeMemberCollection ();
-
- public ParameterDirectiveProcessor ()
- {
- }
-
- public override void StartProcessingRun (CodeDomProvider languageProvider, string templateContents, CompilerErrorCollection errors)
- {
- base.StartProcessingRun (languageProvider, templateContents, errors);
- this.provider = languageProvider;
- //HACK: Mono as of 2.10.2 doesn't implement GenerateCodeFromMember
- if (Type.GetType ("Mono.Runtime") != null)
- useMonoHack = true;
- if (languageProvider is Microsoft.CSharp.CSharpCodeProvider)
- isCSharp = true;
- postStatements.Clear ();
- members.Clear ();
- }
-
- public override void FinishProcessingRun ()
- {
- var statement = new CodeConditionStatement (
- new CodeBinaryOperatorExpression (
- new CodePropertyReferenceExpression (
- new CodePropertyReferenceExpression (new CodeThisReferenceExpression (), "Errors"), "HasErrors"),
- CodeBinaryOperatorType.ValueEquality,
- new CodePrimitiveExpression (false)),
- postStatements.ToArray ());
-
- postStatements.Clear ();
- postStatements.Add (statement);
- }
-
- public override string GetClassCodeForProcessingRun ()
- {
- var options = new CodeGeneratorOptions ();
- using (var sw = new StringWriter ()) {
- GenerateCodeFromMembers (sw, options);
- return Indent (sw.ToString (), " ");
- }
- }
-
- string Indent (string s, string indent)
- {
- if (isCSharp)
- return Mono.TextTemplating.TemplatingEngine.IndentSnippetText (s, indent);
- return s;
- }
-
- public override string[] GetImportsForProcessingRun ()
- {
- return null;
- }
-
- public override string GetPostInitializationCodeForProcessingRun ()
- {
- return Indent (StatementsToCode (postStatements), " ");
- }
-
- public override string GetPreInitializationCodeForProcessingRun ()
- {
- return null;
- }
-
- string StatementsToCode (List statements)
- {
- var options = new CodeGeneratorOptions ();
- using (var sw = new StringWriter ()) {
- foreach (var statement in statements)
- provider.GenerateCodeFromStatement (statement, sw, options);
- return sw.ToString ();
- }
- }
-
- public override string[] GetReferencesForProcessingRun ()
- {
- return null;
- }
-
- public override bool IsDirectiveSupported (string directiveName)
- {
- return directiveName == "parameter";
- }
-
- public override void ProcessDirective (string directiveName, IDictionary arguments)
- {
- string name = arguments["name"];
- string type = arguments["type"];
- if (string.IsNullOrEmpty (name))
- throw new DirectiveProcessorException ("Parameter directive has no name argument");
- if (string.IsNullOrEmpty (type))
- throw new DirectiveProcessorException ("Parameter directive has no type argument");
-
- string fieldName = "_" + name + "Field";
- var typeRef = new CodeTypeReference (type);
- var thisRef = new CodeThisReferenceExpression ();
- var fieldRef = new CodeFieldReferenceExpression (thisRef, fieldName);
-
- var property = new CodeMemberProperty () {
- Name = name,
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- HasGet = true,
- HasSet = false,
- Type = typeRef
- };
- property.GetStatements.Add (new CodeMethodReturnStatement (fieldRef));
- members.Add (new CodeMemberField (typeRef, fieldName));
- members.Add (property);
-
- string acquiredName = "_" + name + "Acquired";
- var valRef = new CodeVariableReferenceExpression ("data");
- var namePrimitive = new CodePrimitiveExpression (name);
- var sessionRef = new CodePropertyReferenceExpression (thisRef, "Session");
- var callContextTypeRefExpr = new CodeTypeReferenceExpression ("System.Runtime.Remoting.Messaging.CallContext");
- var nullPrim = new CodePrimitiveExpression (null);
-
- var acquiredVariable = new CodeVariableDeclarationStatement (typeof (bool), acquiredName, new CodePrimitiveExpression (false));
- var acquiredVariableRef = new CodeVariableReferenceExpression (acquiredVariable.Name);
- this.postStatements.Add (acquiredVariable);
-
- //checks the local called "data" can be cast and assigned to the field, and if successful, sets acquiredVariable to true
- var checkCastThenAssignVal = new CodeConditionStatement (
- new CodeMethodInvokeExpression (
- new CodeTypeOfExpression (typeRef), "IsAssignableFrom", new CodeMethodInvokeExpression (valRef, "GetType")),
- new CodeStatement[] {
- new CodeAssignStatement (fieldRef, new CodeCastExpression (typeRef, valRef)),
- new CodeAssignStatement (acquiredVariableRef, new CodePrimitiveExpression (true)),
- },
- new CodeStatement[] {
- new CodeExpressionStatement (new CodeMethodInvokeExpression (thisRef, "Error",
- new CodePrimitiveExpression ("The type '" + type + "' of the parameter '" + name +
- "' did not match the type passed to the template"))),
- });
-
- //tries to gets the value from the session
- var checkSession = new CodeConditionStatement (
- new CodeBinaryOperatorExpression (NotNull (sessionRef), CodeBinaryOperatorType.BooleanAnd,
- new CodeMethodInvokeExpression (sessionRef, "ContainsKey", namePrimitive)),
- new CodeVariableDeclarationStatement (typeof (object), "data", new CodeIndexerExpression (sessionRef, namePrimitive)),
- checkCastThenAssignVal);
-
- this.postStatements.Add (checkSession);
-
- //if acquiredVariable is false, tries to gets the value from the host
- if (hostSpecific) {
- var hostRef = new CodePropertyReferenceExpression (thisRef, "Host");
- var checkHost = new CodeConditionStatement (
- BooleanAnd (IsFalse (acquiredVariableRef), NotNull (hostRef)),
- new CodeVariableDeclarationStatement (typeof (string), "data",
- new CodeMethodInvokeExpression (hostRef, "ResolveParameterValue", nullPrim, nullPrim, namePrimitive)),
- new CodeConditionStatement (NotNull (valRef), checkCastThenAssignVal));
-
- this.postStatements.Add (checkHost);
- }
-
- //if acquiredVariable is false, tries to gets the value from the call context
- var checkCallContext = new CodeConditionStatement (
- IsFalse (acquiredVariableRef),
- new CodeVariableDeclarationStatement (typeof (object), "data",
- new CodeMethodInvokeExpression (callContextTypeRefExpr, "LogicalGetData", namePrimitive)),
- new CodeConditionStatement (NotNull (valRef), checkCastThenAssignVal));
-
- this.postStatements.Add (checkCallContext);
- }
-
- static CodeBinaryOperatorExpression NotNull (CodeExpression reference)
- {
- return new CodeBinaryOperatorExpression (reference, CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression (null));
- }
-
- static CodeBinaryOperatorExpression IsFalse (CodeExpression expr)
- {
- return new CodeBinaryOperatorExpression (expr, CodeBinaryOperatorType.ValueEquality, new CodePrimitiveExpression (false));
- }
-
- static CodeBinaryOperatorExpression BooleanAnd (CodeExpression expr1, CodeExpression expr2)
- {
- return new CodeBinaryOperatorExpression (expr1, CodeBinaryOperatorType.BooleanAnd, expr2);
- }
-
- void IRecognizeHostSpecific.SetProcessingRunIsHostSpecific (bool hostSpecific)
- {
- this.hostSpecific = hostSpecific;
- }
-
- public bool RequiresProcessingRunIsHostSpecific {
- get { return false; }
- }
-
- void GenerateCodeFromMembers (StringWriter sw, CodeGeneratorOptions options)
- {
- if (!useMonoHack) {
- foreach (CodeTypeMember member in members)
- provider.GenerateCodeFromMember (member, sw, options);
- }
-
- var cgType = typeof (CodeGenerator);
- var cgInit = cgType.GetMethod ("InitOutput", BindingFlags.NonPublic | BindingFlags.Instance);
- var cgFieldGen = cgType.GetMethod ("GenerateField", BindingFlags.NonPublic | BindingFlags.Instance);
- var cgPropGen = cgType.GetMethod ("GenerateProperty", BindingFlags.NonPublic | BindingFlags.Instance);
-
-#pragma warning disable 0618
- var generator = (CodeGenerator) provider.CreateGenerator ();
-#pragma warning restore 0618
- var dummy = new CodeTypeDeclaration ("Foo");
-
- foreach (CodeTypeMember member in members) {
- var f = member as CodeMemberField;
- if (f != null) {
- cgInit.Invoke (generator, new object[] { sw, options });
- cgFieldGen.Invoke (generator, new object[] { f });
- continue;
- }
- var p = member as CodeMemberProperty;
- if (p != null) {
- cgInit.Invoke (generator, new object[] { sw, options });
- cgPropGen.Invoke (generator, new object[] { p, dummy });
- continue;
- }
- }
- }
- }
-}
-
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/RequiresProvidesDirectiveProcessor.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/RequiresProvidesDirectiveProcessor.cs
deleted file mode 100644
index bb48357c..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/RequiresProvidesDirectiveProcessor.cs
+++ /dev/null
@@ -1,196 +0,0 @@
-//
-// RequiresProvidesDirectiveProcessor.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Collections.Generic;
-using System.CodeDom.Compiler;
-using System.Text;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
-
-
- public abstract class RequiresProvidesDirectiveProcessor : DirectiveProcessor
- {
- bool isInProcessingRun;
- ITextTemplatingEngineHost host;
- StringBuilder preInitBuffer = new StringBuilder ();
- StringBuilder postInitBuffer = new StringBuilder ();
- StringBuilder codeBuffer = new StringBuilder ();
- CodeDomProvider languageProvider;
-
- protected RequiresProvidesDirectiveProcessor ()
- {
- }
-
- public override void Initialize (ITextTemplatingEngineHost host)
- {
- base.Initialize (host);
- this.host = host;
- }
-
- protected abstract void InitializeProvidesDictionary (string directiveName, IDictionary providesDictionary);
- protected abstract void InitializeRequiresDictionary (string directiveName, IDictionary requiresDictionary);
- protected abstract string FriendlyName { get; }
-
- protected abstract void GeneratePostInitializationCode (string directiveName, StringBuilder codeBuffer, CodeDomProvider languageProvider,
- IDictionary requiresArguments, IDictionary providesArguments);
- protected abstract void GeneratePreInitializationCode (string directiveName, StringBuilder codeBuffer, CodeDomProvider languageProvider,
- IDictionary requiresArguments, IDictionary providesArguments);
- protected abstract void GenerateTransformCode (string directiveName, StringBuilder codeBuffer, CodeDomProvider languageProvider,
- IDictionary requiresArguments, IDictionary providesArguments);
-
- protected virtual void PostProcessArguments (string directiveName, IDictionary requiresArguments,
- IDictionary providesArguments)
- {
- }
-
- public override string GetClassCodeForProcessingRun ()
- {
- AssertNotProcessing ();
- return codeBuffer.ToString ();
- }
-
- public override string[] GetImportsForProcessingRun ()
- {
- AssertNotProcessing ();
- return null;
- }
-
- public override string[] GetReferencesForProcessingRun ()
- {
- AssertNotProcessing ();
- return null;
- }
-
- public override string GetPostInitializationCodeForProcessingRun ()
- {
- AssertNotProcessing ();
- return postInitBuffer.ToString ();
- }
-
- public override string GetPreInitializationCodeForProcessingRun ()
- {
- AssertNotProcessing ();
- return preInitBuffer.ToString ();
- }
-
- public override void StartProcessingRun (CodeDomProvider languageProvider, string templateContents, CompilerErrorCollection errors)
- {
- AssertNotProcessing ();
- isInProcessingRun = true;
- base.StartProcessingRun (languageProvider, templateContents, errors);
-
- this.languageProvider = languageProvider;
- codeBuffer.Length = 0;
- preInitBuffer.Length = 0;
- postInitBuffer.Length = 0;
- }
-
- public override void FinishProcessingRun ()
- {
- isInProcessingRun = false;
- }
-
- void AssertNotProcessing ()
- {
- if (isInProcessingRun)
- throw new InvalidOperationException ();
- }
-
- //FIXME: handle escaping
- IEnumerable> ParseArgs (string args)
- {
- var pairs = args.Split (';');
- foreach (var p in pairs) {
- int eq = p.IndexOf ('=');
- var k = p.Substring (0, eq);
- var v = p.Substring (eq);
- yield return new KeyValuePair (k, v);
- }
- }
-
- public override void ProcessDirective (string directiveName, IDictionary arguments)
- {
- if (directiveName == null)
- throw new ArgumentNullException ("directiveName");
- if (arguments == null)
- throw new ArgumentNullException ("arguments");
-
- var providesDictionary = new Dictionary ();
- var requiresDictionary = new Dictionary ();
-
- string provides;
- if (arguments.TryGetValue ("provides", out provides)) {
- foreach (var arg in ParseArgs (provides)) {
- providesDictionary.Add (arg.Key, arg.Value);
- }
- }
-
- string requires;
- if (arguments.TryGetValue ("requires", out requires)) {
- foreach (var arg in ParseArgs (requires)) {
- requiresDictionary.Add (arg.Key, arg.Value);
- }
- }
-
- InitializeRequiresDictionary (directiveName, requiresDictionary);
- InitializeProvidesDictionary (directiveName, providesDictionary);
-
- var id = ProvideUniqueId (directiveName, arguments, requiresDictionary, providesDictionary);
-
- foreach (var req in requiresDictionary) {
- var val = host.ResolveParameterValue (id, FriendlyName, req.Key);
- if (val != null)
- requiresDictionary[req.Key] = val;
- else if (req.Value == null)
- throw new DirectiveProcessorException ("Could not resolve required value '" + req.Key + "'");
- }
-
- foreach (var req in providesDictionary) {
- var val = host.ResolveParameterValue (id, FriendlyName, req.Key);
- if (val != null)
- providesDictionary[req.Key] = val;
- }
-
- PostProcessArguments (directiveName, requiresDictionary, providesDictionary);
-
- GeneratePreInitializationCode (directiveName, preInitBuffer, languageProvider, requiresDictionary, providesDictionary);
- GeneratePostInitializationCode (directiveName, postInitBuffer, languageProvider, requiresDictionary, providesDictionary);
- GenerateTransformCode (directiveName, codeBuffer, languageProvider, requiresDictionary, providesDictionary);
- }
-
- protected virtual string ProvideUniqueId (string directiveName, IDictionary arguments,
- IDictionary requiresArguments, IDictionary providesArguments)
- {
- return directiveName;
- }
-
- protected ITextTemplatingEngineHost Host {
- get { return host; }
- }
- }
-}
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/TextTemplatingSession.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/TextTemplatingSession.cs
deleted file mode 100644
index b29dbd01..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/TextTemplatingSession.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-//
-// TextTemplatingSession.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2010 Novell, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Collections.Generic;
-using System.Collections;
-using System.Runtime.Serialization;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
- [Serializable]
- public sealed class TextTemplatingSession : Dictionary, ITextTemplatingSession
- {
- public TextTemplatingSession () : this (Guid.NewGuid ())
- {
- }
-
- public TextTemplatingSession (Guid id)
- {
- this.Id = id;
- }
-
- public Guid Id {
- get; private set;
- }
-
- public override int GetHashCode ()
- {
- return Id.GetHashCode ();
- }
-
- public override bool Equals (object obj)
- {
- var o = obj as TextTemplatingSession;
- return o != null && o.Equals (this);
- }
-
- public bool Equals (Guid other)
- {
- return other.Equals (Id);
- }
-
- public bool Equals (ITextTemplatingSession other)
- {
- return other != null && other.Id == this.Id;
- }
- }
-}
-
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/TextTransformation.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/TextTransformation.cs
deleted file mode 100644
index 409a36a9..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/TextTransformation.cs
+++ /dev/null
@@ -1,219 +0,0 @@
-//
-// TextTransformation.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.CodeDom.Compiler;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
- public abstract class TextTransformation : IDisposable
- {
- Stack indents;
- string currentIndent = string.Empty;
- CompilerErrorCollection errors;
- StringBuilder builder;
- bool endsWithNewline;
-
- public TextTransformation ()
- {
- }
-
- protected internal virtual void Initialize ()
- {
- }
-
- public abstract string TransformText ();
-
- public virtual IDictionary Session { get; set; }
-
- #region Errors
-
- public void Error (string message)
- {
- Errors.Add (new CompilerError (null, -1, -1, null, message));
- }
-
- public void Warning (string message)
- {
- var err = new CompilerError (null, -1, -1, null, message) {
- IsWarning = true,
- };
- Errors.Add (err);
- }
-
- protected internal CompilerErrorCollection Errors {
- get {
- if (errors == null)
- errors = new CompilerErrorCollection ();
- return errors;
- }
- }
-
- Stack Indents {
- get {
- if (indents == null)
- indents = new Stack ();
- return indents;
- }
- }
-
- #endregion
-
- #region Indents
-
- public string PopIndent ()
- {
- if (Indents.Count == 0)
- return "";
- int lastPos = currentIndent.Length - Indents.Pop ();
- string last = currentIndent.Substring (lastPos);
- currentIndent = currentIndent.Substring (0, lastPos);
- return last;
- }
-
- public void PushIndent (string indent)
- {
- if (indent == null)
- throw new ArgumentNullException ("indent");
- Indents.Push (indent.Length);
- currentIndent += indent;
- }
-
- public void ClearIndent ()
- {
- currentIndent = string.Empty;
- Indents.Clear ();
- }
-
- public string CurrentIndent {
- get { return currentIndent; }
- }
-
- #endregion
-
- #region Writing
-
- protected StringBuilder GenerationEnvironment {
- get {
- if (builder == null)
- builder = new StringBuilder ();
- return builder;
- }
- set {
- builder = value;
- }
- }
-
- public void Write (string textToAppend)
- {
- if (string.IsNullOrEmpty (textToAppend))
- return;
-
- if ((GenerationEnvironment.Length == 0 || endsWithNewline) && CurrentIndent.Length > 0) {
- GenerationEnvironment.Append (CurrentIndent);
- }
- endsWithNewline = false;
-
- char last = textToAppend[textToAppend.Length-1];
- if (last == '\n' || last == '\r') {
- endsWithNewline = true;
- }
-
- if (CurrentIndent.Length == 0) {
- GenerationEnvironment.Append (textToAppend);
- return;
- }
-
- //insert CurrentIndent after every newline (\n, \r, \r\n)
- //but if there's one at the end of the string, ignore it, it'll be handled next time thanks to endsWithNewline
- int lastNewline = 0;
- for (int i = 0; i < textToAppend.Length - 1; i++) {
- char c = textToAppend[i];
- if (c == '\r') {
- if (textToAppend[i + 1] == '\n') {
- i++;
- if (i == textToAppend.Length - 1)
- break;
- }
- } else if (c != '\n') {
- continue;
- }
- i++;
- int len = i - lastNewline;
- if (len > 0) {
- GenerationEnvironment.Append (textToAppend, lastNewline, i - lastNewline);
- }
- GenerationEnvironment.Append (CurrentIndent);
- lastNewline = i;
- }
- if (lastNewline > 0)
- GenerationEnvironment.Append (textToAppend, lastNewline, textToAppend.Length - lastNewline);
- else
- GenerationEnvironment.Append (textToAppend);
- }
-
- public void Write (string format, params object[] args)
- {
- Write (string.Format (format, args));
- }
-
- public void WriteLine (string textToAppend)
- {
- Write (textToAppend);
- GenerationEnvironment.AppendLine ();
- endsWithNewline = true;
- }
-
- public void WriteLine (string format, params object[] args)
- {
- WriteLine (string.Format (format, args));
- }
-
- #endregion
-
- #region Dispose
-
- public void Dispose ()
- {
- Dispose (true);
- GC.SuppressFinalize (this);
- }
-
- protected virtual void Dispose (bool disposing)
- {
- }
-
- ~TextTransformation ()
- {
- Dispose (false);
- }
-
- #endregion
-
- }
-}
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/ToStringHelper.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/ToStringHelper.cs
deleted file mode 100644
index 7f5934e2..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/ToStringHelper.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-//
-// ToStringHelper.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-
-namespace Microsoft.VisualStudio.TextTemplating
-{
- public static class ToStringHelper
- {
- static object [] formatProviderAsParameterArray;
-
- static IFormatProvider formatProvider = System.Globalization.CultureInfo.InvariantCulture;
-
- static ToStringHelper ()
- {
- formatProviderAsParameterArray = new object[] { formatProvider };
- }
-
- public static string ToStringWithCulture (object objectToConvert)
- {
- if (objectToConvert == null)
- throw new ArgumentNullException ("objectToConvert");
-
- IConvertible conv = objectToConvert as IConvertible;
- if (conv != null)
- return conv.ToString (formatProvider);
-
- var str = objectToConvert as string;
- if (str != null)
- return str;
-
- //TODO: implement a cache of types and DynamicMethods
- MethodInfo mi = objectToConvert.GetType ().GetMethod ("ToString", new Type[] { typeof (IFormatProvider) });
- if (mi != null)
- return (string) mi.Invoke (objectToConvert, formatProviderAsParameterArray);
- return objectToConvert.ToString ();
- }
-
- public static IFormatProvider FormatProvider {
- get { return (IFormatProvider)formatProviderAsParameterArray[0]; }
- set { formatProviderAsParameterArray[0] = formatProvider = value; }
- }
- }
-}
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating.csproj b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating.csproj
deleted file mode 100644
index 2523f46b..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating.csproj
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
-
- Debug
- AnyCPU
- 9.0.21022
- 2.0
- {A2364D6A-00EF-417C-80A6-815726C70032}
- Library
- Mono.TextTemplating
- Mono.TextTemplating
-
-
- true
- full
- false
- ..\bin
- DEBUG
- prompt
- 4
- false
-
-
- none
- false
- ..\bin
- prompt
- 4
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/CompiledTemplate.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/CompiledTemplate.cs
deleted file mode 100644
index 3e2f9458..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/CompiledTemplate.cs
+++ /dev/null
@@ -1,113 +0,0 @@
-//
-// CompiledTemplate.cs
-//
-// Author:
-// Nathan Baulch
-//
-// Copyright (c) 2009 Nathan Baulch
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Reflection;
-using Microsoft.VisualStudio.TextTemplating;
-using System.CodeDom.Compiler;
-using System.Globalization;
-
-namespace Mono.TextTemplating
-{
- public sealed class CompiledTemplate : MarshalByRefObject, IDisposable
- {
- ITextTemplatingEngineHost host;
- TextTransformation tt;
- CultureInfo culture;
- string[] assemblyFiles;
-
- public CompiledTemplate (ITextTemplatingEngineHost host, CompilerResults results, string fullName, CultureInfo culture,
- string[] assemblyFiles)
- {
- AppDomain.CurrentDomain.AssemblyResolve += ResolveReferencedAssemblies;
- this.host = host;
- this.culture = culture;
- this.assemblyFiles = assemblyFiles;
- Load (results, fullName);
- }
-
- void Load (CompilerResults results, string fullName)
- {
- var assembly = results.CompiledAssembly;
- Type transformType = assembly.GetType (fullName);
- tt = (TextTransformation) Activator.CreateInstance (transformType);
-
- //set the host property if it exists
- var hostProp = transformType.GetProperty ("Host", typeof (ITextTemplatingEngineHost));
- if (hostProp != null && hostProp.CanWrite)
- hostProp.SetValue (tt, host, null);
-
- var sessionHost = host as ITextTemplatingSessionHost;
- if (sessionHost != null) {
- //FIXME: should we create a session if it's null?
- tt.Session = sessionHost.Session;
- }
- }
-
- public string Process ()
- {
- tt.Errors.Clear ();
-
- //set the culture
- if (culture != null)
- ToStringHelper.FormatProvider = culture;
- else
- ToStringHelper.FormatProvider = CultureInfo.InvariantCulture;
-
- tt.Initialize ();
-
- string output = null;
- try {
- output = tt.TransformText ();
- } catch (Exception ex) {
- tt.Error ("Error running transform: " + ex.ToString ());
- }
- host.LogErrors (tt.Errors);
-
- ToStringHelper.FormatProvider = CultureInfo.InvariantCulture;
- return output;
- }
-
- System.Reflection.Assembly ResolveReferencedAssemblies (object sender, ResolveEventArgs args)
- {
- System.Reflection.Assembly asm = null;
- foreach (var asmFile in assemblyFiles) {
- var name = System.IO.Path.GetFileNameWithoutExtension (asmFile);
- if (args.Name.StartsWith (name))
- asm = System.Reflection.Assembly.LoadFrom (asmFile);
- }
- return asm;
- }
-
- public void Dispose ()
- {
- if (host != null) {
- host = null;
- AppDomain.CurrentDomain.AssemblyResolve -= ResolveReferencedAssemblies;
- }
- }
- }
-}
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/CrossAppDomainAssemblyResolver.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/CrossAppDomainAssemblyResolver.cs
deleted file mode 100644
index 593ed734..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/CrossAppDomainAssemblyResolver.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-//
-// CrossAppDomainAssemblyResolver.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2010 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-
-namespace Mono.TextTemplating
-{
- [Serializable]
- ///
- /// Provides a handler for AssemblyResolve events that looks them up in the domain that created the resolver.
- ///
- public class CrossAppDomainAssemblyResolver
- {
- ParentDomainLookup parent = new ParentDomainLookup ();
-
- public System.Reflection.Assembly Resolve (object sender, ResolveEventArgs args)
- {
- var location = parent.GetAssemblyPath (args.Name);
- if (location != null)
- return System.Reflection.Assembly.LoadFrom (location);
- return null;
- }
-
- class ParentDomainLookup : MarshalByRefObject
- {
- public string GetAssemblyPath (string name)
- {
- var assem = System.Reflection.Assembly.Load (name);
- if (assem != null)
- return assem.Location;
- return null;
- }
- }
- }
-}
-
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/ParsedTemplate.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/ParsedTemplate.cs
deleted file mode 100644
index f3ba0ae0..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/ParsedTemplate.cs
+++ /dev/null
@@ -1,320 +0,0 @@
-//
-// Template.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.CodeDom.Compiler;
-using System.Collections.Generic;
-using System.IO;
-using Microsoft.VisualStudio.TextTemplating;
-
-namespace Mono.TextTemplating
-{
-
-
- public class ParsedTemplate
- {
- List segments = new List ();
- CompilerErrorCollection errors = new CompilerErrorCollection ();
- string rootFileName;
-
- public ParsedTemplate (string rootFileName)
- {
- this.rootFileName = rootFileName;
- }
-
- public List RawSegments {
- get { return segments; }
- }
-
- public IEnumerable Directives {
- get {
- foreach (ISegment seg in segments) {
- Directive dir = seg as Directive;
- if (dir != null)
- yield return dir;
- }
- }
- }
-
- public IEnumerable Content {
- get {
- foreach (ISegment seg in segments) {
- TemplateSegment ts = seg as TemplateSegment;
- if (ts != null)
- yield return ts;
- }
- }
- }
-
- public CompilerErrorCollection Errors {
- get { return errors; }
- }
-
- public static ParsedTemplate FromText (string content, ITextTemplatingEngineHost host)
- {
- ParsedTemplate template = new ParsedTemplate (host.TemplateFile);
- try {
- template.Parse (host, new Tokeniser (host.TemplateFile, content));
- } catch (ParserException ex) {
- template.LogError (ex.Message, ex.Location);
- }
- return template;
- }
-
- public void Parse (ITextTemplatingEngineHost host, Tokeniser tokeniser)
- {
- Parse (host, tokeniser, true);
- }
-
- public void ParseWithoutIncludes (Tokeniser tokeniser)
- {
- Parse (null, tokeniser, false);
- }
-
- void Parse (ITextTemplatingEngineHost host, Tokeniser tokeniser, bool parseIncludes)
- {
- bool skip = false;
- while ((skip || tokeniser.Advance ()) && tokeniser.State != State.EOF) {
- skip = false;
- ISegment seg = null;
- switch (tokeniser.State) {
- case State.Block:
- if (!String.IsNullOrEmpty (tokeniser.Value))
- seg = new TemplateSegment (SegmentType.Block, tokeniser.Value, tokeniser.Location);
- break;
- case State.Content:
- if (!String.IsNullOrEmpty (tokeniser.Value))
- seg = new TemplateSegment (SegmentType.Content, tokeniser.Value, tokeniser.Location);
- break;
- case State.Expression:
- if (!String.IsNullOrEmpty (tokeniser.Value))
- seg = new TemplateSegment (SegmentType.Expression, tokeniser.Value, tokeniser.Location);
- break;
- case State.Helper:
- if (!String.IsNullOrEmpty (tokeniser.Value))
- seg = new TemplateSegment (SegmentType.Helper, tokeniser.Value, tokeniser.Location);
- break;
- case State.Directive:
- Directive directive = null;
- string attName = null;
- while (!skip && tokeniser.Advance ()) {
- switch (tokeniser.State) {
- case State.DirectiveName:
- if (directive == null) {
- directive = new Directive (tokeniser.Value.ToLower (), tokeniser.Location);
- directive.TagStartLocation = tokeniser.TagStartLocation;
- if (!parseIncludes || directive.Name != "include")
- segments.Add (directive);
- } else
- attName = tokeniser.Value;
- break;
- case State.DirectiveValue:
- if (attName != null && directive != null)
- directive.Attributes[attName.ToLower ()] = tokeniser.Value;
- else
- LogError ("Directive value without name", tokeniser.Location);
- attName = null;
- break;
- case State.Directive:
- if (directive != null)
- directive.EndLocation = tokeniser.TagEndLocation;
- break;
- default:
- skip = true;
- break;
- }
- }
- if (parseIncludes && directive.Name == "include")
- Import (host, directive, Path.GetDirectoryName (tokeniser.Location.FileName));
- break;
- default:
- throw new InvalidOperationException ();
- }
- if (seg != null) {
- seg.TagStartLocation = tokeniser.TagStartLocation;
- seg.EndLocation = tokeniser.TagEndLocation;
- segments.Add (seg);
- }
- }
- }
-
- void Import (ITextTemplatingEngineHost host, Directive includeDirective, string relativeToDirectory)
- {
- string fileName;
- if (includeDirective.Attributes.Count > 1 || !includeDirective.Attributes.TryGetValue ("file", out fileName)) {
- LogError ("Unexpected attributes in include directive", includeDirective.StartLocation);
- return;
- }
-
- //try to resolve path relative to the file that included it
- if (!Path.IsPathRooted (fileName)) {
- string possible = Path.Combine (relativeToDirectory, fileName);
- if (File.Exists (possible))
- fileName = possible;
- }
-
- string content, resolvedName;
- if (host.LoadIncludeText (fileName, out content, out resolvedName))
- Parse (host, new Tokeniser (resolvedName, content), true);
- else
- LogError ("Could not resolve include file '" + fileName + "'.", includeDirective.StartLocation);
- }
-
- void LogError (string message, Location location, bool isWarning)
- {
- CompilerError err = new CompilerError ();
- err.ErrorText = message;
- if (location.FileName != null) {
- err.Line = location.Line;
- err.Column = location.Column;
- err.FileName = location.FileName ?? string.Empty;
- } else {
- err.FileName = rootFileName ?? string.Empty;
- }
- err.IsWarning = isWarning;
- errors.Add (err);
- }
-
- public void LogError (string message)
- {
- LogError (message, Location.Empty, false);
- }
-
- public void LogWarning (string message)
- {
- LogError (message, Location.Empty, true);
- }
-
- public void LogError (string message, Location location)
- {
- LogError (message, location, false);
- }
-
- public void LogWarning (string message, Location location)
- {
- LogError (message, location, true);
- }
- }
-
- public interface ISegment
- {
- Location StartLocation { get; }
- Location EndLocation { get; set; }
- Location TagStartLocation {get; set; }
- }
-
- public class TemplateSegment : ISegment
- {
- public TemplateSegment (SegmentType type, string text, Location start)
- {
- this.Type = type;
- this.StartLocation = start;
- this.Text = text;
- }
-
- public SegmentType Type { get; private set; }
- public string Text { get; private set; }
- public Location TagStartLocation { get; set; }
- public Location StartLocation { get; private set; }
- public Location EndLocation { get; set; }
- }
-
- public class Directive : ISegment
- {
- public Directive (string name, Location start)
- {
- this.Name = name;
- this.Attributes = new Dictionary ();
- this.StartLocation = start;
- }
-
- public string Name { get; private set; }
- public Dictionary Attributes { get; private set; }
- public Location TagStartLocation { get; set; }
- public Location StartLocation { get; private set; }
- public Location EndLocation { get; set; }
-
- public string Extract (string key)
- {
- string value;
- if (!Attributes.TryGetValue (key, out value))
- return null;
- Attributes.Remove (key);
- return value;
- }
- }
-
- public enum SegmentType
- {
- Block,
- Expression,
- Content,
- Helper
- }
-
- public struct Location : IEquatable
- {
- public Location (string fileName, int line, int column) : this()
- {
- FileName = fileName;
- Column = column;
- Line = line;
- }
-
- public int Line { get; private set; }
- public int Column { get; private set; }
- public string FileName { get; private set; }
-
- public static Location Empty {
- get { return new Location (null, -1, -1); }
- }
-
- public Location AddLine ()
- {
- return new Location (this.FileName, this.Line + 1, 1);
- }
-
- public Location AddCol ()
- {
- return AddCols (1);
- }
-
- public Location AddCols (int number)
- {
- return new Location (this.FileName, this.Line, this.Column + number);
- }
-
- public override string ToString ()
- {
- return string.Format("[{0} ({1},{2})]", FileName, Line, Column);
- }
-
- public bool Equals (Location other)
- {
- return other.Line == Line && other.Column == Column && other.FileName == FileName;
- }
- }
-}
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplateGenerator.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplateGenerator.cs
deleted file mode 100644
index dd752857..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplateGenerator.cs
+++ /dev/null
@@ -1,373 +0,0 @@
-//
-// TemplatingHost.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Collections.Generic;
-using System.CodeDom.Compiler;
-using System.IO;
-using System.Text;
-using Microsoft.VisualStudio.TextTemplating;
-
-namespace Mono.TextTemplating
-{
- public class TemplateGenerator : MarshalByRefObject, ITextTemplatingEngineHost
- {
- //re-usable
- TemplatingEngine engine;
-
- //per-run variables
- string inputFile, outputFile;
- Encoding encoding;
-
- //host fields
- CompilerErrorCollection errors = new CompilerErrorCollection ();
- List refs = new List ();
- List imports = new List ();
- List includePaths = new List ();
- List referencePaths = new List ();
-
- //host properties for consumers to access
- public CompilerErrorCollection Errors { get { return errors; } }
- public List Refs { get { return refs; } }
- public List Imports { get { return imports; } }
- public List IncludePaths { get { return includePaths; } }
- public List ReferencePaths { get { return referencePaths; } }
- public string OutputFile { get { return outputFile; } }
-
- public TemplateGenerator ()
- {
- Refs.Add (typeof (TextTransformation).Assembly.Location);
- Refs.Add (typeof(System.Uri).Assembly.Location);
- Imports.Add ("System");
- }
-
- public CompiledTemplate CompileTemplate (string content)
- {
- if (String.IsNullOrEmpty (content))
- throw new ArgumentNullException ("content");
-
- errors.Clear ();
- encoding = Encoding.UTF8;
-
- return Engine.CompileTemplate (content, this);
- }
-
- protected TemplatingEngine Engine {
- get {
- if (engine == null)
- engine = new TemplatingEngine ();
- return engine;
- }
- }
-
- public bool ProcessTemplate (string inputFile, string outputFile)
- {
- if (String.IsNullOrEmpty (inputFile))
- throw new ArgumentNullException ("inputFile");
- if (String.IsNullOrEmpty (outputFile))
- throw new ArgumentNullException ("outputFile");
-
- string content;
- try {
- content = File.ReadAllText (inputFile);
- } catch (IOException ex) {
- errors.Clear ();
- AddError ("Could not read input file '" + inputFile + "':\n" + ex.ToString ());
- return false;
- }
-
- string output;
- ProcessTemplate (inputFile, content, ref outputFile, out output);
-
- try {
- if (!errors.HasErrors)
- File.WriteAllText (outputFile, output, encoding);
- } catch (IOException ex) {
- AddError ("Could not write output file '" + outputFile + "':\n" + ex.ToString ());
- }
-
- return !errors.HasErrors;
- }
-
- public bool ProcessTemplate (string inputFileName, string inputContent, ref string outputFileName, out string outputContent)
- {
- errors.Clear ();
- encoding = Encoding.UTF8;
-
- this.outputFile = outputFileName;
- this.inputFile = inputFileName;
- outputContent = Engine.ProcessTemplate (inputContent, this);
- outputFileName = this.outputFile;
-
- return !errors.HasErrors;
- }
-
- public bool PreprocessTemplate (string inputFile, string className, string classNamespace,
- string outputFile, System.Text.Encoding encoding, out string language, out string[] references)
- {
- language = null;
- references = null;
-
- if (string.IsNullOrEmpty (inputFile))
- throw new ArgumentNullException ("inputFile");
- if (string.IsNullOrEmpty (outputFile))
- throw new ArgumentNullException ("outputFile");
-
- string content;
- try {
- content = File.ReadAllText (inputFile);
- } catch (IOException ex) {
- errors.Clear ();
- AddError ("Could not read input file '" + inputFile + "':\n" + ex.ToString ());
- return false;
- }
-
- string output;
- PreprocessTemplate (inputFile, className, classNamespace, content, out language, out references, out output);
-
- try {
- if (!errors.HasErrors)
- File.WriteAllText (outputFile, output, encoding);
- } catch (IOException ex) {
- AddError ("Could not write output file '" + outputFile + "':\n" + ex.ToString ());
- }
-
- return !errors.HasErrors;
- }
-
- public bool PreprocessTemplate (string inputFileName, string className, string classNamespace, string inputContent,
- out string language, out string[] references, out string outputContent)
- {
- errors.Clear ();
- encoding = Encoding.UTF8;
-
- this.inputFile = inputFileName;
- outputContent = Engine.PreprocessTemplate (inputContent, this, className, classNamespace, out language, out references);
-
- return !errors.HasErrors;
- }
-
- CompilerError AddError (string error)
- {
- CompilerError err = new CompilerError ();
- err.ErrorText = error;
- Errors.Add (err);
- return err;
- }
-
- #region Virtual members
-
- public virtual object GetHostOption (string optionName)
- {
- return null;
- }
-
- public virtual AppDomain ProvideTemplatingAppDomain (string content)
- {
- return null;
- }
-
- //FIXME: implement
- protected virtual string ResolveAssemblyReference (string assemblyReference)
- {
- //foreach (string referencePath in ReferencePaths) {
- //
- //}
- return assemblyReference;
- }
-
- protected virtual string ResolveParameterValue (string directiveId, string processorName, string parameterName)
- {
- var key = new ParameterKey (processorName, directiveId, parameterName);
- string value;
- if (parameters.TryGetValue (key, out value))
- return value;
- if (processorName != null || directiveId != null)
- return ResolveParameterValue (null, null, parameterName);
- return null;
- }
-
- protected virtual Type ResolveDirectiveProcessor (string processorName)
- {
- KeyValuePair value;
- if (!directiveProcessors.TryGetValue (processorName, out value))
- throw new Exception (string.Format ("No directive processor registered as '{0}'", processorName));
- var asmPath = ResolveAssemblyReference (value.Value);
- if (asmPath == null)
- throw new Exception (string.Format ("Could not resolve assembly '{0}' for directive processor '{1}'", value.Value, processorName));
- var asm = System.Reflection.Assembly.LoadFrom (asmPath);
- return asm.GetType (value.Key, true);
- }
-
- protected virtual string ResolvePath (string path)
- {
- path = System.Environment.ExpandEnvironmentVariables (path);
- if (Path.IsPathRooted (path))
- return path;
- var dir = Path.GetDirectoryName (inputFile);
- var test = Path.Combine (dir, path);
- if (File.Exists (test))
- return test;
- return null;
- }
-
- #endregion
-
- Dictionary parameters = new Dictionary ();
- Dictionary> directiveProcessors = new Dictionary> ();
-
- public void AddDirectiveProcessor (string name, string klass, string assembly)
- {
- directiveProcessors.Add (name, new KeyValuePair (klass,assembly));
- }
-
- public void AddParameter (string processorName, string directiveName, string parameterName, string value)
- {
- parameters.Add (new ParameterKey (processorName, directiveName, parameterName), value);
- }
-
- protected virtual bool LoadIncludeText (string requestFileName, out string content, out string location)
- {
- content = "";
- location = ResolvePath (requestFileName);
-
- if (location == null) {
- foreach (string path in includePaths) {
- string f = Path.Combine (path, requestFileName);
- if (File.Exists (f)) {
- location = f;
- break;
- }
- }
- }
-
- if (location == null)
- return false;
-
- try {
- content = File.ReadAllText (location);
- return true;
- } catch (IOException ex) {
- AddError ("Could not read included file '" + location + "':\n" + ex.ToString ());
- }
- return false;
- }
-
- #region Explicit ITextTemplatingEngineHost implementation
-
- bool ITextTemplatingEngineHost.LoadIncludeText (string requestFileName, out string content, out string location)
- {
- return LoadIncludeText (requestFileName, out content, out location);
- }
-
- void ITextTemplatingEngineHost.LogErrors (CompilerErrorCollection errors)
- {
- this.errors.AddRange (errors);
- }
-
- string ITextTemplatingEngineHost.ResolveAssemblyReference (string assemblyReference)
- {
- return ResolveAssemblyReference (assemblyReference);
- }
-
- string ITextTemplatingEngineHost.ResolveParameterValue (string directiveId, string processorName, string parameterName)
- {
- return ResolveParameterValue (directiveId, processorName, parameterName);
- }
-
- Type ITextTemplatingEngineHost.ResolveDirectiveProcessor (string processorName)
- {
- return ResolveDirectiveProcessor (processorName);
- }
-
- string ITextTemplatingEngineHost.ResolvePath (string path)
- {
- return ResolvePath (path);
- }
-
- void ITextTemplatingEngineHost.SetFileExtension (string extension)
- {
- extension = extension.TrimStart ('.');
- if (Path.HasExtension (outputFile)) {
- outputFile = Path.ChangeExtension (outputFile, extension);
- } else {
- outputFile = outputFile + "." + extension;
- }
- }
-
- void ITextTemplatingEngineHost.SetOutputEncoding (System.Text.Encoding encoding, bool fromOutputDirective)
- {
- this.encoding = encoding;
- }
-
- IList ITextTemplatingEngineHost.StandardAssemblyReferences {
- get { return refs; }
- }
-
- IList ITextTemplatingEngineHost.StandardImports {
- get { return imports; }
- }
-
- string ITextTemplatingEngineHost.TemplateFile {
- get { return inputFile; }
- }
-
- #endregion
-
- struct ParameterKey : IEquatable
- {
- public ParameterKey (string processorName, string directiveName, string parameterName)
- {
- this.processorName = processorName ?? "";
- this.directiveName = directiveName ?? "";
- this.parameterName = parameterName ?? "";
- unchecked {
- hashCode = this.processorName.GetHashCode ()
- ^ this.directiveName.GetHashCode ()
- ^ this.parameterName.GetHashCode ();
- }
- }
-
- string processorName, directiveName, parameterName;
- int hashCode;
-
- public override bool Equals (object obj)
- {
- return obj != null && obj is ParameterKey && Equals ((ParameterKey)obj);
- }
-
- public bool Equals (ParameterKey other)
- {
- return processorName == other.processorName && directiveName == other.directiveName && parameterName == other.parameterName;
- }
-
- public override int GetHashCode ()
- {
- return hashCode;
- }
- }
- }
-}
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplateSettings.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplateSettings.cs
deleted file mode 100644
index 8221c65e..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplateSettings.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-//
-// TemplateSettings.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Text;
-using System.Collections.Generic;
-using Microsoft.VisualStudio.TextTemplating;
-
-namespace Mono.TextTemplating
-{
-
- public class TemplateSettings
- {
- public TemplateSettings ()
- {
- Imports = new HashSet ();
- Assemblies = new HashSet ();
- CustomDirectives = new List ();
- DirectiveProcessors = new Dictionary ();
- }
-
- public bool HostSpecific { get; set; }
- public bool Debug { get; set; }
- public string Inherits { get; set; }
- public string Name { get; set; }
- public string Namespace { get; set; }
- public HashSet Imports { get; private set; }
- public HashSet Assemblies { get; private set; }
- public System.CodeDom.Compiler.CodeDomProvider Provider { get; set; }
- public string Language { get; set; }
- public string CompilerOptions { get; set; }
- public Encoding Encoding { get; set; }
- public string Extension { get; set; }
- public System.Globalization.CultureInfo Culture { get; set; }
- public List CustomDirectives { get; private set; }
- public Dictionary DirectiveProcessors { get; private set; }
- public bool IncludePreprocessingHelpers { get; set; }
- public bool IsPreprocessed { get; set; }
- }
-
- public class CustomDirective
- {
- public CustomDirective (string processorName, Directive directive)
- {
- this.ProcessorName = processorName;
- this.Directive = directive;
- }
-
- public string ProcessorName { get; set; }
- public Directive Directive { get; set; }
- }
-}
diff --git a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplatingEngine.cs b/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplatingEngine.cs
deleted file mode 100644
index 5878adce..00000000
--- a/SparkleShare/Windows/tools/TextTemplating/Mono.TextTemplating/Mono.TextTemplating/TemplatingEngine.cs
+++ /dev/null
@@ -1,963 +0,0 @@
-//
-// Engine.cs
-//
-// Author:
-// Michael Hutchinson
-//
-// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.IO;
-using System.Text;
-using System.Collections.Generic;
-using System.CodeDom;
-using System.CodeDom.Compiler;
-using Microsoft.CSharp;
-using Microsoft.VisualStudio.TextTemplating;
-using System.Linq;
-using System.Reflection;
-
-namespace Mono.TextTemplating
-{
- public class TemplatingEngine : MarshalByRefObject, Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngine
- {
- public string ProcessTemplate (string content, ITextTemplatingEngineHost host)
- {
- var tpl = CompileTemplate (content, host);
- try {
- if (tpl != null)
- return tpl.Process ();
- return null;
- } finally {
- if (tpl != null)
- tpl.Dispose ();
- }
- }
-
- public string PreprocessTemplate (string content, ITextTemplatingEngineHost host, string className,
- string classNamespace, out string language, out string[] references)
- {
- if (content == null)
- throw new ArgumentNullException ("content");
- if (host == null)
- throw new ArgumentNullException ("host");
- if (className == null)
- throw new ArgumentNullException ("className");
- if (classNamespace == null)
- throw new ArgumentNullException ("classNamespace");
-
- language = null;
- references = null;
-
- var pt = ParsedTemplate.FromText (content, host);
- if (pt.Errors.HasErrors) {
- host.LogErrors (pt.Errors);
- return null;
- }
-
- var settings = GetSettings (host, pt);
- if (pt.Errors.HasErrors) {
- host.LogErrors (pt.Errors);
- return null;
- }
- settings.Name = className;
- settings.Namespace = classNamespace;
- settings.IncludePreprocessingHelpers = string.IsNullOrEmpty (settings.Inherits);
- settings.IsPreprocessed = true;
- language = settings.Language;
-
- var ccu = GenerateCompileUnit (host, content, pt, settings);
- references = ProcessReferences (host, pt, settings).ToArray ();
-
- host.LogErrors (pt.Errors);
- if (pt.Errors.HasErrors) {
- return null;
- }
-
- var options = new CodeGeneratorOptions ();
- using (var sw = new StringWriter ()) {
- settings.Provider.GenerateCodeFromCompileUnit (ccu, sw, options);
- return sw.ToString ();
- };
- }
-
- public CompiledTemplate CompileTemplate (string content, ITextTemplatingEngineHost host)
- {
- if (content == null)
- throw new ArgumentNullException ("content");
- if (host == null)
- throw new ArgumentNullException ("host");
-
- var pt = ParsedTemplate.FromText (content, host);
- if (pt.Errors.HasErrors) {
- host.LogErrors (pt.Errors);
- return null;
- }
-
- var settings = GetSettings (host, pt);
- if (pt.Errors.HasErrors) {
- host.LogErrors (pt.Errors);
- return null;
- }
-
- if (!string.IsNullOrEmpty (settings.Extension)) {
- host.SetFileExtension (settings.Extension);
- }
- if (settings.Encoding != null) {
- //FIXME: when is this called with false?
- host.SetOutputEncoding (settings.Encoding, true);
- }
-
- var ccu = GenerateCompileUnit (host, content, pt, settings);
- var references = ProcessReferences (host, pt, settings);
- if (pt.Errors.HasErrors) {
- host.LogErrors (pt.Errors);
- return null;
- }
-
- var results = GenerateCode (host, references, settings, ccu);
- if (results.Errors.HasErrors) {
- host.LogErrors (pt.Errors);
- host.LogErrors (results.Errors);
- return null;
- }
-
- var templateClassFullName = settings.Namespace + "." + settings.Name;
- var domain = host.ProvideTemplatingAppDomain (content);
- if (domain != null) {
- var type = typeof (CompiledTemplate);
- var obj = domain.CreateInstanceAndUnwrap (type.Assembly.FullName, type.FullName, false,
- BindingFlags.CreateInstance, null,
- new object[] { host, results, templateClassFullName, settings.Culture, references.ToArray () },
- null, null);
- return (CompiledTemplate) obj;
- } else {
- return new CompiledTemplate (host, results, templateClassFullName, settings.Culture, references.ToArray ());
- }
- }
-
- static CompilerResults GenerateCode (ITextTemplatingEngineHost host, IEnumerable references, TemplateSettings settings, CodeCompileUnit ccu)
- {
- var pars = new CompilerParameters () {
- GenerateExecutable = false,
- CompilerOptions = settings.CompilerOptions,
- IncludeDebugInformation = settings.Debug,
- GenerateInMemory = false,
- };
-
- foreach (var r in references)
- pars.ReferencedAssemblies.Add (r);
-
- if (settings.Debug)
- pars.TempFiles.KeepFiles = true;
-
- return settings.Provider.CompileAssemblyFromDom (pars, ccu);
- }
-
- static HashSet ProcessReferences (ITextTemplatingEngineHost host, ParsedTemplate pt, TemplateSettings settings)
- {
- var resolved = new HashSet ();
-
- foreach (string assem in settings.Assemblies.Union (host.StandardAssemblyReferences)) {
- if (resolved.Contains (assem))
- continue;
-
- string resolvedAssem = host.ResolveAssemblyReference (assem);
- if (!string.IsNullOrEmpty (resolvedAssem)) {
- resolved.Add (resolvedAssem);
- } else {
- pt.LogError ("Could not resolve assembly reference '" + assem + "'");
- return null;
- }
- }
- return resolved;
- }
-
- public static TemplateSettings GetSettings (ITextTemplatingEngineHost host, ParsedTemplate pt)
- {
- var settings = new TemplateSettings ();
-
- foreach (Directive dt in pt.Directives) {
- switch (dt.Name) {
- case "template":
- string val = dt.Extract ("language");
- if (val != null)
- settings.Language = val;
- val = dt.Extract ("debug");
- if (val != null)
- settings.Debug = string.Compare (val, "true", StringComparison.OrdinalIgnoreCase) == 0;
- val = dt.Extract ("inherits");
- if (val != null)
- settings.Inherits = val;
- val = dt.Extract ("culture");
- if (val != null) {
- System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.GetCultureInfo (val);
- if (culture == null)
- pt.LogWarning ("Could not find culture '" + val + "'", dt.StartLocation);
- else
- settings.Culture = culture;
- }
- val = dt.Extract ("hostspecific");
- if (val != null) {
- settings.HostSpecific = string.Compare (val, "true", StringComparison.OrdinalIgnoreCase) == 0;
- }
- val = dt.Extract ("CompilerOptions");
- if (val != null) {
- settings.CompilerOptions = val;
- }
- break;
-
- case "assembly":
- string name = dt.Extract ("name");
- if (name == null)
- pt.LogError ("Missing name attribute in assembly directive", dt.StartLocation);
- else
- settings.Assemblies.Add (name);
- break;
-
- case "import":
- string namespac = dt.Extract ("namespace");
- if (namespac == null)
- pt.LogError ("Missing namespace attribute in import directive", dt.StartLocation);
- else
- settings.Imports.Add (namespac);
- break;
-
- case "output":
- settings.Extension = dt.Extract ("extension");
- string encoding = dt.Extract ("encoding");
- if (encoding != null)
- settings.Encoding = Encoding.GetEncoding (encoding);
- break;
-
- case "include":
- throw new InvalidOperationException ("Include is handled in the parser");
-
- case "parameter":
- AddDirective (settings, host, "ParameterDirectiveProcessor", dt);
- continue;
-
- default:
- string processorName = dt.Extract ("Processor");
- if (processorName == null)
- throw new InvalidOperationException ("Custom directive '" + dt.Name + "' does not specify a processor");
-
- AddDirective (settings, host, processorName, dt);
- continue;
- }
- ComplainExcessAttributes (dt, pt);
- }
-
- //initialize the custom processors
- foreach (var kv in settings.DirectiveProcessors) {
- kv.Value.Initialize (host);
- var hs = kv.Value as IRecognizeHostSpecific;
- if (hs == null)
- continue;
- if (hs.RequiresProcessingRunIsHostSpecific && !settings.HostSpecific) {
- settings.HostSpecific = true;
- pt.LogWarning ("Directive processor '" + kv.Key + "' requires hostspecific=true, forcing on.");
- }
- hs.SetProcessingRunIsHostSpecific (settings.HostSpecific);
- }
-
- if (settings.Name == null)
- settings.Name = string.Format ("GeneratedTextTransformation{0:x}", new System.Random ().Next ());
- if (settings.Namespace == null)
- settings.Namespace = typeof (TextTransformation).Namespace;
-
- //resolve the CodeDOM provider
- if (String.IsNullOrEmpty (settings.Language)) {
- pt.LogError ("No language was specified for the template");
- return settings;
- }
-
- if (settings.Language == "C#v3.5") {
- Dictionary providerOptions = new Dictionary ();
- providerOptions.Add ("CompilerVersion", "v3.5");
- settings.Provider = new CSharpCodeProvider (providerOptions);
- }
- else {
- settings.Provider = CodeDomProvider.CreateProvider (settings.Language);
- }
-
- if (settings.Provider == null) {
- pt.LogError ("A provider could not be found for the language '" + settings.Language + "'");
- return settings;
- }
-
- return settings;
- }
-
- public static string IndentSnippetText (string text, string indent)
- {
- var builder = new StringBuilder (text.Length);
- builder.Append (indent);
- int lastNewline = 0;
- for (int i = 0; i < text.Length - 1; i++) {
- char c = text[i];
- if (c == '\r') {
- if (text[i + 1] == '\n') {
- i++;
- if (i == text.Length - 1)
- break;
- }
- } else if (c != '\n') {
- continue;
- }
- i++;
- int len = i - lastNewline;
- if (len > 0) {
- builder.Append (text, lastNewline, i - lastNewline);
- }
- builder.Append (indent);
- lastNewline = i;
- }
- if (lastNewline > 0)
- builder.Append (text, lastNewline, text.Length - lastNewline);
- else
- builder.Append (text);
- return builder.ToString ();
- }
-
- static void AddDirective (TemplateSettings settings, ITextTemplatingEngineHost host, string processorName, Directive directive)
- {
- DirectiveProcessor processor;
- if (!settings.DirectiveProcessors.TryGetValue (processorName, out processor)) {
- switch (processorName) {
- case "ParameterDirectiveProcessor":
- processor = new ParameterDirectiveProcessor ();
- break;
- default:
- Type processorType = host.ResolveDirectiveProcessor (processorName);
- processor = (DirectiveProcessor) Activator.CreateInstance (processorType);
- break;
- }
- if (!processor.IsDirectiveSupported (directive.Name))
- throw new InvalidOperationException ("Directive processor '" + processorName + "' does not support directive '" + directive.Name + "'");
-
- settings.DirectiveProcessors [processorName] = processor;
- }
- settings.CustomDirectives.Add (new CustomDirective (processorName, directive));
- }
-
- static bool ComplainExcessAttributes (Directive dt, ParsedTemplate pt)
- {
- if (dt.Attributes.Count == 0)
- return false;
- StringBuilder sb = new StringBuilder ("Unknown attributes ");
- bool first = true;
- foreach (string key in dt.Attributes.Keys) {
- if (!first) {
- sb.Append (", ");
- } else {
- first = false;
- }
- sb.Append (key);
- }
- sb.Append (" found in ");
- sb.Append (dt.Name);
- sb.Append (" directive.");
- pt.LogWarning (sb.ToString (), dt.StartLocation);
- return false;
- }
-
- static void ProcessDirectives (ITextTemplatingEngineHost host, string content, ParsedTemplate pt, TemplateSettings settings)
- {
- foreach (var processor in settings.DirectiveProcessors.Values) {
- processor.StartProcessingRun (settings.Provider, content, pt.Errors);
- }
-
- foreach (var dt in settings.CustomDirectives) {
- var processor = settings.DirectiveProcessors[dt.ProcessorName];
-
- if (processor is RequiresProvidesDirectiveProcessor)
- throw new NotImplementedException ("RequiresProvidesDirectiveProcessor");
-
- processor.ProcessDirective (dt.Directive.Name, dt.Directive.Attributes);
- }
-
- foreach (var processor in settings.DirectiveProcessors.Values) {
- processor.FinishProcessingRun ();
-
- var imports = processor.GetImportsForProcessingRun ();
- if (imports != null)
- settings.Imports.UnionWith (imports);
- var references = processor.GetReferencesForProcessingRun ();
- if (references != null)
- settings.Assemblies.UnionWith (references);
- }
- }
-
- public static CodeCompileUnit GenerateCompileUnit (ITextTemplatingEngineHost host, string content, ParsedTemplate pt, TemplateSettings settings)
- {
- ProcessDirectives (host, content, pt, settings);
-
- //prep the compile unit
- var ccu = new CodeCompileUnit ();
- var namespac = new CodeNamespace (settings.Namespace);
- ccu.Namespaces.Add (namespac);
-
- foreach (string ns in settings.Imports.Union (host.StandardImports))
- namespac.Imports.Add (new CodeNamespaceImport (ns));
-
- //prep the type
- var type = new CodeTypeDeclaration (settings.Name);
- type.IsPartial = true;
- if (!string.IsNullOrEmpty (settings.Inherits)) {
- type.BaseTypes.Add (new CodeTypeReference (settings.Inherits));
- } else if (!settings.IncludePreprocessingHelpers) {
- type.BaseTypes.Add (TypeRef ());
- } else {
- type.BaseTypes.Add (new CodeTypeReference (settings.Name + "Base"));
- }
- namespac.Types.Add (type);
-
- //prep the transform method
- var transformMeth = new CodeMemberMethod () {
- Name = "TransformText",
- ReturnType = new CodeTypeReference (typeof (String)),
- Attributes = MemberAttributes.Public,
- };
- if (!settings.IncludePreprocessingHelpers)
- transformMeth.Attributes |= MemberAttributes.Override;
-
- transformMeth.Statements.Add (new CodeAssignStatement (
- new CodePropertyReferenceExpression (new CodeThisReferenceExpression (), "GenerationEnvironment"),
- new CodePrimitiveExpression (null)));
-
- CodeExpression toStringHelper;
- if (settings.IsPreprocessed) {
- toStringHelper = new CodePropertyReferenceExpression (new CodeThisReferenceExpression (), "ToStringHelper");
- } else {
- toStringHelper = new CodeTypeReferenceExpression (
- new CodeTypeReference (typeof (ToStringHelper), CodeTypeReferenceOptions.GlobalReference));
- }
-
- //method references that will need to be used multiple times
- var writeMeth = new CodeMethodReferenceExpression (new CodeThisReferenceExpression (), "Write");
- var toStringMeth = new CodeMethodReferenceExpression (toStringHelper, "ToStringWithCulture");
- bool helperMode = false;
-
- //build the code from the segments
- foreach (TemplateSegment seg in pt.Content) {
- CodeStatement st = null;
- var location = new CodeLinePragma (seg.StartLocation.FileName ?? host.TemplateFile, seg.StartLocation.Line);
- switch (seg.Type) {
- case SegmentType.Block:
- if (helperMode)
- //TODO: are blocks permitted after helpers?
- throw new ParserException ("Blocks are not permitted after helpers", seg.StartLocation);
- st = new CodeSnippetStatement (seg.Text);
- break;
- case SegmentType.Expression:
- st = new CodeExpressionStatement (
- new CodeMethodInvokeExpression (writeMeth,
- new CodeMethodInvokeExpression (toStringMeth, new CodeSnippetExpression (seg.Text))));
- break;
- case SegmentType.Content:
- st = new CodeExpressionStatement (new CodeMethodInvokeExpression (writeMeth, new CodePrimitiveExpression (seg.Text)));
- break;
- case SegmentType.Helper:
- type.Members.Add (new CodeSnippetTypeMember (seg.Text) { LinePragma = location });
- helperMode = true;
- break;
- default:
- throw new InvalidOperationException ();
- }
- if (st != null) {
- if (helperMode) {
- //convert the statement into a snippet member and attach it to the top level type
- //TODO: is there a way to do this for languages that use indentation for blocks, e.g. python?
- using (var writer = new StringWriter ()) {
- settings.Provider.GenerateCodeFromStatement (st, writer, null);
- type.Members.Add (new CodeSnippetTypeMember (writer.ToString ()) { LinePragma = location });
- }
- } else {
- st.LinePragma = location;
- transformMeth.Statements.Add (st);
- continue;
- }
- }
- }
-
- //complete the transform method
- transformMeth.Statements.Add (new CodeMethodReturnStatement (
- new CodeMethodInvokeExpression (
- new CodePropertyReferenceExpression (
- new CodeThisReferenceExpression (),
- "GenerationEnvironment"),
- "ToString")));
- type.Members.Add (transformMeth);
-
- //class code from processors
- foreach (var processor in settings.DirectiveProcessors.Values) {
- string classCode = processor.GetClassCodeForProcessingRun ();
- if (classCode != null)
- type.Members.Add (new CodeSnippetTypeMember (classCode));
- }
-
- //generate the Host property if needed
- if (settings.HostSpecific) {
- GenerateHostProperty (type, settings);
- }
-
- GenerateInitializationMethod (type, settings);
-
- if (settings.IncludePreprocessingHelpers) {
- var baseClass = new CodeTypeDeclaration (settings.Name + "Base");
- GenerateProcessingHelpers (baseClass, settings);
- AddToStringHelper (baseClass, settings);
- namespac.Types.Add (baseClass);
- }
- return ccu;
- }
-
- static void GenerateHostProperty (CodeTypeDeclaration type, TemplateSettings settings)
- {
- var hostField = new CodeMemberField (TypeRef (), "hostValue");
- hostField.Attributes = (hostField.Attributes & ~MemberAttributes.AccessMask) | MemberAttributes.Private;
- type.Members.Add (hostField);
-
- var hostProp = GenerateGetterSetterProperty ("Host", hostField);
- hostProp.Attributes = MemberAttributes.Public | MemberAttributes.Final;
- type.Members.Add (hostProp);
- }
-
- static void GenerateInitializationMethod (CodeTypeDeclaration type, TemplateSettings settings)
- {
- //initialization method
- var initializeMeth = new CodeMemberMethod () {
- Name = "Initialize",
- ReturnType = new CodeTypeReference (typeof (void), CodeTypeReferenceOptions.GlobalReference),
- Attributes = MemberAttributes.Family
- };
- if (!settings.IncludePreprocessingHelpers)
- initializeMeth.Attributes |= MemberAttributes.Override;
-
- //pre-init code from processors
- foreach (var processor in settings.DirectiveProcessors.Values) {
- string code = processor.GetPreInitializationCodeForProcessingRun ();
- if (code != null)
- initializeMeth.Statements.Add (new CodeSnippetStatement (code));
- }
-
- //base call
- if (!settings.IncludePreprocessingHelpers) {
- initializeMeth.Statements.Add (
- new CodeMethodInvokeExpression (
- new CodeMethodReferenceExpression (
- new CodeBaseReferenceExpression (),
- "Initialize")));
- }
-
- //post-init code from processors
- foreach (var processor in settings.DirectiveProcessors.Values) {
- string code = processor.GetPostInitializationCodeForProcessingRun ();
- if (code != null)
- initializeMeth.Statements.Add (new CodeSnippetStatement (code));
- }
-
- type.Members.Add (initializeMeth);
- }
-
- static void GenerateProcessingHelpers (CodeTypeDeclaration type, TemplateSettings settings)
- {
- var thisRef = new CodeThisReferenceExpression ();
- var sbTypeRef = TypeRef ();
-
- var sessionField = PrivateField (TypeRef> (), "session");
- var sessionProp = GenerateGetterSetterProperty ("Session", sessionField);
- sessionProp.Attributes = MemberAttributes.Public;
-
- var builderField = PrivateField (sbTypeRef, "builder");
- var builderFieldRef = new CodeFieldReferenceExpression (thisRef, builderField.Name);
-
- var generationEnvironmentProp = GenerateGetterSetterProperty ("GenerationEnvironment", builderField);
- AddPropertyGetterInitializationIfFieldIsNull (generationEnvironmentProp, builderFieldRef, TypeRef ());
-
- type.Members.Add (builderField);
- type.Members.Add (sessionField);
- type.Members.Add (sessionProp);
- type.Members.Add (generationEnvironmentProp);
-
- AddErrorHelpers (type, settings);
- AddIndentHelpers (type, settings);
- AddWriteHelpers (type, settings);
- }
-
- static void AddPropertyGetterInitializationIfFieldIsNull (CodeMemberProperty property, CodeFieldReferenceExpression fieldRef, CodeTypeReference typeRef)
- {
- var fieldInit = FieldInitializationIfNull (fieldRef, typeRef);
- property.GetStatements.Insert (0, fieldInit);
- }
-
- static CodeConditionStatement FieldInitializationIfNull (CodeFieldReferenceExpression fieldRef, CodeTypeReference typeRef)
- {
- return new CodeConditionStatement (
- new CodeBinaryOperatorExpression (fieldRef,
- CodeBinaryOperatorType.ValueEquality, new CodePrimitiveExpression (null)),
- new CodeAssignStatement (fieldRef, new CodeObjectCreateExpression (typeRef)));
- }
-
- static void AddErrorHelpers (CodeTypeDeclaration type, TemplateSettings settings)
- {
- var cecTypeRef = TypeRef ();
- var thisRef = new CodeThisReferenceExpression ();
- var stringTypeRef = TypeRef ();
- var nullPrim = new CodePrimitiveExpression (null);
- var minusOnePrim = new CodePrimitiveExpression (-1);
-
- var errorsField = PrivateField (cecTypeRef, "errors");
- var errorsFieldRef = new CodeFieldReferenceExpression (thisRef, errorsField.Name);
-
- var errorsProp = GenerateGetterProperty ("Errors", errorsField);
- errorsProp.Attributes = MemberAttributes.Family | MemberAttributes.Final;
- errorsProp.GetStatements.Insert (0, FieldInitializationIfNull (errorsFieldRef, TypeRef()));
-
- var errorsPropRef = new CodePropertyReferenceExpression (new CodeThisReferenceExpression (), "Errors");
-
- var compilerErrorTypeRef = TypeRef ();
- var errorMeth = new CodeMemberMethod () {
- Name = "Error",
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- };
- errorMeth.Parameters.Add (new CodeParameterDeclarationExpression (stringTypeRef, "message"));
- errorMeth.Statements.Add (new CodeMethodInvokeExpression (errorsPropRef, "Add",
- new CodeObjectCreateExpression (compilerErrorTypeRef, nullPrim, minusOnePrim, minusOnePrim, nullPrim,
- new CodeArgumentReferenceExpression ("message"))));
-
- var warningMeth = new CodeMemberMethod () {
- Name = "Warning",
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- };
- warningMeth.Parameters.Add (new CodeParameterDeclarationExpression (stringTypeRef, "message"));
- warningMeth.Statements.Add (new CodeVariableDeclarationStatement (compilerErrorTypeRef, "val",
- new CodeObjectCreateExpression (compilerErrorTypeRef, nullPrim, minusOnePrim, minusOnePrim, nullPrim,
- new CodeArgumentReferenceExpression ("message"))));
- warningMeth.Statements.Add (new CodeAssignStatement (new CodePropertyReferenceExpression (
- new CodeVariableReferenceExpression ("val"), "IsWarning"), new CodePrimitiveExpression (true)));
- warningMeth.Statements.Add (new CodeMethodInvokeExpression (errorsPropRef, "Add",
- new CodeVariableReferenceExpression ("val")));
-
- type.Members.Add (errorsField);
- type.Members.Add (errorMeth);
- type.Members.Add (warningMeth);
- type.Members.Add (errorsProp);
- }
-
- static void AddIndentHelpers (CodeTypeDeclaration type, TemplateSettings settings)
- {
- var stringTypeRef = TypeRef ();
- var thisRef = new CodeThisReferenceExpression ();
- var zeroPrim = new CodePrimitiveExpression (0);
- var stringEmptyRef = new CodeFieldReferenceExpression (new CodeTypeReferenceExpression (stringTypeRef), "Empty");
- var intTypeRef = TypeRef ();
- var stackIntTypeRef = TypeRef> ();
-
- var indentsField = PrivateField (stackIntTypeRef, "indents");
- var indentsFieldRef = new CodeFieldReferenceExpression (thisRef, indentsField.Name);
-
- var indentsProp = GenerateGetterProperty ("Indents", indentsField);
- indentsProp.Attributes = MemberAttributes.Private;
- AddPropertyGetterInitializationIfFieldIsNull (indentsProp, indentsFieldRef, TypeRef> ());
-
- var indentsPropRef = new CodeFieldReferenceExpression (thisRef, indentsProp.Name);
-
- var currentIndentField = PrivateField (stringTypeRef, "currentIndent");
- currentIndentField.InitExpression = stringEmptyRef;
- var currentIndentFieldRef = new CodeFieldReferenceExpression (thisRef, currentIndentField.Name);
-
- var popIndentMeth = new CodeMemberMethod () {
- Name = "PopIndent",
- ReturnType = stringTypeRef,
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- };
- popIndentMeth.Statements.Add (new CodeConditionStatement (
- new CodeBinaryOperatorExpression (new CodePropertyReferenceExpression (indentsPropRef, "Count"),
- CodeBinaryOperatorType.ValueEquality, zeroPrim),
- new CodeMethodReturnStatement (stringEmptyRef)));
- popIndentMeth.Statements.Add (new CodeVariableDeclarationStatement (intTypeRef, "lastPos",
- new CodeBinaryOperatorExpression (
- new CodePropertyReferenceExpression (currentIndentFieldRef, "Length"),
- CodeBinaryOperatorType.Subtract,
- new CodeMethodInvokeExpression (indentsPropRef, "Pop"))));
- popIndentMeth.Statements.Add (new CodeVariableDeclarationStatement (stringTypeRef, "last",
- new CodeMethodInvokeExpression (currentIndentFieldRef, "Substring", new CodeVariableReferenceExpression ("lastPos"))));
- popIndentMeth.Statements.Add (new CodeAssignStatement (currentIndentFieldRef,
- new CodeMethodInvokeExpression (currentIndentFieldRef, "Substring", zeroPrim, new CodeVariableReferenceExpression ("lastPos"))));
- popIndentMeth.Statements.Add (new CodeMethodReturnStatement (new CodeVariableReferenceExpression ("last")));
-
- var pushIndentMeth = new CodeMemberMethod () {
- Name = "PushIndent",
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- };
- pushIndentMeth.Parameters.Add (new CodeParameterDeclarationExpression (stringTypeRef, "indent"));
- pushIndentMeth.Statements.Add (new CodeMethodInvokeExpression (indentsPropRef, "Push",
- new CodePropertyReferenceExpression (new CodeArgumentReferenceExpression ("indent"), "Length")));
- pushIndentMeth.Statements.Add (new CodeAssignStatement (currentIndentFieldRef,
- new CodeBinaryOperatorExpression (currentIndentFieldRef, CodeBinaryOperatorType.Add, new CodeArgumentReferenceExpression ("indent"))));
-
- var clearIndentMeth = new CodeMemberMethod () {
- Name = "ClearIndent",
- Attributes = MemberAttributes.Public | MemberAttributes.Final,
- };
- clearIndentMeth.Statements.Add (new CodeAssignStatement (currentIndentFieldRef, stringEmptyRef));
- clearIndentMeth.Statements.Add (new CodeMethodInvokeExpression (indentsPropRef, "Clear"));
-
- var currentIndentProp = GenerateGetterProperty ("CurrentIndent", currentIndentField);
- type.Members.Add (currentIndentField);
- type.Members.Add (indentsField);
- type.Members.Add (popIndentMeth);
- type.Members.Add (pushIndentMeth);
- type.Members.Add (clearIndentMeth);
- type.Members.Add (currentIndentProp);
- type.Members.Add (indentsProp);
- }
-
- static void AddWriteHelpers (CodeTypeDeclaration type, TemplateSettings settings)
- {
- var stringTypeRef = TypeRef ();
- var thisRef = new CodeThisReferenceExpression ();
- var genEnvPropRef = new CodePropertyReferenceExpression (thisRef, "GenerationEnvironment");
- var currentIndentFieldRef = new CodeFieldReferenceExpression (thisRef, "currentIndent");
-
- var textToAppendParam = new CodeParameterDeclarationExpression (stringTypeRef, "textToAppend");
- var formatParam = new CodeParameterDeclarationExpression (stringTypeRef, "format");
- var argsParam = new CodeParameterDeclarationExpression (TypeRef