@@ -3,30 +3,32 @@ namespace ValidCode
33{
44 using System ;
55 using System . Reflection ;
6+
67 using NUnit . Framework ;
78
89 public class Accessors
910 {
10- public event EventHandler Baz ;
11+ #pragma warning disable CS0067
12+ public event EventHandler ? E ;
1113
12- public int Bar { get ; set ; }
14+ public int P { get ; set ; }
1315
1416 [ Test ]
1517 public void Valid ( )
1618 {
17- var instance = new Accessors { Bar = 1 } ;
19+ var instance = new Accessors { P = 1 } ;
1820#pragma warning disable REFL014
19- Assert . NotNull ( typeof ( Accessors ) . GetMethod ( "get_Bar " , BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ) ;
20- Assert . AreEqual ( 1 , typeof ( Accessors ) . GetMethod ( "get_Bar " , BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ? . Invoke ( instance , null ) ) ;
21+ Assert . NotNull ( typeof ( Accessors ) . GetMethod ( "get_P " , BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ) ;
22+ Assert . AreEqual ( 1 , typeof ( Accessors ) . GetMethod ( "get_P " , BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ? . Invoke ( instance , null ) ) ;
2123
22- Assert . NotNull ( typeof ( Accessors ) . GetMethod ( "set_Bar " , BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ) ;
23- Assert . Null ( typeof ( Accessors ) . GetMethod ( "set_Bar " , BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ? . Invoke ( instance , new object [ ] { 1 } ) ) ;
24+ Assert . NotNull ( typeof ( Accessors ) . GetMethod ( "set_P " , BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ) ;
25+ Assert . Null ( typeof ( Accessors ) . GetMethod ( "set_P " , BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ? . Invoke ( instance , new object [ ] { 1 } ) ) ;
2426
25- Assert . NotNull ( typeof ( Accessors ) . GetMethod ( "add_Baz " , BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ) ;
26- Assert . Null ( typeof ( Accessors ) . GetMethod ( "add_Baz " , BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ? . Invoke ( instance , new object [ ] { new EventHandler ( ( _ , __ ) => { } ) } ) ) ;
27+ Assert . NotNull ( typeof ( Accessors ) . GetMethod ( "add_E " , BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ) ;
28+ Assert . Null ( typeof ( Accessors ) . GetMethod ( "add_E " , BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ? . Invoke ( instance , new object [ ] { new EventHandler ( ( _ , __ ) => { } ) } ) ) ;
2729
28- Assert . NotNull ( typeof ( Accessors ) . GetMethod ( "remove_Baz " , BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ) ;
29- Assert . Null ( typeof ( Accessors ) . GetMethod ( "remove_Baz " , BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ? . Invoke ( instance , new object [ ] { new EventHandler ( ( _ , __ ) => { } ) } ) ) ;
30+ Assert . NotNull ( typeof ( Accessors ) . GetMethod ( "remove_E " , BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ) ;
31+ Assert . Null ( typeof ( Accessors ) . GetMethod ( "remove_E " , BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ? . Invoke ( instance , new object [ ] { new EventHandler ( ( _ , __ ) => { } ) } ) ) ;
3032#pragma warning restore REFL014
3133 }
3234 }
0 commit comments