Skip to content

Commit 5039e50

Browse files
committed
remove workarounds that are no longer needed
1 parent 6c31368 commit 5039e50

File tree

5 files changed

+0
-161
lines changed

5 files changed

+0
-161
lines changed

src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating.Common.props

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ SPDX-License-Identifier: MIT
2222
$(TargetFramework.StartsWith('netstandard2'))
2323
)
2424
">$(DefineConstants);CAN_OVERRIDE_CUSTOMATTRIBUTEDATA_ATTRIBUTETYPE</DefineConstants>
25-
<!-- enable workaround only on .NET 6.x and .NET 7.x -->
26-
<DefineConstants Condition="
27-
$(TargetFramework.StartsWith('net6.')) or
28-
$(TargetFramework.StartsWith('net7.'))
29-
">$(DefineConstants);WORKAROUND_NULLABILITYINFO_BYREFTYPE</DefineConstants>
3025
</PropertyGroup>
3126

3227
<PropertyGroup Label="assembly attributes">

src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/CSharpFormatter.FormatTypeNameWithNullabilityAnnotation.cs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ FormatTypeNameOptions options
4141
)
4242
{
4343
if (target.Type.IsByRef) {
44-
#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
45-
var elementTypeNullabilityInfo = target.ElementType;
46-
#endif
47-
4844
switch (options.AttributeProvider) {
4945
case ParameterInfo para:
5046
// retval/parameter modifiers
@@ -55,22 +51,11 @@ FormatTypeNameOptions options
5551
else /*if (para.IsRetval)*/
5652
builder.Append("ref ");
5753

58-
#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
59-
// [.net6.0] Currently, NullabilityInfo.ElementType is always null if the type is ByRef.
60-
// Uses the workaround implementation instead in that case.
61-
// See https://github.com/dotnet/runtime/issues/72320
62-
if (options.NullabilityInfoContext is not null && target.ElementType is null && para.ParameterType.HasElementType)
63-
elementTypeNullabilityInfo = options.NullabilityInfoContext.Create(new UnwrapByRefParameterInfo(para));
64-
#endif
6554
break;
6655

6756
case PropertyInfo p:
6857
builder.Append("ref ");
6958

70-
#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
71-
if (options.NullabilityInfoContext is not null && target.ElementType is null && p.PropertyType.HasElementType)
72-
elementTypeNullabilityInfo = options.NullabilityInfoContext.Create(new UnwrapByRefPropertyInfo(p));
73-
#endif
7459
break;
7560

7661
// C# 11 ref fields
@@ -81,39 +66,15 @@ FormatTypeNameOptions options
8166
if (f.IsReadOnly())
8267
builder.Append("readonly ");
8368

84-
#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
85-
#if NET7_0_OR_GREATER
86-
if (options.NullabilityInfoContext is not null && f.FieldType.HasElementType)
87-
#else
88-
if (options.NullabilityInfoContext is not null && target.ElementType is null && f.FieldType.HasElementType)
89-
#endif
90-
elementTypeNullabilityInfo = options.NullabilityInfoContext.Create(new UnwrapByRefFieldInfo(f));
91-
92-
#endif
93-
9469
break;
9570
}
96-
97-
#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
98-
if (elementTypeNullabilityInfo is not null) {
99-
return FormatTypeNameWithNullabilityAnnotation(
100-
elementTypeNullabilityInfo,
101-
builder,
102-
options
103-
);
104-
}
105-
#endif
10671
}
10772

10873
var type = target.Type;
10974

11075
if (type.IsArray)
11176
return FormatArray(target, type, builder, options);
11277

113-
#if WORKAROUND_NULLABILITYINFO_BYREFTYPE
114-
if (type.IsPointer || type.IsByRef)
115-
// pointer types or by-ref types (exclude ParameterInfo, PropertyInfo and FieldInfo)
116-
#else
11778
if (type.IsByRef)
11879
type = type.GetElementType()!;
11980

@@ -122,7 +83,6 @@ FormatTypeNameOptions options
12283

12384
if (type.IsPointer)
12485
// pointer types
125-
#endif
12686
return builder.Append(FormatTypeNameCore(type, options));
12787

12888
#if DEBUG

src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/UnwrapByRefFieldInfo.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/UnwrapByRefParameterInfo.cs

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection/UnwrapByRefPropertyInfo.cs

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)