diff --git a/RESW File Code Generator/IntegrationTests.testsettings b/RESW File Code Generator/IntegrationTests.testsettings
new file mode 100644
index 0000000..cb5acf5
--- /dev/null
+++ b/RESW File Code Generator/IntegrationTests.testsettings
@@ -0,0 +1,14 @@
+
+
+ This test run configuration uses the VS IDE host type in the test run.
+
+
+
+
+
+
+
diff --git a/RESW File Code Generator/RESW File Code Generator.sln b/RESW File Code Generator/RESW File Code Generator.sln
index 38065b6..7e84718 100644
--- a/RESW File Code Generator/RESW File Code Generator.sln
+++ b/RESW File Code Generator/RESW File Code Generator.sln
@@ -1,17 +1,19 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReswCodeGen.CustomTool", "ReswCodeGen.CustomTool\ReswCodeGen.CustomTool.csproj", "{27E6A696-F14D-43F0-B3CB-5FAB2BE385D0}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReswCodeGen.Tests", "ReswCodeGen.Tests\ReswCodeGen.Tests.csproj", "{B56DDC92-E86D-46AA-BE28-7ACA670EE9CE}"
EndProject
-Project("{6141683F-8A12-4E36-9623-2EB02B2C2303}") = "Setup", "Setup\Setup.isproj", "{F2C091E7-8B4A-4629-BF80-738294F5FFB8}"
- ProjectSection(ProjectDependencies) = postProject
- {4180087A-7F13-409B-AFE9-505371874A68} = {4180087A-7F13-409B-AFE9-505371874A68}
- {27E6A696-F14D-43F0-B3CB-5FAB2BE385D0} = {27E6A696-F14D-43F0-B3CB-5FAB2BE385D0}
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VSPackage", "VSPackage\VSPackage.csproj", "{2451352F-1CB8-494A-920B-024B8B486185}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VSPackage_IntegrationTests", "VSPackage\VSPackage_IntegrationTests\VSPackage_IntegrationTests.csproj", "{D03690D8-EE17-4284-9403-F3F277CF4580}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{91EF78EF-DAB6-4031-AA01-3D127F1E0BCD}"
+ ProjectSection(SolutionItems) = preProject
+ IntegrationTests.testsettings = IntegrationTests.testsettings
+ UnitTests.testsettings = UnitTests.testsettings
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReswCodeGen.CustomActions", "ReswCodeGen.CustomActions\ReswCodeGen.CustomActions.csproj", "{4180087A-7F13-409B-AFE9-505371874A68}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VSPackage_UnitTests", "VSPackage\VSPackage_UnitTests\VSPackage_UnitTests.csproj", "{64F7EAFB-9AF1-4DA4-A4DA-013B4DF10306}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -22,16 +24,6 @@ Global
SingleImage|Any CPU = SingleImage|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {27E6A696-F14D-43F0-B3CB-5FAB2BE385D0}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU
- {27E6A696-F14D-43F0-B3CB-5FAB2BE385D0}.CD_ROM|Any CPU.Build.0 = Release|Any CPU
- {27E6A696-F14D-43F0-B3CB-5FAB2BE385D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {27E6A696-F14D-43F0-B3CB-5FAB2BE385D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {27E6A696-F14D-43F0-B3CB-5FAB2BE385D0}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU
- {27E6A696-F14D-43F0-B3CB-5FAB2BE385D0}.DVD-5|Any CPU.Build.0 = Debug|Any CPU
- {27E6A696-F14D-43F0-B3CB-5FAB2BE385D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {27E6A696-F14D-43F0-B3CB-5FAB2BE385D0}.Release|Any CPU.Build.0 = Release|Any CPU
- {27E6A696-F14D-43F0-B3CB-5FAB2BE385D0}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU
- {27E6A696-F14D-43F0-B3CB-5FAB2BE385D0}.SingleImage|Any CPU.Build.0 = Release|Any CPU
{B56DDC92-E86D-46AA-BE28-7ACA670EE9CE}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU
{B56DDC92-E86D-46AA-BE28-7ACA670EE9CE}.CD_ROM|Any CPU.Build.0 = Release|Any CPU
{B56DDC92-E86D-46AA-BE28-7ACA670EE9CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@@ -42,25 +34,36 @@ Global
{B56DDC92-E86D-46AA-BE28-7ACA670EE9CE}.Release|Any CPU.Build.0 = Release|Any CPU
{B56DDC92-E86D-46AA-BE28-7ACA670EE9CE}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU
{B56DDC92-E86D-46AA-BE28-7ACA670EE9CE}.SingleImage|Any CPU.Build.0 = Release|Any CPU
- {F2C091E7-8B4A-4629-BF80-738294F5FFB8}.CD_ROM|Any CPU.ActiveCfg = CD_ROM
- {F2C091E7-8B4A-4629-BF80-738294F5FFB8}.CD_ROM|Any CPU.Build.0 = CD_ROM
- {F2C091E7-8B4A-4629-BF80-738294F5FFB8}.Debug|Any CPU.ActiveCfg = SingleImage
- {F2C091E7-8B4A-4629-BF80-738294F5FFB8}.DVD-5|Any CPU.ActiveCfg = DVD-5
- {F2C091E7-8B4A-4629-BF80-738294F5FFB8}.DVD-5|Any CPU.Build.0 = DVD-5
- {F2C091E7-8B4A-4629-BF80-738294F5FFB8}.Release|Any CPU.ActiveCfg = SingleImage
- {F2C091E7-8B4A-4629-BF80-738294F5FFB8}.Release|Any CPU.Build.0 = SingleImage
- {F2C091E7-8B4A-4629-BF80-738294F5FFB8}.SingleImage|Any CPU.ActiveCfg = SingleImage
- {F2C091E7-8B4A-4629-BF80-738294F5FFB8}.SingleImage|Any CPU.Build.0 = SingleImage
- {4180087A-7F13-409B-AFE9-505371874A68}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU
- {4180087A-7F13-409B-AFE9-505371874A68}.CD_ROM|Any CPU.Build.0 = Release|Any CPU
- {4180087A-7F13-409B-AFE9-505371874A68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {4180087A-7F13-409B-AFE9-505371874A68}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {4180087A-7F13-409B-AFE9-505371874A68}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU
- {4180087A-7F13-409B-AFE9-505371874A68}.DVD-5|Any CPU.Build.0 = Debug|Any CPU
- {4180087A-7F13-409B-AFE9-505371874A68}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {4180087A-7F13-409B-AFE9-505371874A68}.Release|Any CPU.Build.0 = Release|Any CPU
- {4180087A-7F13-409B-AFE9-505371874A68}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU
- {4180087A-7F13-409B-AFE9-505371874A68}.SingleImage|Any CPU.Build.0 = Release|Any CPU
+ {2451352F-1CB8-494A-920B-024B8B486185}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU
+ {2451352F-1CB8-494A-920B-024B8B486185}.CD_ROM|Any CPU.Build.0 = Release|Any CPU
+ {2451352F-1CB8-494A-920B-024B8B486185}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2451352F-1CB8-494A-920B-024B8B486185}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2451352F-1CB8-494A-920B-024B8B486185}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU
+ {2451352F-1CB8-494A-920B-024B8B486185}.DVD-5|Any CPU.Build.0 = Debug|Any CPU
+ {2451352F-1CB8-494A-920B-024B8B486185}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2451352F-1CB8-494A-920B-024B8B486185}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2451352F-1CB8-494A-920B-024B8B486185}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU
+ {2451352F-1CB8-494A-920B-024B8B486185}.SingleImage|Any CPU.Build.0 = Release|Any CPU
+ {D03690D8-EE17-4284-9403-F3F277CF4580}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU
+ {D03690D8-EE17-4284-9403-F3F277CF4580}.CD_ROM|Any CPU.Build.0 = Release|Any CPU
+ {D03690D8-EE17-4284-9403-F3F277CF4580}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D03690D8-EE17-4284-9403-F3F277CF4580}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D03690D8-EE17-4284-9403-F3F277CF4580}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU
+ {D03690D8-EE17-4284-9403-F3F277CF4580}.DVD-5|Any CPU.Build.0 = Debug|Any CPU
+ {D03690D8-EE17-4284-9403-F3F277CF4580}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D03690D8-EE17-4284-9403-F3F277CF4580}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D03690D8-EE17-4284-9403-F3F277CF4580}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU
+ {D03690D8-EE17-4284-9403-F3F277CF4580}.SingleImage|Any CPU.Build.0 = Release|Any CPU
+ {64F7EAFB-9AF1-4DA4-A4DA-013B4DF10306}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU
+ {64F7EAFB-9AF1-4DA4-A4DA-013B4DF10306}.CD_ROM|Any CPU.Build.0 = Release|Any CPU
+ {64F7EAFB-9AF1-4DA4-A4DA-013B4DF10306}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {64F7EAFB-9AF1-4DA4-A4DA-013B4DF10306}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {64F7EAFB-9AF1-4DA4-A4DA-013B4DF10306}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU
+ {64F7EAFB-9AF1-4DA4-A4DA-013B4DF10306}.DVD-5|Any CPU.Build.0 = Debug|Any CPU
+ {64F7EAFB-9AF1-4DA4-A4DA-013B4DF10306}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {64F7EAFB-9AF1-4DA4-A4DA-013B4DF10306}.Release|Any CPU.Build.0 = Release|Any CPU
+ {64F7EAFB-9AF1-4DA4-A4DA-013B4DF10306}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU
+ {64F7EAFB-9AF1-4DA4-A4DA-013B4DF10306}.SingleImage|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/RESW File Code Generator/ReswCodeGen.Tests/CSharpCodeGeneratorTests.cs b/RESW File Code Generator/ReswCodeGen.Tests/CSharpCodeGeneratorTests.cs
index 073894a..dc8ee4c 100644
--- a/RESW File Code Generator/ReswCodeGen.Tests/CSharpCodeGeneratorTests.cs
+++ b/RESW File Code Generator/ReswCodeGen.Tests/CSharpCodeGeneratorTests.cs
@@ -1,5 +1,6 @@
using System.IO;
using System.Linq;
+using ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.CustomTool.Tests
diff --git a/RESW File Code Generator/ReswCodeGen.Tests/ClassNameExtractorTests.cs b/RESW File Code Generator/ReswCodeGen.Tests/ClassNameExtractorTests.cs
index 04dcf31..35f96c5 100644
--- a/RESW File Code Generator/ReswCodeGen.Tests/ClassNameExtractorTests.cs
+++ b/RESW File Code Generator/ReswCodeGen.Tests/ClassNameExtractorTests.cs
@@ -1,4 +1,5 @@
using System.IO;
+using ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.CustomTool.Tests
diff --git a/RESW File Code Generator/ReswCodeGen.Tests/CodeGeneratorFactoryTests.cs b/RESW File Code Generator/ReswCodeGen.Tests/CodeGeneratorFactoryTests.cs
index badfd58..5fb3429 100644
--- a/RESW File Code Generator/ReswCodeGen.Tests/CodeGeneratorFactoryTests.cs
+++ b/RESW File Code Generator/ReswCodeGen.Tests/CodeGeneratorFactoryTests.cs
@@ -1,4 +1,5 @@
using System.IO;
+using ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.CustomTool.Tests
diff --git a/RESW File Code Generator/ReswCodeGen.Tests/ResourceParserErrorHandlingTests.cs b/RESW File Code Generator/ReswCodeGen.Tests/ResourceParserErrorHandlingTests.cs
index afe4fdc..3574630 100644
--- a/RESW File Code Generator/ReswCodeGen.Tests/ResourceParserErrorHandlingTests.cs
+++ b/RESW File Code Generator/ReswCodeGen.Tests/ResourceParserErrorHandlingTests.cs
@@ -1,4 +1,5 @@
using System.IO;
+using ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.CustomTool.Tests
diff --git a/RESW File Code Generator/ReswCodeGen.Tests/ResourceParserTests.cs b/RESW File Code Generator/ReswCodeGen.Tests/ResourceParserTests.cs
index 38f54e6..3cbe6cf 100644
--- a/RESW File Code Generator/ReswCodeGen.Tests/ResourceParserTests.cs
+++ b/RESW File Code Generator/ReswCodeGen.Tests/ResourceParserTests.cs
@@ -1,6 +1,7 @@
using System.IO;
using System.Linq;
using System.Xml.Linq;
+using ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.CustomTool.Tests
diff --git a/RESW File Code Generator/ReswCodeGen.Tests/ReswCodeGen.Tests.csproj b/RESW File Code Generator/ReswCodeGen.Tests/ReswCodeGen.Tests.csproj
index 0d352fc..b9c61a4 100644
--- a/RESW File Code Generator/ReswCodeGen.Tests/ReswCodeGen.Tests.csproj
+++ b/RESW File Code Generator/ReswCodeGen.Tests/ReswCodeGen.Tests.csproj
@@ -81,9 +81,9 @@
-
- {27E6A696-F14D-43F0-B3CB-5FAB2BE385D0}
- ReswCodeGen.CustomTool
+
+ {2451352F-1CB8-494A-920B-024B8B486185}
+ VSPackage
diff --git a/RESW File Code Generator/ReswCodeGen.Tests/VisualBasicCodeGeneratorTests.cs b/RESW File Code Generator/ReswCodeGen.Tests/VisualBasicCodeGeneratorTests.cs
index 2a08d65..ebb4d39 100644
--- a/RESW File Code Generator/ReswCodeGen.Tests/VisualBasicCodeGeneratorTests.cs
+++ b/RESW File Code Generator/ReswCodeGen.Tests/VisualBasicCodeGeneratorTests.cs
@@ -1,5 +1,6 @@
using System.IO;
using System.Linq;
+using ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool;
using Microsoft.VisualBasic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -9,7 +10,7 @@ namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.CustomTool.Tests
[DeploymentItem("Resources/Resources.resw")]
public class VisualBasicCodeGeneratorTests
{
- private const string FilePath = "Resources.resw";
+ private const string FILE_PATH = "Resources.resw";
private string actual;
private string reswFileContents;
private ICodeGenerator target;
@@ -17,9 +18,9 @@ namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.CustomTool.Tests
[TestInitialize]
public void Initialize()
{
- reswFileContents = File.ReadAllText(FilePath);
+ reswFileContents = File.ReadAllText(FILE_PATH);
- target = new CodeGeneratorFactory().Create(FilePath.Replace(".resw", string.Empty), "TestApp", reswFileContents, new VBCodeProvider());
+ target = new CodeGeneratorFactory().Create(FILE_PATH.Replace(".resw", string.Empty), "TestApp", reswFileContents, new VBCodeProvider());
actual = target.GenerateCode();
}
diff --git a/RESW File Code Generator/UnitTests.testsettings b/RESW File Code Generator/UnitTests.testsettings
new file mode 100644
index 0000000..f880c76
--- /dev/null
+++ b/RESW File Code Generator/UnitTests.testsettings
@@ -0,0 +1,9 @@
+
+
+
+ This test run configuration is used for running the unit tests
+
diff --git a/RESW File Code Generator/VSPackage/CustomTool/ClassNameExtractor.cs b/RESW File Code Generator/VSPackage/CustomTool/ClassNameExtractor.cs
new file mode 100644
index 0000000..aa660b8
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/CustomTool/ClassNameExtractor.cs
@@ -0,0 +1,16 @@
+using System.IO;
+
+namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool
+{
+ public static class ClassNameExtractor
+ {
+ public static string GetClassName(string wszInputFilePath)
+ {
+ if (!File.Exists(wszInputFilePath))
+ throw new FileNotFoundException();
+
+ var fileInfo = new FileInfo(wszInputFilePath);
+ return fileInfo.Name.Replace(fileInfo.Extension, string.Empty);
+ }
+ }
+}
diff --git a/RESW File Code Generator/VSPackage/CustomTool/CodeDomCodeGenerator.cs b/RESW File Code Generator/VSPackage/CustomTool/CodeDomCodeGenerator.cs
new file mode 100644
index 0000000..616f107
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/CustomTool/CodeDomCodeGenerator.cs
@@ -0,0 +1,159 @@
+using System;
+using System.CodeDom;
+using System.CodeDom.Compiler;
+using System.Globalization;
+using System.IO;
+using System.Text;
+using Microsoft.CSharp;
+
+namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool
+{
+ public class CodeDomCodeGenerator : CodeGenerator
+ {
+ private readonly string className;
+ private readonly CodeNamespace codeNamespace;
+ private readonly CodeCompileUnit compileUnit;
+ private readonly CodeDomProvider provider;
+
+ public CodeDomCodeGenerator(IResourceParser resourceParser, string className, string defaultNamespace, CodeDomProvider codeDomProvider = null)
+ : base(resourceParser, defaultNamespace)
+ {
+ this.className = className;
+ compileUnit = new CodeCompileUnit();
+ provider = codeDomProvider ?? new CSharpCodeProvider();
+ codeNamespace = new CodeNamespace(defaultNamespace);
+ }
+
+ public override string GenerateCode()
+ {
+ codeNamespace.Comments.Add(new CodeCommentStatement("--------------------------------------------------------------------------------------------------"));
+ codeNamespace.Comments.Add(new CodeCommentStatement(""));
+ codeNamespace.Comments.Add(new CodeCommentStatement("\tThis code was generated by ResW File Code Generator (http://reswcodegen.codeplex.com)"));
+ codeNamespace.Comments.Add(new CodeCommentStatement("\tResW File Code Generator was written by Christian Resma Helle"));
+ codeNamespace.Comments.Add(new CodeCommentStatement("\tand is under GNU General Public License version 2 (GPLv2)"));
+ codeNamespace.Comments.Add(new CodeCommentStatement(string.Empty));
+ codeNamespace.Comments.Add(new CodeCommentStatement("\tThis code contains a helper class exposing property representations"));
+ codeNamespace.Comments.Add(new CodeCommentStatement("\tof the string resources defined in the specified .ResW file"));
+ codeNamespace.Comments.Add(new CodeCommentStatement(string.Empty));
+ codeNamespace.Comments.Add(new CodeCommentStatement("\tGenerated: " + DateTime.Now.ToString(CultureInfo.InvariantCulture)));
+ codeNamespace.Comments.Add(new CodeCommentStatement(""));
+ codeNamespace.Comments.Add(new CodeCommentStatement("--------------------------------------------------------------------------------------------------"));
+
+ codeNamespace.Imports.Add(new CodeNamespaceImport("Windows.ApplicationModel.Resources"));
+
+ var targetClass = new CodeTypeDeclaration(className)
+ {
+ IsClass = true,
+ IsPartial = true,
+ Attributes = MemberAttributes.Public | MemberAttributes.Static
+ };
+
+ const string resourceLoaderType = "ResourceLoader";
+ var resourceLoaderField = new CodeMemberField(resourceLoaderType, "resourceLoader")
+ {
+ Attributes = MemberAttributes.Private | MemberAttributes.Static | MemberAttributes.Final
+ };
+ targetClass.Members.Add(resourceLoaderField);
+
+ var constructor = new CodeTypeConstructor();
+
+ var executingAssemblyVar = new CodeVariableDeclarationStatement(typeof(string), "executingAssemblyName");
+ var executingAssemblyInit = new CodeAssignStatement(
+ new CodeVariableReferenceExpression("executingAssemblyName"),
+ new CodeSnippetExpression("Windows.UI.Xaml.Application.Current.GetType().AssemblyQualifiedName"));
+ var executingAssemblySplit = new CodeVariableDeclarationStatement(typeof(string[]), "executingAssemblySplit");
+ var executingAssemblyInit2 = new CodeAssignStatement(
+ new CodeVariableReferenceExpression("executingAssemblySplit"),
+ new CodeMethodInvokeExpression(new CodeVariableReferenceExpression("executingAssemblyName"), "Split", new CodePrimitiveExpression(',')));
+ var executingAssemblyInit3 = new CodeAssignStatement(
+ new CodeVariableReferenceExpression("executingAssemblyName"),
+ new CodeArrayIndexerExpression(new CodeVariableReferenceExpression("executingAssemblySplit"), new CodePrimitiveExpression(1)));
+
+ var currentAssemblyVar = new CodeVariableDeclarationStatement(typeof(string), "currentAssemblyName");
+ var currentAssemblyInit = new CodeAssignStatement(
+ new CodeVariableReferenceExpression("currentAssemblyName"),
+ new CodePropertyReferenceExpression(new CodeTypeOfExpression(className), "AssemblyQualifiedName"));
+ var currentAssemblySplit = new CodeVariableDeclarationStatement(typeof(string[]), "currentAssemblySplit");
+ var currentAssemblyInit2 = new CodeAssignStatement(
+ new CodeVariableReferenceExpression("currentAssemblySplit"),
+ new CodeMethodInvokeExpression(new CodeVariableReferenceExpression("currentAssemblyName"), "Split", new CodePrimitiveExpression(',')));
+ var currentAssemblyInit3 = new CodeAssignStatement(
+ new CodeVariableReferenceExpression("currentAssemblyName"),
+ new CodeArrayIndexerExpression(new CodeVariableReferenceExpression("currentAssemblySplit"), new CodePrimitiveExpression(1)));
+
+ var createResourceLoader = new CodeConditionStatement(
+ new CodeSnippetExpression("executingAssemblyName.Equals(currentAssemblyName)"),
+ new CodeStatement[] // true
+ {
+ new CodeAssignStatement(
+ new CodeFieldReferenceExpression(null, "resourceLoader"),
+ new CodeObjectCreateExpression(new CodeTypeReference("ResourceLoader"),
+ new CodeSnippetExpression("\"" + className + "\"")))
+ },
+ new CodeStatement[] // false
+ {
+ new CodeAssignStatement(
+ new CodeFieldReferenceExpression(null, "resourceLoader"),
+ new CodeObjectCreateExpression(new CodeTypeReference("ResourceLoader"),
+ new CodeSnippetExpression("currentAssemblyName + \"/" + className + "\"")))
+ });
+
+ constructor.Statements.Add(executingAssemblyVar);
+ constructor.Statements.Add(executingAssemblyInit);
+ constructor.Statements.Add(executingAssemblySplit);
+ constructor.Statements.Add(executingAssemblyInit2);
+ constructor.Statements.Add(executingAssemblyInit3);
+ constructor.Statements.Add(currentAssemblyVar);
+ constructor.Statements.Add(currentAssemblyInit);
+ constructor.Statements.Add(currentAssemblySplit);
+ constructor.Statements.Add(currentAssemblyInit2);
+ constructor.Statements.Add(currentAssemblyInit3);
+ constructor.Statements.Add(createResourceLoader);
+
+ targetClass.Members.Add(constructor);
+
+ var resources = ResourceParser.Parse();
+ foreach (var item in resources)
+ {
+ if (string.IsNullOrEmpty(item.Name) || item.Name.Contains("."))
+ continue;
+
+ var property = new CodeMemberProperty
+ {
+ Name = item.Name.Trim(),
+ Attributes = MemberAttributes.Public | MemberAttributes.Static,
+ HasGet = true,
+ Type = new CodeTypeReference(typeof(string))
+ };
+
+ property.Comments.Add(new CodeCommentStatement("", true));
+ property.Comments.Add(new CodeCommentStatement("Localized resource similar to \"" + (item.Value ?? item.Name) + "\"", true));
+ property.Comments.Add(new CodeCommentStatement("", true));
+ property.GetStatements.Add(
+ new CodeMethodReturnStatement(
+ new CodeMethodInvokeExpression(
+ new CodeFieldReferenceExpression(null, "resourceLoader"), "GetString",
+ new CodePrimitiveExpression(item.Name))));
+
+ targetClass.Members.Add(property);
+ }
+
+ codeNamespace.Types.Add(targetClass);
+ compileUnit.Namespaces.Add(codeNamespace);
+
+ return GenerateCodeFromCompileUnit();
+ }
+
+ private string GenerateCodeFromCompileUnit()
+ {
+ var options = new CodeGeneratorOptions { BracingStyle = "C" };
+
+ var code = new StringBuilder();
+
+ using (var writer = new StringWriter(code))
+ provider.GenerateCodeFromCompileUnit(compileUnit, writer, options);
+
+ return code.ToString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/RESW File Code Generator/VSPackage/CustomTool/CodeGenerator.cs b/RESW File Code Generator/VSPackage/CustomTool/CodeGenerator.cs
new file mode 100644
index 0000000..83bd0b5
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/CustomTool/CodeGenerator.cs
@@ -0,0 +1,16 @@
+namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool
+{
+ public abstract class CodeGenerator : ICodeGenerator
+ {
+ protected CodeGenerator(IResourceParser resourceParser, string defaultNamespace)
+ {
+ ResourceParser = resourceParser;
+ Namespace = defaultNamespace;
+ }
+
+ public IResourceParser ResourceParser { get; set; }
+ public string Namespace { get; set; }
+
+ public abstract string GenerateCode();
+ }
+}
\ No newline at end of file
diff --git a/RESW File Code Generator/VSPackage/CustomTool/CodeGeneratorFactory.cs b/RESW File Code Generator/VSPackage/CustomTool/CodeGeneratorFactory.cs
new file mode 100644
index 0000000..b1c494b
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/CustomTool/CodeGeneratorFactory.cs
@@ -0,0 +1,12 @@
+using System.CodeDom.Compiler;
+
+namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool
+{
+ public class CodeGeneratorFactory
+ {
+ public ICodeGenerator Create(string className, string defaultNamespace, string inputFileContents, CodeDomProvider codeDomProvider = null)
+ {
+ return new CodeDomCodeGenerator(new ResourceParser(inputFileContents), className, defaultNamespace, codeDomProvider);
+ }
+ }
+}
diff --git a/RESW File Code Generator/VSPackage/CustomTool/ICodeGenerator.cs b/RESW File Code Generator/VSPackage/CustomTool/ICodeGenerator.cs
new file mode 100644
index 0000000..6da81f4
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/CustomTool/ICodeGenerator.cs
@@ -0,0 +1,9 @@
+namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool
+{
+ public interface ICodeGenerator
+ {
+ IResourceParser ResourceParser { get; set; }
+ string Namespace { get; set; }
+ string GenerateCode();
+ }
+}
diff --git a/RESW File Code Generator/VSPackage/CustomTool/IResourceParser.cs b/RESW File Code Generator/VSPackage/CustomTool/IResourceParser.cs
new file mode 100644
index 0000000..5212e62
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/CustomTool/IResourceParser.cs
@@ -0,0 +1,10 @@
+using System.Collections.Generic;
+
+namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool
+{
+ public interface IResourceParser
+ {
+ string ReswFileContents { get; set; }
+ List Parse();
+ }
+}
\ No newline at end of file
diff --git a/RESW File Code Generator/VSPackage/CustomTool/ResourceItem.cs b/RESW File Code Generator/VSPackage/CustomTool/ResourceItem.cs
new file mode 100644
index 0000000..4539e8c
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/CustomTool/ResourceItem.cs
@@ -0,0 +1,9 @@
+namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool
+{
+ public class ResourceItem
+ {
+ public string Name { get; set; }
+ public string Value { get; set; }
+ public string Comment { get; set; }
+ }
+}
diff --git a/RESW File Code Generator/VSPackage/CustomTool/ResourceParser.cs b/RESW File Code Generator/VSPackage/CustomTool/ResourceParser.cs
new file mode 100644
index 0000000..e96f6f6
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/CustomTool/ResourceParser.cs
@@ -0,0 +1,53 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Xml.Linq;
+
+namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool
+{
+ public class ResourceParser : IResourceParser
+ {
+ public ResourceParser(string reswFileContents)
+ {
+ ReswFileContents = reswFileContents;
+ }
+
+ public string ReswFileContents { get; set; }
+
+ public List Parse()
+ {
+ var doc = XDocument.Parse(ReswFileContents);
+
+ var list = new List();
+
+ foreach (var element in doc.Descendants("data"))
+ {
+ if (element.Attributes().All(c => c.Name != "name"))
+ continue;
+
+ var item = new ResourceItem();
+
+ var nameAttribute = element.Attribute("name");
+ if (nameAttribute != null)
+ item.Name = nameAttribute.Value;
+
+ if (element.Descendants().Any(c => c.Name == "value"))
+ {
+ var valueElement = element.Descendants("value").FirstOrDefault();
+ if (valueElement != null)
+ item.Value = valueElement.Value;
+ }
+
+ if (element.Descendants().Any(c => c.Name == "comment"))
+ {
+ var commentElement = element.Descendants("comment").FirstOrDefault();
+ if (commentElement != null)
+ item.Comment = commentElement.Value;
+ }
+
+ list.Add(item);
+ }
+
+ return list;
+ }
+ }
+}
diff --git a/RESW File Code Generator/VSPackage/CustomTool/ReswFileCSharpCodeGenerator.cs b/RESW File Code Generator/VSPackage/CustomTool/ReswFileCSharpCodeGenerator.cs
new file mode 100644
index 0000000..75dc072
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/CustomTool/ReswFileCSharpCodeGenerator.cs
@@ -0,0 +1,21 @@
+using System.Runtime.InteropServices;
+using Microsoft.CSharp;
+
+namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool
+{
+ [Guid("98983F6D-BC77-46AC-BA5A-8D9E8763F0D2")]
+ [ComVisible(true)]
+ public class ReswFileCSharpCodeGenerator : ReswFileCodeGenerator
+ {
+ public ReswFileCSharpCodeGenerator()
+ : base(new CSharpCodeProvider())
+ {
+ }
+
+ public override int DefaultExtension(out string pbstrDefaultExtension)
+ {
+ pbstrDefaultExtension = ".cs";
+ return 0;
+ }
+ }
+}
\ No newline at end of file
diff --git a/RESW File Code Generator/VSPackage/CustomTool/ReswFileCodeGenerator.cs b/RESW File Code Generator/VSPackage/CustomTool/ReswFileCodeGenerator.cs
new file mode 100644
index 0000000..640b409
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/CustomTool/ReswFileCodeGenerator.cs
@@ -0,0 +1,56 @@
+using System;
+using System.CodeDom.Compiler;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Windows.Forms;
+using Microsoft.VisualStudio.Shell.Interop;
+
+namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool
+{
+ [ComVisible(true)]
+ public abstract class ReswFileCodeGenerator : IVsSingleFileGenerator
+ {
+ private readonly CodeDomProvider codeDomProvider;
+
+ protected ReswFileCodeGenerator(CodeDomProvider codeDomProvider)
+ {
+ this.codeDomProvider = codeDomProvider;
+ }
+
+ #region IVsSingleFileGenerator Members
+
+ public abstract int DefaultExtension(out string pbstrDefaultExtension);
+
+ public virtual int Generate(string wszInputFilePath,
+ string bstrInputFileContents,
+ string wszDefaultNamespace,
+ IntPtr[] rgbOutputFileContents,
+ out uint pcbOutput,
+ IVsGeneratorProgress pGenerateProgress)
+ {
+ try
+ {
+ var className = ClassNameExtractor.GetClassName(wszInputFilePath);
+ var factory = new CodeGeneratorFactory();
+ var codeGenerator = factory.Create(className, wszDefaultNamespace, bstrInputFileContents, codeDomProvider);
+ var code = codeGenerator.GenerateCode();
+
+ var data = Encoding.UTF8.GetBytes(code);
+
+ rgbOutputFileContents[0] = Marshal.AllocCoTaskMem(data.Length);
+ Marshal.Copy(data, 0, rgbOutputFileContents[0], data.Length);
+
+ pcbOutput = (uint)data.Length;
+ }
+ catch (Exception e)
+ {
+ MessageBox.Show(e.Message, "Unable to generate code");
+ throw;
+ }
+
+ return 0;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/RESW File Code Generator/VSPackage/CustomTool/ReswFileVisualBasicCodeGenerator.cs b/RESW File Code Generator/VSPackage/CustomTool/ReswFileVisualBasicCodeGenerator.cs
new file mode 100644
index 0000000..c44263a
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/CustomTool/ReswFileVisualBasicCodeGenerator.cs
@@ -0,0 +1,21 @@
+using System.Runtime.InteropServices;
+using Microsoft.VisualBasic;
+
+namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool
+{
+ [Guid("92DFB543-7138-419B-99D9-90CC77607671")]
+ [ComVisible(true)]
+ public class ReswFileVisualBasicCodeGenerator : ReswFileCodeGenerator
+ {
+ public ReswFileVisualBasicCodeGenerator()
+ : base(new VBCodeProvider())
+ {
+ }
+
+ public override int DefaultExtension(out string pbstrDefaultExtension)
+ {
+ pbstrDefaultExtension = ".vb";
+ return 0;
+ }
+ }
+}
\ No newline at end of file
diff --git a/RESW File Code Generator/VSPackage/GlobalSuppressions.cs b/RESW File Code Generator/VSPackage/GlobalSuppressions.cs
new file mode 100644
index 0000000..175a74e
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/GlobalSuppressions.cs
@@ -0,0 +1,11 @@
+// This file is used by Code Analysis to maintain SuppressMessage
+// attributes that are applied to this project. Project-level
+// suppressions either have no target or are given a specific target
+// and scoped to a namespace, type, member, etc.
+//
+// To add a suppression to this file, right-click the message in the
+// Error List, point to "Suppress Message(s)", and click "In Project
+// Suppression File". You do not need to add suppressions to this
+// file manually.
+
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1017:MarkAssembliesWithComVisible")]
diff --git a/RESW File Code Generator/VSPackage/Guids.cs b/RESW File Code Generator/VSPackage/Guids.cs
new file mode 100644
index 0000000..4868341
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/Guids.cs
@@ -0,0 +1,15 @@
+// Guids.cs
+// MUST match guids.h
+
+using System;
+
+namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage
+{
+ static class GuidList
+ {
+ public const string guidVSPackagePkgString = "6a4c1726-440f-4b2d-a2e5-711277da6099";
+ public const string guidVSPackageCmdSetString = "fb40dc0b-2f75-404c-ba4e-dc1b90c41941";
+
+ public static readonly Guid guidVSPackageCmdSet = new Guid(guidVSPackageCmdSetString);
+ };
+}
\ No newline at end of file
diff --git a/RESW File Code Generator/VSPackage/Key.snk b/RESW File Code Generator/VSPackage/Key.snk
new file mode 100644
index 0000000..82ea2e0
Binary files /dev/null and b/RESW File Code Generator/VSPackage/Key.snk differ
diff --git a/RESW File Code Generator/VSPackage/License.txt b/RESW File Code Generator/VSPackage/License.txt
new file mode 100644
index 0000000..227626c
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/License.txt
@@ -0,0 +1,88 @@
+GNU General Public License version 2 (GPLv2)
+Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+
+Preamble
+
+The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too.
+
+When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
+
+To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
+
+Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution and modification follow.
+
+GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
+
+1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+
+a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
+
+b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
+
+c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
+
+a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+
+b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+
+c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+
+If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
+
+4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+
+5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
+
+6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
+
+7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
+
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+
+8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+
+9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
+
+10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+
+NO WARRANTY
+
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
\ No newline at end of file
diff --git a/RESW File Code Generator/VSPackage/Properties/AssemblyInfo.cs b/RESW File Code Generator/VSPackage/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..895ef1c
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("ResW File Code Generator Custom Tool")]
+[assembly: AssemblyDescription("A Visual Studio 2012 Custom Tool for generating a strongly typed helper class for accessing localized resources from a .ResW file.")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ResW File Code Generator Custom Tool")]
+[assembly: AssemblyCopyright("Copyright © Christian Resma Helle 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: ComVisible(false)]
+[assembly: CLSCompliant(false)]
+[assembly: NeutralResourcesLanguage("en-US")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+
+[assembly: AssemblyVersion("1.0.3.*")]
+
+[assembly: InternalsVisibleTo("VSPackage_IntegrationTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010045bd05a5b24c74b83f069df52e138682c2fb8b1ee65cb9d351fd7e8d622308aeb588b2a2975d75da4fe8a392510528baa26a3317809ec064d3cc852f0df94752ad2228d9f2a048ee2858c1e9d505b05f7fb4ede02f34154f75ea50445741c84f5ab1c814358f5fd6a6f08bb3d94284cff0524d5ca9d888c8648bcbc7a1e0a3c8")]
+[assembly: InternalsVisibleTo("VSPackage_UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010045bd05a5b24c74b83f069df52e138682c2fb8b1ee65cb9d351fd7e8d622308aeb588b2a2975d75da4fe8a392510528baa26a3317809ec064d3cc852f0df94752ad2228d9f2a048ee2858c1e9d505b05f7fb4ede02f34154f75ea50445741c84f5ab1c814358f5fd6a6f08bb3d94284cff0524d5ca9d888c8648bcbc7a1e0a3c8")]
diff --git a/RESW File Code Generator/VSPackage/Resources.Designer.cs b/RESW File Code Generator/VSPackage/Resources.Designer.cs
new file mode 100644
index 0000000..b246db4
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.18033
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/RESW File Code Generator/VSPackage/Resources.resx b/RESW File Code Generator/VSPackage/Resources.resx
new file mode 100644
index 0000000..352987a
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/Resources.resx
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/RESW File Code Generator/VSPackage/Resources/Package.ico b/RESW File Code Generator/VSPackage/Resources/Package.ico
new file mode 100644
index 0000000..449296f
Binary files /dev/null and b/RESW File Code Generator/VSPackage/Resources/Package.ico differ
diff --git a/RESW File Code Generator/VSPackage/VSPackage.csproj b/RESW File Code Generator/VSPackage/VSPackage.csproj
new file mode 100644
index 0000000..53d0d8c
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/VSPackage.csproj
@@ -0,0 +1,184 @@
+
+
+
+ 11.0
+ 11.0
+ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+
+
+
+ Debug
+ AnyCPU
+ 2.0
+ {2451352F-1CB8-494A-920B-024B8B486185}
+ {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ Library
+ Properties
+ ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage
+ ReswCodeGen.VSPackage
+ True
+ Key.snk
+ v4.5
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ true
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {80CC9F66-E7D8-4DDD-85B6-D9E6CD0E93E2}
+ 8
+ 0
+ 0
+ primary
+ False
+ False
+
+
+ {26AD1324-4B7C-44BC-84F8-B86AED45729F}
+ 10
+ 0
+ 0
+ primary
+ False
+ False
+
+
+ {1A31287A-4D7D-413E-8E32-3B374931BD89}
+ 8
+ 0
+ 0
+ primary
+ False
+ False
+
+
+ {2CE2370E-D744-4936-A090-3FFFE667B0E1}
+ 9
+ 0
+ 0
+ primary
+ False
+ False
+
+
+ {1CBA492E-7263-47BB-87FE-639000619B15}
+ 8
+ 0
+ 0
+ primary
+ False
+ False
+
+
+ {00020430-0000-0000-C000-000000000046}
+ 2
+ 0
+ 0
+ primary
+ False
+ False
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ true
+ VSPackage
+
+
+
+
+ Designer
+
+
+
+
+
+
+
+ Always
+ true
+
+
+ Always
+ true
+
+
+
+ true
+
+
+
+
+
\ No newline at end of file
diff --git a/RESW File Code Generator/VSPackage/VSPackage.resx b/RESW File Code Generator/VSPackage/VSPackage.resx
new file mode 100644
index 0000000..d21ca7f
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/VSPackage.resx
@@ -0,0 +1,140 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+ 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.
+
+
+ Resources\Package.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
\ No newline at end of file
diff --git a/RESW File Code Generator/VSPackage/VSPackagePackage.cs b/RESW File Code Generator/VSPackage/VSPackagePackage.cs
new file mode 100644
index 0000000..18a72be
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/VSPackagePackage.cs
@@ -0,0 +1,65 @@
+using ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool;
+using Microsoft.VisualStudio.Shell;
+using Microsoft.VisualStudio.Shell.Design.Serialization;
+using System.Diagnostics;
+using System.Globalization;
+using System.Runtime.InteropServices;
+
+namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage
+{
+ ///
+ /// This is the class that implements the package exposed by this assembly.
+ ///
+ /// The minimum requirement for a class to be considered a valid package for Visual Studio
+ /// is to implement the IVsPackage interface and register itself with the shell.
+ /// This package uses the helper classes defined inside the Managed Package Framework (MPF)
+ /// to do it: it derives from the Package class that provides the implementation of the
+ /// IVsPackage interface and uses the registration attributes defined in the framework to
+ /// register itself and its components with the shell.
+ ///
+ // This attribute tells the PkgDef creation utility (CreatePkgDef.exe) that this class is
+ // a package.
+ [PackageRegistration(UseManagedResourcesOnly = true)]
+ // This attribute is used to register the information needed to show this package
+ // in the Help/About dialog of Visual Studio.
+ [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
+ [Guid(GuidList.guidVSPackagePkgString)]
+ [DefaultRegistryRoot("Software\\Microsoft\\VisualStudio\\11.0")]
+ [ProvideObject(typeof(ReswFileCSharpCodeGenerator))]
+ [ProvideObject(typeof(ReswFileVisualBasicCodeGenerator))]
+ [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
+ public sealed class VSPackagePackage : Package
+ {
+ ///
+ /// Default constructor of the package.
+ /// Inside this method you can place any initialization code that does not require
+ /// any Visual Studio service because at this point the package object is created but
+ /// not sited yet inside Visual Studio environment. The place to do all the other
+ /// initialization is the Initialize method.
+ ///
+ public VSPackagePackage()
+ {
+ Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));
+ }
+
+
+
+ /////////////////////////////////////////////////////////////////////////////
+ // Overridden Package Implementation
+ #region Package Members
+
+ ///
+ /// Initialization of the package; this method is called right after the package is sited, so this is the place
+ /// where you can put all the initialization code that rely on services provided by VisualStudio.
+ ///
+ protected override void Initialize()
+ {
+ Debug.WriteLine (string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
+ base.Initialize();
+
+ }
+ #endregion
+
+ }
+}
diff --git a/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/IntegrationTest Library/DialogboxPurger.cs b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/IntegrationTest Library/DialogboxPurger.cs
new file mode 100644
index 0000000..90a014d
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/IntegrationTest Library/DialogboxPurger.cs
@@ -0,0 +1,359 @@
+
+namespace Microsoft.VsSDK.IntegrationTestLibrary
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Text;
+ using System.Runtime.InteropServices;
+ using System.Threading;
+ using Microsoft.VisualStudio.Shell.Interop;
+ using Microsoft.VisualStudio.Shell;
+
+ ///
+ /// This class is responsible to close dialog boxes that pop up during different VS Calls
+ ///
+ internal class DialogBoxPurger : IDisposable
+ {
+ ///
+ /// The default number of milliseconds to wait for the threads to signal to terminate.
+ ///
+ private const int DefaultMillisecondsToWait = 3500;
+
+ ///
+ /// Object used for synchronization between thread calls.
+ ///
+ internal static volatile object Mutex = new object();
+
+ ///
+ /// The IVsUIShell. This cannot be queried on the working thread from the service provider. Must be done in the main thread.!!
+ ///
+ private IVsUIShell uiShell;
+
+ ///
+ /// The button to "press" on the dialog.
+ ///
+ private int buttonAction;
+
+ ///
+ /// Thread signales to the calling thread that it is done.
+ ///
+ private bool exitThread = false;
+
+ ///
+ /// Calling thread signales to this thread to die.
+ ///
+ private AutoResetEvent threadDone = new AutoResetEvent(false);
+
+ ///
+ /// The queued thread started.
+ ///
+ private AutoResetEvent threadStarted = new AutoResetEvent(false);
+
+ ///
+ /// The result of the dialogbox closing for all the dialog boxes. That is if there are two of them and one fails this will be false.
+ ///
+ private bool dialogBoxCloseResult = false;
+
+ ///
+ /// The expected text to see on the dialog box. If set the thread will continue finding the dialog box with this text.
+ ///
+ private string expectedDialogBoxText = String.Empty;
+
+ ///
+ /// The number of the same dialog boxes to wait for.
+ /// This is for scenarios when two dialog boxes with the same text are popping up.
+ ///
+ private int numberOfDialogsToWaitFor = 1;
+
+ ///
+ /// Has the object been disposed.
+ ///
+ private bool isDisposed;
+
+ ///
+ /// Overloaded ctor.
+ ///
+ /// The botton to "press" on the dialog box.
+ /// The number of dialog boxes with the same message to wait for. This is the situation when the same action pops up two of the same dialog boxes
+ /// The expected dialog box message to check for.
+ internal DialogBoxPurger(int buttonAction, int numberOfDialogsToWaitFor, string expectedDialogMesssage)
+ {
+ this.buttonAction = buttonAction;
+ this.numberOfDialogsToWaitFor = numberOfDialogsToWaitFor;
+ this.expectedDialogBoxText = expectedDialogMesssage;
+ }
+
+ ///
+ /// Overloaded ctor.
+ ///
+ /// The botton to "press" on the dialog box.
+ /// The number of dialog boxes with the same message to wait for. This is the situation when the same action pops up two of the same dialog boxes
+ internal DialogBoxPurger(int buttonAction, int numberOfDialogsToWaitFor)
+ {
+ this.buttonAction = buttonAction;
+ this.numberOfDialogsToWaitFor = numberOfDialogsToWaitFor;
+ }
+
+ ///
+ /// Overloaded ctor.
+ ///
+ /// The botton to "press" on the dialog box.
+ /// The expected dialog box message to check for.
+ internal DialogBoxPurger(int buttonAction, string expectedDialogMesssage)
+ {
+ this.buttonAction = buttonAction;
+ this.expectedDialogBoxText = expectedDialogMesssage;
+ }
+
+ ///
+ /// Overloaded ctor.
+ ///
+ /// The botton to "press" on the dialog box.
+ internal DialogBoxPurger(int buttonAction)
+ {
+ this.buttonAction = buttonAction;
+ }
+
+ ///
+ #region IDisposable Members
+
+ void IDisposable.Dispose()
+ {
+ if (this.isDisposed)
+ {
+ return;
+ }
+
+ this.WaitForDialogThreadToTerminate();
+
+ this.isDisposed = true;
+ }
+
+ ///
+ /// Spawns a thread that will start listening to dialog boxes.
+ ///
+ internal void Start()
+ {
+ // We ask for the uishell here since we cannot do that on the therad that we will spawn.
+ IVsUIShell uiShell = Package.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell;
+
+ if (uiShell == null)
+ {
+ throw new InvalidOperationException("Could not get the uiShell from the serviceProvider");
+ }
+
+ this.uiShell = uiShell;
+
+ System.Threading.Thread thread = new System.Threading.Thread(new ThreadStart(this.HandleDialogBoxes));
+ thread.Start();
+
+ // We should never deadlock here, hence do not use the lock. Wait to be sure that the thread started.
+ this.threadStarted.WaitOne(3500, false);
+ }
+
+ ///
+ /// Waits for the dialog box close thread to terminate. If the thread does not signal back within millisecondsToWait that it is shutting down,
+ /// then it will tell to the thread to do it.
+ ///
+ internal bool WaitForDialogThreadToTerminate()
+ {
+ return this.WaitForDialogThreadToTerminate(DefaultMillisecondsToWait);
+ }
+
+ ///
+ /// Waits for the dialog box close thread to terminate. If the thread does not signal back within millisecondsToWait that it is shutting down,
+ /// then it will tell to the thread to do it.
+ ///
+ /// The number milliseconds to wait for until the dialog purger thread is signaled to terminate. This is just for safe precaution that we do not hang.
+ /// The result of the dialog boxes closing
+ internal bool WaitForDialogThreadToTerminate(int numberOfMillisecondsToWait)
+ {
+ bool signaled = false;
+
+ // We give millisecondsToWait sec to bring up and close the dialog box.
+ signaled = this.threadDone.WaitOne(numberOfMillisecondsToWait, false);
+
+ // Kill the thread since a timeout occured.
+ if (!signaled)
+ {
+ lock (Mutex)
+ {
+ // Set the exit thread to true. Next time the thread will kill itselfes if it sees
+ this.exitThread = true;
+ }
+
+ // Wait for the thread to finish. We should never deadlock here.
+ this.threadDone.WaitOne();
+ }
+
+ return this.dialogBoxCloseResult;
+ }
+
+ ///
+ /// This is the thread method.
+ ///
+ private void HandleDialogBoxes()
+ {
+ // No synchronization numberOfDialogsToWaitFor since it is readonly
+ IntPtr[] hwnds = new IntPtr[this.numberOfDialogsToWaitFor];
+ bool[] dialogBoxCloseResults = new bool[this.numberOfDialogsToWaitFor];
+
+ try
+ {
+ // Signal that we started
+ lock (Mutex)
+ {
+ this.threadStarted.Set();
+ }
+
+ // The loop will be exited either if a message is send by the caller thread or if we found the dialog. If a message box text is specified the loop will not exit until the dialog is found.
+ bool stayInLoop = true;
+ int dialogBoxesToWaitFor = 1;
+
+ while (stayInLoop)
+ {
+ int hwndIndex = dialogBoxesToWaitFor - 1;
+
+ // We need to lock since the caller might set context to null.
+ lock (Mutex)
+ {
+ if (this.exitThread)
+ {
+ break;
+ }
+
+ // We protect the shell too from reentrency.
+ this.uiShell.GetDialogOwnerHwnd(out hwnds[hwndIndex]);
+
+ }
+
+ if (hwnds[hwndIndex] != IntPtr.Zero)
+ {
+ StringBuilder windowClassName = new StringBuilder(256);
+ NativeMethods.GetClassName(hwnds[hwndIndex], windowClassName, windowClassName.Capacity);
+
+ // The #32770 is the class name of a messagebox dialog.
+ if (windowClassName.ToString().Contains("#32770"))
+ {
+ IntPtr unmanagedMemoryLocation = IntPtr.Zero;
+ string dialogBoxText = String.Empty;
+ try
+ {
+ unmanagedMemoryLocation = Marshal.AllocHGlobal(10 * 1024);
+ NativeMethods.EnumChildWindows(hwnds[hwndIndex], new NativeMethods.CallBack(FindMessageBoxString), unmanagedMemoryLocation);
+ dialogBoxText = Marshal.PtrToStringUni(unmanagedMemoryLocation);
+ }
+ finally
+ {
+ if (unmanagedMemoryLocation != IntPtr.Zero)
+ {
+ Marshal.FreeHGlobal(unmanagedMemoryLocation);
+ }
+ }
+
+ lock (Mutex)
+ {
+
+ // Since this is running on the main thread be sure that we close the dialog.
+ bool dialogCloseResult = false;
+ if (this.buttonAction != 0)
+ {
+ dialogCloseResult = NativeMethods.EndDialog(hwnds[hwndIndex], this.buttonAction);
+ }
+
+ // Check if we have found the right dialog box.
+ if (String.IsNullOrEmpty(this.expectedDialogBoxText) || (!String.IsNullOrEmpty(dialogBoxText) && String.Compare(this.expectedDialogBoxText, dialogBoxText.Trim(), StringComparison.OrdinalIgnoreCase) == 0))
+ {
+ dialogBoxCloseResults[hwndIndex] = dialogCloseResult;
+ if (dialogBoxesToWaitFor++ >= this.numberOfDialogsToWaitFor)
+ {
+ stayInLoop = false;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ finally
+ {
+ //Let the main thread run a possible close command.
+ System.Threading.Thread.Sleep(2000);
+
+ foreach (IntPtr hwnd in hwnds)
+ {
+ // At this point the dialog should be closed, if not attempt to close it.
+ if (hwnd != IntPtr.Zero)
+ {
+ NativeMethods.SendMessage(hwnd, NativeMethods.WM_CLOSE, 0, new IntPtr(0));
+ }
+ }
+
+ lock (Mutex)
+ {
+ // Be optimistic.
+ this.dialogBoxCloseResult = true;
+
+ for (int i = 0; i < dialogBoxCloseResults.Length; i++)
+ {
+ if (!dialogBoxCloseResults[i])
+ {
+ this.dialogBoxCloseResult = false;
+ break;
+ }
+ }
+
+ this.threadDone.Set();
+ }
+ }
+ }
+
+ ///
+ /// Finds a messagebox string on a messagebox.
+ ///
+ /// The windows handle of the dialog
+ /// A pointer to the memorylocation the string will be written to
+ /// True if found.
+ private static bool FindMessageBoxString(IntPtr hwnd, IntPtr unmanagedMemoryLocation)
+ {
+ StringBuilder sb = new StringBuilder(512);
+ NativeMethods.GetClassName(hwnd, sb, sb.Capacity);
+
+ if (sb.ToString().ToLower().Contains("static"))
+ {
+ StringBuilder windowText = new StringBuilder(2048);
+ NativeMethods.GetWindowText(hwnd, windowText, windowText.Capacity);
+
+ if (windowText.Length > 0)
+ {
+ IntPtr stringAsPtr = IntPtr.Zero;
+ try
+ {
+ stringAsPtr = Marshal.StringToHGlobalAnsi(windowText.ToString());
+ char[] stringAsArray = windowText.ToString().ToCharArray();
+
+ // Since unicode characters are copied check if we are out of the allocated length.
+ // If not add the end terminating zero.
+ if ((2 * stringAsArray.Length) + 1 < 2048)
+ {
+ Marshal.Copy(stringAsArray, 0, unmanagedMemoryLocation, stringAsArray.Length);
+ Marshal.WriteInt32(unmanagedMemoryLocation, 2 * stringAsArray.Length, 0);
+ }
+ }
+ finally
+ {
+ if (stringAsPtr != IntPtr.Zero)
+ {
+ Marshal.FreeHGlobal(stringAsPtr);
+ }
+ }
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ #endregion
+ }
+}
diff --git a/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/IntegrationTest Library/NativeMethods.cs b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/IntegrationTest Library/NativeMethods.cs
new file mode 100644
index 0000000..b7ec12f
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/IntegrationTest Library/NativeMethods.cs
@@ -0,0 +1,154 @@
+/***************************************************************************
+
+Copyright (c) Microsoft Corporation. All rights reserved.
+This code is licensed under the Visual Studio SDK license terms.
+THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
+
+***************************************************************************/
+
+namespace Microsoft.VsSDK.IntegrationTestLibrary
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Text;
+ using System.Runtime.InteropServices;
+ using System.Threading;
+ using Microsoft.VisualStudio.Shell.Interop;
+
+ ///
+ /// Defines pinvoked utility methods and internal VS Constants
+ ///
+ internal static class NativeMethods
+ {
+ internal delegate bool CallBack(IntPtr hwnd, IntPtr lParam);
+
+ // Declare two overloaded SendMessage functions
+ [DllImport("user32.dll")]
+ internal static extern UInt32 SendMessage(IntPtr hWnd, UInt32 Msg,
+ UInt32 wParam, IntPtr lParam);
+
+ [DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ internal static extern bool PeekMessage([In, Out] ref Microsoft.VisualStudio.OLE.Interop.MSG msg, HandleRef hwnd, int msgMin, int msgMax, int remove);
+
+ [DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ internal static extern bool TranslateMessage([In, Out] ref Microsoft.VisualStudio.OLE.Interop.MSG msg);
+
+ [DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ internal static extern int DispatchMessage([In] ref Microsoft.VisualStudio.OLE.Interop.MSG msg);
+
+ [DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ internal static extern bool AttachThreadInput(uint idAttach, uint idAttachTo, bool attach);
+
+ [DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ internal static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
+
+ [DllImport("kernel32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ internal static extern uint GetCurrentThreadId();
+
+ [DllImport("user32")]
+ internal static extern int EnumChildWindows(IntPtr hwnd, CallBack x, IntPtr y);
+
+ [DllImport("user32")]
+ internal static extern bool IsWindowVisible(IntPtr hDlg);
+
+ [DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ internal static extern IntPtr SetFocus(IntPtr hWnd);
+
+ [DllImport("user32")]
+ internal static extern int GetClassName(IntPtr hWnd,
+ StringBuilder className,
+ int stringLength);
+ [DllImport("user32")]
+ internal static extern int GetWindowText(IntPtr hWnd, StringBuilder className, int stringLength);
+
+
+ [DllImport("user32")]
+ internal static extern bool EndDialog(IntPtr hDlg, int result);
+
+ [DllImport("Kernel32")]
+ internal static extern long GetLastError();
+
+ internal const int QS_KEY = 0x0001,
+ QS_MOUSEMOVE = 0x0002,
+ QS_MOUSEBUTTON = 0x0004,
+ QS_POSTMESSAGE = 0x0008,
+ QS_TIMER = 0x0010,
+ QS_PAINT = 0x0020,
+ QS_SENDMESSAGE = 0x0040,
+ QS_HOTKEY = 0x0080,
+ QS_ALLPOSTMESSAGE = 0x0100,
+ QS_MOUSE = QS_MOUSEMOVE | QS_MOUSEBUTTON,
+ QS_INPUT = QS_MOUSE | QS_KEY,
+ QS_ALLEVENTS = QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY,
+ QS_ALLINPUT = QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY | QS_SENDMESSAGE;
+
+ internal const int Facility_Win32 = 7;
+
+ internal const int WM_CLOSE = 0x0010;
+
+ internal const int
+ S_FALSE = 0x00000001,
+ S_OK = 0x00000000,
+
+ IDOK = 1,
+ IDCANCEL = 2,
+ IDABORT = 3,
+ IDRETRY = 4,
+ IDIGNORE = 5,
+ IDYES = 6,
+ IDNO = 7,
+ IDCLOSE = 8,
+ IDHELP = 9,
+ IDTRYAGAIN = 10,
+ IDCONTINUE = 11;
+
+ internal static long HResultFromWin32(long error)
+ {
+ if (error <= 0)
+ {
+ return error;
+ }
+
+ return ((error & 0x0000FFFF) | (Facility_Win32 << 16) | 0x80000000);
+ }
+
+ ///
+ /// Please use this "approved" method to compare file names.
+ ///
+ public static bool IsSamePath(string file1, string file2)
+ {
+ if (file1 == null || file1.Length == 0)
+ {
+ return (file2 == null || file2.Length == 0);
+ }
+
+ Uri uri1 = null;
+ Uri uri2 = null;
+
+ try
+ {
+ if (!Uri.TryCreate(file1, UriKind.Absolute, out uri1) || !Uri.TryCreate(file2, UriKind.Absolute, out uri2))
+ {
+ return false;
+ }
+
+ if (uri1 != null && uri1.IsFile && uri2 != null && uri2.IsFile)
+ {
+ return 0 == String.Compare(uri1.LocalPath, uri2.LocalPath, StringComparison.OrdinalIgnoreCase);
+ }
+
+ return file1 == file2;
+ }
+ catch (UriFormatException e)
+ {
+ System.Diagnostics.Trace.WriteLine("Exception " + e.Message);
+ }
+
+ return false;
+ }
+
+ }
+}
diff --git a/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/IntegrationTest Library/Utils.cs b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/IntegrationTest Library/Utils.cs
new file mode 100644
index 0000000..0ea4c62
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/IntegrationTest Library/Utils.cs
@@ -0,0 +1,401 @@
+using System;
+using System.IO;
+using System.Text;
+using System.Reflection;
+using System.Diagnostics;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel.Design;
+using System.Runtime.InteropServices;
+using Microsoft.VisualStudio.Shell.Interop;
+using Microsoft.VisualStudio.Shell;
+using EnvDTE;
+using EnvDTE80;
+using Microsoft.Win32;
+using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Microsoft.VSSDK.Tools.VsIdeTesting;
+using Microsoft.VisualStudio;
+
+namespace Microsoft.VsSDK.IntegrationTestLibrary
+{
+ ///
+ ///
+ public class TestUtils
+ {
+
+ #region Methods: Handling embedded resources
+ ///
+ /// Gets the embedded file identified by the resource name, and converts the
+ /// file into a string.
+ ///
+ /// In VS, is DefaultNamespace.FileName?
+ ///
+ public static string GetEmbeddedStringResource(Assembly assembly, string resourceName)
+ {
+ string result = null;
+
+ // Use the .NET procedure for loading a file embedded in the assembly
+ Stream stream = assembly.GetManifestResourceStream(resourceName);
+ if (stream != null)
+ {
+ // Convert bytes to string
+ byte[] fileContentsAsBytes = new byte[stream.Length];
+ stream.Read(fileContentsAsBytes, 0, (int)stream.Length);
+ result = Encoding.Default.GetString(fileContentsAsBytes);
+ }
+ else
+ {
+ // Embedded resource not found - list available resources
+ Debug.WriteLine("Unable to find the embedded resource file '" + resourceName + "'.");
+ Debug.WriteLine(" Available resources:");
+ foreach (string aResourceName in assembly.GetManifestResourceNames())
+ {
+ Debug.WriteLine(" " + aResourceName);
+ }
+ }
+
+ return result;
+ }
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static void WriteEmbeddedResourceToFile(Assembly assembly, string embeddedResourceName, string fileName)
+ {
+ // Get file contents
+ string fileContents = GetEmbeddedStringResource(assembly, embeddedResourceName);
+ if (fileContents == null)
+ throw new ApplicationException("Failed to get embedded resource '" + embeddedResourceName + "' from assembly '" + assembly.FullName);
+
+ // Write to file
+ StreamWriter sw = new StreamWriter(fileName);
+ sw.Write(fileContents);
+ sw.Close();
+ }
+
+ ///
+ /// Writes an embedded resource to a file.
+ ///
+ /// The name of the assembly that the embedded resource is defined.
+ /// The name of the embedded resource.
+ /// The file to write the embedded resource's content.
+ public static void WriteEmbeddedResourceToBinaryFile(Assembly assembly, string embeddedResourceName, string fileName)
+ {
+ // Get file contents
+ Stream stream = assembly.GetManifestResourceStream(embeddedResourceName);
+ if (stream == null)
+ throw new InvalidOperationException("Failed to get embedded resource '" + embeddedResourceName + "' from assembly '" + assembly.FullName);
+
+ // Write to file
+ BinaryWriter sw = null;
+ FileStream fs = null;
+ try
+ {
+ byte[] fileContentsAsBytes = new byte[stream.Length];
+ stream.Read(fileContentsAsBytes, 0, (int)stream.Length);
+
+ FileMode mode = FileMode.CreateNew;
+ if (File.Exists(fileName))
+ {
+ mode = FileMode.Truncate;
+ }
+
+ fs = new FileStream(fileName, mode);
+
+ sw = new BinaryWriter(fs);
+ sw.Write(fileContentsAsBytes);
+ }
+ finally
+ {
+ if (fs != null)
+ {
+ fs.Close();
+ }
+ if (sw != null)
+ {
+ sw.Close();
+ }
+ }
+ }
+
+ #endregion
+
+ #region Methods: Handling temporary files and directories
+ ///
+ /// Returns the first available file name on the form
+ /// [baseFileName]i.[extension]
+ /// where [i] starts at 1 and increases until there is an available file name
+ /// in the given directory. Also creates an empty file with that name to mark
+ /// that file as occupied.
+ ///
+ /// Directory that the file should live in.
+ ///
+ /// may be null, in which case the .[extension] part
+ /// is not added.
+ /// Full file name.
+ public static string GetNewFileName(string directory, string baseFileName, string extension)
+ {
+ // Get the new file name
+ string fileName = GetNewFileOrDirectoryNameWithoutCreatingAnything(directory, baseFileName, extension);
+
+ // Create an empty file to mark it as taken
+ StreamWriter sw = new StreamWriter(fileName);
+
+ sw.Write("");
+ sw.Close();
+ return fileName;
+ }
+ ///
+ /// Returns the first available directory name on the form
+ /// [baseDirectoryName]i
+ /// where [i] starts at 1 and increases until there is an available directory name
+ /// in the given directory. Also creates the directory to mark it as occupied.
+ ///
+ /// Directory that the file should live in.
+ ///
+ /// Full directory name.
+ public static string GetNewDirectoryName(string directory, string baseDirectoryName)
+ {
+ // Get the new file name
+ string directoryName = GetNewFileOrDirectoryNameWithoutCreatingAnything(directory, baseDirectoryName, null);
+
+ // Create an empty directory to make it as occupied
+ Directory.CreateDirectory(directoryName);
+
+ return directoryName;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private static string GetNewFileOrDirectoryNameWithoutCreatingAnything(string directory, string baseFileName, string extension)
+ {
+ // - get a file name that we can use
+ string fileName;
+ int i = 1;
+
+ string fullFileName = null;
+ while (true)
+ {
+ // construct next file name
+ fileName = baseFileName + i;
+ if (extension != null)
+ fileName += '.' + extension;
+
+ // check if that file exists in the directory
+ fullFileName = Path.Combine(directory, fileName);
+
+ if (!File.Exists(fullFileName) && !Directory.Exists(fullFileName))
+ break;
+ else
+ i++;
+ }
+
+ return fullFileName;
+ }
+ #endregion
+
+ #region Methods: Handling solutions
+ ///
+ /// Closes the currently open solution (if any), and creates a new solution with the given name.
+ ///
+ /// Name of new solution.
+ public void CreateEmptySolution(string directory, string solutionName)
+ {
+ CloseCurrentSolution(__VSSLNSAVEOPTIONS.SLNSAVEOPT_NoSave);
+
+ string solutionDirectory = GetNewDirectoryName(directory, solutionName);
+
+ // Create and force save solution
+ IVsSolution solutionService = (IVsSolution)VsIdeTestHostContext.ServiceProvider.GetService(typeof(IVsSolution));
+ solutionService.CreateSolution(solutionDirectory, solutionName, (uint)__VSCREATESOLUTIONFLAGS.CSF_SILENT);
+ solutionService.SaveSolutionElement((uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_ForceSave, null, 0);
+ DTE dte = VsIdeTestHostContext.Dte;
+ Assert.AreEqual(solutionName + ".sln", Path.GetFileName(dte.Solution.FileName), "Newly created solution has wrong Filename");
+ }
+
+ public void CloseCurrentSolution(__VSSLNSAVEOPTIONS saveoptions)
+ {
+ // Get solution service
+ IVsSolution solutionService = (IVsSolution)VsIdeTestHostContext.ServiceProvider.GetService(typeof(IVsSolution));
+
+ // Close already open solution
+ solutionService.CloseSolutionElement((uint)saveoptions, null, 0);
+ }
+
+ public void ForceSaveSolution()
+ {
+ // Get solution service
+ IVsSolution solutionService = (IVsSolution)VsIdeTestHostContext.ServiceProvider.GetService(typeof(IVsSolution));
+
+ // Force-save the solution
+ solutionService.SaveSolutionElement((uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_ForceSave, null, 0);
+ }
+
+ ///
+ /// Get current number of open project in solution
+ ///
+ ///
+ public int ProjectCount()
+ {
+ // Get solution service
+ IVsSolution solutionService = (IVsSolution)VsIdeTestHostContext.ServiceProvider.GetService(typeof(IVsSolution));
+ object projectCount;
+ solutionService.GetProperty((int)__VSPROPID.VSPROPID_ProjectCount, out projectCount);
+ return (int)projectCount;
+ }
+ #endregion
+
+ #region Methods: Handling projects
+ ///
+ /// Creates a project.
+ ///
+ /// Name of new project.
+ /// Name of project template to use
+ /// language
+ /// New project.
+ public void CreateProjectFromTemplate(string projectName, string templateName, string language, bool exclusive)
+ {
+ DTE dte = (DTE)VsIdeTestHostContext.ServiceProvider.GetService(typeof(DTE));
+
+ Solution2 sol = dte.Solution as Solution2;
+ string projectTemplate = sol.GetProjectTemplate(templateName, language);
+
+ // - project name and directory
+ string solutionDirectory = Directory.GetParent(dte.Solution.FullName).FullName;
+ string projectDirectory = GetNewDirectoryName(solutionDirectory, projectName);
+
+ dte.Solution.AddFromTemplate(projectTemplate, projectDirectory, projectName, false);
+ }
+ #endregion
+
+ #region Methods: Handling project items
+ ///
+ /// Create a new item in the project
+ ///
+ /// the parent collection for the new item
+ ///
+ ///
+ ///
+ ///
+ public ProjectItem AddNewItemFromVsTemplate(ProjectItems parent, string templateName, string language, string name)
+ {
+ if (parent == null)
+ throw new ArgumentException("project");
+ if (name == null)
+ throw new ArgumentException("name");
+
+ DTE dte = (DTE)VsIdeTestHostContext.ServiceProvider.GetService(typeof(DTE));
+
+ Solution2 sol = dte.Solution as Solution2;
+
+ string filename = sol.GetProjectItemTemplate(templateName, language);
+
+ parent.AddFromTemplate(filename, name);
+
+ return parent.Item(name);
+ }
+
+ ///
+ /// Save an open document.
+ ///
+ /// for filebased documents this is the full path to the document
+ public void SaveDocument(string documentMoniker)
+ {
+ // Get document cookie and hierarchy for the file
+ IVsRunningDocumentTable runningDocumentTableService = (IVsRunningDocumentTable)VsIdeTestHostContext.ServiceProvider.GetService(typeof(IVsRunningDocumentTable));
+ uint docCookie;
+ IntPtr docData;
+ IVsHierarchy hierarchy;
+ uint itemId;
+ runningDocumentTableService.FindAndLockDocument(
+ (uint)Microsoft.VisualStudio.Shell.Interop._VSRDTFLAGS.RDT_NoLock,
+ documentMoniker,
+ out hierarchy,
+ out itemId,
+ out docData,
+ out docCookie);
+
+ // Save the document
+ IVsSolution solutionService = (IVsSolution)VsIdeTestHostContext.ServiceProvider.GetService(typeof(IVsSolution));
+ solutionService.SaveSolutionElement((uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_ForceSave, hierarchy, docCookie);
+ }
+
+ public void CloseInEditorWithoutSaving(string fullFileName)
+ {
+ // Get the RDT service
+ IVsRunningDocumentTable runningDocumentTableService = (IVsRunningDocumentTable)VsIdeTestHostContext.ServiceProvider.GetService(typeof(IVsRunningDocumentTable));
+ Assert.IsNotNull(runningDocumentTableService, "Failed to get the Running Document Table Service");
+
+ // Get our document cookie and hierarchy for the file
+ uint docCookie;
+ IntPtr docData;
+ IVsHierarchy hierarchy;
+ uint itemId;
+ runningDocumentTableService.FindAndLockDocument(
+ (uint)Microsoft.VisualStudio.Shell.Interop._VSRDTFLAGS.RDT_NoLock,
+ fullFileName,
+ out hierarchy,
+ out itemId,
+ out docData,
+ out docCookie);
+
+ // Get the SolutionService
+ IVsSolution solutionService = VsIdeTestHostContext.ServiceProvider.GetService(typeof(IVsSolution)) as IVsSolution;
+ Assert.IsNotNull(solutionService, "Failed to get IVsSolution service");
+
+ // Close the document
+ solutionService.CloseSolutionElement(
+ (uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_NoSave,
+ hierarchy,
+ docCookie);
+ }
+ #endregion
+
+ #region Methods: Handling Toolwindows
+ public bool CanFindToolwindow(Guid persistenceGuid)
+ {
+ IVsUIShell uiShellService = VsIdeTestHostContext.ServiceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell;
+ Assert.IsNotNull(uiShellService);
+ IVsWindowFrame windowFrame;
+ int hr = uiShellService.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fFindFirst, ref persistenceGuid, out windowFrame);
+ Assert.IsTrue(hr == VSConstants.S_OK);
+
+ return (windowFrame != null);
+ }
+ #endregion
+
+ #region Methods: Loading packages
+ public IVsPackage LoadPackage(Guid packageGuid)
+ {
+ IVsShell shellService = (IVsShell)VsIdeTestHostContext.ServiceProvider.GetService(typeof(SVsShell));
+ IVsPackage package;
+ shellService.LoadPackage(ref packageGuid, out package);
+ Assert.IsNotNull(package, "Failed to load package");
+ return package;
+ }
+ #endregion
+
+ ///
+ /// Executes a Command (menu item) in the given context
+ ///
+ public void ExecuteCommand(CommandID cmd)
+ {
+ object Customin = null;
+ object Customout = null;
+ string guidString = cmd.Guid.ToString("B").ToUpper();
+ int cmdId = cmd.ID;
+ DTE dte = VsIdeTestHostContext.Dte;
+ dte.Commands.Raise(guidString, cmdId, ref Customin, ref Customout);
+ }
+
+ }
+}
diff --git a/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/Key.snk b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/Key.snk
new file mode 100644
index 0000000..82ea2e0
Binary files /dev/null and b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/Key.snk differ
diff --git a/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/PackageTest.cs b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/PackageTest.cs
new file mode 100644
index 0000000..0afd317
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/PackageTest.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Text;
+using System.Collections.Generic;
+using System.Linq;
+using ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Microsoft.VSSDK.Tools.VsIdeTesting;
+using Microsoft.VisualStudio.Shell.Interop;
+using Microsoft.VisualStudio.Shell;
+using EnvDTE;
+
+namespace VSPackage_IntegrationTests
+{
+ ///
+ /// Integration test for package validation
+ ///
+ [TestClass]
+ public class PackageTest
+ {
+ private delegate void ThreadInvoker();
+
+ private TestContext testContextInstance;
+
+ ///
+ ///Gets or sets the test context which provides
+ ///information about and functionality for the current test run.
+ ///
+ public TestContext TestContext
+ {
+ get
+ {
+ return testContextInstance;
+ }
+ set
+ {
+ testContextInstance = value;
+ }
+ }
+
+ [TestMethod]
+ [HostType("VS IDE")]
+ public void PackageLoadTest()
+ {
+ UIThreadInvoker.Invoke((ThreadInvoker)delegate()
+ {
+
+ //Get the Shell Service
+ IVsShell shellService = VsIdeTestHostContext.ServiceProvider.GetService(typeof(SVsShell)) as IVsShell;
+ Assert.IsNotNull(shellService);
+
+ //Validate package load
+ IVsPackage package;
+ Guid packageGuid = new Guid(GuidList.guidVSPackagePkgString);
+ Assert.IsTrue(0 == shellService.LoadPackage(ref packageGuid, out package));
+ Assert.IsNotNull(package, "Package failed to load");
+
+ });
+ }
+ }
+}
diff --git a/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/SignOff-Tests/CPPProjectTests.cs b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/SignOff-Tests/CPPProjectTests.cs
new file mode 100644
index 0000000..1ee1f5b
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/SignOff-Tests/CPPProjectTests.cs
@@ -0,0 +1,109 @@
+using System;
+using System.Text;
+using System.Collections.Generic;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Microsoft.VsSDK.IntegrationTestLibrary;
+using Microsoft.VSSDK.Tools.VsIdeTesting;
+using EnvDTE;
+using System.IO;
+
+namespace VSPackage_IntegrationTests.IntegrationTests
+{
+ [TestClass]
+ public class CPPProjectTests
+ {
+ #region fields
+ private delegate void ThreadInvoker();
+ private TestContext _testContext;
+ #endregion
+
+ #region properties
+ ///
+ ///Gets or sets the test context which provides
+ ///information about and functionality for the current test run.
+ ///
+ public TestContext TestContext
+ {
+ get { return _testContext; }
+ set { _testContext = value; }
+ }
+ #endregion
+
+ #region ctors
+ public CPPProjectTests()
+ {
+ }
+ #endregion
+
+ #region Additional test attributes
+ //
+ // You can use the following additional attributes as you write your tests:
+ //
+ // Use ClassInitialize to run code before running the first test in the class
+ // [ClassInitialize()]
+ // public static void MyClassInitialize(TestContext testContext) { }
+ //
+ // Use ClassCleanup to run code after all tests in a class have run
+ // [ClassCleanup()]
+ // public static void MyClassCleanup() { }
+ //
+ // Use TestInitialize to run code before running each test
+ // [TestInitialize()]
+ // public void MyTestInitialize() { }
+ //
+ // Use TestCleanup to run code after each test has run
+ // [TestCleanup()]
+ // public void MyTestCleanup() { }
+ //
+ #endregion
+
+ [HostType("VS IDE")]
+ [TestMethod]
+ public void CPPWinformsApplication()
+ {
+ UIThreadInvoker.Invoke((ThreadInvoker)delegate()
+ {
+ //Solution and project creation parameters
+ string solutionName = "CPPWinApp";
+ string projectName = "CPPWinApp";
+
+ //Template parameters
+ string projectType = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}";
+ string projectTemplateName = Path.Combine("vcNet", "mc++appwiz.vsz");
+
+ string itemTemplateName = "newc++file.cpp";
+ string newFileName = "Test.cpp";
+
+ DTE dte = (DTE)VsIdeTestHostContext.ServiceProvider.GetService(typeof(DTE));
+
+ TestUtils testUtils = new TestUtils();
+
+ testUtils.CreateEmptySolution(TestContext.TestDir, solutionName);
+ Assert.AreEqual(0, testUtils.ProjectCount());
+
+ //Add new CPP Windows application project to existing solution
+ string solutionDirectory = Directory.GetParent(dte.Solution.FullName).FullName;
+ string projectDirectory = TestUtils.GetNewDirectoryName(solutionDirectory, projectName);
+ string projectTemplatePath = Path.Combine(dte.Solution.get_TemplatePath(projectType), projectTemplateName);
+ Assert.IsTrue(File.Exists(projectTemplatePath), string.Format("Could not find template file: {0}", projectTemplatePath));
+ dte.Solution.AddFromTemplate(projectTemplatePath, projectDirectory, projectName, false);
+
+ //Verify that the new project has been added to the solution
+ Assert.AreEqual(1, testUtils.ProjectCount());
+
+ //Get the project
+ Project project = dte.Solution.Item(1);
+ Assert.IsNotNull(project);
+ Assert.IsTrue(string.Compare(project.Name, projectName, StringComparison.InvariantCultureIgnoreCase) == 0);
+
+ //Verify Adding new code file to project
+ string newItemTemplatePath = Path.Combine(dte.Solution.ProjectItemsTemplatePath(projectType), itemTemplateName);
+ Assert.IsTrue(File.Exists(newItemTemplatePath));
+ ProjectItem item = project.ProjectItems.AddFromTemplate(newItemTemplatePath, newFileName);
+ Assert.IsNotNull(item);
+
+ });
+ }
+
+ }
+}
diff --git a/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/SignOff-Tests/CSharpProjectTests.cs b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/SignOff-Tests/CSharpProjectTests.cs
new file mode 100644
index 0000000..e2d4d47
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/SignOff-Tests/CSharpProjectTests.cs
@@ -0,0 +1,83 @@
+using System;
+using System.Text;
+using System.Collections.Generic;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Microsoft.VsSDK.IntegrationTestLibrary;
+using Microsoft.VSSDK.Tools.VsIdeTesting;
+
+namespace VSPackage_IntegrationTests.IntegrationTests
+{
+ [TestClass]
+ public class CSharpProjectTests
+ {
+ #region fields
+ private delegate void ThreadInvoker();
+ private TestContext _testContext;
+ #endregion
+
+ #region properties
+ ///
+ ///Gets or sets the test context which provides
+ ///information about and functionality for the current test run.
+ ///
+ public TestContext TestContext
+ {
+ get { return _testContext; }
+ set { _testContext = value; }
+ }
+ #endregion
+
+ #region ctors
+ public CSharpProjectTests()
+ {
+ }
+ #endregion
+
+ #region Additional test attributes
+ //
+ // You can use the following additional attributes as you write your tests:
+ //
+ // Use ClassInitialize to run code before running the first test in the class
+ // [ClassInitialize()]
+ // public static void MyClassInitialize(TestContext testContext) { }
+ //
+ // Use ClassCleanup to run code after all tests in a class have run
+ // [ClassCleanup()]
+ // public static void MyClassCleanup() { }
+ //
+ // Use TestInitialize to run code before running each test
+ // [TestInitialize()]
+ // public void MyTestInitialize() { }
+ //
+ // Use TestCleanup to run code after each test has run
+ // [TestCleanup()]
+ // public void MyTestCleanup() { }
+ //
+ #endregion
+
+ [TestMethod]
+ [HostType("VS IDE")]
+ public void WinformsApplication()
+ {
+ UIThreadInvoker.Invoke((ThreadInvoker)delegate()
+ {
+ TestUtils testUtils = new TestUtils();
+
+ testUtils.CreateEmptySolution(TestContext.TestDir, "CSWinApp");
+ Assert.AreEqual(0, testUtils.ProjectCount());
+
+ //Create Winforms application project
+ //TestUtils.CreateProjectFromTemplate("MyWindowsApp", "Windows Application", "CSharp", false);
+ //Assert.AreEqual(1, TestUtils.ProjectCount());
+
+ //TODO Verify that we can debug launch the application
+
+ //TODO Set Break point and verify that will hit
+
+ //TODO Verify Adding new project item to project
+
+ });
+ }
+
+ }
+}
diff --git a/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/SignOff-Tests/SolutionTests.cs b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/SignOff-Tests/SolutionTests.cs
new file mode 100644
index 0000000..20828da
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/SignOff-Tests/SolutionTests.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Text;
+using System.Collections.Generic;
+using Microsoft.VisualStudio.Shell.Interop;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Microsoft.VSSDK.Tools.VsIdeTesting;
+using EnvDTE;
+using System.IO;
+using Microsoft.VsSDK.IntegrationTestLibrary;
+
+
+namespace VSPackage_IntegrationTests.IntegrationTests
+{
+ [TestClass]
+ public class SolutionTests
+ {
+ #region fields
+ private delegate void ThreadInvoker();
+ private TestContext _testContext;
+ #endregion
+
+ #region properties
+ ///
+ ///Gets or sets the test context which provides
+ ///information about and functionality for the current test run.
+ ///
+ public TestContext TestContext
+ {
+ get { return _testContext; }
+ set { _testContext = value; }
+ }
+ #endregion
+
+
+ #region ctors
+ public SolutionTests()
+ {
+ }
+
+ #endregion
+
+ [TestMethod]
+ [HostType("VS IDE")]
+ public void CreateEmptySolution()
+ {
+ UIThreadInvoker.Invoke((ThreadInvoker)delegate()
+ {
+ TestUtils testUtils = new TestUtils();
+ testUtils.CloseCurrentSolution(__VSSLNSAVEOPTIONS.SLNSAVEOPT_NoSave);
+ testUtils.CreateEmptySolution(TestContext.TestDir, "EmptySolution");
+ });
+ }
+
+ }
+}
diff --git a/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/SignOff-Tests/VBProjectTests.cs b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/SignOff-Tests/VBProjectTests.cs
new file mode 100644
index 0000000..5598ab7
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/SignOff-Tests/VBProjectTests.cs
@@ -0,0 +1,101 @@
+using System;
+using System.Text;
+using System.Collections.Generic;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Microsoft.VsSDK.IntegrationTestLibrary;
+using Microsoft.VSSDK.Tools.VsIdeTesting;
+using EnvDTE;
+
+namespace VSPackage_IntegrationTests.IntegrationTests
+{
+ [TestClass]
+ public class VisualBasicProjectTests
+ {
+ #region fields
+ private delegate void ThreadInvoker();
+ private TestContext _testContext;
+ #endregion
+
+ #region properties
+ ///
+ ///Gets or sets the test context which provides
+ ///information about and functionality for the current test run.
+ ///
+ public TestContext TestContext
+ {
+ get { return _testContext; }
+ set { _testContext = value; }
+ }
+ #endregion
+
+ #region ctors
+ public VisualBasicProjectTests()
+ {
+ }
+ #endregion
+
+ #region Additional test attributes
+ //
+ // You can use the following additional attributes as you write your tests:
+ //
+ // Use ClassInitialize to run code before running the first test in the class
+ // [ClassInitialize()]
+ // public static void MyClassInitialize(TestContext testContext) { }
+ //
+ // Use ClassCleanup to run code after all tests in a class have run
+ // [ClassCleanup()]
+ // public static void MyClassCleanup() { }
+ //
+ // Use TestInitialize to run code before running each test
+ // [TestInitialize()]
+ // public void MyTestInitialize() { }
+ //
+ // Use TestCleanup to run code after each test has run
+ // [TestCleanup()]
+ // public void MyTestCleanup() { }
+ //
+ #endregion
+
+ [HostType("VS IDE")]
+ [TestMethod]
+ public void VBWinformsApplication()
+ {
+ UIThreadInvoker.Invoke((ThreadInvoker)delegate()
+ {
+ //Solution and project creation parameters
+ string solutionName = "VBWinApp";
+ string projectName = "VBWinApp";
+
+ //Template parameters
+ string language = "VisualBasic";
+ string projectTemplateName = "WindowsApplication.Zip";
+ string itemTemplateName = "CodeFile.zip";
+ string newFileName = "Test.vb";
+
+ DTE dte = (DTE)VsIdeTestHostContext.ServiceProvider.GetService(typeof(DTE));
+
+ TestUtils testUtils = new TestUtils();
+
+ testUtils.CreateEmptySolution(TestContext.TestDir, solutionName);
+ Assert.AreEqual(0, testUtils.ProjectCount());
+
+ //Add new Windows application project to existing solution
+ testUtils.CreateProjectFromTemplate(projectName, projectTemplateName, language, false);
+
+ //Verify that the new project has been added to the solution
+ Assert.AreEqual(1, testUtils.ProjectCount());
+
+ //Get the project
+ Project project = dte.Solution.Item(1);
+ Assert.IsNotNull(project);
+ Assert.IsTrue(string.Compare(project.Name, projectName, StringComparison.InvariantCultureIgnoreCase) == 0);
+
+ //Verify Adding new code file to project
+ ProjectItem newCodeFileItem = testUtils.AddNewItemFromVsTemplate(project.ProjectItems, itemTemplateName, language, newFileName);
+ Assert.IsNotNull(newCodeFileItem, "Could not create new project item");
+
+ });
+ }
+
+ }
+}
diff --git a/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/VSPackage_IntegrationTests.csproj b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/VSPackage_IntegrationTests.csproj
new file mode 100644
index 0000000..10d11f1
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/VSPackage_IntegrationTests/VSPackage_IntegrationTests.csproj
@@ -0,0 +1,87 @@
+
+
+
+ Debug
+ AnyCPU
+ 2.0
+ {D03690D8-EE17-4284-9403-F3F277CF4580}
+ Library
+ Properties
+ VSPackage_IntegrationTests
+ VSPackage_IntegrationTests
+ v4.5
+ 512
+ {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ Key.snk
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {2451352F-1CB8-494A-920B-024B8B486185}
+ VSPackage
+
+
+
+
+
\ No newline at end of file
diff --git a/RESW File Code Generator/VSPackage/VSPackage_UnitTests/Key.snk b/RESW File Code Generator/VSPackage/VSPackage_UnitTests/Key.snk
new file mode 100644
index 0000000..82ea2e0
Binary files /dev/null and b/RESW File Code Generator/VSPackage/VSPackage_UnitTests/Key.snk differ
diff --git a/RESW File Code Generator/VSPackage/VSPackage_UnitTests/PackageTest.cs b/RESW File Code Generator/VSPackage/VSPackage_UnitTests/PackageTest.cs
new file mode 100644
index 0000000..22eb379
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/VSPackage_UnitTests/PackageTest.cs
@@ -0,0 +1,56 @@
+/***************************************************************************
+
+Copyright (c) Microsoft Corporation. All rights reserved.
+This code is licensed under the Visual Studio SDK license terms.
+THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
+
+***************************************************************************/
+
+using System;
+using System.Collections;
+using System.Text;
+using System.Reflection;
+using ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage;
+using Microsoft.VsSDK.UnitTestLibrary;
+using Microsoft.VisualStudio.Shell.Interop;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace VSPackage_UnitTests
+{
+ [TestClass()]
+ public class PackageTest
+ {
+ [TestMethod()]
+ public void CreateInstance()
+ {
+ VSPackagePackage package = new VSPackagePackage();
+ }
+
+ [TestMethod()]
+ public void IsIVsPackage()
+ {
+ VSPackagePackage package = new VSPackagePackage();
+ Assert.IsNotNull(package as IVsPackage, "The object does not implement IVsPackage");
+ }
+
+ [TestMethod()]
+ public void SetSite()
+ {
+ // Create the package
+ IVsPackage package = new VSPackagePackage() as IVsPackage;
+ Assert.IsNotNull(package, "The object does not implement IVsPackage");
+
+ // Create a basic service provider
+ OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();
+
+ // Site the package
+ Assert.AreEqual(0, package.SetSite(serviceProvider), "SetSite did not return S_OK");
+
+ // Unsite the package
+ Assert.AreEqual(0, package.SetSite(null), "SetSite(null) did not return S_OK");
+ }
+ }
+}
diff --git a/RESW File Code Generator/VSPackage/VSPackage_UnitTests/VSPackage_UnitTests.csproj b/RESW File Code Generator/VSPackage/VSPackage_UnitTests/VSPackage_UnitTests.csproj
new file mode 100644
index 0000000..d6e1cb9
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/VSPackage_UnitTests/VSPackage_UnitTests.csproj
@@ -0,0 +1,76 @@
+
+
+
+ Debug
+ AnyCPU
+ 2.0
+ {64F7EAFB-9AF1-4DA4-A4DA-013B4DF10306}
+ Library
+ Properties
+ VSPackage_UnitTests
+ VSPackage_UnitTests
+ v4.5
+ {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ Key.snk
+
+
+ true
+
+
+
+
+
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {2451352F-1CB8-494A-920B-024B8B486185}
+ VSPackage
+
+
+
+
\ No newline at end of file
diff --git a/RESW File Code Generator/VSPackage/source.extension.vsixmanifest b/RESW File Code Generator/VSPackage/source.extension.vsixmanifest
new file mode 100644
index 0000000..0cfeda4
--- /dev/null
+++ b/RESW File Code Generator/VSPackage/source.extension.vsixmanifest
@@ -0,0 +1,37 @@
+
+
+
+
+ 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.
+ http://visualstudiogallery.msdn.microsoft.com/3ab88efd-1afb-4ff5-9faf-8825a282596a
+ License.txt
+ Resources\Package.ico
+ Resources\Package.ico
+
+
+
+
+
+
+
+
+
+
+
+