From e48e628f28a2e17ae5a96de8e37df87ac49e6a90 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 26 Oct 2017 08:46:51 -0500 Subject: [PATCH] [tests] fix for Xamarin.Android.Tools.Bytecode-Tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Context: https://github.com/xamarin/xamarin-android/pull/978 When bumping java.interop in xamarin-android, a test failure occurred in the `ClassPath.GetDocletType` method. This was added in #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. --- src/Xamarin.Android.Tools.Bytecode/ClassPath.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs b/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs index 4ba0119cf..c6584d847 100644 --- a/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs +++ b/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs @@ -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 ("") && rawXML.Contains ("") && rawXML.Contains ("