Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Formatting
  • Loading branch information
vitek-karas committed Jul 20, 2021
commit 4ddd3edf0cc6ed3dd27417174cf84ebbe6a720d7
2 changes: 1 addition & 1 deletion src/linker/Linker.Steps/MarkStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,7 @@ void MarkField (FieldDefinition field, in DependencyInfo reason)

break;
}


if (CheckProcessed (field))
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ public static void MethodWithSingleAnnotatedParameter (
class AttributeWithConstructorWithAnnotation : Attribute
{
public AttributeWithConstructorWithAnnotation (
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] Type type) { }
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] Type type)
{ }
}

[ExpectedWarning ("IL2111", nameof (MethodWithSingleAnnotatedParameter))]
Expand All @@ -95,7 +96,7 @@ static void Reflection ()
}

// Should not warn, there's nothing wrong about this
[AttributeWithConstructorWithAnnotation(typeof (TestType))]
[AttributeWithConstructorWithAnnotation (typeof (TestType))]
static void AnnotatedAttributeConstructor ()
{
}
Expand Down Expand Up @@ -278,27 +279,27 @@ public static void GenericWithAnnotation<
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.Interfaces)] T> ()
{ }

static void ReflectionOnly()
static void ReflectionOnly ()
{
// Should not warn - there's nothing wrong with asking for MethodInfo alone
typeof (AnnotatedGenerics).GetMethod (nameof (GenericWithAnnotation));
}

// Similarly to direct reflection - no warning expected
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicMethods, typeof(AnnotatedGenerics))]
[DynamicDependency (DynamicallyAccessedMemberTypes.PublicMethods, typeof (AnnotatedGenerics))]
static void DynamicDependency ()
{
}

// Similarly to direct reflection - no warning expected
static void DynamicallyAccessedMembers()
static void DynamicallyAccessedMembers ()
{
typeof (AnnotatedGenerics).RequiresPublicMethods ();
}

// This should produce IL2071 https://github.com/mono/linker/issues/2144
[ExpectedWarning ("IL2070", "MakeGenericMethod")]
static void InstantiateGeneric(Type type = null)
static void InstantiateGeneric (Type type = null)
{
// This should warn due to MakeGenericMethod - in this case the generic parameter is unannotated type
typeof (AnnotatedGenerics).GetMethod (nameof (GenericWithAnnotation)).MakeGenericMethod (type);
Expand All @@ -319,11 +320,13 @@ class AnnotationOnGenerics
class GenericWithAnnotatedMethod<T>
{
public static void AnnotatedMethod (
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] Type type) { }
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] Type type)
{ }
}

public static void GenericMethodWithAnnotation<T>(
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] Type type) {}
public static void GenericMethodWithAnnotation<T> (
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] Type type)
{ }

[ExpectedWarning ("IL2111", nameof (GenericWithAnnotatedMethod<TestType>.AnnotatedMethod))]
public static void GenericTypeWithStaticMethodViaLdftn ()
Expand All @@ -343,7 +346,7 @@ public static void GenericMethodWithAnnotationDirectCall ()
GenericMethodWithAnnotation<TestType> (typeof (TestType));
}

[ExpectedWarning ("IL2111", nameof(GenericMethodWithAnnotation))]
[ExpectedWarning ("IL2111", nameof (GenericMethodWithAnnotation))]
public static void GenericMethodWithAnnotationViaLdftn ()
{
var _ = new Action<Type> (GenericMethodWithAnnotation<TestType>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
[SandboxDependency ("Dependencies/TestSystemTypeBase.cs")]

// Suppress warnings about accessing methods with annotations via reflection - the test below does that a LOT
[UnconditionalSuppressMessage("test", "IL2111")]
// (The test accessed these methods through DynamicallyAccessedMembers annotations which is effectively the same reflection access)
[UnconditionalSuppressMessage ("test", "IL2111")]
class VirtualMethodHierarchyDataflowAnnotationValidation
{
public static void Main ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ public static void GenericMethodWithNoRequirements<T> () { }
[Kept]
public static void GenericMethodWithRequirements<
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] T> ()
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] T> ()
{ }

[Kept]
public static void GenericMethodWithRequirementsNoArguments<
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] T> ()
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] T> ()
{ }

[Kept]
Expand Down