-
Notifications
You must be signed in to change notification settings - Fork 64
Doclet Type detection fix + tests #202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
effd0da
50d123c
97031e6
675ed94
60f154e
99b4e87
3538b7a
fde965e
d2d85a3
8301bf6
21e82d3
f050780
fef5efe
b975f8e
f1b0ba7
937297a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be in the |
||
| File.Delete (tempFile); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't need to be wrapped in try/catch. |
||
| } | ||
| catch { } | ||
|
|
||
| Assert.Fail("An unexpected exception was thrown : {0}", ex); | ||
| Assert.Fail ("An unexpected exception was thrown : {0}", ex); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -63,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); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't need to wrap this in try/catch. |
||
| } | ||
| catch { } | ||
|
|
||
| Assert.Fail ("An unexpected exception was thrown : {0}", ex); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...all the more reason to delete |
||
| } | ||
| } | ||
|
|
||
| [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 { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we actually need this |
||
| 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); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly relevant to your patch, but given that
CreateDocScraper()can be called multiple times, for multiple paths -- once per value inClassPath.DocumentationPaths-- then I don't thinkDocletTypeshould be used at all. What happens if/whenClassPath.DocumentationPathscontains multiple different types: the first one "wins"?This should probably just be:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any objection to making
GetDocletTypepublic then? need some way to surface this code to tests.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, from what I can tell, the intention behind
DocletTypein the first place was to allow classe-parse.exe to override the automatic detection. This property gets set if you invoke said exe with--docstype=...So I guess we should leave this behaviour as is (leave the
switch (DocletType ?? GetDocletType (..))) and just make public theGetDocletTypemethod.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's troubling about this statement is that
class-parsealways setsClassPath.DocletType.docsTypeis aJavaDocletType, not aJavaDocletType?, so ifclass-parse --docstypeisn't used, thenClassPath.DocletTypewill be set toJavaDocletType.DroidDoc, which is almost certainly wrong.I'm starting to think we should
[Obsolete]theClassPath.DocletTypeproperty, and make it an error to use it entirely. :-/There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On that matter, we could pretty much do away with all the various
<ItemGroup>names currently out there and just use a<JavaParameterNameDocsPath .. />or something similar sinceClassPathalready does the work of checking. In fact, theClassParsetask just concatenates all of these different items into a single set of doc paths: https://github.com/xamarin/xamarin-android/blob/master/src/Xamarin.Android.Build.Tasks/Tasks/ClassParse.cs#L36-L41So, if we obsolete
ClassPath.DocletTypewe should also make it an error to specify--docstype=in class-parse.exe.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might also explain some weirdness i've seen in getting the generator to parse parameter names for the android support library bindings which are known to be in the documentation... Seems like maybe it's just getting detected as a DroidDoc always.