diff options
author | Vitek Karas <vitek.karas@microsoft.com> | 2020-11-26 12:56:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-26 12:56:39 +0300 |
commit | 01f8592b4dcbc5a5e5e395cc2dba31260e3d3114 (patch) | |
tree | 7874312a72e8d73ccbb4998c5b8c741fbf64197f /test/Mono.Linker.Tests.Cases.Expectations | |
parent | 93a76d90e751850e67357aa0f86ee0a9a7ce25d9 (diff) |
Fix linker crash on unresolved types in generic and attribute data flow handling (#1645)
Unresolved types should be handled as "unknown" value nodes. This is already the case when they appear in a method body. But when they're used either as generic arguments or in attribute instantiations linker doesn't handle this case correctly.
For generics linker would fail with an exception. For attributes linker would ignore the type.
Both cases are wrong since linker needs to make sure to issue a warning if it can't guarantee to meet the requirements posed by the data flow annotations. So ignoring unresolved types is also wrong.
The change fixes these behaviors to treat the value as "unknown" which leads into warnings when used somewhere with data flow requirements.
There's also a small change in where the attribute related warnings are reported - now they should consistently report the warning in the place where the attribute is used (and not on the attribute definition) and also correctly report which members are involved (it used to report the `this` for ctor arguments for example).
Added a new test infra capability to remove an assembly from linker input - to be able to emulate unresolved assembly.
Diffstat (limited to 'test/Mono.Linker.Tests.Cases.Expectations')
-rw-r--r-- | test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileBeforeAttribute.cs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileBeforeAttribute.cs b/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileBeforeAttribute.cs index 54dd63027..0ede197cf 100644 --- a/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileBeforeAttribute.cs +++ b/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileBeforeAttribute.cs @@ -8,7 +8,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata [AttributeUsage (AttributeTargets.Class, AllowMultiple = true)] public class SetupCompileBeforeAttribute : BaseMetadataAttribute { - public SetupCompileBeforeAttribute (string outputName, string[] sourceFiles, string[] references = null, string[] defines = null, string[] resources = null, string additionalArguments = null, string compilerToUse = null, bool addAsReference = true) + public SetupCompileBeforeAttribute (string outputName, string[] sourceFiles, string[] references = null, string[] defines = null, string[] resources = null, string additionalArguments = null, string compilerToUse = null, bool addAsReference = true, bool removeFromLinkerInput = false) { if (sourceFiles == null) throw new ArgumentNullException (nameof (sourceFiles)); @@ -17,7 +17,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata throw new ArgumentException ("Value cannot be null or empty.", nameof (outputName)); } - public SetupCompileBeforeAttribute (string outputName, Type[] typesToIncludeSourceFor, string[] references = null, string[] defines = null, string[] resources = null, string additionalArguments = null, string compilerToUse = null, bool addAsReference = true) + public SetupCompileBeforeAttribute (string outputName, Type[] typesToIncludeSourceFor, string[] references = null, string[] defines = null, string[] resources = null, string additionalArguments = null, string compilerToUse = null, bool addAsReference = true, bool removeFromLinkerInput = false) { if (typesToIncludeSourceFor == null) throw new ArgumentNullException (nameof (typesToIncludeSourceFor)); |