@@ -41,7 +41,7 @@ File1.cs
41
41
.editorconfig
42
42
```
43
43
44
- ### Writing (applies to Slnx 2.0, see below code block for Slnx 3.0)
44
+ ### Writing (applies to Slnx 3.0)
45
45
``` cs
46
46
using Slnx ;
47
47
using System .Text .Json ;
@@ -57,6 +57,7 @@ folder.AddProject(new Project("./DockerCompose/DockerCompose.dcproj", typeGuid:
57
57
var moreFolders = new Folder (" C++" );
58
58
moreFolders .AddFiles ([" util.cpp" , " util.h" , " data.cc" , " data.h" ]);
59
59
folder .AddFiles ([" File1.cs" , " File2.cs" ]);
60
+ folder .AddFolder (moreFolders );
60
61
61
62
factory .AddFolder (folder );
62
63
factory .AddProjectWithPathOnly (" Slnx/Slnx.csproj" );
@@ -69,58 +70,8 @@ File.AppendAllText("OutputSlnx.txt", content);
69
70
var model = SlnxModel .Load (File .ReadAllText (" OutputSlnx.txt" ));
70
71
Console .WriteLine (JsonSerializer .Serialize (model ));
71
72
```
72
- #### For Slnx 3.0
73
- Note: The constructor of the ` Project ` class was slightly changed in Slnx 3.0. Change this:
74
- ``` cs
75
- // ...
76
- folder .AddProject (new Project (" ./DockerCompose/DockerCompose.dcproj" , typeGuid : Guid .NewGuid (), config : new (solution : " *|*" , project : " *|*|Deploy" )));
77
- var moreFolders = new Folder (" C++" );
78
- ```
79
- to:
80
- ``` cs
81
- // ...
82
- folder .AddProject (new Project (" ./DockerCompose/DockerCompose.dcproj" , /* HERE -->*/ type : Guid .NewGuid ().ToString (), /* <-- HERE*/ config : new (solution : " *|*" , project : " *|*|Deploy" )));
83
- var moreFolders = new Folder (" C++" );
84
- ```
73
+ The program will generate a file named ` OutputSlnx.txt ` with these contents:
85
74
86
- Starting with Slnx 3.0, you can convert ` SlnxModel ` to ` string ` asynchronously:
87
- ``` cs
88
- // ...
89
- factory .AddProjectWithPathOnly (" App/App.shproj" );
90
-
91
- string content = await factory .AsModel ().StoreAsync (); // <---
92
- File .AppendAllText (" OutputSlnx.txt" , content );
93
- ```
94
-
95
- ### Writing (applies to Slnx 1.0)
96
- ``` cs
97
- using Slnx ;
98
-
99
- var factory = new SlnxFactory ();
100
- factory .Folders .Add (new Folder (" Solution Items" , new []
101
- {
102
- new Project (" ./CSharp/CSharp.csproj" ),
103
- new Project (" ./VB.NET/VB.NET.vbproj" ),
104
- new Project (" ./DockerCompose/DockerCompose.dcproj" , Guid .NewGuid (), new (solution : " *|*" , project : " *|*|Deploy" ))
105
- }, new []
106
- {
107
- new Folder (" C++" , Array .Empty <Project >(), Array .Empty <Folder >(), new []
108
- {
109
- " util.cpp" ,
110
- " util.h" ,
111
- " data.cc" ,
112
- " data.h"
113
- })
114
- }, new string [] { " File1.cs" , " File2.cs" }));
115
-
116
- factory .Projects .Add (new Project (" Slnx/Slnx.csproj" ));
117
- factory .Projects .Add (new Project (" App/App.shproj" ));
118
-
119
- var model = factory .AsModel ();
120
- model .Store (" OutputSlnx.txt" );
121
- ```
122
-
123
- Both of these programs will generate ` OutputSlnx.txt ` with the following contents:
124
75
```
125
76
<Solution>
126
77
<Project Path="Slnx/Slnx.csproj" />
@@ -144,40 +95,78 @@ Both of these programs will generate `OutputSlnx.txt` with the following content
144
95
```
145
96
146
97
# Contributing
147
- Bug reports, suggestions, questions and other feedback are welcome.
98
+ Bug reports, feature suggestions, questions, and other feedback are welcome.
148
99
149
100
# Compatibility
150
101
Slnx uses the .NET 6.0 Runtime, but it works fine for preceding versions, including .NET 7.0, 8.0, and future releases.
151
102
152
103
# Benchmarking
153
- This is the benchmark for SLNX version 2.0, using ` BenchmarkDotNet ` . Benchmarks are found in the ` ./benchmark ` folder.
154
- ### Read
104
+
105
+ ## Read Benchmark
106
+ Input:
107
+ ``` xml
108
+ <Solution >
109
+ <Folder Name =" Solution Items" >
110
+ <File Path =" File1.cs" />
111
+ <File Path =" .editorconfig" />
112
+ <Project Path =" File.csproj" />
113
+ <Folder Name =" Test" >
114
+ <File Path =" .editorconfig" />
115
+ <File Path =" data.cs" />
116
+ </Folder >
117
+ </Folder >
118
+ </Solution >
155
119
```
156
120
157
- BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3)
121
+ Benchmark result:
122
+ ```
123
+
124
+ BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3)
158
125
AMD Ryzen 7 4700U with Radeon Graphics, 1 CPU, 8 logical and 8 physical cores
159
- .NET SDK 8.0.204
160
- [Host] : .NET 8.0.4 (8.0.424.16909), X64 RyuJIT AVX2
161
- DefaultJob : .NET 8.0.4 (8.0.424.16909), X64 RyuJIT AVX2
126
+ .NET SDK 8.0.303
127
+ [Host] : .NET 8.0.7 (8.0.724.31311), X64 RyuJIT AVX2
128
+ DefaultJob : .NET 8.0.7 (8.0.724.31311), X64 RyuJIT AVX2
129
+
130
+
131
+ ```
132
+ | Method | Mean | Error | StdDev | Gen0 | Allocated |
133
+ | ------------ | ---------:| ----------:| ----------:| -------:| ----------:|
134
+ | ReadBenchie | 4.486 μs | 0.0301 μs | 0.0267 μs | 7.1106 | 14.55 KB |
135
+
136
+ ## Write Benchmark
137
+ Code:
138
+ ``` cs
139
+ var factory = new SlnxFactory ();
162
140
141
+ var folder = new Folder (" Solution Items" );
142
+ folder .AddProjectWithPathOnly (" ./CSharp/CSharp.csproj" );
143
+ folder .AddProjectWithPathOnly (" ./VB.NET/VB.NET.vbproj" );
144
+ folder .AddProject (new Project (" ./DockerCompose/DockerCompose.dcproj" , type : null , config : new (solution : " *|*" , project : " *|*|Deploy" )));
145
+ var moreFolders = new Folder (" C++" );
146
+ moreFolders .AddFiles ([" util.cpp" , " util.h" , " data.cc" , " data.h" ]);
147
+ folder .AddFiles ([" File1.cs" , " File2.cs" ]);
148
+ folder .AddFolder (moreFolders );
149
+
150
+ factory .AddFolder (folder );
151
+ factory .AddProjectWithPathOnly (" Slnx/Slnx.csproj" );
152
+ factory .AddProjectWithPathOnly (" App/App.shproj" );
163
153
154
+ _ = factory .AsModel ().Store ();
164
155
```
165
- | Method | Mean | Error | StdDev | Gen0 | Allocated |
166
- | -------- | ---------:| ----------:| ----------:| -------:| ----------:|
167
- | Execute | 4.469 μs | 0.0834 μs | 0.0739 μs | 6.8970 | 14.17 KB |
156
+ To provide the accurate benchmark, we're not saving or logging the result anywhere like console or file - we're
157
+ just focusing on how fast Slnx can export the SlnxFactory instance as a string.
168
158
169
- ### Write
159
+ Benchmark result:
170
160
```
171
161
172
- BenchmarkDotNet v0.13.12 , Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3)
162
+ BenchmarkDotNet v0.14.0 , Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3)
173
163
AMD Ryzen 7 4700U with Radeon Graphics, 1 CPU, 8 logical and 8 physical cores
174
- .NET SDK 8.0.204
175
- [Host] : .NET 8.0.4 (8.0.424.16909 ), X64 RyuJIT AVX2
176
- DefaultJob : .NET 8.0.4 (8.0.424.16909 ), X64 RyuJIT AVX2
164
+ .NET SDK 8.0.303
165
+ [Host] : .NET 8.0.7 (8.0.724.31311 ), X64 RyuJIT AVX2
166
+ DefaultJob : .NET 8.0.7 (8.0.724.31311 ), X64 RyuJIT AVX2
177
167
178
168
179
169
```
180
- | Method | Mean | Error | StdDev | Gen0 | Allocated |
181
- | -------- | ---------:| ----------:| ----------:| --------:| ----------:|
182
- | Execute | 8.763 μs | 0.1065 μs | 0.0944 μs | 17.6392 | 36.2 KB |
183
-
170
+ | Method | Mean | Error | StdDev | Gen0 | Allocated |
171
+ | ------------- | ---------:| ----------:| ----------:| -------:| ----------:|
172
+ | WriteBenchie | 4.841 μs | 0.0371 μs | 0.0310 μs | 9.4299 | 19.33 KB |
0 commit comments