diff --git a/RESW File Code Generator/IntegrationTests.testsettings b/RESW File Code Generator/IntegrationTests.testsettings
index cb5acf5..c409011 100644
--- a/RESW File Code Generator/IntegrationTests.testsettings
+++ b/RESW File Code Generator/IntegrationTests.testsettings
@@ -1,14 +1,18 @@
-
-
+
+
This test run configuration uses the VS IDE host type in the test run.
-
-
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/RESW File Code Generator/ReswCodeGen.Tests/CSharpCodeGeneratorTests.cs b/RESW File Code Generator/ReswCodeGen.Tests/CSharpCodeGeneratorTests.cs
index fd10f52..5e1c68c 100644
--- a/RESW File Code Generator/ReswCodeGen.Tests/CSharpCodeGeneratorTests.cs
+++ b/RESW File Code Generator/ReswCodeGen.Tests/CSharpCodeGeneratorTests.cs
@@ -29,6 +29,12 @@ public void GenerateCodeDoesNotReturnNull()
Assert.IsNotNull(actual);
}
+ [TestMethod]
+ public void GeneratedCodeIsAPublicClass()
+ {
+ Assert.IsTrue(actual.Contains("public partial class"));
+ }
+
[TestMethod]
public void GeneratedCodeContainsPropertiesDefinedInResources()
{
diff --git a/RESW File Code Generator/ReswCodeGen.Tests/CSharpCodeGeneratorTestsInternal.cs b/RESW File Code Generator/ReswCodeGen.Tests/CSharpCodeGeneratorTestsInternal.cs
index b407c01..94b52e8 100644
--- a/RESW File Code Generator/ReswCodeGen.Tests/CSharpCodeGeneratorTestsInternal.cs
+++ b/RESW File Code Generator/ReswCodeGen.Tests/CSharpCodeGeneratorTestsInternal.cs
@@ -1,6 +1,6 @@
-using System.CodeDom;
using System.IO;
using System.Linq;
+using System.Reflection;
using ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -20,7 +20,7 @@ public void Initialize()
{
reswFileContents = File.ReadAllText(FILE_PATH);
- target = new CodeGeneratorFactory().Create(FILE_PATH.Replace(".resw", string.Empty), "TestApp", reswFileContents, classAccessibility: MemberAttributes.Assembly);
+ target = new CodeGeneratorFactory().Create(FILE_PATH.Replace(".resw", string.Empty), "TestApp", reswFileContents, classAccessibility: TypeAttributes.NestedAssembly);
actual = target.GenerateCode();
}
@@ -30,6 +30,12 @@ public void GenerateCodeDoesNotReturnNull()
Assert.IsNotNull(actual);
}
+ [TestMethod]
+ public void GeneratedCodeIsAnInternalClass()
+ {
+ Assert.IsTrue(actual.Contains("internal partial class"));
+ }
+
[TestMethod]
public void GeneratedCodeContainsPropertiesDefinedInResources()
{
diff --git a/RESW File Code Generator/ReswCodeGen.Tests/ReswCodeGen.Tests.csproj b/RESW File Code Generator/ReswCodeGen.Tests/ReswCodeGen.Tests.csproj
index 08deaf1..e2b8f4b 100644
--- a/RESW File Code Generator/ReswCodeGen.Tests/ReswCodeGen.Tests.csproj
+++ b/RESW File Code Generator/ReswCodeGen.Tests/ReswCodeGen.Tests.csproj
@@ -57,6 +57,7 @@
+
diff --git a/RESW File Code Generator/ReswCodeGen.Tests/VisualBasicCodeGeneratorInternalTests.cs b/RESW File Code Generator/ReswCodeGen.Tests/VisualBasicCodeGeneratorInternalTests.cs
new file mode 100644
index 0000000..feb6135
--- /dev/null
+++ b/RESW File Code Generator/ReswCodeGen.Tests/VisualBasicCodeGeneratorInternalTests.cs
@@ -0,0 +1,70 @@
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool;
+using Microsoft.VisualBasic;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.CustomTool.Tests
+{
+ [TestClass]
+ [DeploymentItem("Resources/Resources.resw")]
+ public class VisualBasicCodeGeneratorInternalTests
+ {
+ private const string FILE_PATH = "Resources.resw";
+ private string actual;
+ private string reswFileContents;
+ private ICodeGenerator target;
+
+ [TestInitialize]
+ public void Initialize()
+ {
+ reswFileContents = File.ReadAllText(FILE_PATH);
+
+ target = new CodeGeneratorFactory().Create(FILE_PATH.Replace(".resw", string.Empty), "TestApp", reswFileContents, new VBCodeProvider(), TypeAttributes.NestedAssembly);
+ actual = target.GenerateCode();
+ }
+
+ [TestMethod]
+ public void GenerateCodeDoesNotReturnNull()
+ {
+ Assert.IsNotNull(actual);
+ }
+
+ [TestMethod]
+ public void GeneratedCodeIsFriendClass()
+ {
+ Assert.IsTrue(actual.Contains("Partial Friend Class"));
+ }
+
+ [TestMethod]
+ public void GeneratedCodeContainsPropertiesDefinedInResources()
+ {
+ var resourceItems = target.ResourceParser.Parse();
+
+ foreach (var item in resourceItems.Where(item => !item.Name.Contains(".")))
+ Assert.IsTrue(actual.Contains("Public Shared ReadOnly Property " + item.Name + "() As String"));
+ }
+
+ [TestMethod]
+ public void GeneratedCodePropertiesContainsCommentsSimilarToValuesDefinedInResources()
+ {
+ var resourceItems = target.ResourceParser.Parse();
+
+ foreach (var item in resourceItems.Where(item => !item.Name.Contains(".")))
+ Assert.IsTrue(actual.Contains("Localized resource similar to \"" + item.Value + "\""));
+ }
+
+ [TestMethod]
+ public void ClassNameEqualsFileNameWithoutExtension()
+ {
+ Assert.IsTrue(actual.Contains("Class Resources"));
+ }
+
+ [TestMethod]
+ public void ResourceLoaderInitializedWithClassName()
+ {
+ Assert.IsTrue(actual.Contains("New ResourceLoader(currentAssemblyName + \"/Resources\")"));
+ }
+ }
+}
\ No newline at end of file
diff --git a/RESW File Code Generator/UnitTests.testsettings b/RESW File Code Generator/UnitTests.testsettings
index f880c76..50ae80e 100644
--- a/RESW File Code Generator/UnitTests.testsettings
+++ b/RESW File Code Generator/UnitTests.testsettings
@@ -1,9 +1,15 @@
-
-
-
+
+
This test run configuration is used for running the unit tests
-
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/RESW File Code Generator/VSPackage/CustomTool/CodeDomCodeGenerator.cs b/RESW File Code Generator/VSPackage/CustomTool/CodeDomCodeGenerator.cs
index ba2a5f4..1a2f437 100644
--- a/RESW File Code Generator/VSPackage/CustomTool/CodeDomCodeGenerator.cs
+++ b/RESW File Code Generator/VSPackage/CustomTool/CodeDomCodeGenerator.cs
@@ -3,6 +3,7 @@
using System.CodeDom.Compiler;
using System.Globalization;
using System.IO;
+using System.Reflection;
using System.Text;
using Microsoft.CSharp;
@@ -11,12 +12,12 @@ namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool
public class CodeDomCodeGenerator : CodeGenerator, IDisposable
{
private readonly string className;
- private readonly MemberAttributes? classAccessibility;
+ private readonly TypeAttributes? classAccessibility;
private readonly CodeNamespace codeNamespace;
private readonly CodeCompileUnit compileUnit;
private readonly CodeDomProvider provider;
- public CodeDomCodeGenerator(IResourceParser resourceParser, string className, string defaultNamespace, CodeDomProvider codeDomProvider = null, MemberAttributes? classAccessibility = null)
+ public CodeDomCodeGenerator(IResourceParser resourceParser, string className, string defaultNamespace, CodeDomProvider codeDomProvider = null, TypeAttributes? classAccessibility = null)
: base(resourceParser, defaultNamespace)
{
this.className = className;
@@ -47,7 +48,7 @@ public override string GenerateCode()
{
IsClass = true,
IsPartial = true,
- Attributes = (classAccessibility.HasValue ? classAccessibility.Value : MemberAttributes.Public) | MemberAttributes.Static
+ TypeAttributes = classAccessibility.HasValue ? classAccessibility.Value : TypeAttributes.Public
};
const string resourceLoaderType = "ResourceLoader";
@@ -159,7 +160,7 @@ private string GenerateCodeFromCompileUnit()
}
#region IDisposable
-
+
private bool disposed;
~CodeDomCodeGenerator()
@@ -180,7 +181,7 @@ protected virtual void Dispose(bool dispose)
if (dispose)
provider.Dispose();
- }
+ }
#endregion
}
diff --git a/RESW File Code Generator/VSPackage/CustomTool/CodeGeneratorFactory.cs b/RESW File Code Generator/VSPackage/CustomTool/CodeGeneratorFactory.cs
index 0a849b1..bdd013f 100644
--- a/RESW File Code Generator/VSPackage/CustomTool/CodeGeneratorFactory.cs
+++ b/RESW File Code Generator/VSPackage/CustomTool/CodeGeneratorFactory.cs
@@ -1,11 +1,12 @@
using System.CodeDom;
using System.CodeDom.Compiler;
+using System.Reflection;
namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool
{
public class CodeGeneratorFactory
{
- public ICodeGenerator Create(string className, string defaultNamespace, string inputFileContents, CodeDomProvider codeDomProvider = null, MemberAttributes? classAccessibility = null)
+ public ICodeGenerator Create(string className, string defaultNamespace, string inputFileContents, CodeDomProvider codeDomProvider = null, TypeAttributes? classAccessibility = null)
{
return new CodeDomCodeGenerator(new ResourceParser(inputFileContents), className, defaultNamespace, codeDomProvider, classAccessibility);
}
diff --git a/RESW File Code Generator/VSPackage/CustomTool/ReswFileCSharpCodeGeneratorInternal.cs b/RESW File Code Generator/VSPackage/CustomTool/ReswFileCSharpCodeGeneratorInternal.cs
index 728ba2f..d5b1cfb 100644
--- a/RESW File Code Generator/VSPackage/CustomTool/ReswFileCSharpCodeGeneratorInternal.cs
+++ b/RESW File Code Generator/VSPackage/CustomTool/ReswFileCSharpCodeGeneratorInternal.cs
@@ -1,4 +1,5 @@
using System.CodeDom;
+using System.Reflection;
using System.Runtime.InteropServices;
using Microsoft.CSharp;
@@ -9,7 +10,7 @@ namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool
public class ReswFileCSharpCodeGeneratorInternal : ReswFileCodeGenerator
{
public ReswFileCSharpCodeGeneratorInternal()
- : base(new CSharpCodeProvider(), MemberAttributes.Assembly)
+ : base(new CSharpCodeProvider(), TypeAttributes.NestedAssembly)
{
}
diff --git a/RESW File Code Generator/VSPackage/CustomTool/ReswFileCodeGenerator.cs b/RESW File Code Generator/VSPackage/CustomTool/ReswFileCodeGenerator.cs
index b1a7e8c..85ed102 100644
--- a/RESW File Code Generator/VSPackage/CustomTool/ReswFileCodeGenerator.cs
+++ b/RESW File Code Generator/VSPackage/CustomTool/ReswFileCodeGenerator.cs
@@ -1,6 +1,7 @@
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
+using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
@@ -12,9 +13,9 @@ namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool
public abstract class ReswFileCodeGenerator : IVsSingleFileGenerator
{
private readonly CodeDomProvider codeDomProvider;
- private readonly MemberAttributes? classAccessibility;
+ private readonly TypeAttributes? classAccessibility;
- protected ReswFileCodeGenerator(CodeDomProvider codeDomProvider, MemberAttributes? classAccessibility = null)
+ protected ReswFileCodeGenerator(CodeDomProvider codeDomProvider, TypeAttributes? classAccessibility = null)
{
this.codeDomProvider = codeDomProvider;
this.classAccessibility = classAccessibility;
diff --git a/RESW File Code Generator/VSPackage/CustomTool/ReswFileVisualBasicCodeGeneratorInternal.cs b/RESW File Code Generator/VSPackage/CustomTool/ReswFileVisualBasicCodeGeneratorInternal.cs
index d296f6a..1e4dad2 100644
--- a/RESW File Code Generator/VSPackage/CustomTool/ReswFileVisualBasicCodeGeneratorInternal.cs
+++ b/RESW File Code Generator/VSPackage/CustomTool/ReswFileVisualBasicCodeGeneratorInternal.cs
@@ -1,4 +1,4 @@
-using System.CodeDom;
+using System.Reflection;
using System.Runtime.InteropServices;
using Microsoft.VisualBasic;
@@ -9,7 +9,7 @@ namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool
public class ReswFileVisualBasicCodeGeneratorInternal : ReswFileCodeGenerator
{
public ReswFileVisualBasicCodeGeneratorInternal()
- : base(new VBCodeProvider(), MemberAttributes.Assembly)
+ : base(new VBCodeProvider(), TypeAttributes.NestedAssembly)
{
}
diff --git a/RESW File Code Generator/VSPackage/VisualStudio2012Package.cs b/RESW File Code Generator/VSPackage/VisualStudio2012Package.cs
index 6134de4..868ee8b 100644
--- a/RESW File Code Generator/VSPackage/VisualStudio2012Package.cs
+++ b/RESW File Code Generator/VSPackage/VisualStudio2012Package.cs
@@ -27,12 +27,14 @@ namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage
[DefaultRegistryRoot("Software\\Microsoft\\VisualStudio\\11.0")]
[ProvideObject(typeof(ReswFileCSharpCodeGenerator))]
[ProvideObject(typeof(ReswFileVisualBasicCodeGenerator))]
+ [ProvideObject(typeof(ReswFileCSharpCodeGeneratorInternal))]
+ [ProvideObject(typeof(ReswFileVisualBasicCodeGeneratorInternal))]
[ProvideGeneratorAttribute(typeof(ReswFileCSharpCodeGenerator), "ReswFileCodeGenerator", "ResW File Code Generator for C#", "{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}", true)] // csharp
[ProvideGeneratorAttribute(typeof(ReswFileVisualBasicCodeGenerator), "ReswFileCodeGenerator", "ResW File Code Generator for VB", "{164B10B9-B200-11D0-8C61-00A0C91E29D5}", true)] // visual basic
[ProvideGeneratorAttribute(typeof(ReswFileCSharpCodeGenerator), "PublicReswFileCodeGenerator", "ResW File Code Generator for C#", "{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}", true)] // csharp
[ProvideGeneratorAttribute(typeof(ReswFileVisualBasicCodeGenerator), "PublicReswFileCodeGenerator", "ResW File Code Generator for VB", "{164B10B9-B200-11D0-8C61-00A0C91E29D5}", true)] // visual basic
- [ProvideGeneratorAttribute(typeof(ReswFileCSharpCodeGeneratorInternal), "InternalReswFileCodeGenerator", "ResW File Code Generator for C#", "{151F74CA-404D-4188-B994-D7683C32ACF4}", true)] // csharp
- [ProvideGeneratorAttribute(typeof(ReswFileVisualBasicCodeGeneratorInternal), "InternalReswFileCodeGenerator", "ResW File Code Generator for VB", "{6C6AC14F-9B11-47C1-BC90-DFBFB89B1CB8}", true)] // visual basic
+ [ProvideGeneratorAttribute(typeof(ReswFileCSharpCodeGeneratorInternal), "InternalReswFileCodeGenerator", "ResW File Code Generator for C#", "{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}", true)] // csharp
+ [ProvideGeneratorAttribute(typeof(ReswFileVisualBasicCodeGeneratorInternal), "InternalReswFileCodeGenerator", "ResW File Code Generator for VB", "{164B10B9-B200-11D0-8C61-00A0C91E29D5}", true)] // visual basic
public sealed class VisualStudio2012Package : Package
{
///
diff --git a/RESW File Code Generator/VSPackage/VisualStudio2013Package.cs b/RESW File Code Generator/VSPackage/VisualStudio2013Package.cs
index 2236e57..c8474a3 100644
--- a/RESW File Code Generator/VSPackage/VisualStudio2013Package.cs
+++ b/RESW File Code Generator/VSPackage/VisualStudio2013Package.cs
@@ -27,12 +27,14 @@ namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage
[DefaultRegistryRoot("Software\\Microsoft\\VisualStudio\\12.0")]
[ProvideObject(typeof(ReswFileCSharpCodeGenerator))]
[ProvideObject(typeof(ReswFileVisualBasicCodeGenerator))]
+ [ProvideObject(typeof(ReswFileCSharpCodeGeneratorInternal))]
+ [ProvideObject(typeof(ReswFileVisualBasicCodeGeneratorInternal))]
[ProvideGeneratorAttribute(typeof(ReswFileCSharpCodeGenerator), "ReswFileCodeGenerator", "ResW File Code Generator for C#", "{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}", true)] // csharp
[ProvideGeneratorAttribute(typeof(ReswFileVisualBasicCodeGenerator), "ReswFileCodeGenerator", "ResW File Code Generator for VB", "{164B10B9-B200-11D0-8C61-00A0C91E29D5}", true)] // visual basic
[ProvideGeneratorAttribute(typeof(ReswFileCSharpCodeGenerator), "PublicReswFileCodeGenerator", "ResW File Code Generator for C#", "{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}", true)] // csharp
[ProvideGeneratorAttribute(typeof(ReswFileVisualBasicCodeGenerator), "PublicReswFileCodeGenerator", "ResW File Code Generator for VB", "{164B10B9-B200-11D0-8C61-00A0C91E29D5}", true)] // visual basic
- [ProvideGeneratorAttribute(typeof(ReswFileCSharpCodeGeneratorInternal), "InternalReswFileCodeGenerator", "ResW File Code Generator for C#", "{151F74CA-404D-4188-B994-D7683C32ACF4}", true)] // csharp
- [ProvideGeneratorAttribute(typeof(ReswFileVisualBasicCodeGeneratorInternal), "InternalReswFileCodeGenerator", "ResW File Code Generator for VB", "{6C6AC14F-9B11-47C1-BC90-DFBFB89B1CB8}", true)] // visual basic
+ [ProvideGeneratorAttribute(typeof(ReswFileCSharpCodeGeneratorInternal), "InternalReswFileCodeGenerator", "ResW File Code Generator for C#", "{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}", true)] // csharp
+ [ProvideGeneratorAttribute(typeof(ReswFileVisualBasicCodeGeneratorInternal), "InternalReswFileCodeGenerator", "ResW File Code Generator for VB", "{164B10B9-B200-11D0-8C61-00A0C91E29D5}", true)] // visual basic
public sealed class VisualStudio2013Package : Package
{
///
diff --git a/RESW File Code Generator/VSPackage/source.extension.vsixmanifest b/RESW File Code Generator/VSPackage/source.extension.vsixmanifest
index dd3e688..c55bbbd 100644
--- a/RESW File Code Generator/VSPackage/source.extension.vsixmanifest
+++ b/RESW File Code Generator/VSPackage/source.extension.vsixmanifest
@@ -8,7 +8,7 @@
Language="en-US"
Publisher="Christian Resma Helle" />
ResW File Code Generator
- Information about my packageA Visual Studio 2012 Custom Tool for generating a strongly typed helper class for accessing localized resources from a .ResW file.
+ A Visual Studio Custom Tool for generating a strongly typed helper class for accessing localized resources from a .ResW file.
http://visualstudiogallery.msdn.microsoft.com/3ab88efd-1afb-4ff5-9faf-8825a282596a
License.txt