Skip to content
Merged
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
10 changes: 8 additions & 2 deletions examples/Demo/Shared/ReflectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,12 @@ public static string ToTypeNameString(this ParameterInfo parameterInfo, Func<Typ
public static string ToTypeNameString(this MethodInfo methodInfo, Func<Type, Queue<string>, 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<TupleElementNamesAttribute>()?.TransformNames, typeNameConverter,
invokeTypeNameConverterForGenericType);
invokeTypeNameConverterForGenericType) + (isNullableType ? "?" : "");
}

/// <summary>
Expand All @@ -206,9 +209,12 @@ public static string ToTypeNameString(this MethodInfo methodInfo, Func<Type, Que
public static string ToTypeNameString(this PropertyInfo propertyInfo, Func<Type, Queue<string>, 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<TupleElementNamesAttribute>()?.TransformNames, typeNameConverter,
invokeTypeNameConverterForGenericType);
invokeTypeNameConverterForGenericType) + (isNullableType ? "?" : "");
}

/// <summary>
Expand Down