Skip to content

Commit

Permalink
Release v3.14.0.0
Browse files Browse the repository at this point in the history
* Issue #7: Have a way to import all the script files in a directory (Support for //css_inc sub*.cs)
* Issue #6: CodeCom Evaluator gets slower after many LoadCode iterations (removed test code)
*Reinstated WPF support/sample
  • Loading branch information
taras-au committed Aug 3, 2016
1 parent 2672f54 commit f671cfc
Show file tree
Hide file tree
Showing 15 changed files with 125 additions and 73 deletions.
2 changes: 1 addition & 1 deletion Source/CSSCodeProvider.v.2.0/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]

[assembly: AssemblyVersion("3.13.3.0")]
[assembly: AssemblyVersion("3.14.0.0")]
2 changes: 1 addition & 1 deletion Source/CSSCodeProvider.v3.5/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.13.3.0")]
[assembly: AssemblyVersion("3.14.0.0")]
2 changes: 1 addition & 1 deletion Source/CSSCodeProvider.v4.6/CSSCodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static ICodeCompiler CreateCompilerImpl(string sourceFile)
.CreateCompiler();
else
return new CSharpCodeProvider().SetCompilerSettings(CompilerPath, CompilerServerTimeToLive)
.CreateCompiler();
.CreateCompiler();
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source/CSSCodeProvider/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]

[assembly: AssemblyVersion("3.13.3.0")]
[assembly: AssemblyVersion("3.14.0.0")]
4 changes: 2 additions & 2 deletions Source/CSScriptLibrary/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.13.3.0")]
[assembly: AssemblyFileVersion("3.13.3.0")]
[assembly: AssemblyVersion("3.14.0.0")]
[assembly: AssemblyFileVersion("3.14.0.0")]

//
// In order to sign your assembly you must specify a key to use. Refer to the
Expand Down
4 changes: 2 additions & 2 deletions Source/NAnt.CSScript/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.13.3.0")]
[assembly: AssemblyFileVersion("3.13.3.0")]
[assembly: AssemblyVersion("3.14.0.0")]
[assembly: AssemblyFileVersion("3.14.0.0")]
4 changes: 2 additions & 2 deletions Source/Tests/Generic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static void SayHello(string greeting)
Console.WriteLine(greeting);
}";
var parser = new CSharpParser(code, false, null);
var parser = new CSharpParser(code, false, null, null);
});
//parser.GetRawStatements("//css_inc", code.Length-1);

Expand Down Expand Up @@ -78,6 +78,6 @@ public void Test_CSS_Init()

CSharpParser.InitInfo Parse(string code)
{
return new CSharpParser(code + "\n", false, null).Inits.FirstOrDefault();
return new CSharpParser(code + "\n", false, null, null).Inits.FirstOrDefault();
}
}
15 changes: 11 additions & 4 deletions Source/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,12 @@ public static string[] RemovePathDuplicates(string[] list)
System.Collections.ArrayList retval = new System.Collections.ArrayList();
foreach (string item in list)
{
string path = Path.GetFullPath(item.Trim());

string path = item.Trim();
if (path == "")
continue;

path = Path.GetFullPath(path);

bool found = false;
foreach (string pathItem in retval)
Expand All @@ -132,6 +137,8 @@ public static string[] RemovePathDuplicates(string[] list)

if (!found)
retval.Add(path);


}

return (string[]) retval.ToArray(typeof(string));
Expand Down Expand Up @@ -2029,7 +2036,7 @@ static string GetPackageName(string path)
prev = current;
}

result = result.Substring(0, i+1); //i-inclusive
result = result.Substring(0, i + 1); //i-inclusive
return result;
}

Expand Down Expand Up @@ -2070,7 +2077,7 @@ static public string[] GetPackageDependencies(string rootDir, string package)
.Where(x => x != package)
.Distinct()
.ToArray();

return packages;
}

Expand Down Expand Up @@ -2102,7 +2109,7 @@ static public string[] GetSinglePackageLibDirs(string package, string version, s
{
List<string> result = new List<string>();

string packageDir = rootDir??Path.Combine(NuGetCache, package);
string packageDir = rootDir ?? Path.Combine(NuGetCache, package);

string requiredVersion;

Expand Down
33 changes: 26 additions & 7 deletions Source/cscscript/CSScriptLibrary.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Source/cscscript/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.13.3.0")]
[assembly: AssemblyFileVersion("3.13.3.0")]
[assembly: AssemblyVersion("3.14.0.0")]
[assembly: AssemblyFileVersion("3.14.0.0")]
92 changes: 59 additions & 33 deletions Source/csparser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ bool TryParseInt(string text, out int value)
/// </summary>
public class ImportInfo
{
internal static ImportInfo[] ResolveStatement(string statement, string parentScript, params string[] probinghDirs)
internal static ImportInfo[] ResolveStatement(string statement, string parentScript, string[] probinghDirs)
{
if (statement.Contains("*") || statement.Contains("?"))
{
Expand All @@ -240,6 +240,7 @@ internal static ImportInfo[] ResolveStatement(string statement, string parentScr
return (ImportInfo[])result.ToArray(typeof(ImportInfo));
#else
List<ImportInfo> result = new List<ImportInfo>();

foreach (string file in FileParser.ResolveFiles(filePattern, probinghDirs, false))
{
parts[0] = file; //substitute the file path pattern with the actual path
Expand Down Expand Up @@ -373,24 +374,19 @@ static void InitEnvironment()
public CSharpParser(string code)
{
InitEnvironment();
Init(code, "");
Construct(code, false, null, null);
}

///// <summary>
///// Creates an instance of CSharpParser.
///// </summary>
///// <param name="script">C# script (code or file).</param>
///// <param name="isFile">If set to 'true' the script is a file, otherwise it is a C# code.</param>
//public CSharpParser(string script, bool isFile)
//{
// InitEnvironment();

// if (!isFile)
// Init(script, "");
// else
// using (StreamReader sr = new StreamReader(script, Encoding.UTF8))
// Init(sr.ReadToEnd(), script);
//}
/// <summary>
/// Creates an instance of CSharpParser.
/// </summary>
/// <param name="script">C# script (code or file).</param>
/// <param name="isFile">If set to 'true' the script is a file, otherwise it is a C# code.</param>
public CSharpParser(string script, bool isFile)
{
InitEnvironment();
Construct(script, isFile, null, null);
}

/// <summary>
/// Creates an instance of CSharpParser.
Expand All @@ -399,36 +395,66 @@ public CSharpParser(string code)
/// <param name="isFile">If set to 'true' the script is a file, otherwise it is a C# code.</param>
/// <param name="directivesToSearch">Additional C# script directives to search. The search result is stored in CSharpParser.CustomDirectives.</param>
public CSharpParser(string script, bool isFile, string[] directivesToSearch)
{
InitEnvironment();
Construct(script, isFile, directivesToSearch, null);
}

/// <summary>
/// Creates an instance of CSharpParser.
/// </summary>
/// <param name="script">C# script (code or file).</param>
/// <param name="isFile">If set to 'true' the script is a file, otherwise it is a C# code.</param>
/// <param name="directivesToSearch">Additional C# script directives to search. The search result is stored in CSharpParser.CustomDirectives.</param>
/// <param name="probingDirs">Search directories for resolving wild card paths in //css_inc and //css_imp</param>
public CSharpParser(string script, bool isFile, string[] directivesToSearch, string[] probingDirs)
{
InitEnvironment();
Construct(script, isFile, directivesToSearch, probingDirs);
}

void Construct(string script, bool isFile, string[] directivesToSearch, string[] probingDirs)
{
if (!isFile)
Init(script, "", directivesToSearch);
Init(script, "", directivesToSearch, probingDirs);
else
using (StreamReader sr = new StreamReader(script))
Init(sr.ReadToEnd(), script, directivesToSearch);
Init(sr.ReadToEnd(), script, directivesToSearch, probingDirs);
}

/// <summary>
/// The result of search for additional C# script directives to search (directive vs. value).
/// </summary>
public Hashtable CustomDirectives = new Hashtable();

/// <summary>
/// Parses the C# code. Only one of the 'code' and 'file' parameters can be non empty.
/// </summary>
/// <param name="code">C# script code (empty string if code is in a file form).</param>
/// <param name="file">The script file name (empty if code is in the text form).</param>
public void Init(string code, string file)
{
Init(code, file, null);
}
///// <summary>
///// Parses the C# code. Only one of the 'code' and 'file' parameters can be non empty.
///// </summary>
///// <param name="code">C# script code (empty string if code is in a file form).</param>
///// <param name="file">The script file name (empty if code is in the text form).</param>
//public void Init(string code, string file)
//{
// Init(code, file, null, null);
//}

///// <summary>
///// Parses the C# code.
///// </summary>
///// <param name="code">C# script (code or file).</param>
///// <param name="file">If set to 'true' the script is a file, otherwise it is a C# code.</param>
///// <param name="directivesToSearch">Additional C# script directives to search. The search result is stored in CSharpParser.CustomDirectives.</param>
//void Init(string code, string file, string[] directivesToSearch)
//{
// Init(code, file, directivesToSearch, null);
//}
/// <summary>
/// Parses the C# code.
/// </summary>
/// <param name="code">C# script (code or file).</param>
/// <param name="file">If set to 'true' the script is a file, otherwise it is a C# code.</param>
/// <param name="directivesToSearch">Additional C# script directives to search. The search result is stored in CSharpParser.CustomDirectives.</param>
public void Init(string code, string file, string[] directivesToSearch)
/// <param name="probingDirs">Search directories for resolving wild card paths in //css_inc and //css_imp</param>
void Init(string code, string file, string[] directivesToSearch, string[] probingDirs)
{
string workingDir = Environment.CurrentDirectory;
if (file != "")
Expand Down Expand Up @@ -487,13 +513,13 @@ public void Init(string code, string file, string[] directivesToSearch)

//analyse script imports/includes
foreach (string statement in GetRawStatements("//css_import", endCodePos))
imports.AddRange(ImportInfo.ResolveStatement(Environment.ExpandEnvironmentVariables(statement).Trim(), file, directivesToSearch));
imports.AddRange(ImportInfo.ResolveStatement(Environment.ExpandEnvironmentVariables(statement).Trim(), file, probingDirs));
foreach (string statement in GetRawStatements("//css_imp", endCodePos))
imports.AddRange(ImportInfo.ResolveStatement(Environment.ExpandEnvironmentVariables(statement).Trim(), file, directivesToSearch));
imports.AddRange(ImportInfo.ResolveStatement(Environment.ExpandEnvironmentVariables(statement).Trim(), file, probingDirs));
foreach (string statement in GetRawStatements("//css_include", endCodePos))
imports.AddRange(ImportInfo.ResolveStatement(Environment.ExpandEnvironmentVariables(statement).Trim() + ",preserve_main", file, directivesToSearch));
imports.AddRange(ImportInfo.ResolveStatement(Environment.ExpandEnvironmentVariables(statement).Trim() + ",preserve_main", file, probingDirs));
foreach (string statement in GetRawStatements("//css_inc", endCodePos))
imports.AddRange(ImportInfo.ResolveStatement(Environment.ExpandEnvironmentVariables(statement).Trim() + ",preserve_main", file, directivesToSearch));
imports.AddRange(ImportInfo.ResolveStatement(Environment.ExpandEnvironmentVariables(statement).Trim() + ",preserve_main", file, probingDirs));

//analyse assembly references
foreach (string statement in GetRawStatements("//css_reference", endCodePos))
Expand Down
4 changes: 2 additions & 2 deletions Source/css_config/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.13.3.0")]
[assembly: AssemblyFileVersion("3.13.3.0")]
[assembly: AssemblyVersion("3.14.0.0")]
[assembly: AssemblyFileVersion("3.14.0.0")]
6 changes: 3 additions & 3 deletions Source/csscript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public void Execute(string[] args, PrintDelegate printDelg, string primaryScript
CSharpParser.CmdScriptInfo[] cmdScripts = new CSharpParser.CmdScriptInfo[0];

//do quick parsing for pre/post scripts, ThreadingModel and embedded script arguments
CSharpParser parser = new CSharpParser(options.scriptFileName, true, options.searchDirs);
CSharpParser parser = new CSharpParser(options.scriptFileName, true, null, options.searchDirs);

if (parser.Inits.Length != 0)
options.initContext = parser.Inits[0];
Expand Down Expand Up @@ -372,15 +372,15 @@ public void Execute(string[] args, PrintDelegate printDelg, string primaryScript
{
using (IDisposable currDir = new CurrentDirGuard())
{
CSharpParser impParser = new CSharpParser(file, true, options.searchDirs);
CSharpParser impParser = new CSharpParser(file, true, null, options.searchDirs);
Environment.CurrentDirectory = Path.GetDirectoryName(file);

foreach (string dir in impParser.ExtraSearchDirs)
newSearchDirs.Add(Path.GetFullPath(dir));

options.searchDirs = newSearchDirs.ToArray();
}
preScripts.AddRange(new CSharpParser(file, true, options.searchDirs).CmdScripts);
preScripts.AddRange(new CSharpParser(file, true, null, options.searchDirs).CmdScripts);
}
}
catch { } //some files may not be generated yet
Expand Down
4 changes: 2 additions & 2 deletions Source/cswscript/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:

[assembly: AssemblyVersion("3.13.3.0")]
[assembly: AssemblyFileVersion("3.13.3.0")]
[assembly: AssemblyVersion("3.14.0.0")]
[assembly: AssemblyFileVersion("3.14.0.0")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
Expand Down
Loading

0 comments on commit f671cfc

Please sign in to comment.