-
Notifications
You must be signed in to change notification settings - Fork 54
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
XML syntax warnings when using JavaSourceJar #850
Comments
I think the only current workaround for this is to remove the
|
@cncb-gh: How are you observing this error? It looks like you have We should only be emitting a warning for this, and probably not even a warning… (We should fix that.) |
I don' t know - they are showing up as errors in the Build Output as well as the Error List. Is there another setting in VS that might affect this? I tried removing the source jar files and now get invalid token errors in some generated files. It is placing '?' in some methods like so (notice "void?"):
|
Looks like this is the full output message that is being emitted:
This part:
Is close enough to the MSBuild error format that MSBuild seems to be recognizing it as an actual error, which is not intended. I think if we change this line to something else we can get this back to an informational message as intended:
|
I have a PR that fixes MSBuild interpreting these error messages as real errors: I believe @pjcollins will be looking at improving the Javadoc parsing in the future to prevent the messages from happening in the first place. (See also #843) |
Thanks. In the meantime, do you know how I can fix the "invalid token" error when removing the JavaDoc references? |
Did you remove them from all of your projects? I had tried removing them from all the projects, and did not get the invalid token errors you mentioned. |
Context: #850 When a parsing issue is hit when importing Javadoc info, an "error" is printed out like this: Error (31:41): Syntax error, expected: #PCDATA, <tt>, <TT>, <i>, <I>, {@code, {@docroot}, {@inheritdoc}, {@link, {@linkplain, {@literal, {@value}, {@value, UnknownHtmlElementStart, </tt>, </TT>, </i>, </I>, </p>, </P>, <p>, <P>, <pre>, <PRE>, @author, @apiSince, @deprecated, @deprecatedSince, @exception, @param, @return, @see, @Serialdata, @serialField, @SInCE, @throws, @[unknown], @Version {@link #getCurrentTrackSelections()}}.</li> This is intended to be informational, but this output format triggers the MSBuild error parsing regex, and is interpreted as an actual error, causing the build to fail. Avoid the error by prepending `JavadocImport-` to the `LogMessage.Level` enum value, so that MSBuild doesn't interpret the string as an error and the build can successfully complete: JavadocImport-Error (31:41): Syntax error, expected: #PCDATA, <tt>, <TT>, <i>, <I>, {@code, {@docroot}, {@inheritdoc}, {@link, {@linkplain, {@literal, {@value}, {@value, UnknownHtmlElementStart, </tt>, </TT>, </i>, </I>, </p>, </P>, <p>, <P>, <pre>, <PRE>, @author, @apiSince, @deprecated, @deprecatedSince, @exception, @param, @return, @see, @Serialdata, @serialField, @SInCE, @throws, @[unknown], @Version {@link #getCurrentTrackSelections()}}.</li>
Context: #850 When a parsing issue is hit when importing Javadoc info, an "error" is printed out like this: Error (31:41): Syntax error, expected: #PCDATA, <tt>, <TT>, <i>, <I>, {@code, {@docroot}, {@inheritdoc}, {@link, {@linkplain, {@literal, {@value}, {@value, UnknownHtmlElementStart, </tt>, </TT>, </i>, </I>, </p>, </P>, <p>, <P>, <pre>, <PRE>, @author, @apiSince, @deprecated, @deprecatedSince, @exception, @param, @return, @see, @Serialdata, @serialField, @SInCE, @throws, @[unknown], @Version {@link #getCurrentTrackSelections()}}.</li> This is intended to be informational, but this output format triggers the MSBuild error parsing regex, and is interpreted as an actual error, causing the build to fail. Avoid the error by prepending `JavadocImport-` to the `LogMessage.Level` enum value, so that MSBuild doesn't interpret the string as an error and the build can successfully complete: JavadocImport-Error (31:41): Syntax error, expected: #PCDATA, <tt>, <TT>, <i>, <I>, {@code, {@docroot}, {@inheritdoc}, {@link, {@linkplain, {@literal, {@value}, {@value, UnknownHtmlElementStart, </tt>, </TT>, </i>, </I>, </p>, </P>, <p>, <P>, <pre>, <PRE>, @author, @apiSince, @deprecated, @deprecatedSince, @exception, @param, @return, @see, @Serialdata, @serialField, @SInCE, @throws, @[unknown], @Version {@link #getCurrentTrackSelections()}}.</li>
Context: dotnet/java-interop#850 Changes: http://github.com/xamarin/Java.Interop/compare/a5ed8919fb2ec894cb8144e51ae7c29b4811ee2a...5e3164733cf85db304c250999dcfa3c69d240301 * dotnet/java-interop@5e316473: [generator] Avoid 'error (…):' construct in diagnostic messages (#851) * dotnet/java-interop@ab687cab: [build] Bump to Mono with MSBuild 16.10 (#848) * dotnet/java-interop@ce869c76: [generator] Gracefully handle BindingGeneratorException. (#845)
I removed them from all projects but it still adds a "void?" to WriteToParcel() for me. |
I can't figure out how to avoid the void? generation. The following in metadata.xml do not work. Thanks for any help.
|
You could try something like:
|
Unfortunately, this didn't work for me either. The only thing that works is removing the whole Metadata class with remove-node. Thanks for your help. |
Somehow even though it builds successfully, several interfaces and classes are missing in the output. I think I tracked it down to the "Player" interface never being generated. I get this warning but it does not tell me anything specific:
Player Interface: I would appreciate any more help you are able to give. Thanks for your time. |
That's not one I see very often. It means it found the interface Hopefully there is another message somewhere in the diagnostic output that tells what is wrong with the |
I turned on "Diagnostic" build output and unfortunately don't see anything that tells what is wrong with the interface. Just the one warning for BasePlayer about the invalid interface and several invalid parameter and return type warnings where the Player interface is attempted to be used. Here is the build output: |
It's in your log:
You will need to follow the trail to figure out the root issue causing the types to be invalidated. That is:
|
I traced it back to me removing the Metadata class to avoid the 'void?' token error. I have tried both your suggestion as well as
but it always generates a 'void?' (it seems that IEntryInvoker is automatically generated by the binder for IEntry because it is not defined in Java). Any other ideas on how to solve this? |
The easiest way to solve it would be to turn off |
|
Context: #850 (comment) When a user binds a Java library that contains a Java interface which implements another Java interface: // Java; android.jar public interface /* android.view. */ Menu {…} // Java; androidx.core.core.jar public interface /* androidx.core.internal.view. */ SupportMenu implements android.view.Menu {…} then when we create the binding for the "leaf" interface: // C# binding for androidx.core.core namespace AndroidX.Core.Internal.View { public interface ISupportMenu : Android.Views.IMenu {…} internal partial class ISupportMenuInvoker : Java.Lang.Object, ISupportMenu { // … } } The generated `*Invoker` type implements all methods for all implemented interfaces, e.g. methods from both `IMenu` and `ISupportMenu`. When: 1. The base interface (e.g. `IMenu`) comes from a referenced assembly, *and* 2. `$(Nullable)`=Enable when binding the derived interface then we interpret the return types on imported interface methods as *always* being of a nullable type, even for types such as `void`: // C# binding for androidx.core.core with $(Nullable)=Enable partial class ISupportMenuInvoker : Java.Lang.Object, ISupportMenu { public unsafe void? Clear () {…} } This results in errors from the C# compiler: Error CS1519: Invalid token '?' in class, record, struct, or interface member declaration Error CS1520: Method must have a return type Error CS0535: 'ISupportMenuInvoker' does not implement interface member 'IMenu.Clear()' The culprit is twofold: - In `CecilApiImporter`, we set `Method.ManagedReturn` to `System.Void` instead of `void`. - In `CodeGenerationOptions`, we only check for `void` to omit the null operator, not `System.Void`. Note this also happens for all primitive types like `System.Int32`/`int`. This commit fixes both aspects: - Change `Method.ManagedReturn` to contain primitive types instead of fully qualified types. - Update `CodeGenerationOptions.GetNullable()` to correctly handle fully qualified types if one slips through. With this change, all of AndroidX/GooglePlayServices/FaceBook/MLKit can be successfully compiled with `<Nullable>enable</Nullable>`.
Context: #850 (comment) When a user binds a Java library that contains a Java interface which implements another Java interface: // Java; android.jar public interface /* android.view. */ Menu {…} // Java; androidx.core.core.jar public interface /* androidx.core.internal.view. */ SupportMenu implements android.view.Menu {…} then when we create the binding for the "leaf" interface: // C# binding for androidx.core.core namespace AndroidX.Core.Internal.View { public interface ISupportMenu : Android.Views.IMenu {…} internal partial class ISupportMenuInvoker : Java.Lang.Object, ISupportMenu { // … } } The generated `*Invoker` type implements all methods for all implemented interfaces, e.g. methods from both `IMenu` and `ISupportMenu`. When: 1. The base interface (e.g. `IMenu`) comes from a referenced assembly, *and* 2. `$(Nullable)`=Enable when binding the derived interface then we interpret the return types on imported interface methods as *always* being of a nullable type, even for types such as `void`: // C# binding for androidx.core.core with $(Nullable)=Enable partial class ISupportMenuInvoker : Java.Lang.Object, ISupportMenu { public unsafe void? Clear () {…} } This results in errors from the C# compiler: Error CS1519: Invalid token '?' in class, record, struct, or interface member declaration Error CS1520: Method must have a return type Error CS0535: 'ISupportMenuInvoker' does not implement interface member 'IMenu.Clear()' The culprit is twofold: - In `CecilApiImporter`, we set `Method.ManagedReturn` to `System.Void` instead of `void`. - In `CodeGenerationOptions`, we only check for `void` to omit the null operator, not `System.Void`. Note this also happens for all primitive types like `System.Int32`/`int`. This commit fixes both aspects: - Change `Method.ManagedReturn` to contain primitive types instead of fully qualified types. - Update `CodeGenerationOptions.GetNullable()` to correctly handle fully qualified types if one slips through. With this change, all of AndroidX/GooglePlayServices/FaceBook/MLKit can be successfully compiled with `<Nullable>enable</Nullable>`.
Error Message or Issue
After upgrading to VS 16.10 (from 16.4), I get several general XML syntax errors when trying to compile the https://github.com/Baseflow/ExoPlayerXamarin binding library:
Severity Code Description Project File Line Suppression State Error (1 24): Syntax error, expected: #PCDATA, <tt>, <TT>, <i>, <I>, {@code, {@docRoot}, {@inheritDoc}, {@link, {@linkplain, {@literal, {@value}, {@value, UnknownHtmlElementStart, <p>, <P>, <pre>, <PRE>, @author, @apiSince, @deprecated, @deprecatedSince, @exception, @param, @return, @see, @serialData, @serialField, @since, @throws, @[unknown], @version ExoPlayer.Common C:\Craigs Files\Apps\ExoPlayerXamarin-develop\ExoPlayer.Common\BINDINGSGENERATOR 1
Version Information
Other Helpful Info
The text was updated successfully, but these errors were encountered: