diff options
author | Mateo Torres-Ruiz <mateoatr@users.noreply.github.com> | 2020-07-16 08:40:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-16 08:40:31 +0300 |
commit | 65dc2f30a160d6fc39183747581175fcddabb17c (patch) | |
tree | 793d58165c01c9086cd03a5f4a8f7f80328bd234 | |
parent | 84528f4185f43ccf2f6d1da804f8be353fd576d0 (diff) |
Show error on invalid command-line argument (#1360)
-rw-r--r-- | docs/error-codes.md | 4 | ||||
-rw-r--r-- | src/linker/Linker/Driver.cs | 9 | ||||
-rw-r--r-- | test/Mono.Linker.Tests.Cases/CommandLine/InvalidArguments.cs | 15 |
3 files changed, 21 insertions, 7 deletions
diff --git a/docs/error-codes.md b/docs/error-codes.md index 5c4a02211..373489d44 100644 --- a/docs/error-codes.md +++ b/docs/error-codes.md @@ -55,6 +55,10 @@ error and warning codes. - Element in 'XML document location' contains a 'featuredefault' attribute with an invalid value. This attribute only supports the true value, to indicate that this is the default behavior for a feature when a value is not given. +#### `IL1015`: Unrecognized command-line option: 'option' + +- The linker was passed a string that was not a linker option. + ---- ## Warning Codes diff --git a/src/linker/Linker/Driver.cs b/src/linker/Linker/Driver.cs index b72250775..1a47d1443 100644 --- a/src/linker/Linker/Driver.cs +++ b/src/linker/Linker/Driver.cs @@ -145,11 +145,6 @@ namespace Mono.Linker } } - static void ErrorUnrecognizedOption (string optionName) - { - Console.WriteLine ($"Unrecognized command-line option: '{optionName}'"); - } - static void ErrorMissingArgument (string optionName) { Console.WriteLine ($"Missing argument for '{optionName}' option"); @@ -189,7 +184,7 @@ namespace Mono.Linker while (arguments.Count > 0) { string token = arguments.Dequeue (); if (token.Length < 2) { - ErrorUnrecognizedOption (token); + context.LogError ($"Unrecognized command-line option: '{token}'", 1015); return -1; } @@ -563,7 +558,7 @@ namespace Mono.Linker } } - ErrorUnrecognizedOption (token); + context.LogError ($"Unrecognized command-line option: '{token}'", 1015); return -1; } diff --git a/test/Mono.Linker.Tests.Cases/CommandLine/InvalidArguments.cs b/test/Mono.Linker.Tests.Cases/CommandLine/InvalidArguments.cs new file mode 100644 index 000000000..22f21400a --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/CommandLine/InvalidArguments.cs @@ -0,0 +1,15 @@ +using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; + +namespace Mono.Linker.Tests.Cases.CommandLine +{ + [SetupLinkerArgument ("--verbose", "--invalidArgument")] + [LogContains ("Unrecognized command-line option")] + [NoLinkedOutput] + public class InvalidArguments + { + public static void Main () + { + } + } +} |