Browse files

Fix #228 - restore support for public resource classes

(Set Generator/Custom Tool property of resx to PublicResxScriptGenerator)
  • Loading branch information...
1 parent 55f378e commit b0cf099ce3718758dd6d674cac65771d66f80be9 @nikhilk committed Sep 6, 2012
View
8 src/Core/Build/Generators/ResXCodeBuilder.cs
@@ -42,7 +42,7 @@ namespace {0} {{
return _codeBuilder.ToString();
}
- public void GenerateCode(string resourceFileName, string resourceFileContent) {
+ public void GenerateCode(string resourceFileName, string resourceFileContent, string resourceGenerator) {
if (IsLocalizedResourceFile(resourceFileName)) {
return;
}
@@ -53,6 +53,10 @@ namespace {0} {{
}
string className = Path.GetFileNameWithoutExtension(resourceFileName);
+ string accessModifier = "internal";
+ if (String.Compare(resourceGenerator, "PublicResxScriptGenerator", StringComparison.OrdinalIgnoreCase) == 0) {
+ accessModifier = "public";
+ }
_codeBuilder.AppendLine();
_codeBuilder.AppendFormat(" /// <summary>{0} resources class</summary>", className);
@@ -62,7 +66,7 @@ namespace {0} {{
this.GetType().Name,
typeof(ResXCodeBuilder).Assembly.GetName().Version.ToString());
_codeBuilder.AppendLine();
- _codeBuilder.AppendFormat(" internal static class {0} {{", className);
+ _codeBuilder.AppendFormat(" {0} static class {1} {{", accessModifier, className);
_codeBuilder.AppendLine();
foreach (ResXItem resourceItem in resourceItems) {
View
3 src/Core/Build/Tasks/ResXCodeGeneratorTask.cs
@@ -70,9 +70,10 @@ public sealed class ResXCodeGeneratorTask : Task {
codeBuilder.Start(_namespace);
foreach (ITaskItem resourceItem in _resources) {
string resourceFileName = resourceItem.ItemSpec;
+ string resourceGenerator = resourceItem.GetMetadata("Generator");
string resourceContent = File.ReadAllText(resourceFileName);
- codeBuilder.GenerateCode(resourceFileName, resourceContent);
+ codeBuilder.GenerateCode(resourceFileName, resourceContent, resourceGenerator);
}
string code = codeBuilder.End();
View
4 tests/ScriptSharp/BasicTests.cs
@@ -86,11 +86,11 @@ public sealed class BasicTests : CompilationTest {
ResXCodeBuilder resxCodeBuilder = new ResXCodeBuilder();
resxCodeBuilder.Start("Resources");
- resxCodeBuilder.GenerateCode("Strings1.resx", resource1Markup);
+ resxCodeBuilder.GenerateCode("Strings1.resx", resource1Markup, null);
string code1 = resxCodeBuilder.End();
resxCodeBuilder.Start("Resources");
- resxCodeBuilder.GenerateCode("Strings2.resx", resource2Markup);
+ resxCodeBuilder.GenerateCode("Strings2.resx", resource2Markup, "PublicResxScriptGenerator");
string code2 = resxCodeBuilder.End();
RunTest((c) => {
View
4 tests/TestCases/Basic/Resources/Baseline.txt
@@ -19,9 +19,9 @@ test._strings1 = {
////////////////////////////////////////////////////////////////////////////////
-// test._strings2
+// test.Strings2
-test._strings2 = {
+test.Strings2 = {
string1: 's2',
string2: '1234'
};

0 comments on commit b0cf099

Please sign in to comment.