コード例 #1
0
ファイル: PackageAnalysis.cs プロジェクト: rohitshe/Code
        /// <summary>
        /// Runs a full analysis on this package.
        /// </summary>
        /// <param name="log">The log.</param>
        public void Run(ILogger log)
        {
            if (log == null)
            {
                throw new ArgumentNullException("log");
            }

            // If the package doesn't have a meta name, fix it here
            if (string.IsNullOrWhiteSpace(package.Meta.Name) && package.FullPath != null)
            {
                package.Meta.Name = package.FullPath.GetFileName();
                package.IsDirty   = true;
            }

            if (Parameters.IsPackageCheckDependencies)
            {
                CheckDependencies().CopyTo(log);
            }

            if (Parameters.IsProcessingUPaths)
            {
                ProcessPackageUPaths();
            }

            if (Parameters.IsProcessingAssetReferences)
            {
                ProcessRootAssetReferences(package.RootAssets, package, log);
                foreach (var dependency in package.LocalDependencies)
                {
                    var referencedPackage = package.Session.Packages.Find(dependency.Id);
                    if (referencedPackage != null)
                    {
                        ProcessRootAssetReferences(dependency.RootAssets, referencedPackage, log);
                    }
                }
                foreach (var dependency in package.Meta.Dependencies)
                {
                    var referencedPackage = package.Session.Packages.Find(dependency);
                    if (referencedPackage != null)
                    {
                        ProcessRootAssetReferences(dependency.RootAssets, referencedPackage, log);
                    }
                }
            }

            if (Parameters.AssetTemplatingMergeModifiedAssets || Parameters.AssetTemplatingRemoveUnusedBaseParts)
            {
                var packageTemplating = new PackageAssetTemplatingAnalysis(package, log)
                {
                    MergeModifiedAssets   = Parameters.AssetTemplatingMergeModifiedAssets,
                    RemoveUnusedBaseParts = Parameters.AssetTemplatingRemoveUnusedBaseParts
                };
                packageTemplating.Run();
            }

            ProcessAssets().CopyTo(log);
        }
コード例 #2
0
        /// <summary>
        /// Runs a full analysis on this package.
        /// </summary>
        /// <param name="log">The log.</param>
        public void Run(ILogger log)
        {
            if (log == null) throw new ArgumentNullException("log");

            // If the package doesn't have a meta name, fix it here
            if (string.IsNullOrWhiteSpace(package.Meta.Name) && package.FullPath != null)
            {
                package.Meta.Name = package.FullPath.GetFileName();
                package.IsDirty = true;
            }

            if (Parameters.IsPackageCheckDependencies)
            {
                CheckDependencies().CopyTo(log);
            }

            if (Parameters.IsProcessingUPaths)
            {
                ProcessPackageUPaths();
            }

            if (Parameters.IsProcessingAssetReferences)
            {
                ProcessRootAssetReferences(package.RootAssets, package, log);
                foreach (var dependency in package.LocalDependencies)
                {
                    var referencedPackage = package.Session.Packages.Find(dependency.Id);
                    if (referencedPackage != null)
                        ProcessRootAssetReferences(dependency.RootAssets, referencedPackage, log);
                }
                foreach (var dependency in package.Meta.Dependencies)
                {
                    var referencedPackage = package.Session.Packages.Find(dependency);
                    if (referencedPackage != null)
                        ProcessRootAssetReferences(dependency.RootAssets, referencedPackage, log);
                }
            }

            if (Parameters.EnableAssetTemplating)
            {
                var packageTemplating = new PackageAssetTemplatingAnalysis(package, log);
                packageTemplating.Run();
            }

            ProcessAssets().CopyTo(log);
        }
コード例 #3
0
        public void TestPackageAnalysis()
        {
            var package = new Package();

            var baseAsset = new TestDiffAsset() { Name = "Red", Value = 1 };
            var baseItem = new AssetItem("base", baseAsset);

            var childAsset = (TestDiffAsset)baseItem.CreateChildAsset();
            var childItem = new AssetItem("child", childAsset);

            var newBaseAsset = (TestDiffAsset)AssetCloner.Clone(baseAsset);
            newBaseAsset.Name = "Green";
            var newBaseItem = new AssetItem("base", newBaseAsset);

            package.Assets.Add(newBaseItem);
            package.Assets.Add(childItem);

            var session = new PackageSession();
            session.Packages.Add(package);

            var result = new LoggerResult();
            var analysis = new PackageAssetTemplatingAnalysis(package, result);
            analysis.Run();

            Assert.False(result.HasErrors);

            var assetModified = (TestDiffAsset)package.Assets.Find("child").Asset;
            Assert.AreEqual("Green", assetModified.Name);
        }