File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
tests/PolySharp.TypeForwards.Tests Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Linq ;
2
3
using System . Reflection ;
3
4
#if NET6_0_OR_GREATER
4
5
using System . Runtime . CompilerServices ;
@@ -58,5 +59,32 @@ public void IsExternalInit_IsForwarded()
58
59
#endif
59
60
}
60
61
62
+ [ TestMethod ]
63
+ public void RequiresLocationAttribute_IsForwarded ( )
64
+ {
65
+ MethodInfo method = typeof ( TypeForwardTests ) . GetMethod ( nameof ( MethodWithRefReadonlyParameter ) , BindingFlags . Static | BindingFlags . NonPublic ) ! ;
66
+ ParameterInfo parameter = method . GetParameters ( ) [ 0 ] ;
67
+ CustomAttributeData attribute = parameter . CustomAttributes . Last ( ) ;
68
+
69
+ Assert . AreEqual ( "System.Runtime.CompilerServices.RequiresLocationAttribute" , attribute . AttributeType . FullName ) ;
70
+
71
+ #if NET8_0_OR_GREATER
72
+ Assert . AreEqual ( typeof ( object ) . Assembly , typeof ( RequiresLocationAttribute ) . Assembly ) ;
73
+
74
+ string requiresLocationAttributeAssemblyName = typeof ( RequiresLocationAttribute ) . Assembly . GetName ( ) . Name ! ;
75
+
76
+ // Verify the type has been forwarded correctly
77
+ Assert . AreEqual ( requiresLocationAttributeAssemblyName , attribute . AttributeType . Assembly . GetName ( ) . Name ) ;
78
+ Assert . AreEqual ( requiresLocationAttributeAssemblyName , typeof ( TypeForwardTests ) . Assembly . GetType ( "System.Runtime.CompilerServices.RequiresLocationAttribute" ) ! . Assembly . GetName ( ) . Name ) ;
79
+ #else
80
+ // If RequiresLocationAttribute is not available, it should be polyfilled in this project
81
+ Assert . AreEqual ( "PolySharp.TypeForwards.Tests" , attribute . AttributeType . Assembly . GetName ( ) . Name ) ;
82
+ #endif
83
+ }
84
+
61
85
private sealed record Person ( string Name ) ;
86
+
87
+ private static void MethodWithRefReadonlyParameter ( ref readonly int x )
88
+ {
89
+ }
62
90
}
You can’t perform that action at this time.
0 commit comments