@@ -127,59 +127,59 @@ public void Generate_ProxyType_HasCtorAndCreateInstance ()
127127
128128 }
129129
130- public class AcwProxy : IDisposable
131- {
132- readonly string _outputDir = CreateTempDir ( ) ;
133- public void Dispose ( ) => DeleteTempDir ( _outputDir ) ;
130+ public class AcwProxy : IDisposable
131+ {
132+ readonly string _outputDir = CreateTempDir ( ) ;
133+ public void Dispose ( ) => DeleteTempDir ( _outputDir ) ;
134134
135- [ Fact ]
136- public void Generate_AcwProxy_HasRegisterNativesAndUcoMethods ( )
137- {
138- var peers = ScanFixtures ( ) ;
139- var acwPeer = peers . First ( p => p . JavaName == "my/app/TouchHandler" ) ;
140- var path = GenerateAssembly ( new [ ] { acwPeer } , _outputDir , "AcwTest" ) ;
141- var ( pe , reader ) = OpenAssembly ( path ) ;
142- using ( pe ) {
143- var proxy = reader . TypeDefinitions
144- . Select ( h => reader . GetTypeDefinition ( h ) )
145- . First ( t => reader . GetString ( t . Name ) == "MyApp_TouchHandler_Proxy" ) ;
146-
147- var methods = proxy . GetMethods ( )
148- . Select ( h => reader . GetMethodDefinition ( h ) )
149- . Select ( m => reader . GetString ( m . Name ) )
150- . ToList ( ) ;
151-
152- Assert . Contains ( "RegisterNatives" , methods ) ;
153- Assert . Contains ( methods , m => m . StartsWith ( "n_" ) && m . EndsWith ( "_uco_0" ) ) ;
154- }
155- }
156-
157- [ Fact ]
158- public void Generate_AcwProxy_HasUnmanagedCallersOnlyAttribute ( )
159- {
160- var peers = ScanFixtures ( ) ;
161- var acwPeer = peers . First ( p => p . JavaName == "my/app/TouchHandler" ) ;
162- var path = GenerateAssembly ( new [ ] { acwPeer } , _outputDir , "UcoTest" ) ;
163- var ( pe , reader ) = OpenAssembly ( path ) ;
164- using ( pe ) {
165- var proxy = reader . TypeDefinitions
166- . Select ( h => reader . GetTypeDefinition ( h ) )
167- . First ( t => reader . GetString ( t . Name ) == "MyApp_TouchHandler_Proxy" ) ;
168-
169- var ucoMethod = proxy . GetMethods ( )
170- . Select ( h => reader . GetMethodDefinition ( h ) )
171- . First ( m => reader . GetString ( m . Name ) . Contains ( "_uco_" ) ) ;
172-
173- var attrs = ucoMethod . GetCustomAttributes ( )
174- . Select ( h => reader . GetCustomAttribute ( h ) )
175- . ToList ( ) ;
176- Assert . NotEmpty ( attrs ) ;
177- }
178- }
179-
180- }
181-
182- public class IgnoresAccessChecksTo : IDisposable
135+ [ Fact ]
136+ public void Generate_AcwProxy_HasRegisterNativesAndUcoMethods ( )
137+ {
138+ var peers = ScanFixtures ( ) ;
139+ var acwPeer = peers . First ( p => p . JavaName == "my/app/TouchHandler" ) ;
140+ var path = GenerateAssembly ( new [ ] { acwPeer } , _outputDir , "AcwTest" ) ;
141+ var ( pe , reader ) = OpenAssembly ( path ) ;
142+ using ( pe ) {
143+ var proxy = reader . TypeDefinitions
144+ . Select ( h => reader . GetTypeDefinition ( h ) )
145+ . First ( t => reader . GetString ( t . Name ) == "MyApp_TouchHandler_Proxy" ) ;
146+
147+ var methods = proxy . GetMethods ( )
148+ . Select ( h => reader . GetMethodDefinition ( h ) )
149+ . Select ( m => reader . GetString ( m . Name ) )
150+ . ToList ( ) ;
151+
152+ Assert . Contains ( "RegisterNatives" , methods ) ;
153+ Assert . Contains ( methods , m => m . StartsWith ( "n_" ) && m . EndsWith ( "_uco_0" ) ) ;
154+ }
155+ }
156+
157+ [ Fact ]
158+ public void Generate_AcwProxy_HasUnmanagedCallersOnlyAttribute ( )
159+ {
160+ var peers = ScanFixtures ( ) ;
161+ var acwPeer = peers . First ( p => p . JavaName == "my/app/TouchHandler" ) ;
162+ var path = GenerateAssembly ( new [ ] { acwPeer } , _outputDir , "UcoTest" ) ;
163+ var ( pe , reader ) = OpenAssembly ( path ) ;
164+ using ( pe ) {
165+ var proxy = reader . TypeDefinitions
166+ . Select ( h => reader . GetTypeDefinition ( h ) )
167+ . First ( t => reader . GetString ( t . Name ) == "MyApp_TouchHandler_Proxy" ) ;
168+
169+ var ucoMethod = proxy . GetMethods ( )
170+ . Select ( h => reader . GetMethodDefinition ( h ) )
171+ . First ( m => reader . GetString ( m . Name ) . Contains ( "_uco_" ) ) ;
172+
173+ var attrs = ucoMethod . GetCustomAttributes ( )
174+ . Select ( h => reader . GetCustomAttribute ( h ) )
175+ . ToList ( ) ;
176+ Assert . NotEmpty ( attrs ) ;
177+ }
178+ }
179+
180+ }
181+
182+ public class IgnoresAccessChecksTo : IDisposable
183183 {
184184 readonly string _outputDir = CreateTempDir ( ) ;
185185 public void Dispose ( ) => DeleteTempDir ( _outputDir ) ;
@@ -280,63 +280,63 @@ public void Generate_EmptyPeerList_ProducesValidAssembly ()
280280
281281 }
282282
283- public class JniSignatureHelperTests
284- {
283+ public class JniSignatureHelperTests
284+ {
285285
286- [ Theory ]
287- [ InlineData ( "()V" , 0 ) ]
288- [ InlineData ( "(I)V" , 1 ) ]
289- [ InlineData ( "(Landroid/os/Bundle;)V" , 1 ) ]
290- [ InlineData ( "(IFJ)V" , 3 ) ]
291- [ InlineData ( "(ZLandroid/view/View;I)Z" , 3 ) ]
292- [ InlineData ( "([Ljava/lang/String;)V" , 1 ) ]
293- public void ParseParameterTypes_ParsesCorrectCount ( string signature , int expectedCount )
294- {
295- var actual = JniSignatureHelper . ParseParameterTypes ( signature ) ;
296- Assert . Equal ( expectedCount , actual . Count ) ;
297- }
298-
299- [ Theory ]
300- [ InlineData ( "(Z)V" , JniParamKind . Boolean ) ]
301- [ InlineData ( "(Ljava/lang/String;)V" , JniParamKind . Object ) ]
302- public void ParseParameterTypes_SingleParam_MapsToCorrectKind ( string signature , JniParamKind expectedKind )
303- {
304- var types = JniSignatureHelper . ParseParameterTypes ( signature ) ;
305- Assert . Single ( types ) ;
306- Assert . Equal ( expectedKind , types [ 0 ] ) ;
307- }
308-
309- [ Theory ]
310- [ InlineData ( "()V" , JniParamKind . Void ) ]
311- [ InlineData ( "()I" , JniParamKind . Int ) ]
312- [ InlineData ( "()Z" , JniParamKind . Boolean ) ]
313- [ InlineData ( "()Ljava/lang/String;" , JniParamKind . Object ) ]
314- public void ParseReturnType_MapsToCorrectKind ( string signature , JniParamKind expectedKind )
315- {
316- Assert . Equal ( expectedKind , JniSignatureHelper . ParseReturnType ( signature ) ) ;
317- }
286+ [ Theory ]
287+ [ InlineData ( "()V" , 0 ) ]
288+ [ InlineData ( "(I)V" , 1 ) ]
289+ [ InlineData ( "(Landroid/os/Bundle;)V" , 1 ) ]
290+ [ InlineData ( "(IFJ)V" , 3 ) ]
291+ [ InlineData ( "(ZLandroid/view/View;I)Z" , 3 ) ]
292+ [ InlineData ( "([Ljava/lang/String;)V" , 1 ) ]
293+ public void ParseParameterTypes_ParsesCorrectCount ( string signature , int expectedCount )
294+ {
295+ var actual = JniSignatureHelper . ParseParameterTypes ( signature ) ;
296+ Assert . Equal ( expectedCount , actual . Count ) ;
297+ }
318298
319- }
299+ [ Theory ]
300+ [ InlineData ( "(Z)V" , JniParamKind . Boolean ) ]
301+ [ InlineData ( "(Ljava/lang/String;)V" , JniParamKind . Object ) ]
302+ public void ParseParameterTypes_SingleParam_MapsToCorrectKind ( string signature , JniParamKind expectedKind )
303+ {
304+ var types = JniSignatureHelper . ParseParameterTypes ( signature ) ;
305+ Assert . Single ( types ) ;
306+ Assert . Equal ( expectedKind , types [ 0 ] ) ;
307+ }
320308
321- public class NegativeEdgeCase
322- {
309+ [ Theory ]
310+ [ InlineData ( "()V" , JniParamKind . Void ) ]
311+ [ InlineData ( "()I" , JniParamKind . Int ) ]
312+ [ InlineData ( "()Z" , JniParamKind . Boolean ) ]
313+ [ InlineData ( "()Ljava/lang/String;" , JniParamKind . Object ) ]
314+ public void ParseReturnType_MapsToCorrectKind ( string signature , JniParamKind expectedKind )
315+ {
316+ Assert . Equal ( expectedKind , JniSignatureHelper . ParseReturnType ( signature ) ) ;
317+ }
323318
324- [ Theory ]
325- [ InlineData ( "" ) ]
326- [ InlineData ( "not-a-sig" ) ]
327- [ InlineData ( "(" ) ]
328- public void ParseParameterTypes_InvalidSignature_ThrowsOrReturnsEmpty ( string signature )
329- {
330- try {
331- var result = JniSignatureHelper . ParseParameterTypes ( signature ) ;
332- Assert . NotNull ( result ) ;
333- } catch ( Exception ex ) when ( ex is ArgumentException || ex is IndexOutOfRangeException || ex is FormatException ) {
334- }
335- }
319+ }
336320
337- }
321+ public class NegativeEdgeCase
322+ {
323+
324+ [ Theory ]
325+ [ InlineData ( "" ) ]
326+ [ InlineData ( "not-a-sig" ) ]
327+ [ InlineData ( "(" ) ]
328+ public void ParseParameterTypes_InvalidSignature_ThrowsOrReturnsEmpty ( string signature )
329+ {
330+ try {
331+ var result = JniSignatureHelper . ParseParameterTypes ( signature ) ;
332+ Assert . NotNull ( result ) ;
333+ } catch ( Exception ex ) when ( ex is ArgumentException || ex is IndexOutOfRangeException || ex is FormatException ) {
334+ }
335+ }
336+
337+ }
338338
339- public class CreateInstancePaths : IDisposable
339+ public class CreateInstancePaths : IDisposable
340340 {
341341 readonly string _outputDir = CreateTempDir ( ) ;
342342 public void Dispose ( ) => DeleteTempDir ( _outputDir ) ;
0 commit comments