From bbc1ae59ad13a000726eb38e10aa2db00835958a Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Fri, 26 Oct 2012 16:58:46 -0400 Subject: [PATCH] Add new API namespace() to set the root namespace of a C# project, independent of the project name --- src/actions/vstudio/vs2005_csproj.lua | 2 +- src/base/api.lua | 8 ++++++ .../vstudio/cs2005/projectsettings.lua | 28 +++++++++++++++++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/actions/vstudio/vs2005_csproj.lua b/src/actions/vstudio/vs2005_csproj.lua index 4da1b804..0a146bd4 100644 --- a/src/actions/vstudio/vs2005_csproj.lua +++ b/src/actions/vstudio/vs2005_csproj.lua @@ -104,7 +104,7 @@ _p(2,'Properties') local target = cfg.buildtarget - _p(2,'%s', target.basename) + _p(2,'%s', prj.namespace or target.basename) _p(2,'%s', target.basename) local framework = prj.framework or frameworks[_ACTION] diff --git a/src/base/api.lua b/src/base/api.lua index b39325d9..34d615f8 100644 --- a/src/base/api.lua +++ b/src/base/api.lua @@ -698,6 +698,14 @@ tokens = true, } + + api.register { + name = "namespace", + scope = "project", + kind = "string", + tokens = true, + } + api.register { name = "objdir", scope = "config", diff --git a/tests/actions/vstudio/cs2005/projectsettings.lua b/tests/actions/vstudio/cs2005/projectsettings.lua index 4aa617e3..e5e642c4 100755 --- a/tests/actions/vstudio/cs2005/projectsettings.lua +++ b/tests/actions/vstudio/cs2005/projectsettings.lua @@ -16,12 +16,14 @@ local sln, prj function suite.setup() - sln, prj = test.createsolution() + _ACTION = "vs2005" + sln = test.createsolution() language "C#" uuid "AE61726D-187C-E440-BD07-2556188A6565" end local function prepare() + prj = premake.solution.getproject_ng(sln, 1) cs2005.projectsettings(prj) end @@ -31,7 +33,6 @@ -- function suite.OnVs2005() - _ACTION = "vs2005" prepare() test.capture [[ @@ -117,7 +118,6 @@ -- function suite.OnFrameworkVersion() - _ACTION = "vs2005" framework "3.0" prepare() test.capture [[ @@ -137,3 +137,25 @@ end +-- +-- Make sure the root namespace can be overridden. +-- + + function suite.canOverrideRootNamespace() + namespace "MyCompany.%{prj.name}" + prepare() + test.capture [[ + + Debug + AnyCPU + 8.0.50727 + 2.0 + {AE61726D-187C-E440-BD07-2556188A6565} + Exe + Properties + MyCompany.MyProject + MyProject + + ]] + end +