diff options
author | Sung Yoon Whang <suwhang@microsoft.com> | 2019-06-14 10:30:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-14 10:30:31 -0700 |
commit | 87a8b4d87b0c9b5a9110af06ce62e6d24a197d77 (patch) | |
tree | 291b106300161cefa0474503d348dc498ef4e63e | |
parent | c65b784b46b9cc7914e595b43ae1378c5cd9aa1e (diff) | |
download | coreclr-87a8b4d87b0c9b5a9110af06ce62e6d24a197d77.tar.gz coreclr-87a8b4d87b0c9b5a9110af06ce62e6d24a197d77.tar.bz2 coreclr-87a8b4d87b0c9b5a9110af06ce62e6d24a197d77.zip |
Make DisplayUnits string.Empty by default instead of null (#25104)
* Make DisplayUnits string.Empty by default instead of null
* PR feedback on DisplayName and setter validation
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/DiagnosticCounter.cs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/DiagnosticCounter.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/DiagnosticCounter.cs index ade22c7553..5a4429f23f 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/DiagnosticCounter.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/DiagnosticCounter.cs @@ -45,6 +45,7 @@ namespace System.Diagnostics.Tracing _group = CounterGroup.GetCounterGroup(eventSource); _group.Add(this); Name = name; + DisplayUnits = string.Empty; EventSource = eventSource; } @@ -75,9 +76,29 @@ namespace System.Diagnostics.Tracing } } - public string? DisplayName { get; set; } + private string _displayName = ""; + public string DisplayName + { + set + { + if (value == null) + throw new ArgumentException("Cannot set null as DisplayName"); + _displayName = value; + } + get { return _displayName; } + } - public string? DisplayUnits { get; set; } + private string _displayUnits = ""; + public string DisplayUnits + { + set + { + if (value == null) + throw new ArgumentException("Cannot set null as DisplayUnits"); + _displayUnits = value; + } + get { return _displayUnits; } + } public string Name { get; } |