Skip to content

Commit 5ca16b7

Browse files
committed
add fallback implementation for target framework which does not have NullabilityInfoContext
1 parent e0c3b42 commit 5ca16b7

File tree

1 file changed

+12
-0
lines changed
  • src/Smdn.Reflection.ReverseGenerating.ListApi.Core/Smdn.Reflection.ReverseGenerating.ListApi

1 file changed

+12
-0
lines changed

src/Smdn.Reflection.ReverseGenerating.ListApi.Core/Smdn.Reflection.ReverseGenerating.ListApi/ApiListWriter.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ static int OrderOfRootNamespace(string ns)
8282
.ThenBy(static ns => ns, StringComparer.Ordinal);
8383

8484
if (options.Writer.WriteNullableAnnotationDirective) {
85+
#if SYSTEM_REFLECTION_NULLABILITYINFOCONTEXT
8586
if (
8687
options.TypeDeclaration.NullabilityInfoContext is not null &&
8788
options.MemberDeclaration.NullabilityInfoContext is not null
@@ -99,6 +100,9 @@ options.MemberDeclaration.NullabilityInfoContext is null
99100
else {
100101
BaseWriter.WriteLine();
101102
}
103+
#else
104+
BaseWriter.WriteLine();
105+
#endif
102106
}
103107
else {
104108
BaseWriter.WriteLine();
@@ -139,13 +143,21 @@ static int OrderOfType(Type t)
139143
.ThenBy(static type => type.FullName, StringComparer.Ordinal);
140144

141145
var enableNullableAnnotationsOnlyOnTypes =
146+
#if SYSTEM_REFLECTION_NULLABILITYINFOCONTEXT
142147
options.Writer.WriteNullableAnnotationDirective &&
143148
options.TypeDeclaration.NullabilityInfoContext is not null &&
144149
options.MemberDeclaration.NullabilityInfoContext is null;
150+
#else
151+
false;
152+
#endif
145153
var enableNullableAnnotationsOnlyOnMembers =
154+
#if SYSTEM_REFLECTION_NULLABILITYINFOCONTEXT
146155
options.Writer.WriteNullableAnnotationDirective &&
147156
options.TypeDeclaration.NullabilityInfoContext is null &&
148157
options.MemberDeclaration.NullabilityInfoContext is not null;
158+
#else
159+
false;
160+
#endif
149161

150162
foreach (var type in orderedTypes) {
151163
var isDelegate = type.IsDelegate();

0 commit comments

Comments
 (0)