From effd0dad517813730440e8d8e12c19e00e8d69fd Mon Sep 17 00:00:00 2001 From: Redth Date: Thu, 26 Oct 2017 12:20:48 -0400 Subject: [PATCH 01/16] Fix doclet type detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously detection for _ApiXml doclet type was added but without consideration to the fact that `GetDocletType` really expects a directory and not a *file* path. This fixes things so that a file path can be passed in without a) causing an exception when the ‘index.html’ is appended to the file path and attempted to be read as a file, and b) won’t cause an exception if a directory is passed and tried to be opened as a file. --- .../ClassPath.cs | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs b/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs index 4ba0119cf..1d6c1a476 100644 --- a/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs +++ b/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs @@ -237,27 +237,34 @@ JavaDocletType GetDocletType (string path) { var kind = JavaDocletType.DroidDoc; char [] buf = new char [500]; + string packagesHtml = Path.Combine (path, "packages.html"); if (File.Exists (packagesHtml) && File.ReadAllText (packagesHtml).Contains ("") && rawXML.Contains ("") && rawXML.Contains (" Date: Thu, 26 Oct 2017 12:22:31 -0400 Subject: [PATCH 02/16] Assign DocletType to be readable The `DocletType` property was used as a way to *set* which doclet type to use, but if it was null, and a doclet type was detected via the passed path in `CreateDocScraper`, we never assigned the resolved doclet type back to the property. This is useful primarily in creating tests, but arguably how it should have worked in the first place. --- src/Xamarin.Android.Tools.Bytecode/ClassPath.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs b/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs index 1d6c1a476..8854f3c16 100644 --- a/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs +++ b/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs @@ -271,7 +271,10 @@ JavaDocletType GetDocletType (string path) IAndroidDocScraper CreateDocScraper (string src) { - switch (DocletType ?? GetDocletType (src)) { + if (!DocletType.HasValue) + DocletType = GetDocletType(src); + + switch (DocletType) { default: return new DroidDoc2Scraper (src); case JavaDocletType.DroidDoc: return new DroidDocScraper (src); case JavaDocletType.Java6: return new JavaDocScraper (src); From 97031e6a2b317256dddbd7abd0ea86e211adf9af Mon Sep 17 00:00:00 2001 From: Redth Date: Thu, 26 Oct 2017 12:24:49 -0400 Subject: [PATCH 03/16] Bytecode Tests - Load resource to temp file helper This adds a helper to the fixture to get a test resource and save its contents to a temp file. --- .../Tests/ClassFileFixture.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Xamarin.Android.Tools.Bytecode/Tests/ClassFileFixture.cs b/src/Xamarin.Android.Tools.Bytecode/Tests/ClassFileFixture.cs index e305de8f2..fe04b3204 100644 --- a/src/Xamarin.Android.Tools.Bytecode/Tests/ClassFileFixture.cs +++ b/src/Xamarin.Android.Tools.Bytecode/Tests/ClassFileFixture.cs @@ -25,6 +25,17 @@ protected static string LoadString (string resource) return r.ReadToEnd (); } + protected static string LoadToTempFile (string resource) + { + var tempFilePath = Path.GetTempFileName (); + + using (var w = File.Create (tempFilePath)) + using (var s = Assembly.GetExecutingAssembly ().GetManifestResourceStream (resource)) + s.CopyTo (w); + + return tempFilePath; + } + protected static void AssertXmlDeclaration (string classResource, string xmlResource, string documentationPath = null, JavaDocletType? javaDocletType = null) { var classPathBuilder = new ClassPath () { From 675ed9425beedeed00ddc8283b5e63ba00cd1c55 Mon Sep 17 00:00:00 2001 From: Redth Date: Thu, 26 Oct 2017 12:25:58 -0400 Subject: [PATCH 04/16] Bytecode Tests - added doclet type assertion Takes a path and expected doclet type and asserts they match. --- .../Tests/ClassFileFixture.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Xamarin.Android.Tools.Bytecode/Tests/ClassFileFixture.cs b/src/Xamarin.Android.Tools.Bytecode/Tests/ClassFileFixture.cs index fe04b3204..f75bda25d 100644 --- a/src/Xamarin.Android.Tools.Bytecode/Tests/ClassFileFixture.cs +++ b/src/Xamarin.Android.Tools.Bytecode/Tests/ClassFileFixture.cs @@ -78,6 +78,22 @@ protected static void AssertXmlDeclaration (string[] classResources, string xmlR Assert.AreEqual (expected, actual.ToString ()); } + + protected static void AssertDocletType (string path, JavaDocletType docletType) + { + var classPathBuilder = new ClassPath () { + ApiSource = "class-parse", + DocumentationPaths = new string[] { + path, + }, + AutoRename = true + }; + + var actual = new StringWriter (); + classPathBuilder.SaveXmlDescription (actual); + + Assert.AreEqual (docletType, classPathBuilder.DocletType); + } } } From 60f154e622b34980fea6e3c9cb16d786b421dcbd Mon Sep 17 00:00:00 2001 From: Redth Date: Thu, 26 Oct 2017 12:27:36 -0400 Subject: [PATCH 05/16] Bytecode Tests - fix code formatting on old test This also switches to use the `LoadToTempFile` fixture helper instead of manually getting a temp path and loading the file. --- .../Tests/ParameterFixupTests.cs | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs b/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs index e7b4035e3..507f3b138 100644 --- a/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs +++ b/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs @@ -30,27 +30,22 @@ public void XmlDeclaration_FixedUpFromDocumentation() } [Test] - public void XmlDeclaration_FixedUpFromApiXmlDocumentation() + public void XmlDeclaration_FixedUpFromApiXmlDocumentation () { string tempFile = null; - try - { - tempFile = Path.GetTempFileName(); - File.WriteAllText(tempFile, LoadString("ParameterFixupApiXmlDocs.xml")); + try { + tempFile = LoadToTempFile ("ParameterFixupApiXmlDocs.xml"); - AssertXmlDeclaration("Collection.class", "ParameterFixupFromDocs.xml", tempFile, Bytecode.JavaDocletType._ApiXml); - } - catch (Exception ex) - { - try - { - if (File.Exists(tempFile)) - File.Delete(tempFile); + AssertXmlDeclaration ("Collection.class", "ParameterFixupFromDocs.xml", tempFile, Bytecode.JavaDocletType._ApiXml); + } catch (Exception ex) { + try { + if (File.Exists (tempFile)) + File.Delete (tempFile); } catch { } - Assert.Fail("An unexpected exception was thrown : {0}", ex); + Assert.Fail ("An unexpected exception was thrown : {0}", ex); } } From 99b4e876c065754d562ccc253d48a9d3722b2f44 Mon Sep 17 00:00:00 2001 From: Redth Date: Thu, 26 Oct 2017 12:28:53 -0400 Subject: [PATCH 06/16] Bytecode Tests - add doclet type resolution tests We could use more for Java Doc types, but at least now this ensures the GetDocletType can handle both directories and paths. --- .../Tests/ParameterFixupTests.cs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs b/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs index 507f3b138..4a1b69590 100644 --- a/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs +++ b/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs @@ -58,6 +58,48 @@ public void XmlDeclaration_DoesNotThrowAnExceptionIfDocumentationNotFound () Assert.Fail ("An unexpected exception was thrown : {0}", ex); } } + + [Test] + public void DocletType_ShouldDetectApiXml () + { + string tempFile = null; + + try { + tempFile = LoadToTempFile ("ParameterFixupApiXmlDocs.xml"); + + AssertDocletType (tempFile, Bytecode.JavaDocletType._ApiXml); + } catch (Exception ex) { + try { + if (File.Exists (tempFile)) + File.Delete (tempFile); + } + catch { } + + Assert.Fail ("An unexpected exception was thrown : {0}", ex); + } + } + + [Test] + public void DocletType_ShouldDetectDroidDocs () + { + var androidSdkPath = Environment.GetEnvironmentVariable ("ANDROID_SDK_PATH"); + if (string.IsNullOrEmpty (androidSdkPath)) { + Assert.Ignore("The `ANDROID_SDK_PATH` environment variable isn't set; " + + "cannot test importing parameter names from HTML. Skipping..."); + return; + } + + try { + var droidDocsPath = Path.Combine (androidSdkPath, "docs", "reference"); + + if (!Directory.Exists (droidDocsPath)) + Assert.Fail("The Android SDK Documentation path `{0}` was not found.", droidDocsPath); + + AssertDocletType (droidDocsPath, Bytecode.JavaDocletType.DroidDoc2); + } catch (Exception ex) { + Assert.Fail("An unexpected exception was thrown : {0}", ex); + } + } } } From 3538b7a17e9ec5e424b46f18414f6e4e5fccbec8 Mon Sep 17 00:00:00 2001 From: Redth Date: Thu, 26 Oct 2017 14:22:16 -0400 Subject: [PATCH 07/16] Revert back to DocletType ?? GetDocletType (..) class-parse.exe expects to be able to set the DocletType property and override all invocations to GetDocletType, so reverting this in the spirit of not changing expected behaviour there. --- src/Xamarin.Android.Tools.Bytecode/ClassPath.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs b/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs index 8854f3c16..1d6c1a476 100644 --- a/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs +++ b/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs @@ -271,10 +271,7 @@ JavaDocletType GetDocletType (string path) IAndroidDocScraper CreateDocScraper (string src) { - if (!DocletType.HasValue) - DocletType = GetDocletType(src); - - switch (DocletType) { + switch (DocletType ?? GetDocletType (src)) { default: return new DroidDoc2Scraper (src); case JavaDocletType.DroidDoc: return new DroidDocScraper (src); case JavaDocletType.Java6: return new JavaDocScraper (src); From fde965e177fe1ac7968ee483d252dfc836111955 Mon Sep 17 00:00:00 2001 From: Redth Date: Thu, 26 Oct 2017 14:24:31 -0400 Subject: [PATCH 08/16] Change DocletType Assertion, invoke GetDocletType GetDocletType is made public to invoke from tests. There was no other visible way to test the doclet type resolution/detection as `DocletType` property is never assigned any value from this detection and only intended to be _set_. --- src/Xamarin.Android.Tools.Bytecode/ClassPath.cs | 2 +- .../Tests/ClassFileFixture.cs | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs b/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs index 1d6c1a476..e392ef707 100644 --- a/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs +++ b/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs @@ -233,7 +233,7 @@ void FixupParametersFromDocs (XElement api) } } - JavaDocletType GetDocletType (string path) + public JavaDocletType GetDocletType (string path) { var kind = JavaDocletType.DroidDoc; char [] buf = new char [500]; diff --git a/src/Xamarin.Android.Tools.Bytecode/Tests/ClassFileFixture.cs b/src/Xamarin.Android.Tools.Bytecode/Tests/ClassFileFixture.cs index f75bda25d..4b8c11eac 100644 --- a/src/Xamarin.Android.Tools.Bytecode/Tests/ClassFileFixture.cs +++ b/src/Xamarin.Android.Tools.Bytecode/Tests/ClassFileFixture.cs @@ -81,18 +81,11 @@ protected static void AssertXmlDeclaration (string[] classResources, string xmlR protected static void AssertDocletType (string path, JavaDocletType docletType) { - var classPathBuilder = new ClassPath () { - ApiSource = "class-parse", - DocumentationPaths = new string[] { - path, - }, - AutoRename = true - }; + var classPathBuilder = new ClassPath (); - var actual = new StringWriter (); - classPathBuilder.SaveXmlDescription (actual); + var actual = classPathBuilder.GetDocletType(path); - Assert.AreEqual (docletType, classPathBuilder.DocletType); + Assert.AreEqual (docletType, actual); } } } From d2d85a3250ae6be2b26f53b13a3944b02be8dff7 Mon Sep 17 00:00:00 2001 From: Redth Date: Thu, 26 Oct 2017 14:25:16 -0400 Subject: [PATCH 09/16] Bytecode tests - delete temp file in finally --- .../Tests/ParameterFixupTests.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs b/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs index 4a1b69590..57019bea7 100644 --- a/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs +++ b/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs @@ -38,14 +38,12 @@ public void XmlDeclaration_FixedUpFromApiXmlDocumentation () tempFile = LoadToTempFile ("ParameterFixupApiXmlDocs.xml"); AssertXmlDeclaration ("Collection.class", "ParameterFixupFromDocs.xml", tempFile, Bytecode.JavaDocletType._ApiXml); - } catch (Exception ex) { + } finally { try { if (File.Exists (tempFile)) File.Delete (tempFile); } catch { } - - Assert.Fail ("An unexpected exception was thrown : {0}", ex); } } @@ -68,14 +66,12 @@ public void DocletType_ShouldDetectApiXml () tempFile = LoadToTempFile ("ParameterFixupApiXmlDocs.xml"); AssertDocletType (tempFile, Bytecode.JavaDocletType._ApiXml); - } catch (Exception ex) { + } finally { try { if (File.Exists (tempFile)) File.Delete (tempFile); } catch { } - - Assert.Fail ("An unexpected exception was thrown : {0}", ex); } } From 8301bf634d3233effeee0ce7d8d7a8dbd0e42b1a Mon Sep 17 00:00:00 2001 From: Redth Date: Thu, 26 Oct 2017 14:26:50 -0400 Subject: [PATCH 10/16] Bytecode tests - doc type is implicit This test should not be explicitly setting doctype, it should be determined by ClassPath instead. --- src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs b/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs index 57019bea7..7c240d3e7 100644 --- a/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs +++ b/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs @@ -37,7 +37,7 @@ public void XmlDeclaration_FixedUpFromApiXmlDocumentation () try { tempFile = LoadToTempFile ("ParameterFixupApiXmlDocs.xml"); - AssertXmlDeclaration ("Collection.class", "ParameterFixupFromDocs.xml", tempFile, Bytecode.JavaDocletType._ApiXml); + AssertXmlDeclaration ("Collection.class", "ParameterFixupFromDocs.xml", tempFile); } finally { try { if (File.Exists (tempFile)) From 21e82d3ecf9103508bd69e4b535af4c74b855f20 Mon Sep 17 00:00:00 2001 From: Redth Date: Thu, 26 Oct 2017 14:30:18 -0400 Subject: [PATCH 11/16] Bytecode tests - remove unnecssary try/catch --- .../Tests/ParameterFixupTests.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs b/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs index 7c240d3e7..0f3cae85b 100644 --- a/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs +++ b/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs @@ -85,16 +85,12 @@ public void DocletType_ShouldDetectDroidDocs () return; } - try { - var droidDocsPath = Path.Combine (androidSdkPath, "docs", "reference"); + var droidDocsPath = Path.Combine (androidSdkPath, "docs", "reference"); - if (!Directory.Exists (droidDocsPath)) - Assert.Fail("The Android SDK Documentation path `{0}` was not found.", droidDocsPath); + if (!Directory.Exists (droidDocsPath)) + Assert.Fail("The Android SDK Documentation path `{0}` was not found.", droidDocsPath); - AssertDocletType (droidDocsPath, Bytecode.JavaDocletType.DroidDoc2); - } catch (Exception ex) { - Assert.Fail("An unexpected exception was thrown : {0}", ex); - } + AssertDocletType (droidDocsPath, Bytecode.JavaDocletType.DroidDoc2); } } } From f05078072a720a6f823b8dfd78a2780e30a7f7d8 Mon Sep 17 00:00:00 2001 From: Redth Date: Thu, 26 Oct 2017 15:02:31 -0400 Subject: [PATCH 12/16] Move GetDocletType to AndroidDocScraper This also does away with the `AssertDocletType` helper since the tests can now do the same directly in one line of code. --- .../ClassPath.cs | 38 +----------------- .../JavaDocumentScraper.cs | 39 +++++++++++++++++++ .../Tests/ClassFileFixture.cs | 9 ----- .../Tests/ParameterFixupTests.cs | 5 ++- 4 files changed, 43 insertions(+), 48 deletions(-) diff --git a/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs b/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs index e392ef707..355730a06 100644 --- a/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs +++ b/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs @@ -233,45 +233,9 @@ void FixupParametersFromDocs (XElement api) } } - public JavaDocletType GetDocletType (string path) - { - var kind = JavaDocletType.DroidDoc; - char [] buf = new char [500]; - - string packagesHtml = Path.Combine (path, "packages.html"); - if (File.Exists (packagesHtml) && File.ReadAllText (packagesHtml).Contains ("") && rawXML.Contains ("") && rawXML.Contains (" Date: Thu, 26 Oct 2017 15:04:20 -0400 Subject: [PATCH 13/16] Bytecode Tests - remove unnecessary try/catch These temp files should really not be ever accessed by anything else, so there should be no issue calling .Delete on them if they exist. --- .../Tests/ParameterFixupTests.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs b/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs index 19dcfee90..d8ff131ad 100644 --- a/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs +++ b/src/Xamarin.Android.Tools.Bytecode/Tests/ParameterFixupTests.cs @@ -40,11 +40,8 @@ public void XmlDeclaration_FixedUpFromApiXmlDocumentation () AssertXmlDeclaration ("Collection.class", "ParameterFixupFromDocs.xml", tempFile); } finally { - try { - if (File.Exists (tempFile)) - File.Delete (tempFile); - } - catch { } + if (File.Exists (tempFile)) + File.Delete (tempFile); } } @@ -68,11 +65,8 @@ public void DocletType_ShouldDetectApiXml () Assert.AreEqual (JavaDocletType._ApiXml, AndroidDocScraper.GetDocletType (tempFile)); } finally { - try { - if (File.Exists (tempFile)) - File.Delete (tempFile); - } - catch { } + if (File.Exists (tempFile)) + File.Delete (tempFile); } } From b975f8e8d9ae818b6acdb3f21ebc3d92e63456a4 Mon Sep 17 00:00:00 2001 From: Redth Date: Thu, 26 Oct 2017 21:29:45 -0400 Subject: [PATCH 14/16] Fix formatting { got autoformatted to new line --- .../JavaDocumentScraper.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Xamarin.Android.Tools.Bytecode/JavaDocumentScraper.cs b/src/Xamarin.Android.Tools.Bytecode/JavaDocumentScraper.cs index 216a8d15a..b210fe14a 100644 --- a/src/Xamarin.Android.Tools.Bytecode/JavaDocumentScraper.cs +++ b/src/Xamarin.Android.Tools.Bytecode/JavaDocumentScraper.cs @@ -301,8 +301,7 @@ public static JavaDocletType GetDocletType (string path) kind = JavaDocletType.DroidDoc2; string indexHtml = Path.Combine (path, "index.html"); - if (File.Exists (indexHtml)) - { + if (File.Exists (indexHtml)) { using (var reader = File.OpenText (indexHtml)) reader.ReadBlock (buf, 0, buf.Length); string rawHTML = new string (buf); @@ -315,11 +314,9 @@ public static JavaDocletType GetDocletType (string path) } // Check to see if it's an api.xml formatted doc - if (File.Exists (path)) - { + if (File.Exists (path)) { string rawXML = null; - using (var reader = File.OpenText (path)) - { + using (var reader = File.OpenText (path)) { int len = reader.ReadBlock (buf, 0, buf.Length); rawXML = new string (buf, 0, len); } From f1b0ba78d8fdb4ed4e483cbe920730d19614a68f Mon Sep 17 00:00:00 2001 From: Redth Date: Thu, 26 Oct 2017 21:38:03 -0400 Subject: [PATCH 15/16] class-parse docsType should be null by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently the default is set to 0 (so `DroidDoc`), so there is a value set even if the `—docstype` isn’t specified as a parameter. Since `ClassPath` is [always instantiated](https://github.com/xamarin/java.interop/blob/master/tools/class-parse/Program.cs#L74) with `DocletType` assigned to this value, when `CreateDocScraper` [gets invoked](https://github.com/xamarin/java.interop/blob/master/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs#L267) it is always using the `DroidDoc` value instead of automatically detecting the doc type. This small change should cause automatic resolution of doc type to happen if `class-parse.exe` is invoked without the `—docstype` arg. --- tools/class-parse/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/class-parse/Program.cs b/tools/class-parse/Program.cs index e63530bd0..d1d7871cf 100644 --- a/tools/class-parse/Program.cs +++ b/tools/class-parse/Program.cs @@ -15,7 +15,7 @@ class App { public static void Main (string[] args) { - JavaDocletType docsType = 0; + JavaDocletType? docsType = null; bool dump = false; bool help = false; From 937297afdf19c4ad763e3f9d43aa258a735a4689 Mon Sep 17 00:00:00 2001 From: Redth Date: Fri, 27 Oct 2017 11:24:52 -0400 Subject: [PATCH 16/16] Remove DocletType and auto detect always --- .../ClassPath.cs | 4 +-- .../Tests/ClassFileFixture.cs | 6 +--- tools/class-parse/Program.cs | 28 ++++--------------- 3 files changed, 7 insertions(+), 31 deletions(-) diff --git a/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs b/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs index 355730a06..8b7303cd6 100644 --- a/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs +++ b/src/Xamarin.Android.Tools.Bytecode/ClassPath.cs @@ -26,8 +26,6 @@ public class ClassPath { public string ApiSource { get; set; } - public JavaDocletType? DocletType { get; set; } - public IEnumerable DocumentationPaths { get; set; } public string AndroidFrameworkPlatform { get; set; } @@ -235,7 +233,7 @@ void FixupParametersFromDocs (XElement api) IAndroidDocScraper CreateDocScraper (string src) { - switch (DocletType ?? AndroidDocScraper.GetDocletType (src)) { + switch (AndroidDocScraper.GetDocletType (src)) { default: return new DroidDoc2Scraper (src); case JavaDocletType.DroidDoc: return new DroidDocScraper (src); case JavaDocletType.Java6: return new JavaDocScraper (src); diff --git a/src/Xamarin.Android.Tools.Bytecode/Tests/ClassFileFixture.cs b/src/Xamarin.Android.Tools.Bytecode/Tests/ClassFileFixture.cs index fe04b3204..2eac73bc6 100644 --- a/src/Xamarin.Android.Tools.Bytecode/Tests/ClassFileFixture.cs +++ b/src/Xamarin.Android.Tools.Bytecode/Tests/ClassFileFixture.cs @@ -36,7 +36,7 @@ protected static string LoadToTempFile (string resource) return tempFilePath; } - protected static void AssertXmlDeclaration (string classResource, string xmlResource, string documentationPath = null, JavaDocletType? javaDocletType = null) + protected static void AssertXmlDeclaration (string classResource, string xmlResource, string documentationPath = null) { var classPathBuilder = new ClassPath () { ApiSource = "class-parse", @@ -44,14 +44,10 @@ protected static void AssertXmlDeclaration (string classResource, string xmlReso documentationPath, }, }; - if (javaDocletType.HasValue) - classPathBuilder.DocletType = javaDocletType.Value; classPathBuilder.Add (LoadClassFile (classResource)); var actual = new StringWriter (); classPathBuilder.ApiSource = "class-parse"; - if (javaDocletType.HasValue) - classPathBuilder.DocletType = javaDocletType.Value; classPathBuilder.SaveXmlDescription (actual); var expected = LoadString (xmlResource); diff --git a/tools/class-parse/Program.cs b/tools/class-parse/Program.cs index d1d7871cf..d3123f77e 100644 --- a/tools/class-parse/Program.cs +++ b/tools/class-parse/Program.cs @@ -15,10 +15,9 @@ class App { public static void Main (string[] args) { - JavaDocletType? docsType = null; - bool dump = false; bool help = false; + bool docsType = false; int verbosity = 0; bool autorename = false; var outputFile = (string) null; @@ -40,9 +39,8 @@ public static void Main (string[] args) "Documentation {PATH} for parameter fixup", doc => docsPaths.Add (doc) }, { "docstype=", - "{TYPE} of the docs within --docspath. Values:\n " + - string.Join ("\n ", JavaDocletTypeMapping.Keys.OrderBy (s => s)), - t => docsType = GetJavaDocletType (t) }, + "OBSOLETE: Previously used to specify a doc type (now auto detected).", + t => docsType = t != null }, { "v|verbose:", "See stack traces on error.", (int? v) => verbosity = v.HasValue ? v.Value : verbosity + 1 }, @@ -61,6 +59,8 @@ public static void Main (string[] args) p.WriteOptionDescriptions (Console.Out); return; } + if (docsType) + Console.WriteLine ("class-parse: --docstype is obsolete and no longer a valid option."); var output = outputFile == null ? Console.Out : (TextWriter) new StreamWriter (outputFile, append: false, encoding: new UTF8Encoding (encoderShouldEmitUTF8Identifier: false)); @@ -71,7 +71,6 @@ public static void Main (string[] args) ApiSource = "class-parse", AndroidFrameworkPlatform = platform, DocumentationPaths = docsPaths.Count == 0 ? null : docsPaths, - DocletType = docsType, AutoRename = autorename }; foreach (var file in files) { @@ -93,23 +92,6 @@ public static void Main (string[] args) output.Close (); } - static Dictionary JavaDocletTypeMapping = new Dictionary { - { "droiddoc", JavaDocletType.DroidDoc }, - { "droiddoc2", JavaDocletType.DroidDoc2 }, - { "java6", JavaDocletType.Java6 }, - { "java7", JavaDocletType.Java7 }, - { "java8", JavaDocletType.Java8 }, - { "apixml", JavaDocletType._ApiXml }, - }; - - static JavaDocletType GetJavaDocletType (string value) - { - JavaDocletType type; - if (value != null && JavaDocletTypeMapping.TryGetValue (value.ToLowerInvariant (), out type)) - return type; - return JavaDocletType.DroidDoc; - } - static void DumpFileToXml (ClassPath jar, string file) { using (var s = File.OpenRead (file)) {