Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 73484d4

Browse files
authored
Merge pull request #22577 from dotnet-maestro-bot/merge/release/2.1-to-release/2.2
[automated] Merge branch 'release/2.1' => 'release/2.2'
2 parents 8d03738 + b73e084 commit 73484d4

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

ILAsmVersion.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.2.1-servicing-27207-03
1+
2.2.1-servicing-27207-03

src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/SimpleTypeInfos.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ public override void WriteData(TraceLoggingDataCollector collector, PropertyValu
269269
internal sealed class NullableTypeInfo : TraceLoggingTypeInfo
270270
{
271271
private readonly TraceLoggingTypeInfo valueInfo;
272-
private readonly Func<PropertyValue, PropertyValue> hasValueGetter;
273272
private readonly Func<PropertyValue, PropertyValue> valueGetter;
274273

275274
public NullableTypeInfo(Type type, List<Type> recursionCheck)
@@ -278,7 +277,6 @@ public NullableTypeInfo(Type type, List<Type> recursionCheck)
278277
var typeArgs = type.GenericTypeArguments;
279278
Debug.Assert(typeArgs.Length == 1);
280279
this.valueInfo = TraceLoggingTypeInfo.GetInstance(typeArgs[0], recursionCheck);
281-
this.hasValueGetter = PropertyValue.GetPropertyGetter(type.GetTypeInfo().GetDeclaredProperty("HasValue"));
282280
this.valueGetter = PropertyValue.GetPropertyGetter(type.GetTypeInfo().GetDeclaredProperty("Value"));
283281
}
284282

@@ -294,9 +292,11 @@ public override void WriteMetadata(
294292

295293
public override void WriteData(TraceLoggingDataCollector collector, PropertyValue value)
296294
{
297-
var hasValue = hasValueGetter(value);
295+
// It's not currently possible to get the HasValue property of a nullable type through reflection when the
296+
// value is null. Instead, we simply check that the nullable is not null.
297+
var hasValue = value.ReferenceValue != null;
298298
collector.AddScalar(hasValue);
299-
var val = hasValue.ScalarValue.AsBoolean ? valueGetter(value) : valueInfo.PropertyValueFactory(Activator.CreateInstance(valueInfo.DataType));
299+
var val = hasValue ? valueGetter(value) : valueInfo.PropertyValueFactory(Activator.CreateInstance(valueInfo.DataType));
300300
this.valueInfo.WriteData(collector, val);
301301
}
302302
}

src/mscorlib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingDataCollector.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ public void AddScalar(double value)
8484
DataCollector.ThreadInstance.AddScalar(&value, sizeof(double));
8585
}
8686

87+
/// <summary>
88+
/// Adds a Boolean value to the event payload.
89+
/// </summary>
90+
/// <param name="value">Value to be added.</param>
91+
public void AddScalar(bool value)
92+
{
93+
DataCollector.ThreadInstance.AddScalar(&value, sizeof(bool));
94+
}
95+
8796
/// <summary>
8897
/// Adds a null-terminated String value to the event payload.
8998
/// </summary>

0 commit comments

Comments
 (0)