@@ -269,11 +269,7 @@ public void ProjectDependencies ([Values(true, false)] bool projectReference)
269269 } ;
270270 libB . Sources . Clear ( ) ;
271271 libB . Sources . Add ( new BuildItem . Source ( "Foo.cs" ) {
272- TextContent = ( ) => @"public class Foo {
273- public Foo () {
274- var bar = new Bar();
275- }
276- }" ,
272+ TextContent = ( ) => "public class Foo : Bar { }" ,
277273 } ) ;
278274
279275 var libC = new XamarinAndroidLibraryProject ( ) {
@@ -283,7 +279,7 @@ public Foo () {
283279 } ;
284280 libC . Sources . Clear ( ) ;
285281 libC . Sources . Add ( new BuildItem . Source ( "Bar.cs" ) {
286- TextContent = ( ) => "public class Bar { }" ,
282+ TextContent = ( ) => "public class Bar : Java.Lang.Object { }" ,
287283 } ) ;
288284 libC . Sources . Add ( new BuildItem ( "EmbeddedResource" , "Foo.resx" ) {
289285 TextContent = ( ) => InlineData . ResxWithContents ( "<data name=\" CancelButton\" ><value>Cancel</value></data>" )
@@ -309,8 +305,8 @@ public Foo () {
309305 ProjectName = "AppA" ,
310306 IsRelease = true ,
311307 Sources = {
312- new BuildItem . Source ( "Bar .cs" ) {
313- TextContent = ( ) => "public class Bar : Foo { }" ,
308+ new BuildItem . Source ( "Baz .cs" ) {
309+ TextContent = ( ) => "public class Baz : Foo { }" ,
314310 } ,
315311 new BuildItem ( "EmbeddedResource" , "Foo.resx" ) {
316312 TextContent = ( ) => InlineData . ResxWithContents ( "<data name=\" CancelButton\" ><value>Cancel</value></data>" )
@@ -321,6 +317,10 @@ public Foo () {
321317 }
322318 } ;
323319 appA . AddReference ( libB ) ;
320+ if ( ! projectReference ) {
321+ // @(ProjectReference) implicits adds this reference. For `class Baz : Foo : Bar`:
322+ appA . OtherBuildItems . Add ( new BuildItem . Reference ( $@ "..\{ libC . ProjectName } \bin\Release\{ libC . TargetFramework } \{ libC . ProjectName } .dll") ) ;
323+ }
324324 var appBuilder = CreateApkBuilder ( Path . Combine ( path , appA . ProjectName ) ) ;
325325 Assert . IsTrue ( appBuilder . Build ( appA ) , $ "{ appA . ProjectName } should succeed") ;
326326
@@ -332,6 +332,17 @@ public Foo () {
332332 helper . AssertContainsEntry ( $ "assemblies/{ libC . ProjectName } .dll") ;
333333 helper . AssertContainsEntry ( $ "assemblies/es/{ appA . ProjectName } .resources.dll") ;
334334 helper . AssertContainsEntry ( $ "assemblies/es/{ libC . ProjectName } .resources.dll") ;
335+
336+ var intermediate = Path . Combine ( Root , appBuilder . ProjectDirectory , appA . IntermediateOutputPath ) ;
337+ var dexFile = Path . Combine ( intermediate , "android" , "bin" , "classes.dex" ) ;
338+ FileAssert . Exists ( dexFile ) ;
339+
340+ // NOTE: the crc hashes here might change one day, but if we used [Android.Runtime.Register("")]
341+ // LibraryB.dll would have a reference to Mono.Android.dll, which invalidates the test.
342+ string className = "Lcrc6414a4b78410c343a2/Bar;" ;
343+ Assert . IsTrue ( DexUtils . ContainsClass ( className , dexFile , AndroidSdkPath ) , $ "`{ dexFile } ` should include `{ className } `!") ;
344+ className = "Lcrc646d2d82b4d8b39bd8/Foo;" ;
345+ Assert . IsTrue ( DexUtils . ContainsClass ( className , dexFile , AndroidSdkPath ) , $ "`{ dexFile } ` should include `{ className } `!") ;
335346 }
336347
337348 [ Test ]
0 commit comments