Closed Str1ker17 closed 3 years ago
As I mentioned in #3, the basic principles are map and data using active collections. The only thing is that 2.5.x does not provide a better ways around data from scratch. But it would be considered later I think.
However, even today it is still quite simple, for example:
// provide some data; it can be either other processed .sln or from scratch, etc.
// for example, some headers ~
var header = new SlnHeader();
header.SetFormatVersion("12.0");
header.SetMinimumVersion("10.0.40219.1");
// some project collection from scratch ~
var projects = new[] { new ProjectItem("MyProject", ProjectType.Cs, "path") };
// ... and so on;
// then prepare write-handlers related to your data, eg.:
var whandlers = new Dictionary<Type, HandlerValue>()
{
[typeof(LVisualStudioVersion)] = new HandlerValue(new WVisualStudioVersion(header)),
[typeof(LProject)] = new HandlerValue(new WProject(projects, new LProjectDependencies())),
};
// commit this
using var w = new SlnWriter("result.sln", whandlers);
w.Write(new[] // for 2.5.x only manual mapping from scratch like here
{
new Section(new LVisualStudioVersion(), null),
new Section(new LProject(), null)
});
result.sln
Microsoft Visual Studio Solution File, Format Version 12.00
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyProject", "path", "{CD128011-5F3E-4A88-A2D2-24A1E4DCD580}"
EndProject
The title is the question itself