Skip to content

Commit 9c1ed73

Browse files
committed
add fallback implementation
1 parent cd89add commit 9c1ed73

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/TypeGenericParameterExtensions.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// SPDX-FileCopyrightText: 2022 smdn <smdn@smdn.jp>
22
// SPDX-License-Identifier: MIT
3+
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER || NET5_0_OR_GREATER
4+
#define SYSTEM_TYPE_ISGENERICMETHODPARAMETER
5+
#endif
6+
37
using System;
48
#if NULL_STATE_STATIC_ANALYSIS_ATTRIBUTES
59
using System.Diagnostics.CodeAnalysis;
@@ -58,9 +62,13 @@ out CustomAttributeData? attrNullableContext
5862
private static CustomAttributeData? FindNullableContextAttribute(Type genericParameter)
5963
{
6064
if (
65+
#if SYSTEM_TYPE_ISGENERICMETHODPARAMETER
6166
genericParameter.IsGenericMethodParameter &&
67+
#else
6268
genericParameter.DeclaringMethod is not null &&
63-
TryGetNullableContextAttribute(genericParameter.DeclaringMethod, out var methodAttr)
69+
genericParameter.IsGenericParameter &&
70+
#endif
71+
TryGetNullableContextAttribute(genericParameter.DeclaringMethod!, out var methodAttr)
6472
) {
6573
return methodAttr;
6674
}

0 commit comments

Comments
 (0)