Skip to content

Commit

Permalink
Short syntax for overridable fields
Browse files Browse the repository at this point in the history
  • Loading branch information
yevhen committed May 28, 2014
1 parent 26a4d5b commit e5da703
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Nake.csx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ using System.Linq;
using System.Xml.Linq;
using System.Diagnostics;

public const string RootPath = "$NakeScriptDirectory$";
public const string OutputPath = RootPath + @"\Output";
const string RootPath = "$NakeScriptDirectory$";
const string OutputPath = RootPath + @"\Output";

/// Builds sources in debug mode
[Task] void Default()
Expand Down
8 changes: 4 additions & 4 deletions Publish.csx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ using EasyHttp.Infrastructure;

using Ionic.Zip;

static string OutputPath = @"$NakeScriptDirectory$\Output";
static string PackagePath = @"{OutputPath}\Package";
var OutputPath = @"$NakeScriptDirectory$\Output";
var PackagePath = @"{OutputPath}\Package";

static string DebugOutputPath = @"{PackagePath}\Debug";
static string ReleaseOutputPath = @"{PackagePath}\Release";
var DebugOutputPath = @"{PackagePath}\Debug";
var ReleaseOutputPath = @"{PackagePath}\Release";

Func<string> PackageFile = () => PackagePath + @"\Nake.{Version()}.nupkg";
Func<string> ArchiveFile = () => OutputPath + @"\{Version()}.zip";
Expand Down
13 changes: 9 additions & 4 deletions Source/Nake.Tests/Redefining_public_fields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ namespace Nake
class Redefining_public_fields : CodeFixture
{
[Test]
public void Can_redefine_any_public_field_or_constant()
public void Can_redefine_any_script_level_var_any_public_field_or_constant()
{
Build(@"
var scriptLevelVar = ""0"";
public const string PublicConstField = ""0"";
public static string PublicStaticField = ""0"";
Expand All @@ -24,8 +26,9 @@ class NestedClass
public static string PublicField = ""0"";
}
[Task] public static void Test()
[Task] void Test()
{
Env.Var[""ScriptLevelVar""] = scriptLevelVar;
Env.Var[""PublicConstField""] = PublicConstField;
Env.Var[""PublicStaticField""] = PublicStaticField;
Env.Var[""PrivateConstField""] = PrivateConstField;
Expand All @@ -35,6 +38,7 @@ [Task] public static void Test()
",

Substitute()
.Var("ScriptLevelVar", "1")
.Var("PublicConstField", "1")
.Var("PublicStaticField", "1")
.Var("NestedClass.PublicField", "1")
Expand All @@ -44,11 +48,12 @@ [Task] public static void Test()

Invoke("Test");

Assert.That(Env.Var["ScriptLevelVar"], Is.EqualTo("1"));
Assert.That(Env.Var["PublicConstField"], Is.EqualTo("1"));
Assert.That(Env.Var["PublicStaticField"], Is.EqualTo("1"));
Assert.That(Env.Var["NestedClass.PublicField"], Is.EqualTo("1"));
Assert.That(Env.Var["PrivateConstField"], Is.EqualTo("0"));
Assert.That(Env.Var["PrivateStaticField"], Is.EqualTo("0"));
Assert.That(Env.Var["PrivateConstField"], Is.EqualTo("1"));
Assert.That(Env.Var["PrivateStaticField"], Is.EqualTo("1"));
}

[Test]
Expand Down
8 changes: 1 addition & 7 deletions Source/Nake/Magic/FieldSubstitution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,7 @@ LiteralExpressionSyntax StringLiteral()

public static bool Qualifies(IFieldSymbol symbol)
{
var isAccessible =
symbol.DeclaredAccessibility == Accessibility.Public &&
(symbol.IsConst || symbol.IsStatic);

var isTypeSupported = TypeConverter.IsSupported(symbol.Type);

return isAccessible && isTypeSupported;
return TypeConverter.IsSupported(symbol.Type);
}
}
}
4 changes: 2 additions & 2 deletions Source/ProductAssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Reflection;

[assembly: AssemblyVersion("2.0.7.0")]
[assembly: AssemblyInformationalVersion("2.0.7-beta")]
[assembly: AssemblyVersion("2.0.8.0")]
[assembly: AssemblyInformationalVersion("2.0.8-beta")]
[assembly: AssemblyCopyright("Copyright © Yevhen Bobrov 2013")]
Binary file modified Tools/Nake/Meta.dll
Binary file not shown.
Binary file modified Tools/Nake/Meta.pdb
Binary file not shown.
Binary file modified Tools/Nake/Nake.exe
Binary file not shown.
Binary file modified Tools/Nake/Nake.pdb
Binary file not shown.
Binary file modified Tools/Nake/Utility.dll
Binary file not shown.
Binary file modified Tools/Nake/Utility.pdb
Binary file not shown.

0 comments on commit e5da703

Please sign in to comment.