commit 79fe714b5bbfda7adac781bfda5dcb34af9ff29e Author: Christian Resma Helle Date: Tue Nov 6 23:37:40 2012 +0100 initial commit diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000..e6c4cd3 --- /dev/null +++ b/.hgignore @@ -0,0 +1,7 @@ +syntax: glob +*/bin/* +*/obj/* +*/TestResults/* +*.suo +*.user +*ReSharper* diff --git a/RESW File Code Generator/RESW File Code Generator.sln b/RESW File Code Generator/RESW File Code Generator.sln new file mode 100644 index 0000000..a7ed6ed --- /dev/null +++ b/RESW File Code Generator/RESW File Code Generator.sln @@ -0,0 +1,32 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReswCodeGen.Core", "ReswCodeGen.Core\ReswCodeGen.Core.csproj", "{53912EB5-C7DD-486F-9293-8B485AEB0366}" +EndProject +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 +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {53912EB5-C7DD-486F-9293-8B485AEB0366}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {53912EB5-C7DD-486F-9293-8B485AEB0366}.Debug|Any CPU.Build.0 = Debug|Any CPU + {53912EB5-C7DD-486F-9293-8B485AEB0366}.Release|Any CPU.ActiveCfg = Release|Any CPU + {53912EB5-C7DD-486F-9293-8B485AEB0366}.Release|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}.Release|Any CPU.ActiveCfg = Release|Any CPU + {27E6A696-F14D-43F0-B3CB-5FAB2BE385D0}.Release|Any CPU.Build.0 = Release|Any CPU + {B56DDC92-E86D-46AA-BE28-7ACA670EE9CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B56DDC92-E86D-46AA-BE28-7ACA670EE9CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B56DDC92-E86D-46AA-BE28-7ACA670EE9CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B56DDC92-E86D-46AA-BE28-7ACA670EE9CE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/RESW File Code Generator/ReswCodeGen.Core/CodeGeneratorFactory.cs b/RESW File Code Generator/ReswCodeGen.Core/CodeGeneratorFactory.cs new file mode 100644 index 0000000..30a0203 --- /dev/null +++ b/RESW File Code Generator/ReswCodeGen.Core/CodeGeneratorFactory.cs @@ -0,0 +1,10 @@ +namespace ReswCodeGen.Core +{ + public class CodeGeneratorFactory + { + public ICodeGenerator Create(string defaultNamespace, string inputFileContents) + { + return null; + } + } +} diff --git a/RESW File Code Generator/ReswCodeGen.Core/ICodeGenerator.cs b/RESW File Code Generator/ReswCodeGen.Core/ICodeGenerator.cs new file mode 100644 index 0000000..74e1455 --- /dev/null +++ b/RESW File Code Generator/ReswCodeGen.Core/ICodeGenerator.cs @@ -0,0 +1,9 @@ +namespace ReswCodeGen.Core +{ + public interface ICodeGenerator + { + string Namespace { get; set; } + string ReswContent { get; set; } + string GenerateCode(); + } +} diff --git a/RESW File Code Generator/ReswCodeGen.Core/Properties/AssemblyInfo.cs b/RESW File Code Generator/ReswCodeGen.Core/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d6cdd06 --- /dev/null +++ b/RESW File Code Generator/ReswCodeGen.Core/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +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("ReswCodeGen.Core")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ReswCodeGen.Core")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("0cc6c5d3-85b1-4c0e-9267-1f5dec1feeab")] + +// 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 Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RESW File Code Generator/ReswCodeGen.Core/ReswCodeGen.Core.csproj b/RESW File Code Generator/ReswCodeGen.Core/ReswCodeGen.Core.csproj new file mode 100644 index 0000000..d938256 --- /dev/null +++ b/RESW File Code Generator/ReswCodeGen.Core/ReswCodeGen.Core.csproj @@ -0,0 +1,63 @@ + + + + + Debug + AnyCPU + {53912EB5-C7DD-486F-9293-8B485AEB0366} + Library + Properties + ReswCodeGen.Core + ReswCodeGen.Core + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + + + ReswCodeGen.snk + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RESW File Code Generator/ReswCodeGen.Core/ReswCodeGen.snk b/RESW File Code Generator/ReswCodeGen.Core/ReswCodeGen.snk new file mode 100644 index 0000000..f0ae47e Binary files /dev/null and b/RESW File Code Generator/ReswCodeGen.Core/ReswCodeGen.snk differ diff --git a/RESW File Code Generator/ReswCodeGen.CustomTool/Properties/AssemblyInfo.cs b/RESW File Code Generator/ReswCodeGen.CustomTool/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f266866 --- /dev/null +++ b/RESW File Code Generator/ReswCodeGen.CustomTool/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +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("ReswCodeGen.CustomTool")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ReswCodeGen.CustomTool")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9e8fe64d-ce90-4da0-a69e-3dc4d1c23450")] + +// 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 Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RESW File Code Generator/ReswCodeGen.CustomTool/ReswCodeGen.CustomTool.csproj b/RESW File Code Generator/ReswCodeGen.CustomTool/ReswCodeGen.CustomTool.csproj new file mode 100644 index 0000000..3ab38d7 --- /dev/null +++ b/RESW File Code Generator/ReswCodeGen.CustomTool/ReswCodeGen.CustomTool.csproj @@ -0,0 +1,73 @@ + + + + + Debug + AnyCPU + {27E6A696-F14D-43F0-B3CB-5FAB2BE385D0} + Library + Properties + ReswCodeGen.CustomTool + ReswCodeGen.CustomTool + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + + + ReswCodeGen.snk + + + + False + + + + + + + + + + + + + + + + + + + + {53912EB5-C7DD-486F-9293-8B485AEB0366} + ReswCodeGen.Core + + + + + \ No newline at end of file diff --git a/RESW File Code Generator/ReswCodeGen.CustomTool/ReswCodeGen.snk b/RESW File Code Generator/ReswCodeGen.CustomTool/ReswCodeGen.snk new file mode 100644 index 0000000..b6d9a32 Binary files /dev/null and b/RESW File Code Generator/ReswCodeGen.CustomTool/ReswCodeGen.snk differ diff --git a/RESW File Code Generator/ReswCodeGen.CustomTool/ReswFileCodeGenerator.cs b/RESW File Code Generator/ReswCodeGen.CustomTool/ReswFileCodeGenerator.cs new file mode 100644 index 0000000..3508b9d --- /dev/null +++ b/RESW File Code Generator/ReswCodeGen.CustomTool/ReswFileCodeGenerator.cs @@ -0,0 +1,53 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; +using System.Windows.Forms; +using Microsoft.VisualStudio.Shell.Interop; +using ReswCodeGen.Core; + +namespace ReswCodeGen.CustomTool +{ + [Guid("98983F6D-BC77-46AC-BA5A-8D9E8763F0D2")] + [ComVisible(true)] + public class ReswFileCodeGenerator : IVsSingleFileGenerator + { + #region IVsSingleFileGenerator Members + + public int DefaultExtension(out string pbstrDefaultExtension) + { + pbstrDefaultExtension = ".cs"; + return 0; + } + + public int Generate(string wszInputFilePath, + string bstrInputFileContents, + string wszDefaultNamespace, + IntPtr[] rgbOutputFileContents, + out uint pcbOutput, + IVsGeneratorProgress pGenerateProgress) + { + try + { + var factory = new CodeGeneratorFactory(); + var codeGenerator = factory.Create(wszDefaultNamespace, bstrInputFileContents); + 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/ReswCodeGen.Tests/Properties/AssemblyInfo.cs b/RESW File Code Generator/ReswCodeGen.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9fcff92 --- /dev/null +++ b/RESW File Code Generator/ReswCodeGen.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +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("ReswCodeGen.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ReswCodeGen.Tests")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("948cb0e4-5fec-4bb0-84c3-afdd75406336")] + +// 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 Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RESW File Code Generator/ReswCodeGen.Tests/ReswCodeGen.Tests.csproj b/RESW File Code Generator/ReswCodeGen.Tests/ReswCodeGen.Tests.csproj new file mode 100644 index 0000000..a048699 --- /dev/null +++ b/RESW File Code Generator/ReswCodeGen.Tests/ReswCodeGen.Tests.csproj @@ -0,0 +1,83 @@ + + + + Debug + AnyCPU + {B56DDC92-E86D-46AA-BE28-7ACA670EE9CE} + Library + Properties + ReswCodeGen.Tests + ReswCodeGen.Tests + v4.5 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + False + + + False + + + False + + + False + + + + + + + + \ No newline at end of file diff --git a/RESW File Code Generator/ReswCodeGen.Tests/Spikes.cs b/RESW File Code Generator/ReswCodeGen.Tests/Spikes.cs new file mode 100644 index 0000000..27dac17 --- /dev/null +++ b/RESW File Code Generator/ReswCodeGen.Tests/Spikes.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace ReswCodeGen.Tests +{ + [TestClass] + public class Spikes + { + [TestMethod] + public void MarshalToIntPtrArray() + { + const string text = "test"; + var data = Encoding.UTF8.GetBytes(text); + var pData = Marshal.AllocCoTaskMem(data.Length); + Marshal.Copy(data, 0, pData, data.Length); + + var pDataArray = new IntPtr[data.Length]; + Marshal.Copy(pData, pDataArray, 0, data.Length); + Marshal.FreeCoTaskMem(pData); + } + } +} \ No newline at end of file