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

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitek Karas <vitek.karas@microsoft.com>2020-07-08 14:08:43 +0300
committerGitHub <noreply@github.com>2020-07-08 14:08:43 +0300
commitcf697fca5162e2a87c77226798c67b42f6828178 (patch)
tree275a11046463df9a1b066aea8a217e8fd9c2c8d8 /test/Mono.Linker.Tests.Cases.Expectations
parentf1aadabc832eaad6be133a13d5bb69ef2ab0011f (diff)
Validation of annotations across virtual method hierarchies (#1315)
For the linker to work correctly all correctness annotations must be exactly the same on all methods in a single virtual method override hierarchy. Currently this applies to DynamicallyAccessedMemberAttribute and RequiresUnreferencedCodeAttribute. The validation is postponed after the MarkStep since it requires full knowledge of virtual method hierarchies (and interface method hierarchies). With TypeMapStep these are available during MarkStep as well, but we're trying to move away from that requirement, so the validation is done after MarkStep, this only adds a very small amount of memory (the list of methods to validate is currently cca 200 for the entire corelibe). Refactorings to help with this change: * Change how we store generic parameter annotations - it now copies the method parameter annotation storage - array indexed by the index of the generic parameter on the type/method. This makes it easy to map the annotation to a generic parameter on any method in the virtual hierarchy (as they all share the same index). * FlowAnnotations are now stored directly on the Annotations class (since the new step needs them after MarkStep) * Move some helpers into DataFlowUtilities - mostly around getting description of members for error message purposes * Synchronize behavior of LogContains and LogDoesNotContain test attributes - both now support "contains" and "regex" versions * Correctly detect persense of LogContains and LogDoesNotContain attributes on all members of a test, so that test logging is turned on when they're used * Added a TestSystemTypeBase class - which is a class derived from System.Type and implements all abstract members. This is used to then write test classes which need to derive from System.Type (to test the "this" parameter annotations).
Diffstat (limited to 'test/Mono.Linker.Tests.Cases.Expectations')
-rw-r--r--test/Mono.Linker.Tests.Cases.Expectations/Assertions/LogDoesNotContainAttribute.cs2
-rw-r--r--test/Mono.Linker.Tests.Cases.Expectations/Support/TestSystemTypeBase.cs165
2 files changed, 166 insertions, 1 deletions
diff --git a/test/Mono.Linker.Tests.Cases.Expectations/Assertions/LogDoesNotContainAttribute.cs b/test/Mono.Linker.Tests.Cases.Expectations/Assertions/LogDoesNotContainAttribute.cs
index d4299fde1..599908cfb 100644
--- a/test/Mono.Linker.Tests.Cases.Expectations/Assertions/LogDoesNotContainAttribute.cs
+++ b/test/Mono.Linker.Tests.Cases.Expectations/Assertions/LogDoesNotContainAttribute.cs
@@ -8,7 +8,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
Inherited = false)]
public class LogDoesNotContainAttribute : EnableLoggerAttribute
{
- public LogDoesNotContainAttribute (string message)
+ public LogDoesNotContainAttribute (string message, bool regexMatch = false)
{
if (string.IsNullOrEmpty (message))
throw new ArgumentException ("Value cannot be null or empty.", nameof (message));
diff --git a/test/Mono.Linker.Tests.Cases.Expectations/Support/TestSystemTypeBase.cs b/test/Mono.Linker.Tests.Cases.Expectations/Support/TestSystemTypeBase.cs
new file mode 100644
index 000000000..c1a90a423
--- /dev/null
+++ b/test/Mono.Linker.Tests.Cases.Expectations/Support/TestSystemTypeBase.cs
@@ -0,0 +1,165 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Globalization;
+using System.Reflection;
+
+namespace System
+{
+ public class TestSystemTypeBase : Type
+ {
+ public override Assembly Assembly => throw new NotImplementedException ();
+
+ public override string AssemblyQualifiedName => throw new NotImplementedException ();
+
+ public override Type BaseType => throw new NotImplementedException ();
+
+ public override string FullName => throw new NotImplementedException ();
+
+ public override Guid GUID => throw new NotImplementedException ();
+
+ public override Module Module => throw new NotImplementedException ();
+
+ public override string Namespace => throw new NotImplementedException ();
+
+ public override Type UnderlyingSystemType => throw new NotImplementedException ();
+
+ public override string Name => throw new NotImplementedException ();
+
+ public override ConstructorInfo[] GetConstructors (BindingFlags bindingAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override object[] GetCustomAttributes (bool inherit)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override object[] GetCustomAttributes (Type attributeType, bool inherit)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override Type GetElementType ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override EventInfo GetEvent (string name, BindingFlags bindingAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override EventInfo[] GetEvents (BindingFlags bindingAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override FieldInfo GetField (string name, BindingFlags bindingAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override FieldInfo[] GetFields (BindingFlags bindingAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override Type GetInterface (string name, bool ignoreCase)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override Type[] GetInterfaces ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override MemberInfo[] GetMembers (BindingFlags bindingAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override MethodInfo[] GetMethods (BindingFlags bindingAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override Type GetNestedType (string name, BindingFlags bindingAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override Type[] GetNestedTypes (BindingFlags bindingAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override PropertyInfo[] GetProperties (BindingFlags bindingAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override object InvokeMember (string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override bool IsDefined (Type attributeType, bool inherit)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected override TypeAttributes GetAttributeFlagsImpl ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected override ConstructorInfo GetConstructorImpl (BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected override MethodInfo GetMethodImpl (string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected override PropertyInfo GetPropertyImpl (string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected override bool HasElementTypeImpl ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected override bool IsArrayImpl ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected override bool IsByRefImpl ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected override bool IsCOMObjectImpl ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected override bool IsPointerImpl ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected override bool IsPrimitiveImpl ()
+ {
+ throw new NotImplementedException ();
+ }
+ }
+} \ No newline at end of file