Skip to content

Commit cf11da5

Browse files
[tests] Add test for System.IO.Hashing 10.0.0 (#10614)
Context: #10606 I was mainly verifying this is a NativeAOT-only issue, but let's add the test as well.
1 parent 746e8bc commit cf11da5

File tree

1 file changed

+31
-0
lines changed
  • src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests

1 file changed

+31
-0
lines changed

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,5 +2182,36 @@ public void IncrementalBuildDifferentDevice ([Values] AndroidRuntime runtime)
21822182
Assert.IsTrue (builder.Build (proj, parameters: [ "_SingleRID=android-x64", "_SingleABI=x86_64" ], doNotCleanupOnUpdate: true),
21832183
"second build should have succeeded.");
21842184
}
2185+
2186+
[Test]
2187+
public void SystemIOHashing ([Values] AndroidRuntime runtime)
2188+
{
2189+
if (runtime == AndroidRuntime.NativeAOT) {
2190+
Assert.Ignore ("https://github.com/dotnet/android/issues/10606");
2191+
}
2192+
2193+
var proj = new XamarinAndroidApplicationProject {
2194+
PackageReferences = {
2195+
new Package { Id = "System.IO.Hashing", Version = "10.0.0" }
2196+
},
2197+
};
2198+
proj.SetRuntime (runtime);
2199+
proj.MainActivity = proj.DefaultMainActivity.Replace (
2200+
"base.OnCreate (bundle);",
2201+
"""
2202+
base.OnCreate (bundle);
2203+
2204+
// Use System.IO.Hashing to compute a hash
2205+
var crc32 = new System.IO.Hashing.Crc32 ();
2206+
var data = System.Text.Encoding.UTF8.GetBytes ("Hello World");
2207+
crc32.Append (data);
2208+
var hash = crc32.GetCurrentHash ();
2209+
Console.WriteLine ($"CRC32 Hash: {BitConverter.ToString (hash)}");
2210+
"""
2211+
);
2212+
2213+
using var builder = CreateApkBuilder ();
2214+
Assert.IsTrue (builder.Build (proj), "build should have succeeded.");
2215+
}
21852216
}
21862217
}

0 commit comments

Comments
 (0)