Skip to content

Conversation

@dellis1972
Copy link
Contributor

@dellis1972 dellis1972 commented Sep 20, 2023

Fixes: #7692

When .java files are part of a project through
@(AndroidJavaSource), it would be nice if the bindings for those
Java types would be available through IDE IntelliSense/code completion.

Update the AddBindingsToCompile target so that it includes all
$(IntermediateOutputPath)generated\**\*.cs files into the design-
time build.

Additionally, fix an issue where if you remove the libraries the
generated files are not removed.

Finally move the Layout CodeBehind generated files to their own
directory. This new directory is in $(IntermediateOutputPath)codebehind.
The reason behind this is to keep the code behind and generated code sepereate.
It makes it easier to update and clean up if one or the other changes. If all the files
are in the same location we might end up deleting things we need during an
update process.

@dellis1972 dellis1972 marked this pull request as ready for review September 22, 2023 10:18
@jonpryor
Copy link
Contributor

jonpryor commented Sep 22, 2023

WIP commit message:

Fixes: https://github.com/xamarin/xamarin-android/issues/7692

When `.java` files are part of a project through
`@(AndroidJavaSource)`, it would be nice if the *bindings* for those
Java types would be available through IDE IntelliSense/code completion.

Update the `AddBindingsToCompile` target so that it includes all
`$(IntermediateOutputPath)generated\**\*.cs` files into the design-
time build.

Additionally, fix an issue where if you remove the libraries the
generated files are not removed.

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to test after only a design-time build, and then use Mono.Cecil to assert a type exists in the design-time build output? I don't remember if an assembly exists on disk after a design-time build completes.

@dellis1972
Copy link
Contributor Author

Is it possible to test after only a design-time build, and then use Mono.Cecil to assert a type exists in the design-time build output? I don't remember if an assembly exists on disk after a design-time build completes.

The assembly does not get written to disk for DTB.

@dellis1972 dellis1972 force-pushed the javabindingstuff branch 3 times, most recently from ef2226b to f824e0f Compare September 28, 2023 13:10
@jonpryor
Copy link
Contributor

jonpryor commented Oct 9, 2023

@dellis1972: I forget when we wanted to move the codebehind files into $(IntermediateOutputPath)codebehind. That aside, it looks like the draft commit message is still largely correct, in that the AddBindingsToCompile target now includes all $(IntermediateOutputPath)generated\**\*.cs.

However, shouldn't IntelliSense also know about/show the CodeBehind API? https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/LayoutCodeBehind.md

Shouldn't IntelliSense show the Binding.Main & related types?

@dellis1972
Copy link
Contributor Author

Shouldn't IntelliSense show the Binding.Main & related types?
It should lol

@dellis1972
Copy link
Contributor Author

@jonpryor jonpryor merged commit 2b0761b into dotnet:main Oct 12, 2023
jonathanpeppers pushed a commit that referenced this pull request Oct 13, 2023
)

Fixes: #7692

When `.java` files are part of a project through
`@(AndroidJavaSource)`, it would be nice if the *bindings* for those
Java types would be available through IDE IntelliSense/code completion.

Update the `AddBindingsToCompile` target so that it includes all
`$(IntermediateOutputPath)generated\**\*.cs` files into the design-
time build.

Additionally, fix an issue where if you remove the libraries the
generated files are not removed.

Finally, move the Layout CodeBehind generated files to their own
`$(IntermediateOutputPath)codebehind` directory.  This is to keep the
code behind and generated code separate, as it makes it easier to
update and clean up if one or the other changes.  When all the files
are in the same location we might end up deleting files we otherwise
need during an update process, slowing down the build.
grendello added a commit to grendello/xamarin-android that referenced this pull request Oct 13, 2023
* main:
  [Xamarin.Android.Build.Tasks] Include Bindings Design Time builds (dotnet#8357)
jonathanpeppers pushed a commit that referenced this pull request Oct 17, 2023
)

Fixes: #7692

When `.java` files are part of a project through
`@(AndroidJavaSource)`, it would be nice if the *bindings* for those
Java types would be available through IDE IntelliSense/code completion.

Update the `AddBindingsToCompile` target so that it includes all
`$(IntermediateOutputPath)generated\**\*.cs` files into the design-
time build.

Additionally, fix an issue where if you remove the libraries the
generated files are not removed.

Finally, move the Layout CodeBehind generated files to their own
`$(IntermediateOutputPath)codebehind` directory.  This is to keep the
code behind and generated code separate, as it makes it easier to
update and clean up if one or the other changes.  When all the files
are in the same location we might end up deleting files we otherwise
need during an update process, slowing down the build.
@github-actions github-actions bot locked and limited conversation to collaborators Jan 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bindings from $(AndroidJavaSource) don't work with Intellisense

4 participants