Commit c2aadba
[Xamarin.Android.Build.Tasks] remove Distinct() from <ResolveLibraryProjectImports/> (#3296)
The `<ResolveLibraryProjectImports/>` task has some logic that needs
to look at the item metadata of each `@(Reference)`:
* `%(AndroidSkipResourceExtraction)` to skip unzipping anything
* `%(AndroidSkipResourceProcessing)` to skip
`<ConvertResourcesCases/>`
To make matters weird, we had some LINQ:
foreach (var assemblyPath in Assemblies
.Select (a => a.ItemSpec)
.Distinct ()) {
And we would basically lose the metadata information...
To handle this problem, we had two `HashSet`s we used to lookup
the values:
assembliesToSkipCaseFixup = new HashSet<string> (StringComparer.OrdinalIgnoreCase);
assembliestoSkipExtraction = new HashSet<string> (StringComparer.OrdinalIgnoreCase);
bool metaDataValue;
foreach (var asm in Assemblies) {
if (bool.TryParse (asm.GetMetadata (AndroidSkipResourceProcessing), out metaDataValue) && metaDataValue)
assembliesToSkipCaseFixup.Add (asm.ItemSpec);
if (bool.TryParse (asm.GetMetadata (GetAdditionalResourcesFromAssemblies.AndroidSkipResourceExtraction), out metaDataValue) && metaDataValue)
assembliestoSkipExtraction.Add (asm.ItemSpec);
}
I added a test to see what happens when we use multiple `@(Reference)`
such as:
* `<PackageReference/>`
* `packages.config` and a regular `<Reference/>`
* `<Reference/>` with a full path
It turns out there are MSBuild targets that disambiguate duplicate
assembly references:
https://github.com/NuGet/NuGet.BuildTasks/blob/640c8e13a9b7ab6e86264a296638fbf3cc016ad1/src/Microsoft.NuGet.Build.Tasks/Microsoft.NuGet.targets#L186-L207
The `ResolveNuGetPackageAssets` does a `Remove` against duplicate
`@(Reference)`, even if there are no NuGet packages present in the
project.
It seems safe for us to just drop the `Distinct()` and the
`HashSet`s. The code is a bit simpler after doing this.
I'm also seeing a small ~25ms performance improvement with this change.1 parent 6ac1aab commit c2aadba
File tree
2 files changed
+29
-18
lines changed- src/Xamarin.Android.Build.Tasks
- Tasks
- Tests/Xamarin.Android.Build.Tests
2 files changed
+29
-18
lines changedLines changed: 6 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | 70 | | |
72 | 71 | | |
73 | 72 | | |
| |||
83 | 82 | | |
84 | 83 | | |
85 | 84 | | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | 85 | | |
97 | 86 | | |
98 | 87 | | |
| |||
170 | 159 | | |
171 | 160 | | |
172 | 161 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
177 | 165 | | |
178 | 166 | | |
179 | 167 | | |
| |||
185 | 173 | | |
186 | 174 | | |
187 | 175 | | |
188 | | - | |
| 176 | + | |
189 | 177 | | |
190 | 178 | | |
191 | 179 | | |
| |||
216 | 204 | | |
217 | 205 | | |
218 | 206 | | |
219 | | - | |
| 207 | + | |
220 | 208 | | |
221 | 209 | | |
222 | 210 | | |
| |||
320 | 308 | | |
321 | 309 | | |
322 | 310 | | |
323 | | - | |
| 311 | + | |
324 | 312 | | |
325 | 313 | | |
326 | 314 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
137 | 160 | | |
138 | 161 | | |
139 | 162 | | |
| |||
0 commit comments