Skip to content

Commit

Permalink
Clean up IL2020/IL2021
Browse files Browse the repository at this point in the history
  • Loading branch information
sbomer committed Aug 6, 2020
1 parent 9c53c5a commit f36f95c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 22 deletions.
5 changes: 4 additions & 1 deletion src/linker/Linker.Steps/LinkAttributesStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ List<CustomAttributeArgument> ProcessAttributeArguments (MethodDefinition attrib
object argValue;
TypeDefinition parameterType = attributeConstructor.Parameters[i].ParameterType.Resolve ();
if (!TryConvertValue (arguments[i], parameterType, out argValue)) {
Context.LogWarning ($"Invalid argument value '{arguments[i]}' for attribute '{attributeConstructor.DeclaringType.GetDisplayName ()}'", 2054, _xmlDocumentLocation);
Context.LogWarning (
$"Invalid argument value '{arguments[i]}' for parameter type '{parameterType.GetDisplayName ()}' of attribute '{attributeConstructor.DeclaringType.GetDisplayName ()}'",
2054,
_xmlDocumentLocation);
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ public void TestWarn (string warnArg, WarnVersion expectedVersion)
#nullable enable
[Theory]
[InlineData (true, null, null, new uint[] { }, new uint[] { })]
[InlineData (false, "IL1001,IL####,IL2000,IL2021,IL2022", null,
new uint[] { 2021, 2022 }, new uint[] { })]
[InlineData (false, "IL1001,IL####,IL2000,IL2054,IL2022", null,
new uint[] { 2054, 2022 }, new uint[] { })]
[InlineData (false, "IL2023,IL6000;IL5042 IL2040", "IL4000,IL4001;IL4002 IL4003",
new uint[] { 2023, 2040, 5042, 6000 }, new uint[] { 4000, 4001, 4002, 4003 })]
[InlineData (false, "IL3000;IL3000;ABCD", "IL2005 il3000 IL2005",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;
using Mono.Linker.Tests.Cases.Expectations.Assertions;
Expand Down Expand Up @@ -28,14 +28,6 @@ public static void Main ()

}

public class AttributeWithDoubleNumberParameterAttribute : Attribute
{
public AttributeWithDoubleNumberParameterAttribute (double doubleParameter)
{
}
}


public enum AttributeEnum
{
None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,21 @@
<!-- IL2031 -->
<attribute fullname="NonExistentAttribute"/>

<!-- IL2020 -->
<attribute fullname="Mono.Linker.Tests.Cases.LinkAttributes.LinkAttributeErrorCases/AttributeWithDoubleNumberParameterAttribute">
<argument>3.14</argument>
<!-- IL2022 -->
<attribute fullname="Mono.Linker.Tests.Cases.LinkAttributes.LinkAttributeErrorCases/AttributeWithNoParametersAttribute">
<argument>ExtraArgumentValue</argument>
</attribute>

<!-- IL2021 -->
<!-- IL2054 -->
<attribute fullname="Mono.Linker.Tests.Cases.LinkAttributes.LinkAttributeErrorCases/AttributeWithEnumParameterAttribute">
<argument>NonExistentEnumValue</argument>
</attribute>

<!-- IL2021 -->
<!-- IL2054 -->
<attribute fullname="Mono.Linker.Tests.Cases.LinkAttributes.LinkAttributeErrorCases/AttributeWithIntParameterAttribute">
<argument>NotANumber</argument>
</attribute>

<!-- IL2022 -->
<attribute fullname="Mono.Linker.Tests.Cases.LinkAttributes.LinkAttributeErrorCases/AttributeWithNoParametersAttribute">
<argument>ExtraArgumentValue</argument>
</attribute>

<!-- IL2023 -->
<method name="GetTypeMethod">
<return>
Expand Down

0 comments on commit f36f95c

Please sign in to comment.