Add DataFormats for Microsoft Visual Studio solution and prjoect files
This commit is contained in:
parent
430ffe8e67
commit
faee706cc9
@ -0,0 +1,141 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using UniversalEditor.ObjectModels.Markup;
|
||||
using UniversalEditor.DataFormats.Markup.XML;
|
||||
|
||||
using UniversalEditor.ObjectModels.Solution;
|
||||
|
||||
namespace UniversalEditor.DataFormats.Solution.Microsoft.VisualStudio
|
||||
{
|
||||
public class VisualStudioProjectDataFormat : XMLDataFormat
|
||||
{
|
||||
private static DataFormatReference _dfr = null;
|
||||
public override DataFormatReference MakeReference()
|
||||
{
|
||||
if (_dfr == null)
|
||||
{
|
||||
_dfr = base.MakeReference();
|
||||
_dfr.Capabilities.Add(typeof(SolutionObjectModel), DataFormatCapabilities.All);
|
||||
_dfr.Filters.Add("Microsoft Visual Studio project", new string[] { "*.vbproj", "*.csproj", "*.jsproj", "*.wixproj", "*.fsproj", "*.pyproj", "*.sqlproj", "*.phpproj" });
|
||||
}
|
||||
return _dfr;
|
||||
}
|
||||
|
||||
protected override void BeforeLoadInternal(Stack<ObjectModel> objectModels)
|
||||
{
|
||||
objectModels.Push(new MarkupObjectModel());
|
||||
}
|
||||
protected override void AfterLoadInternal(Stack<ObjectModel> objectModels)
|
||||
{
|
||||
MarkupObjectModel mom = (objectModels.Pop() as MarkupObjectModel);
|
||||
SolutionObjectModel sln = (objectModels.Pop() as SolutionObjectModel);
|
||||
}
|
||||
protected override void BeforeSaveInternal(Stack<ObjectModel> objectModels)
|
||||
{
|
||||
SolutionObjectModel sln = (objectModels.Pop() as SolutionObjectModel);
|
||||
MarkupObjectModel mom = new MarkupObjectModel();
|
||||
|
||||
Project proj = sln.Projects[0];
|
||||
|
||||
MarkupTagElement tagProject = new MarkupTagElement();
|
||||
tagProject.FullName = "Project";
|
||||
// remove for compatibility with older VS versions
|
||||
tagProject.Attributes.Add("ToolsVersion", "4.0");
|
||||
tagProject.Attributes.Add("DefaultTargets", "Build");
|
||||
tagProject.Attributes.Add("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");
|
||||
|
||||
#region PropertyGroup
|
||||
{
|
||||
MarkupTagElement tagPropertyGroup = new MarkupTagElement();
|
||||
tagPropertyGroup.FullName = "PropertyGroup";
|
||||
|
||||
MarkupTagElement tagConfiguration = new MarkupTagElement();
|
||||
tagConfiguration.FullName = "Configuration";
|
||||
tagConfiguration.Attributes.Add("Condition", " '$(Configuration)' == '' ");
|
||||
tagConfiguration.Value = "Debug";
|
||||
tagPropertyGroup.Elements.Add(tagConfiguration);
|
||||
|
||||
MarkupTagElement tagName = new MarkupTagElement();
|
||||
tagName.FullName = "Name";
|
||||
tagName.Value = proj.Title;
|
||||
tagPropertyGroup.Elements.Add(tagName);
|
||||
|
||||
MarkupTagElement tagProjectGUID = new MarkupTagElement();
|
||||
tagProjectGUID.FullName = "ProjectGuid";
|
||||
tagProjectGUID.Value = proj.ID.ToString("D");
|
||||
tagPropertyGroup.Elements.Add(tagProjectGUID);
|
||||
|
||||
MarkupTagElement tagOutputType = new MarkupTagElement();
|
||||
tagOutputType.FullName = "OutputType";
|
||||
tagOutputType.Value = "Library";
|
||||
tagPropertyGroup.Elements.Add(tagOutputType);
|
||||
|
||||
MarkupTagElement tagRootNamespace = new MarkupTagElement();
|
||||
tagRootNamespace.FullName = "RootNamespace";
|
||||
tagRootNamespace.Value = proj.Title;
|
||||
tagPropertyGroup.Elements.Add(tagRootNamespace);
|
||||
|
||||
MarkupTagElement tagProjectTypeGUIDs = new MarkupTagElement();
|
||||
tagProjectTypeGUIDs.FullName = "ProjectTypeGuids";
|
||||
tagProjectTypeGUIDs.Value = proj.ProjectType.ID.ToString("B");
|
||||
tagPropertyGroup.Elements.Add(tagProjectTypeGUIDs);
|
||||
|
||||
MarkupTagElement tagAssemblyName = new MarkupTagElement();
|
||||
tagAssemblyName.FullName = "AssemblyName";
|
||||
tagAssemblyName.Value = proj.Title;
|
||||
tagPropertyGroup.Elements.Add(tagAssemblyName);
|
||||
|
||||
tagProject.Elements.Add(tagPropertyGroup);
|
||||
}
|
||||
#endregion
|
||||
#region PropertyGroup
|
||||
{
|
||||
MarkupTagElement tagPropertyGroup = new MarkupTagElement();
|
||||
tagPropertyGroup.FullName = "PropertyGroup";
|
||||
tagPropertyGroup.Attributes.Add("Condition", " '$(Configuration)' == 'Debug' ");
|
||||
|
||||
MarkupTagElement tagIncludeDebugInformation = new MarkupTagElement();
|
||||
tagIncludeDebugInformation.FullName = "IncludeDebugInformation";
|
||||
tagIncludeDebugInformation.Value = "true";
|
||||
tagPropertyGroup.Elements.Add(tagIncludeDebugInformation);
|
||||
|
||||
tagProject.Elements.Add(tagPropertyGroup);
|
||||
}
|
||||
#endregion
|
||||
#region PropertyGroup
|
||||
{
|
||||
MarkupTagElement tagPropertyGroup = new MarkupTagElement();
|
||||
tagPropertyGroup.FullName = "PropertyGroup";
|
||||
tagPropertyGroup.Attributes.Add("Condition", " '$(Configuration)' == 'Release' ");
|
||||
|
||||
MarkupTagElement tagIncludeDebugInformation = new MarkupTagElement();
|
||||
tagIncludeDebugInformation.FullName = "IncludeDebugInformation";
|
||||
tagIncludeDebugInformation.Value = "false";
|
||||
tagPropertyGroup.Elements.Add(tagIncludeDebugInformation);
|
||||
|
||||
tagProject.Elements.Add(tagPropertyGroup);
|
||||
}
|
||||
#endregion
|
||||
#region ItemGroup
|
||||
{
|
||||
MarkupTagElement tagItemGroup = new MarkupTagElement();
|
||||
tagItemGroup.FullName = "ItemGroup";
|
||||
tagItemGroup.Attributes.Add("Condition", " '$(Configuration)' == 'Debug' ");
|
||||
|
||||
MarkupTagElement tagCompile = new MarkupTagElement();
|
||||
tagCompile.FullName = "Compile";
|
||||
tagCompile.Attributes.Add("Include", "filename.txt");
|
||||
tagItemGroup.Elements.Add(tagCompile);
|
||||
|
||||
tagProject.Elements.Add(tagItemGroup);
|
||||
}
|
||||
#endregion
|
||||
|
||||
mom.Elements.Add(tagProject);
|
||||
objectModels.Push(mom);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UniversalEditor.Accessors;
|
||||
using UniversalEditor.IO;
|
||||
using UniversalEditor.ObjectModels.PropertyList;
|
||||
using UniversalEditor.ObjectModels.Solution;
|
||||
|
||||
namespace UniversalEditor.DataFormats.Solution.Microsoft.VisualStudio
|
||||
{
|
||||
public class VisualStudioSolutionDataFormat : DataFormat
|
||||
{
|
||||
private static DataFormatReference _dfr = null;
|
||||
public override DataFormatReference MakeReference()
|
||||
{
|
||||
if (_dfr == null)
|
||||
{
|
||||
_dfr = base.MakeReference();
|
||||
_dfr.Capabilities.Add(typeof(SolutionObjectModel), DataFormatCapabilities.All);
|
||||
_dfr.Filters.Add("Microsoft Visual Studio solution", new byte?[][]
|
||||
{
|
||||
new byte?[] { (byte)0xEF, (byte)0xBB, (byte)0xBF, (byte)0x0D, (byte)0x0A, (byte)'M', (byte)'i', (byte)'c', (byte)'r', (byte)'o', (byte)'s', (byte)'o', (byte)'f', (byte)'t', (byte)' ', (byte)'V', (byte)'i', (byte)'s', (byte)'u', (byte)'a', (byte)'l', (byte)' ', (byte)'S', (byte)'t', (byte)'u', (byte)'d', (byte)'i', (byte)'o', (byte)' ', (byte)'S', (byte)'o', (byte)'l', (byte)'u', (byte)'t', (byte)'i', (byte)'o', (byte)'n', (byte)' ', (byte)'F', (byte)'i', (byte)'l', (byte)'e', (byte)',', (byte)' ', (byte)'F', (byte)'o', (byte)'r', (byte)'m', (byte)'a', (byte)'t', (byte)' ', (byte)'V', (byte)'e', (byte)'r', (byte)'s', (byte)'i', (byte)'o', (byte)'n', (byte)' ' }
|
||||
}, new string[] { "*.sln" }); ;
|
||||
}
|
||||
return _dfr;
|
||||
}
|
||||
|
||||
protected override void LoadInternal(ref ObjectModel objectModel)
|
||||
{
|
||||
SolutionObjectModel sol = (objectModel as SolutionObjectModel);
|
||||
if (sol == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
Reader reader = base.Accessor.Reader;
|
||||
byte[] signature1 = reader.ReadBytes(3);
|
||||
if (!signature1.Match(new byte[] { 0xEF, 0xBB, 0xBF }))
|
||||
{
|
||||
// this is a Unicode Byte-Order-Mark... do we have to rely on it?
|
||||
// if we don't find it let's just back up since we may have an
|
||||
// ASCII file even though VS is known to put the BOM in its sln
|
||||
// files
|
||||
reader.Accessor.Seek(-3, SeekOrigin.Current);
|
||||
}
|
||||
|
||||
string signature2a = reader.ReadLine();
|
||||
if (!String.IsNullOrEmpty(signature2a)) throw new InvalidDataFormatException("Empty line should be present at beginning of file");
|
||||
|
||||
string signature2Verify = "Microsoft Visual Studio Solution File, Format Version ";
|
||||
string signature2 = reader.ReadLine();
|
||||
if (!signature2.StartsWith(signature2Verify)) throw new InvalidDataFormatException("File does not begin with \"" + signature2Verify + "\"");
|
||||
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
string line = reader.ReadLine();
|
||||
if (line.StartsWith("#") || String.IsNullOrEmpty(line)) continue;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SaveInternal(ObjectModel objectModel)
|
||||
{
|
||||
SolutionObjectModel sol = (objectModel as SolutionObjectModel);
|
||||
if (sol == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
string soldir = String.Empty;
|
||||
if (sol.Accessor is FileAccessor)
|
||||
{
|
||||
soldir = System.IO.Path.GetDirectoryName((sol.Accessor as FileAccessor).FileName);
|
||||
}
|
||||
|
||||
Writer writer = base.Accessor.Writer;
|
||||
writer.WriteBytes(new byte[] { 0xEF, 0xBB, 0xBF });
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("Microsoft Visual Studio Solution File, Format Version 12.00");
|
||||
writer.WriteLine("# Visual Studio 2012");
|
||||
|
||||
foreach (Project project in sol.Projects)
|
||||
{
|
||||
/*
|
||||
if (project is SolutionFolder)
|
||||
{
|
||||
writer.WriteLine("Project(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"" + project.Title + "\", \"" + project.Title + "\", \"" + project.ID.ToString("B") + "\"");
|
||||
writer.WriteLine("EndProject");
|
||||
}
|
||||
else
|
||||
{
|
||||
*/
|
||||
writer.WriteLine("Project(\"" + project.ProjectType.ID.ToString("B") + "\") = \"" + project.Title + "\", \"" + project.RelativeFileName + "\", \"" + project.ID.ToString("B") + "\"");
|
||||
writer.WriteLine("EndProject");
|
||||
/*
|
||||
}
|
||||
*/
|
||||
|
||||
SolutionObjectModel solproj = new SolutionObjectModel();
|
||||
solproj.Projects.Add(project);
|
||||
Document.Save(solproj, new VisualStudioProjectDataFormat(), new FileAccessor(soldir + "/" + project.Title + "/" + project.Title + ".ueproj"), true);
|
||||
}
|
||||
|
||||
writer.WriteLine("Global");
|
||||
writer.WriteLine("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution");
|
||||
writer.WriteLine("\t\tDebug|Any CPU = Debug|Any CPU");
|
||||
writer.WriteLine("\t\tRelease|Any CPU = Release|Any CPU");
|
||||
writer.WriteLine("\tEndGlobalSection");
|
||||
writer.WriteLine("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution");
|
||||
foreach (Project project in sol.Projects)
|
||||
{
|
||||
writer.WriteLine("\t\t" + project.ID.ToString("B") + ".Debug|Any CPU.ActiveCfg = Debug|Any CPU");
|
||||
writer.WriteLine("\t\t" + project.ID.ToString("B") + ".Debug|Any CPU.Build.0 = Debug|Any CPU");
|
||||
writer.WriteLine("\t\t" + project.ID.ToString("B") + ".Debug|x86.ActiveCfg = Debug|Any CPU");
|
||||
writer.WriteLine("\t\t" + project.ID.ToString("B") + ".Release|Any CPU.ActiveCfg = Release|Any CPU");
|
||||
writer.WriteLine("\t\t" + project.ID.ToString("B") + ".Release|Any CPU.Build.0 = Release|Any CPU");
|
||||
writer.WriteLine("\t\t" + project.ID.ToString("B") + ".Release|x86.ActiveCfg = Release|Any CPU");
|
||||
}
|
||||
writer.WriteLine("\tEndGlobalSection");
|
||||
writer.WriteLine("\tGlobalSection(SolutionProperties) = preSolution");
|
||||
foreach (Property prop in sol.Configuration.Properties)
|
||||
{
|
||||
writer.WriteLine("\t\t" + prop.Name + " = " + prop.Value);
|
||||
}
|
||||
writer.WriteLine("\tEndGlobalSection");
|
||||
writer.WriteLine("\tGlobalSection(NestedProjects) = preSolution");
|
||||
writer.WriteLine("\tEndGlobalSection");
|
||||
writer.WriteLine("EndGlobal");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -53,6 +53,8 @@
|
||||
<Compile Include="DataFormats\PropertyList\UniversalPropertyList\VariantType.cs" />
|
||||
<Compile Include="DataFormats\PropertyList\WindowsConfigurationDataFormat.cs" />
|
||||
<Compile Include="DataFormats\PropertyList\XML\XMLPropertyListDataFormat.cs" />
|
||||
<Compile Include="DataFormats\Solution\Microsoft\VisualStudio\VisualStudioProjectDataFormat.cs" />
|
||||
<Compile Include="DataFormats\Solution\Microsoft\VisualStudio\VisualStudioSolutionDataFormat.cs" />
|
||||
<Compile Include="ObjectModels\Chunked\ChunkedObjectModel.cs" />
|
||||
<Compile Include="ObjectModels\Chunked\RIFFChunk.cs" />
|
||||
<Compile Include="ObjectModels\Chunked\RIFFDataChunk.cs" />
|
||||
|
||||
@ -89,6 +89,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Mul
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Surodoine", "..\..\Surodoine\Surodoine\Surodoine.csproj", "{E0897B7B-617A-4709-A4C6-FC0F6B441B2A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Microsoft.Merlin", "Plugins\UniversalEditor.Plugins.Microsoft.Merlin\UniversalEditor.Plugins.Microsoft.Merlin.csproj", "{9F1FDC26-5F1C-4C2A-BBBF-3A597A72802D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -303,6 +305,12 @@ Global
|
||||
{E0897B7B-617A-4709-A4C6-FC0F6B441B2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E0897B7B-617A-4709-A4C6-FC0F6B441B2A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E0897B7B-617A-4709-A4C6-FC0F6B441B2A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{9F1FDC26-5F1C-4C2A-BBBF-3A597A72802D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9F1FDC26-5F1C-4C2A-BBBF-3A597A72802D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9F1FDC26-5F1C-4C2A-BBBF-3A597A72802D}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{9F1FDC26-5F1C-4C2A-BBBF-3A597A72802D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9F1FDC26-5F1C-4C2A-BBBF-3A597A72802D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9F1FDC26-5F1C-4C2A-BBBF-3A597A72802D}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -335,6 +343,7 @@ Global
|
||||
{FD6B879E-46B0-47BE-860E-BF0C11135590} = {71CFF024-26F7-4626-A526-B435FDF8D64E}
|
||||
{41DBA506-177E-4B2D-8E6D-738E371326A1} = {71CFF024-26F7-4626-A526-B435FDF8D64E}
|
||||
{BED1EEAF-9ADD-46F6-92D0-53957858E25B} = {71CFF024-26F7-4626-A526-B435FDF8D64E}
|
||||
{9F1FDC26-5F1C-4C2A-BBBF-3A597A72802D} = {71CFF024-26F7-4626-A526-B435FDF8D64E}
|
||||
{FE016EA3-DC31-4A92-8B0A-8C746EC117E1} = {46041F27-7C1C-4209-B72B-251EDB5D4C61}
|
||||
{C1F34183-7A2F-41A6-9958-F6F329099654} = {A846CA33-9CAA-4237-B14F-8721DBA89442}
|
||||
{5A423A3E-51C5-4188-8AD5-FB5C0CB76C6A} = {C1F34183-7A2F-41A6-9958-F6F329099654}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user