Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>2018-01-03 20:32:39 +0300
committerGitHub <noreply@github.com>2018-01-03 20:32:39 +0300
commit42e586596d96407d8e5b56c94fa5103d0ab9fdb3 (patch)
tree6b594d31d412738f93d010ba45e7254efafb598c /tests
parent55b4a7edef7223cde96ba6d86f9d34524103e4bf (diff)
Add handling of method parameter custom attributes (#5188)
We need to apply the same rules as elsewhere to make the attributes reflectable.
Diffstat (limited to 'tests')
-rw-r--r--tests/src/Simple/Reflection/Reflection.cs42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/src/Simple/Reflection/Reflection.cs b/tests/src/Simple/Reflection/Reflection.cs
index 7f05486d6..4454e9415 100644
--- a/tests/src/Simple/Reflection/Reflection.cs
+++ b/tests/src/Simple/Reflection/Reflection.cs
@@ -9,6 +9,7 @@
#endif
using System;
+using System.Runtime.CompilerServices;
using System.Reflection;
[assembly: TestAssembly]
@@ -34,6 +35,7 @@ internal class ReflectionTest
TestStringConstructor.Run();
TestAssemblyAndModuleAttributes.Run();
TestAttributeExpressions.Run();
+ TestParameterAttributes.Run();
//
// Mostly functionality tests
@@ -212,6 +214,46 @@ internal class ReflectionTest
}
}
+ class TestParameterAttributes
+ {
+#if OPTIMIZED_MODE_WITHOUT_SCANNER
+ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+#endif
+ public static bool Method([Parameter] ParameterType parameter)
+ {
+ return parameter == null;
+ }
+
+ public class ParameterType { }
+
+ class ParameterAttribute : Attribute
+ {
+ public ParameterAttribute([CallerMemberName] string memberName = null)
+ {
+ MemberName = memberName;
+ }
+
+ public string MemberName { get; }
+ }
+
+ public static void Run()
+ {
+ Console.WriteLine(nameof(TestParameterAttributes));
+
+ // Ensure things we reflect on are in the static callgraph
+ if (string.Empty.Length > 0)
+ {
+ Method(null);
+ }
+
+ MethodInfo method = typeof(TestParameterAttributes).GetMethod(nameof(Method));
+
+ var attribute = method.GetParameters()[0].GetCustomAttribute<ParameterAttribute>();
+ if (attribute.MemberName != nameof(Method))
+ throw new Exception();
+ }
+ }
+
class TestAttributeExpressions
{
struct FirstNeverUsedType { }