diff --git a/examples/Demo/Shared/ReflectionExtensions.cs b/examples/Demo/Shared/ReflectionExtensions.cs index 1896bde9a4..2885d1c3ff 100644 --- a/examples/Demo/Shared/ReflectionExtensions.cs +++ b/examples/Demo/Shared/ReflectionExtensions.cs @@ -181,9 +181,12 @@ public static string ToTypeNameString(this ParameterInfo parameterInfo, Func, string> typeNameConverter = null, bool invokeTypeNameConverterForGenericType = false) { + bool isNullableType = !methodInfo.ReturnType.IsValueType + && (new NullabilityInfoContext().Create(methodInfo.ReturnParameter).ReadState is NullabilityState.Nullable); + return methodInfo.ReturnType.ToNameStringWithValueTupleNames( methodInfo.ReturnParameter?.GetCustomAttribute()?.TransformNames, typeNameConverter, - invokeTypeNameConverterForGenericType); + invokeTypeNameConverterForGenericType) + (isNullableType ? "?" : ""); } /// @@ -206,9 +209,12 @@ public static string ToTypeNameString(this MethodInfo methodInfo, Func, string> typeNameConverter = null, bool invokeTypeNameConverterForGenericType = false) { + bool isNullableType = !propertyInfo.PropertyType.IsValueType + && (new NullabilityInfoContext().Create(propertyInfo).WriteState is NullabilityState.Nullable); + return propertyInfo.PropertyType.ToNameStringWithValueTupleNames( propertyInfo.GetCustomAttribute()?.TransformNames, typeNameConverter, - invokeTypeNameConverterForGenericType); + invokeTypeNameConverterForGenericType) + (isNullableType ? "?" : ""); } ///