blob: a798dfa515900ba9f905310b97dbd3776c7a305f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Diagnostics.CodeAnalysis;
using Mono.Linker.Tests.Cases.Expectations.Assertions;
using Mono.Linker.Tests.Cases.Expectations.Helpers;
using Mono.Linker.Tests.Cases.Expectations.Metadata;
namespace Mono.Linker.Tests.Cases.LinkAttributes
{
[SkipKeptItemsValidation]
[SetupCompileResource ("EmbeddedLinkAttributes.xml", "ILLink.LinkAttributes.xml")]
[IgnoreLinkAttributes (false)]
[RemovedResourceInAssembly ("test.exe", "ILLink.LinkAttributes.xml")]
[ExpectedNoWarnings]
class EmbeddedLinkAttributes
{
public static void Main ()
{
var instance = new EmbeddedLinkAttributes ();
instance.ReadFromInstanceField ();
instance.ReadFromInstanceField2 ();
}
Type _typeWithPublicParameterlessConstructor;
[ExpectedWarning ("IL2077", nameof (DataFlowTypeExtensions) + "." + nameof (DataFlowTypeExtensions.RequiresPublicConstructors))]
[ExpectedWarning ("IL2077", nameof (DataFlowTypeExtensions) + "." + nameof (DataFlowTypeExtensions.RequiresNonPublicConstructors))]
private void ReadFromInstanceField ()
{
_typeWithPublicParameterlessConstructor.RequiresPublicParameterlessConstructor ();
_typeWithPublicParameterlessConstructor.RequiresPublicConstructors ();
_typeWithPublicParameterlessConstructor.RequiresNonPublicConstructors ();
}
Type _typeWithPublicFields;
[ExpectedWarning ("IL2077", nameof (DataFlowTypeExtensions) + "." + nameof (DataFlowTypeExtensions.RequiresPublicConstructors))]
private void ReadFromInstanceField2 ()
{
_typeWithPublicFields.RequiresPublicConstructors ();
_typeWithPublicFields.RequiresPublicFields ();
}
}
}
|