Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ public static CompilationUnitSyntax BuildCompilationUnit(string namespaceName, p
.NormalizeWhitespace();
}

private static readonly string GeneratorVersion = Assembly.GetAssembly(typeof(Generator))!.GetName().Version!.ToString();

private static SyntaxTrivia[] GetFileHeader()
{
string headerText = @$"
//------------------------------------------------------------------------------
// <auto-generated>
// Generated using NetDaemon CodeGenerator nd-codegen v{GeneratorVersion}
// Generated using NetDaemon CodeGenerator nd-codegen v{VersionHelper.GeneratorVersion}
// At: {DateTime.Now:O}
//
// *** Make sure the version of the codegen tool and your nugets Joysoftware.NetDaemon.* have the same version.***
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Reflection;

namespace NetDaemon.HassModel.CodeGenerator.Helpers;

#pragma warning disable CA1303

/// <summary>
/// Helper class for managing NetDaemon version tasks
/// </summary>
public static class VersionHelper
{
/// <summary>
/// Returns current version of NetDaemon
/// </summary>
public static string GeneratorVersion { get; } =
Assembly.GetAssembly(typeof(Generator))!.GetName().Version!.ToString();

/// <summary>
/// Pretty prints version information to console
/// </summary>
public static void PrintVersion()
{
Console.Write("Codegen version: ");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(GeneratorVersion);
Console.ResetColor();
}
}
1 change: 1 addition & 0 deletions src/HassModel/NetDaemon.HassModel.CodeGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
generationSettings.GenerateOneFilePerEntity = args.Any(arg => arg.ToLower(CultureInfo.InvariantCulture) == "-fpe");

var controller = new Controller(generationSettings, haSettings);
VersionHelper.PrintVersion();
await controller.RunAsync().ConfigureAwait(false);

Console.WriteLine();
Expand Down