-
Notifications
You must be signed in to change notification settings - Fork 564
[Xamarin.Android.Build.Tasks] <GenerateJavaStubs/> only for MonoAndroid assemblies #2643
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
[Xamarin.Android.Build.Tasks] <GenerateJavaStubs/> only for MonoAndroid assemblies #2643
Conversation
|
Binlogs: logs.zip |
| foreach (var p in arguments.FixedArguments) { | ||
| // Of the form "MonoAndroid,Version=v8.1" | ||
| var value = p.Value?.ToString (); | ||
| if (value != null && value.StartsWith ("MonoAndroid", StringComparison.Ordinal)) { |
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.
I prefer this original code of using value.StartsWith("MonoAndroid") -- though perhaps it should be extended to value.StartsWith("MonoAndroid,")? -- largely because I'm not sure about what are the requirements and constraints on framework names.
For example, if a "framework name" could contain a comma, the new approach of splitting on all commas may cause a "mismatch". Using StartsWith() against MonoAndroid, would alloy such fears.
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.
After using IndexOf + Substring, I think it's still OK to just compare targetFrameworkIdentifier == "MonoAndroid":
//
// Summary:
// Reports the zero-based index of the first occurrence of the specified string
// in the current System.String object. A parameter specifies the type of search
// to use for the specified string.
//
// Returns:
// The index position of the value parameter if that string is found, or -1 if it
// is not. If value is System.String.Empty, the return value is 0.
public int IndexOf (String value, StringComparison comparisonType);It should be the first instance of , and targetFrameworkIdentifier will be everything before it.
…id assemblies
Currently the `<GenerateJavaStubs/>` MSBuild task will load and
iterate over NetStandard or PCL assemblies. It simply looks at all
items in `@(_ResolvedUserAssemblies)` and writes Java stubs if needed.
We could look at the `TargetFrameworkIdentifier` and *only* do this
work for `MonoAndroid` assemblies.
To make this work:
- The `<ResolveAssemblies/>` MSBuild task needs to parse the
`TargetFrameworkIdentifier` and add it to the item metadata for each
assembly.
- `<GenerateJavaStubs/>` should use a subset of
`@(_ResolvedUserAssemblies)` where `TargetFrameworkIdentifier` is
`MonoAndroid`.
Results:
Before
First: 1200 ms GenerateJavaStubs 1 calls
Incremental: 1047 ms GenerateJavaStubs 1 calls
After
First: 1084 ms GenerateJavaStubs 1 calls
Incremental: 868 ms GenerateJavaStubs 1 calls
This seems to save ~200ms in the Xamarin.Forms integration project in
this repo. Projects using lots of NetStandard/PCL assemblies should
see a bigger benefit.
8dadab6 to
56da8ba
Compare
Currently the
<GenerateJavaStubs/>MSBuild task will load anditerate over NetStandard or PCL assemblies. It simply looks at all
items in
@(_ResolvedUserAssemblies)and writes Java stubs if needed.We could look at the
TargetFrameworkIdentifierand only do thiswork for
MonoAndroidassemblies.To make this work:
<ResolveAssemblies/>MSBuild task needs to parse theTargetFrameworkIdentifierand add it to the item metadata for eachassembly.
<GenerateJavaStubs/>should use a subset of@(_ResolvedUserAssemblies)whereTargetFrameworkIdentifierisMonoAndroid.Results:
This seems to save ~200ms in the Xamarin.Forms integration project in
this repo. Projects using lots of NetStandard/PCL assemblies should
see a bigger benefit.