Skip to content

Conversation

@jonathanpeppers
Copy link
Member

Context: https://github.com/xamarin/AndroidSupportComponents

When compiling the Xamarin support libraries from source, its binding
projects generate thousands of warnings. Most of these warnings are
noise that could be fixed, and generator is just overdue for some
improvement.

My first steps to improve this:

  • By default generator-Tests should fail if there is a C# compiler
    warning
  • Add an AllowWarnings option for BaseGeneratorTest, since there
    are a few tests that generate C# compiler warnings that aren’t
    addressed yet. The hope is this feature could be dropped from the tests
    eventually.
  • Fix the most common warning: Invoker types have a warning of a
    missing new keyword on the generated class_ref field

Since Java.Lang.Object has a static class_ref property, all Invoker
types will produce this warning. An Invoker is generated for any
interface or abstract class, so you can see how a large binding
project could run into this warning many times.

Context: https://github.com/xamarin/AndroidSupportComponents

When compiling the Xamarin support libraries from source, its binding
projects generate thousands of warnings. Most of these warnings are
noise that could be fixed, and `generator` is just overdue for some
improvement.

My first steps to improve this:
- By default `generator-Tests` should fail if there is a C# compiler
warning
- Add an `AllowWarnings` option for `BaseGeneratorTest`, since there
are a few tests that generate C# compiler warnings that aren’t
addressed yet. The hope is this feature could be dropped from the tests
eventually.
- Fix the most common warning: `Invoker` types have a warning of a
missing `new` keyword on the generated `class_ref` field

Since `Java.Lang.Object` has a static `class_ref` property, all `Invoker`
types will produce this warning. An `Invoker` is generated for any
`interface` or `abstract` class, so you can see how a large binding
project could run into this warning many times.
@dnfclas
Copy link

dnfclas commented Nov 22, 2017

@jonathanpeppers,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by .NET Foundation. We will now review your pull request.
Thanks,
.NET Foundation Pull Request Bot

@jonpryor jonpryor merged commit 5b18729 into dotnet:master Nov 28, 2017
jonathanpeppers added a commit to jonathanpeppers/java.interop that referenced this pull request Dec 13, 2017
Context: dotnet#217

There is one difference in generator-Tests compared to how real
Xamarin.Android binding projects would work:
- generator-Tests put everything in one assembly
- Real binding projects have `Java.Lang.*` in a separate assembly

This means that some members that are marked `internal` will not need
the `new` keyword at all—even though the tests currently *would* need
the `new` keyword. The real fix here is to make the tests generate two
separate assemblies so that we are more closely reproducing what real
Xamarin.Android binding projects would do.

Since we are branching for 15-6 soon, it seems better to revert the
`new` keyword addition, and set `AllowWarnings=true` in some of these
tests.

I also included a comment for every test that sets
`AllowWarnings=true`, so that it is clear which warning is occurring.
jonathanpeppers added a commit to jonathanpeppers/java.interop that referenced this pull request Dec 13, 2017
Context: dotnet#217

When testing generator from xamarin-android/master, I noticed that
building a binding project has some *new* warnings:
```
obj/Debug/generated/src/GoogleAnalytics.Tracking.ILogger.cs(159,14): warning CS0109:
	The member 'ILoggerInvoker.class_ref' does not hide an accessible member.
	The new keyword is not required.
```
Binding project: https://github.com/jonathanpeppers/GoogleAnalytics/tree/master/GoogleAnalytics.Droid

This was due to a change made in dotnet#217, I was *tricked* by how warnings
operate differently in `generator-Tests` than what happens in a real
Xamarin.Android binding project.

The difference is:
- `generator-Tests` put everything in one assembly
- Real binding projects have `Java.Lang.*` and Android types in a
separate assembly

This means that some members that are marked `internal` will not need
the `new` keyword at all—even though the tests currently *would* need
the `new` keyword. The real fix here is to make the tests generate two
separate assemblies so that we are more closely reproducing the
situation of a Xamarin.Android binding project.

Since we are branching for 15-6 soon, it seems better to revert the
`new` keyword change in `InterfaceGen`, and set `AllowWarnings=true`
where required in `generator-Tests`..

I also included a comment for every test that sets
`AllowWarnings=true`, so that it is clear which warning is occurring.
@jonathanpeppers jonathanpeppers deleted the generator-warnings branch December 13, 2017 19:25
@github-actions github-actions bot locked and limited conversation to collaborators Apr 14, 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.

3 participants