-
Notifications
You must be signed in to change notification settings - Fork 408
Expand file tree
/
Copy pathSolutionGenerator.cs
More file actions
64 lines (57 loc) · 2.32 KB
/
SolutionGenerator.cs
File metadata and controls
64 lines (57 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Text;
using CodeGen.Helpers;
using CodeGen.JsonTypes;
namespace CodeGen.Generators.UnitsNetGen
{
internal class SolutionGenerator : GeneratorBase
{
private readonly Quantity[] _quantities;
private readonly Guid _globalGuid = new("71d2836c-ed62-4b76-ba38-e15badcca916"); // Randomly generated guids.
private readonly Guid _solutionGuid = new("1f322b1f-1612-4e69-a31f-cb46bf87ec3e");
public SolutionGenerator(Quantity[] quantities)
{
_quantities = quantities;
}
public string Generate()
{
StringBuilder sb = new();
Writer.WL($@"
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29609.76
MinimumVisualStudioVersion = 10.0.40219.1");
foreach (var quantity in _quantities)
{
var projectGuid = HashGuid.ToHashGuid(quantity.Name);
var projectName = $"UnitsNet.{quantity.Name}";
Writer.WL($@"
Project(""{_globalGuid:B}"") = ""{projectName}"", ""UnitsNet.Modular\{projectName}\{projectName}.csproj"", ""{projectGuid:B}""
EndProject");
sb.Append($"{{{projectGuid}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r\n");
sb.Append($"{{{projectGuid}}}.Debug|Any CPU.Build.0 = Debug|Any CPU\r\n");
sb.Append($"{{{projectGuid}}}.Debug|Any CPU.Deploy.0 = Debug|Any CPU\r\n");
sb.Append($"{{{projectGuid}}}.Release|Any CPU.ActiveCfg = Release|Any CPU\r\n");
sb.Append($"{{{projectGuid}}}.Release|Any CPU.Build.0 = Release|Any CPU\r\n");
sb.Append($"{{{projectGuid}}}.Release|Any CPU.Deploy.0 = Release|Any CPU\r\n");
}
Writer.WL(@"Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution");
Writer.WL(sb.ToString());
Writer.WL($@" EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {_solutionGuid:B}
EndGlobalSection
EndGlobal
");
return Writer.ToString();
}
}
}