-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more warning suppression scenarios (#1232)
Co-authored-by: Vitek Karas <[email protected]>
- Loading branch information
1 parent
9edcb49
commit ba6d3da
Showing
5 changed files
with
241 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
test/Mono.Linker.Tests.Cases/WarningSuppression/SuppressWarningsInAssembly.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Mono.Linker.Tests.Cases.Expectations.Assertions; | ||
using Mono.Linker.Tests.Cases.Expectations.Metadata; | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq.Expressions; | ||
|
||
[assembly: UnconditionalSuppressMessage ("Test", "IL2006:Suppress unrecognized reflection pattern warnings in this assembly")] | ||
|
||
namespace Mono.Linker.Tests.Cases.WarningSuppression | ||
{ | ||
[SkipKeptItemsValidation] | ||
[LogDoesNotContain ("TriggerUnrecognizedPattern()")] | ||
public class SuppressWarningsInAssembly | ||
{ | ||
public static void Main () | ||
{ | ||
Expression.Call (TriggerUnrecognizedPattern (), "", Type.EmptyTypes); | ||
} | ||
|
||
public static Type TriggerUnrecognizedPattern () | ||
{ | ||
return typeof (SuppressWarningsInAssembly); | ||
} | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
...ono.Linker.Tests.Cases/WarningSuppression/SuppressWarningsInMembersAndTypesUsingTarget.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using Mono.Linker.Tests.Cases.Expectations.Assertions; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq.Expressions; | ||
using System.Text; | ||
|
||
[module: UnconditionalSuppressMessage ("Test", "IL2006", Scope = "type", Target = "T:Mono.Linker.Tests.Cases.WarningSuppression.WarningsInType")] | ||
[module: UnconditionalSuppressMessage ("Test", "IL2006", Scope = "member", Target = "M:Mono.Linker.Tests.Cases.WarningSuppression.WarningsInMembers.Method")] | ||
[module: UnconditionalSuppressMessage ("Test", "IL2006", Scope = "member", Target = "M:Mono.Linker.Tests.Cases.WarningSuppression.WarningsInMembers.get_Property")] | ||
|
||
namespace Mono.Linker.Tests.Cases.WarningSuppression | ||
{ | ||
[SkipKeptItemsValidation] | ||
[LogDoesNotContain ("TriggerUnrecognizedPattern()")] | ||
public class SuppressWarningsInMembersAndTypesUsingTarget | ||
{ | ||
public static void Main () | ||
{ | ||
var warningsInType = new WarningsInType (); | ||
warningsInType.Warning1 (); | ||
warningsInType.Warning2 (); | ||
var warningInNestedType = new WarningsInType.NestedType (); | ||
warningInNestedType.Warning3 (); | ||
|
||
var warningsInMembers = new WarningsInMembers (); | ||
warningsInMembers.Method (); | ||
int propertyThatTriggersWarning = warningsInMembers.Property; | ||
} | ||
|
||
public static Type TriggerUnrecognizedPattern () | ||
{ | ||
return typeof (SuppressWarningsInMembersAndTypesUsingTarget); | ||
} | ||
|
||
public class NestedType | ||
{ | ||
public static void Warning () | ||
{ | ||
Expression.Call (TriggerUnrecognizedPattern (), "", Type.EmptyTypes); | ||
} | ||
} | ||
} | ||
|
||
public class WarningsInType | ||
{ | ||
public void Warning1 () | ||
{ | ||
Expression.Call (SuppressWarningsInMembersAndTypesUsingTarget.TriggerUnrecognizedPattern (), "", Type.EmptyTypes); | ||
} | ||
|
||
public void Warning2 () | ||
{ | ||
Expression.Call (SuppressWarningsInMembersAndTypesUsingTarget.TriggerUnrecognizedPattern (), "", Type.EmptyTypes); | ||
} | ||
|
||
public class NestedType | ||
{ | ||
public void Warning3 () | ||
{ | ||
void Warning4 () | ||
{ | ||
Expression.Call (SuppressWarningsInMembersAndTypesUsingTarget.TriggerUnrecognizedPattern (), "", Type.EmptyTypes); | ||
} | ||
|
||
SuppressWarningsInMembersAndTypesUsingTarget.TriggerUnrecognizedPattern (); | ||
Warning4 (); | ||
} | ||
} | ||
} | ||
|
||
public class WarningsInMembers | ||
{ | ||
public void Method () | ||
{ | ||
Expression.Call (SuppressWarningsInMembersAndTypesUsingTarget.TriggerUnrecognizedPattern (), "", Type.EmptyTypes); | ||
} | ||
|
||
public int Property { | ||
get { | ||
Expression.Call (SuppressWarningsInMembersAndTypesUsingTarget.TriggerUnrecognizedPattern (), "", Type.EmptyTypes); | ||
return 0; | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
test/Mono.Linker.Tests.Cases/WarningSuppression/SuppressWarningsInModule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Mono.Linker.Tests.Cases.Expectations.Assertions; | ||
using Mono.Linker.Tests.Cases.Expectations.Metadata; | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq.Expressions; | ||
|
||
[module: UnconditionalSuppressMessage ("Test", "IL2006:Suppress unrecognized reflection pattern warnings in this module")] | ||
|
||
namespace Mono.Linker.Tests.Cases.WarningSuppression | ||
{ | ||
[SkipKeptItemsValidation] | ||
[LogDoesNotContain ("TriggerUnrecognizedPattern()")] | ||
public class SuppressWarningsInModule | ||
{ | ||
public static void Main () | ||
{ | ||
Expression.Call (TriggerUnrecognizedPattern (), "", Type.EmptyTypes); | ||
} | ||
|
||
public static Type TriggerUnrecognizedPattern () | ||
{ | ||
return typeof (SuppressWarningsInModule); | ||
} | ||
} | ||
} |