11using System ;
22using System . Collections . Generic ;
3- using System . Linq ;
43
54using Mono . Cecil ;
65using Mono . Cecil . Cil ;
@@ -29,7 +28,7 @@ static bool IsMatch (MethodDefinition ctor, params (string Namespace, string Nam
2928 return true ;
3029 }
3130
32- static MethodDefinition GetConstructor ( TypeDefinition type , params ( string Namespace , string Name ) [ ] parameterTypes )
31+ static MethodDefinition ? GetConstructor ( TypeDefinition type , params ( string Namespace , string Name ) [ ] parameterTypes )
3332 {
3433 foreach ( var ctor in type . Methods ) {
3534 if ( IsMatch ( ctor , parameterTypes ) )
@@ -38,9 +37,9 @@ static MethodDefinition GetConstructor (TypeDefinition type, params (string Name
3837 return null ;
3938 }
4039
41- static string GetLocation ( MethodDefinition method )
40+ static string GetLocation ( MethodDefinition ? method )
4241 {
43- if ( method . DebugInformation . HasSequencePoints ) {
42+ if ( method ? . DebugInformation ? . HasSequencePoints == true ) {
4443 var seq = method . DebugInformation . SequencePoints [ 0 ] ;
4544 return seq . Document . Url + ":" + seq . StartLine + ": " ;
4645 }
@@ -58,7 +57,7 @@ static bool IsFunctionEnd (IList<Instruction> instructions, int index)
5857 return false ;
5958 }
6059
61- static bool VerifyInstructions ( MethodDefinition method , IList < Instruction > instructions , out string reason )
60+ static bool VerifyInstructions ( MethodDefinition method , IList < Instruction > instructions , out string ? reason )
6261 {
6362 reason = null ;
6463
@@ -70,7 +69,7 @@ static bool VerifyInstructions (MethodDefinition method, IList<Instruction> inst
7069 instructions [ 0 ] . OpCode == OpCodes . Ldarg_0 &&
7170 instructions [ 1 ] . OpCode == OpCodes . Ldarg_1 &&
7271 instructions [ 2 ] . OpCode == OpCodes . Call ) {
73- var targetMethod = ( instructions [ 2 ] . Operand as MethodReference ) . Resolve ( ) ;
72+ var targetMethod = ( instructions [ 2 ] . Operand as MethodReference ) ! . Resolve ( ) ;
7473 if ( ! targetMethod . IsConstructor ) {
7574 reason = $ "Calls another method which is not a constructor: { targetMethod . FullName } ";
7675 return false ;
@@ -85,7 +84,7 @@ static bool VerifyInstructions (MethodDefinition method, IList<Instruction> inst
8584 return true ;
8685
8786 if ( instructions [ 3 ] . OpCode == OpCodes . Ldarg_0 && instructions [ 4 ] . OpCode == OpCodes . Ldc_I4_0 && instructions [ 5 ] . OpCode == OpCodes . Call ) {
88- targetMethod = ( instructions [ 5 ] . Operand as MethodReference ) . Resolve ( ) ;
87+ targetMethod = ( instructions [ 5 ] . Operand as MethodReference ) ! . Resolve ( ) ;
8988 if ( targetMethod . Name != "set_IsDirectBinding" ) {
9089 reason = $ "Calls unknown method: { targetMethod . FullName } ";
9190 return false ;
@@ -96,7 +95,7 @@ static bool VerifyInstructions (MethodDefinition method, IList<Instruction> inst
9695 }
9796
9897 if ( instructions [ 3 ] . OpCode == OpCodes . Ldarg_0 && instructions [ 4 ] . OpCode == OpCodes . Call ) {
99- targetMethod = ( instructions [ 4 ] . Operand as MethodReference ) . Resolve ( ) ;
98+ targetMethod = ( instructions [ 4 ] . Operand as MethodReference ) ! . Resolve ( ) ;
10099 if ( targetMethod . Name != "MarkDirtyIfDerived" ) {
101100 reason = $ "Calls unknown method: { targetMethod . FullName } ";
102101 return false ;
@@ -113,7 +112,7 @@ static bool VerifyInstructions (MethodDefinition method, IList<Instruction> inst
113112 instructions [ 1 ] . OpCode == OpCodes . Ldarg_1 &&
114113 ( instructions [ 2 ] . OpCode == OpCodes . Ldarg_2 || instructions [ 2 ] . OpCode == OpCodes . Ldc_I4_0 ) &&
115114 instructions [ 3 ] . OpCode == OpCodes . Call ) {
116- var targetMethod = ( instructions [ 3 ] . Operand as MethodReference ) . Resolve ( ) ;
115+ var targetMethod = ( instructions [ 3 ] . Operand as MethodReference ) ! . Resolve ( ) ;
117116 if ( ! targetMethod . IsConstructor ) {
118117 reason = $ "Calls another method which is not a constructor (2): { targetMethod . FullName } ";
119118 return false ;
@@ -135,7 +134,7 @@ static bool VerifyInstructions (MethodDefinition method, IList<Instruction> inst
135134 ( instructions [ 2 ] . OpCode == OpCodes . Ldarg_2 || instructions [ 2 ] . OpCode == OpCodes . Ldc_I4_0 ) &&
136135 ( instructions [ 3 ] . OpCode == OpCodes . Ldc_I4_0 || instructions [ 3 ] . OpCode == OpCodes . Ldc_I4_1 ) &&
137136 instructions [ 4 ] . OpCode == OpCodes . Call ) {
138- var targetMethod = ( instructions [ 4 ] . Operand as MethodReference ) . Resolve ( ) ;
137+ var targetMethod = ( instructions [ 4 ] . Operand as MethodReference ) ! . Resolve ( ) ;
139138 if ( ! targetMethod . IsConstructor ) {
140139 reason = $ "Calls another method which is not a constructor (2): { targetMethod . FullName } ";
141140 return false ;
@@ -156,7 +155,7 @@ static bool VerifyInstructions (MethodDefinition method, IList<Instruction> inst
156155 return false ;
157156 }
158157
159- static bool VerifyConstructor ( MethodDefinition ctor , out string failureReason )
158+ static bool VerifyConstructor ( MethodDefinition ? ctor , out string ? failureReason )
160159 {
161160 failureReason = null ;
162161 // There's nothing wrong with a constructor that doesn't exist
@@ -175,7 +174,7 @@ static bool VerifyConstructor (MethodDefinition ctor, out string failureReason)
175174 return true ;
176175 }
177176
178- public static bool ImplementsINativeObject ( TypeDefinition type )
177+ public static bool ImplementsINativeObject ( TypeDefinition ? type )
179178 {
180179 if ( type is null )
181180 return false ;
@@ -189,7 +188,7 @@ public static bool ImplementsINativeObject (TypeDefinition type)
189188 return ImplementsINativeObject ( type . BaseType ? . Resolve ( ) ) ;
190189 }
191190
192- public static bool SubclassesNSObject ( TypeDefinition type )
191+ public static bool SubclassesNSObject ( TypeDefinition ? type )
193192 {
194193 if ( type is null )
195194 return false ;
@@ -236,7 +235,6 @@ public void INativeObjectIntPtrConstructorDoesNotOwnHandle (ApplePlatform platfo
236235
237236 var failures = new List < string > ( ) ;
238237 foreach ( var dll in Configuration . GetBaseLibraryImplementations ( platform ) ) {
239- Console . WriteLine ( dll ) ;
240238 using ( var ad = AssemblyDefinition . ReadAssembly ( dll , new ReaderParameters ( ReadingMode . Deferred ) { ReadSymbols = true } ) ) {
241239 foreach ( var type in ad . MainModule . Types ) {
242240 // Skip classes we know aren't (properly) reference counted.
0 commit comments