mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 17:56:44 +02:00
Removing hardcoded version numbers from c# telemetry events. (#5283)
* Removing hardcoded version numbers from c# telemetry events. * Removing dependency on powertoysInterop for getting version string. * Defensive checks around getting assembly version
This commit is contained in:
committed by
GitHub
parent
e23b406364
commit
d98d1193fc
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Tracing;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.PowerToys.Telemetry.Events
|
||||
@@ -12,5 +13,26 @@ namespace Microsoft.PowerToys.Telemetry.Events
|
||||
public class EventBase
|
||||
{
|
||||
public bool UTCReplace_AppSessionGuid => true;
|
||||
|
||||
private string _version;
|
||||
public string Version
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_version))
|
||||
{
|
||||
_version = GetVersionFromAssembly();
|
||||
}
|
||||
return _version;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetVersionFromAssembly()
|
||||
{
|
||||
// For consistency this should be formatted the same way as
|
||||
// https://github.com/microsoft/PowerToys/blob/710f92d99965109fd788d85ebf8b6b9e0ba1524a/src/common/common.cpp#L635
|
||||
var version = Assembly.GetExecutingAssembly()?.GetName()?.Version ?? new Version();
|
||||
return $"v{version.Major}.{version.Minor}.{version.Build}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user