This commit is contained in:
@@ -36,6 +36,12 @@ public static class ShrinkInstallerDevelopmentValidation
|
||||
?.GetValue(null) as IEnumerable;
|
||||
Require(Count(packages) == 20, "包目录数量不是 20。");
|
||||
Require(Count(bundles) == 8, "推荐组合数量不是 8。");
|
||||
Require(BundleContainsInstallRoot(bundles, "基础应用(推荐)",
|
||||
"com.cneicy.shrink-context-eventbus-adapter"),
|
||||
"基础应用组合没有显式安装 Context 事件适配。");
|
||||
Require(BundleContainsInstallRoot(bundles, "常用完整套件",
|
||||
"com.cneicy.shrink-context-eventbus-adapter"),
|
||||
"常用完整套件没有显式安装 Context 事件适配。");
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -60,6 +66,32 @@ public static class ShrinkInstallerDevelopmentValidation
|
||||
return count;
|
||||
}
|
||||
|
||||
private static bool BundleContainsInstallRoot(IEnumerable bundles, string bundleName, string packageName)
|
||||
{
|
||||
foreach (var bundle in bundles)
|
||||
{
|
||||
var bundleType = bundle.GetType();
|
||||
if (!string.Equals(bundleType.GetProperty("DisplayName")?.GetValue(bundle) as string, bundleName,
|
||||
StringComparison.Ordinal))
|
||||
continue;
|
||||
|
||||
var roots = bundleType.GetProperty("InstallRoots")?.GetValue(bundle) as IEnumerable;
|
||||
if (roots == null)
|
||||
return false;
|
||||
|
||||
foreach (var root in roots)
|
||||
{
|
||||
var value = root.GetType().GetProperty("PackageName")?.GetValue(root) as string;
|
||||
if (string.Equals(value, packageName, StringComparison.Ordinal))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Type FindType(string fullName) => AppDomain.CurrentDomain.GetAssemblies()
|
||||
.Select(assembly => assembly.GetType(fullName, false))
|
||||
.FirstOrDefault(type => type != null)
|
||||
|
||||
Reference in New Issue
Block a user