diff options
author | Mateo Torres-Ruiz <mateoatr@users.noreply.github.com> | 2021-07-08 23:51:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-08 23:51:38 +0300 |
commit | b9501922637806f4135df09a9922d5540e203858 (patch) | |
tree | 29d37c1e66236a2148e6c9351180261c8fbd26fe /docs | |
parent | a80487eb681649f8182d729f5c2dc4d9be0e7b40 (diff) |
Check target of module/assembly level suppressions (#2129)
* Check that global level suppressions do not specify any target
* Run lint
* Update test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInModule.cs
Co-authored-by: Sven Boemer <sbomer@gmail.com>
* Add code snippet with an example of 2108.
* PR feedback
Add tests
* Lint
* Don't silently suppress warnings on module if scope is missing and a target was used.
Co-authored-by: Sven Boemer <sbomer@gmail.com>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/error-codes.md | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/docs/error-codes.md b/docs/error-codes.md index 2ef1b68ff..115b3c243 100644 --- a/docs/error-codes.md +++ b/docs/error-codes.md @@ -1683,6 +1683,29 @@ class Test } ``` +#### `IL2108`: Invalid scope 'scope' used in 'UnconditionalSuppressMessageAttribute' on module 'module' with target 'target'. + +The only scopes supported on global unconditional suppressions are 'module', 'type' and 'member'. If the scope and target arguments are null or missing on a global suppression, +it is assumed that the suppression is put on the module. Global unconditional suppressions using invalid scopes are ignored. + +```C# +// Invalid scope 'method' used in 'UnconditionalSuppressMessageAttribute' on module 'Warning' with target 'MyTarget'. +[module: UnconditionalSuppressMessage ("Test suppression with invalid scope", "IL2026", Scope = "method", Target = "MyTarget")] + +class Warning +{ + static void Main(string[] args) + { + Foo(); + } + + [RequiresUnreferencedCode("Warn when Foo() is called")] + static void Foo() + { + } +} +``` + ## Single-File Warning Codes #### `IL3000`: 'member' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory' |