public void CanFlattenDependencies() { var tree = PackageDependencyTree.Load(); var flattened = tree.Flatten("Xamarin.AndroidX.Palette").ToArray(); Assert.Contains("Xamarin.AndroidX.Annotation", flattened); Assert.Equal(flattened, flattened.Distinct().ToArray()); }
public void CanLoadJsonFile() { var tree = PackageDependencyTree.Load(); Assert.NotEmpty(tree.Packages); Assert.NotNull(tree.Packages.FirstOrDefault(p => p.Id == "Xamarin.Google.Android.Material")); var material = tree.GetOrCreate("Xamarin.Google.Android.Material"); Assert.Contains("Xamarin.AndroidX.AppCompat", material.Dependencies); }
public void FlattenThenReduceEndsUpInTheSamePlace() { var tree = PackageDependencyTree.Load(); var ids = new[] { "Xamarin.AndroidX.AppCompat" }; var flattened = tree.Flatten(ids); Assert.NotEmpty(flattened); Assert.NotEqual(ids, flattened); var actual = tree.Reduce(flattened); Assert.Equal(ids, actual); }
public void FlattensNoDependenciesCorrectlyWhenExcludingTopLevel() { var tree = PackageDependencyTree.Load(); var ids = new[] { "Xamarin.AndroidX.Annotation", }; var expected = new string[0]; var flattened = tree.Flatten(ids, false); Assert.Equal(expected, flattened); }
public void CanReduceNoDependencyCorrectly() { var ids = new[] { "Xamarin.AndroidX.Annotation", }; var expected = new[] { "Xamarin.AndroidX.Annotation", }; var tree = PackageDependencyTree.Load(); var actual = tree.Reduce(ids); Assert.Equal(expected, actual); }
public void FlattensNoDependenciesCorrectly() { var tree = PackageDependencyTree.Load(); var ids = new[] { "Xamarin.AndroidX.Annotation", }; var expected = new[] { "Xamarin.AndroidX.Annotation", }; var flattened = tree.Flatten(ids); Assert.Equal(expected, flattened); }
public void FlattensSharedDependencyCorrectlyWhenExcludingTopLevel() { var tree = PackageDependencyTree.Load(); var ids = new[] { "Xamarin.AndroidX.Collection", "Xamarin.AndroidX.CursorAdapter", }; var expected = new[] { "Xamarin.AndroidX.Annotation", }; var flattened = tree.Flatten(ids, false); Assert.Equal(expected, flattened); }
public void FlattensTripleDependencyCorrectly() { var tree = PackageDependencyTree.Load(); var ids = new[] { "Xamarin.AndroidX.VersionedParcelable", }; var expected = new[] { "Xamarin.AndroidX.VersionedParcelable", "Xamarin.AndroidX.Annotation", "Xamarin.AndroidX.Collection", }; var flattened = tree.Flatten(ids); Assert.Equal(expected, flattened); }
public void FlattensSingleDependencyCorrectly() { var tree = PackageDependencyTree.Load(); var ids = new[] { "Xamarin.AndroidX.Collection", }; var expected = new[] { "Xamarin.AndroidX.Collection", "Xamarin.AndroidX.Annotation", "Xamarin.AndroidX.Migration", "Xamarin.AndroidX.MultiDex", }; var flattened = tree.Flatten(ids); Assert.Equal(expected, flattened); }
public void XamarinFormsTotalDependencyIsReduced() { var ids = new[] { "Xamarin.AndroidX.Arch.Core.Common", "Xamarin.AndroidX.Arch.Core.Runtime", "Xamarin.AndroidX.Lifecycle.Common", "Xamarin.AndroidX.Lifecycle.LiveData.Core", "Xamarin.AndroidX.Lifecycle.LiveData", "Xamarin.AndroidX.Lifecycle.Runtime", "Xamarin.AndroidX.Lifecycle.ViewModel", "Xamarin.AndroidX.VectorDrawable.Animated", "Xamarin.AndroidX.Annotation", "Xamarin.AndroidX.AsyncLayoutInflater", "Xamarin.AndroidX.Collection", "Xamarin.AndroidX.Core", "Xamarin.AndroidX.CoordinatorLayout", "Xamarin.AndroidX.Legacy.Support.Core.UI", "Xamarin.AndroidX.Legacy.Support.Core.Utils", "Xamarin.AndroidX.CursorAdapter", "Xamarin.AndroidX.Browser", "Xamarin.AndroidX.CustomView", "Xamarin.Google.Android.Material", "Xamarin.AndroidX.DocumentFile", "Xamarin.AndroidX.DrawerLayout", "Xamarin.AndroidX.Fragment", "Xamarin.AndroidX.Interpolator", "Xamarin.AndroidX.Loader", "Xamarin.AndroidX.LocalBroadcastManager", "Xamarin.AndroidX.Media", "Xamarin.AndroidX.Print", "Xamarin.AndroidX.SlidingPaneLayout", "Xamarin.AndroidX.SwipeRefreshLayout", "Xamarin.AndroidX.Transition", "Xamarin.AndroidX.Legacy.Support.V4", "Xamarin.AndroidX.AppCompat", "Xamarin.AndroidX.CardView", "Xamarin.AndroidX.MediaRouter", "Xamarin.AndroidX.Palette", "Xamarin.AndroidX.RecyclerView", "Xamarin.AndroidX.VectorDrawable", "Xamarin.AndroidX.VersionedParcelable", "Xamarin.AndroidX.ViewPager", }; var expected = new[] { "Xamarin.AndroidX.Browser", "Xamarin.AndroidX.Legacy.Support.V4", "Xamarin.AndroidX.Lifecycle.LiveData", "Xamarin.AndroidX.MediaRouter", "Xamarin.Google.Android.Material", }; var tree = PackageDependencyTree.Load(); var flattened = tree.Reduce(ids).ToList(); flattened.Sort(); Assert.Equal(expected, flattened); }
public void XamarinFormsTopLevelPackagesExpandToAll() { var ids = new[] { "Xamarin.AndroidX.AppCompat", "Xamarin.AndroidX.Browser", "Xamarin.AndroidX.CardView", "Xamarin.AndroidX.Legacy.Support.Core.Utils", "Xamarin.AndroidX.Legacy.Support.V4", "Xamarin.Google.Android.Material", }; var expected = new[] { "Xamarin.AndroidX.Activity", "Xamarin.AndroidX.Annotation", "Xamarin.AndroidX.AppCompat", "Xamarin.AndroidX.AppCompat.AppCompatResources", "Xamarin.AndroidX.Arch.Core.Common", //"Xamarin.AndroidX.Arch.Core.Runtime", "Xamarin.AndroidX.AsyncLayoutInflater", "Xamarin.AndroidX.Browser", "Xamarin.AndroidX.CardView", "Xamarin.AndroidX.Collection", "Xamarin.AndroidX.CoordinatorLayout", "Xamarin.AndroidX.Core", "Xamarin.AndroidX.CursorAdapter", "Xamarin.AndroidX.CustomView", "Xamarin.AndroidX.DocumentFile", "Xamarin.AndroidX.DrawerLayout", "Xamarin.AndroidX.Fragment", "Xamarin.AndroidX.Interpolator", "Xamarin.AndroidX.Legacy.Support.Core.UI", "Xamarin.AndroidX.Legacy.Support.Core.Utils", "Xamarin.AndroidX.Legacy.Support.V4", "Xamarin.AndroidX.Lifecycle.Common", //"Xamarin.AndroidX.Lifecycle.LiveData", "Xamarin.AndroidX.Lifecycle.LiveData.Core", "Xamarin.AndroidX.Lifecycle.Runtime", "Xamarin.AndroidX.Lifecycle.ViewModel", "Xamarin.AndroidX.Lifecycle.ViewModelSavedState", "Xamarin.AndroidX.Loader", "Xamarin.AndroidX.LocalBroadcastManager", "Xamarin.AndroidX.Media", "Xamarin.AndroidX.Migration", "Xamarin.AndroidX.MultiDex", "Xamarin.AndroidX.Print", "Xamarin.AndroidX.RecyclerView", "Xamarin.AndroidX.SavedState", "Xamarin.AndroidX.SlidingPaneLayout", "Xamarin.AndroidX.SwipeRefreshLayout", "Xamarin.AndroidX.Transition", "Xamarin.AndroidX.VectorDrawable", "Xamarin.AndroidX.VectorDrawable.Animated", "Xamarin.AndroidX.VersionedParcelable", "Xamarin.AndroidX.ViewPager", "Xamarin.AndroidX.ViewPager2", "Xamarin.Google.Android.Material", "Xamarin.Google.Guava.ListenableFuture", }; var tree = PackageDependencyTree.Load(); var flattened = tree.Flatten(ids).ToList(); flattened.Sort(); Assert.Equal(expected, flattened); }
public override bool Execute() { // if there are no assemblies, then we are done if (ResolvedAssemblies == null || ResolvedAssemblies.Length == 0) { Log.LogMessage($"There were no assemblies to check."); return(true); } try { var hasMissing = false; var assemblyNames = ResolvedAssemblies.Select(a => Path.GetFileNameWithoutExtension(a.ItemSpec)); var mapping = new AndroidXAssembliesCsvMapping(); var assemblyPairs = new Dictionary <string, string>(); var androidxAssemblies = new Dictionary <string, bool>(); foreach (var support in assemblyNames) { // if there was no mapping found, then we don't care if (!mapping.TryGetAndroidXAssembly(support, out var androidx)) { continue; } ContainsSupportAssemblies = true; Log.LogMessage(MessageImportance.Low, $"Making sure that the Android Support assembly '{support}' has a replacement Android X assembly..."); // make sure the mapped assembly is referenced var exists = assemblyNames.Contains(androidx); androidxAssemblies[androidx] = exists; assemblyPairs[androidx] = support; if (exists) { Log.LogMessage(MessageImportance.Low, $"Found the Android X assembly '{androidx}'."); } else { Log.LogMessage(MessageImportance.Low, $"Missing the Android X assembly '{androidx}'."); hasMissing = true; } } if (hasMissing) { var missing = androidxAssemblies.Where(p => !p.Value).Select(p => p.Key).ToArray(); var tree = PackageDependencyTree.Load(); var reduced = tree.Reduce(missing).ToArray(); var packages = new StringBuilder(); var references = new StringBuilder(); foreach (var assembly in reduced) { mapping.TryGetAndroidXPackage(assembly, out var package); mapping.TryGetAndroidXVersion(assembly, out var version); packages.AppendLine(); packages.Append($" - {package}"); references.AppendLine(); references.Append($" <PackageReference Include=\"{package}\" Version=\"{version}\" />"); } var msg = $"Could not find {missing.Length} Android X assemblies, make sure to install the following NuGet packages:" + packages + Environment.NewLine + $"You can also copy-and-paste the following snippet into your .csproj file:" + references; if (UseWarningsInsteadOfErrors) { Log.LogWarning(msg); } else { Log.LogError(msg); } } return(!hasMissing || UseWarningsInsteadOfErrors); } catch { if (UseWarningsInsteadOfErrors) { return(true); } throw; } }