Skip to content

Commit

Permalink
[tests] fix for Xamarin.Android.Tools.Bytecode-Tests
Browse files Browse the repository at this point in the history
Context: dotnet/android#978

When bumping java.interop in xamarin-android, a test failure occurred
in the `ClassPath.GetDocletType` method. This was added in dotnet#188, but
since `ANDROID_SDK_PATH` is not set during java.interop’s test runs the
test was skipped.

The incoming `path` can be a directory, so the `File.OpenText` call
will fail in that case. Added a `File.Exists` check as a fix.
  • Loading branch information
jonathanpeppers committed Oct 26, 2017
1 parent 5cf61f5 commit e48e628
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Xamarin.Android.Tools.Bytecode/ClassPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,15 @@ JavaDocletType GetDocletType (string path)
kind = JavaDocletType.Java8;

// Check to see if it's an api.xml formatted doc
string rawXML = null;
using (var reader = File.OpenText (path)) {
int len = reader.ReadBlock (buf, 0, buf.Length);
rawXML = new string (buf, 0, len);
if (File.Exists (path)) {
string rawXML = null;
using (var reader = File.OpenText (path)) {
int len = reader.ReadBlock (buf, 0, buf.Length);
rawXML = new string (buf, 0, len);
}
if (rawXML.Contains ("<api>") && rawXML.Contains ("<package"))
kind = JavaDocletType._ApiXml;
}
if (rawXML.Contains ("<api>") && rawXML.Contains ("<package"))
kind = JavaDocletType._ApiXml;

return kind;
}
Expand Down

0 comments on commit e48e628

Please sign in to comment.