Skip to content

Commit 6bd2897

Browse files
committed
codegen: Fix version in AssemblyInfo.cs
1 parent 107b0b9 commit 6bd2897

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

CodeGen/Generators/NanoFrameworkGen/PropertyGenerator.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,21 @@ namespace CodeGen.Generators.NanoFrameworkGen
66
{
77
class PropertyGenerator : GeneratorBase
88
{
9+
private readonly string _version;
10+
11+
public PropertyGenerator(string version)
12+
{
13+
_version = version;
14+
}
15+
916
public override string Generate()
1017
{
1118
Writer.WL(GeneratedFileHeader);
12-
Writer.W(@"using System.Reflection;
19+
Writer.W($@"using System.Reflection;
1320
using System.Runtime.CompilerServices;
1421
using System.Runtime.InteropServices;
1522
16-
// General Information about an assembly is controlled through the following
23+
// General Information about an assembly is controlled through the following
1724
// set of attributes. Change these attribute values to modify the information
1825
// associated with an assembly.
1926
[assembly: AssemblyTitle(""CUnitsNet"")]
@@ -25,23 +32,22 @@ public override string Generate()
2532
[assembly: AssemblyTrademark("""")]
2633
[assembly: AssemblyCulture("""")]
2734
28-
// Setting ComVisible to false makes the types in this assembly not visible
29-
// to COM components. If you need to access a type in this assembly from
35+
// Setting ComVisible to false makes the types in this assembly not visible
36+
// to COM components. If you need to access a type in this assembly from
3037
// COM, set the ComVisible attribute to true on that type.
3138
[assembly: ComVisible(false)]
3239
3340
// Version information for an assembly consists of the following four values:
3441
//
3542
// Major Version
36-
// Minor Version
43+
// Minor Version
3744
// Build Number
3845
// Revision
3946
//
40-
// You can specify all the values or you can default the Build and Revision Numbers
47+
// You can specify all the values or you can default the Build and Revision Numbers
4148
// by using the '*' as shown below:
42-
// [assembly: AssemblyVersion(""1.0.*"")]
43-
[assembly: AssemblyVersion(""1.0.0.0"")]
44-
[assembly: AssemblyFileVersion(""1.0.0.0"")]
49+
[assembly: AssemblyVersion(""{_version}"")]
50+
[assembly: AssemblyFileVersion(""{_version}"")]
4551
4652
//////////////////////////////////////////////////
4753
// This assembly doens't require native support //

CodeGen/Generators/NanoFrameworkGenerator.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,14 @@ public static void Generate(string rootDir, Quantity[] quantities, bool updateNa
7474

7575
Log.Information($"Directory NanoFramework creation(OK)");
7676

77-
SetDependencyVersions(resource, cache, logger, cancellationToken, updateNanoFrameworkDependencies, outputDir);
78-
GenerateProperties(Path.Combine(outputProperties, "AssemblyInfo.cs"));
79-
Log.Information($"Property(OK)");
77+
var lengthNuspecFile = Path.Combine(outputDir, "Length", "UnitsNet.NanoFramework.Length.nuspec");
78+
var projectVersion = ParseVersion(File.ReadAllText(lengthNuspecFile),
79+
new Regex(@"<version>(?<version>[\d\.]+)</version>", RegexOptions.IgnoreCase),
80+
"projectVersion");
81+
82+
SetDependencyVersions(resource, cache, logger, ct, updateNanoFrameworkDependencies, outputDir);
83+
GenerateProperties(Path.Combine(outputProperties, "AssemblyInfo.cs"), projectVersion);
84+
Log.Information("Property(OK)");
8085

8186
int numberQuantity = 0;
8287
foreach (var quantity in quantities)
@@ -220,9 +225,9 @@ private static void GenerateNuspec(
220225
File.WriteAllText(filePath, content);
221226
}
222227

223-
private static void GenerateProperties(string filePath)
228+
private static void GenerateProperties(string filePath, string version)
224229
{
225-
var content = new PropertyGenerator().Generate();
230+
var content = new PropertyGenerator(version).Generate();
226231
File.WriteAllText(filePath, content);
227232
}
228233

UnitsNet.NanoFramework/GeneratedCode/Properties/AssemblyInfo.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
using System.Runtime.CompilerServices;
2222
using System.Runtime.InteropServices;
2323

24-
// General Information about an assembly is controlled through the following
24+
// General Information about an assembly is controlled through the following
2525
// set of attributes. Change these attribute values to modify the information
2626
// associated with an assembly.
2727
[assembly: AssemblyTitle("CUnitsNet")]
@@ -33,21 +33,20 @@
3333
[assembly: AssemblyTrademark("")]
3434
[assembly: AssemblyCulture("")]
3535

36-
// Setting ComVisible to false makes the types in this assembly not visible
37-
// to COM components. If you need to access a type in this assembly from
36+
// Setting ComVisible to false makes the types in this assembly not visible
37+
// to COM components. If you need to access a type in this assembly from
3838
// COM, set the ComVisible attribute to true on that type.
3939
[assembly: ComVisible(false)]
4040

4141
// Version information for an assembly consists of the following four values:
4242
//
4343
// Major Version
44-
// Minor Version
44+
// Minor Version
4545
// Build Number
4646
// Revision
4747
//
48-
// You can specify all the values or you can default the Build and Revision Numbers
48+
// You can specify all the values or you can default the Build and Revision Numbers
4949
// by using the '*' as shown below:
50-
// [assembly: AssemblyVersion("4.99.0")]
5150
[assembly: AssemblyVersion("4.99.0")]
5251
[assembly: AssemblyFileVersion("4.99.0")]
5352

0 commit comments

Comments
 (0)